From bc9b35e960f49cb9534239847635e7e8d01fc4dc Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+termigator1359@users.noreply.github.com> Date: Sun, 3 Jan 2021 10:38:53 -0500 Subject: [PATCH 01/22] fixed glowmask offsets and bobbit worm mvt issues --- CalamityLists.cs | 3 ++- Items/TreasureBags/DevourerofGodsBag.cs | 9 +++------ Items/TreasureBags/PolterghastBag.cs | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CalamityLists.cs b/CalamityLists.cs index fc8d2bff93..5b4f1a4306 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -540,7 +540,8 @@ namespace CalamityMod ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), - ModContent.NPCType() + ModContent.NPCType(), + ModContent.NPCType() }; confusionEnemyList = new List() diff --git a/Items/TreasureBags/DevourerofGodsBag.cs b/Items/TreasureBags/DevourerofGodsBag.cs index eb192bfbae..830ecb6d76 100644 --- a/Items/TreasureBags/DevourerofGodsBag.cs +++ b/Items/TreasureBags/DevourerofGodsBag.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Items.TreasureBags { item.maxStack = 999; item.consumable = true; - item.width = 24; - item.height = 24; + item.width = 36; + item.height = 34; item.rare = 9; item.expert = true; } @@ -43,10 +43,7 @@ namespace CalamityMod.Items.TreasureBags item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.GetTexture("CalamityMod/Items/TreasureBags/DevourerofGodsBagGlow")); } - public override bool CanRightClick() - { - return true; - } + public override bool CanRightClick() => true; public override void PostUpdate() => CalamityUtils.ForceItemIntoWorld(item); diff --git a/Items/TreasureBags/PolterghastBag.cs b/Items/TreasureBags/PolterghastBag.cs index 916271394f..899e9110eb 100644 --- a/Items/TreasureBags/PolterghastBag.cs +++ b/Items/TreasureBags/PolterghastBag.cs @@ -30,8 +30,8 @@ namespace CalamityMod.Items.TreasureBags { item.maxStack = 999; item.consumable = true; - item.width = 24; - item.height = 24; + item.width = 32; + item.height = 34; item.rare = 9; item.expert = true; } From 0c891a7cac93b4ba41957aaf1344bd3defba4212 Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+termigator1359@users.noreply.github.com> Date: Mon, 4 Jan 2021 09:52:51 -0500 Subject: [PATCH 02/22] silva/auric now gives Irradiated immunity --- Items/Armor/AuricTeslaBodyArmor.cs | 1 + Items/Armor/SilvaArmor.cs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Items/Armor/AuricTeslaBodyArmor.cs b/Items/Armor/AuricTeslaBodyArmor.cs index 5d93e94a5e..a18c5c3563 100644 --- a/Items/Armor/AuricTeslaBodyArmor.cs +++ b/Items/Armor/AuricTeslaBodyArmor.cs @@ -50,6 +50,7 @@ namespace CalamityMod.Items.Armor CalamityPlayer modPlayer = player.Calamity(); modPlayer.fBarrier = true; modPlayer.godSlayerReflect = true; + player.buffImmune[ModContent.BuffType()] = true; player.statLifeMax2 += 100; player.allDamage += 0.08f; modPlayer.AllCritBoost(5); diff --git a/Items/Armor/SilvaArmor.cs b/Items/Armor/SilvaArmor.cs index 7412430403..e42d797e69 100644 --- a/Items/Armor/SilvaArmor.cs +++ b/Items/Armor/SilvaArmor.cs @@ -14,7 +14,8 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Silva Armor"); Tooltip.SetDefault("+80 max life\n" + - "12% increased damage and 8% increased critical strike chance"); + "12% increased damage and 8% increased critical strike chance\n" + + "Grants immunity to the irradiated debuff"); } public override void SetDefaults() @@ -32,6 +33,7 @@ namespace CalamityMod.Items.Armor player.statLifeMax2 += 80; player.allDamage += 0.12f; player.Calamity().AllCritBoost(8); + player.buffImmune[ModContent.BuffType()] = true; } public override void AddRecipes() From b5d97a49fb3a160b2e7778948473153b34a17bc3 Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+termigator1359@users.noreply.github.com> Date: Mon, 4 Jan 2021 11:07:50 -0500 Subject: [PATCH 03/22] using directives --- Items/Armor/AuricTeslaBodyArmor.cs | 1 + Items/Armor/SilvaArmor.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/Items/Armor/AuricTeslaBodyArmor.cs b/Items/Armor/AuricTeslaBodyArmor.cs index a18c5c3563..1fa8e18fc6 100644 --- a/Items/Armor/AuricTeslaBodyArmor.cs +++ b/Items/Armor/AuricTeslaBodyArmor.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.Items.Accessories; using CalamityMod.Items.Materials; diff --git a/Items/Armor/SilvaArmor.cs b/Items/Armor/SilvaArmor.cs index e42d797e69..46369f5acc 100644 --- a/Items/Armor/SilvaArmor.cs +++ b/Items/Armor/SilvaArmor.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Accessories; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables; From da580f271c9a671ebe71beebd844e06e14ce3570 Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+termigator1359@users.noreply.github.com> Date: Tue, 5 Jan 2021 20:21:02 -0500 Subject: [PATCH 04/22] adjusted aegis dashes --- CalPlayer/CalamityPlayer.cs | 4 ++-- Items/Accessories/AsgardianAegis.cs | 3 ++- Items/Accessories/ElysianAegis.cs | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index a4a7e60725..a4d0442171 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -8336,7 +8336,7 @@ namespace CalamityMod.CalPlayer } else if (dashMod == 3) //Elysian Aegis { - if (DoADash(21.9f)) + if (DoADash(22f)) { for (int d = 0; d < 40; d++) { @@ -8354,7 +8354,7 @@ namespace CalamityMod.CalPlayer } else if (dashMod == 4) //Asgardian Aegis { - if (DoADash(22.7f)) + if (DoADash(23.3f)) { for (int d = 0; d < 60; d++) { diff --git a/Items/Accessories/AsgardianAegis.cs b/Items/Accessories/AsgardianAegis.cs index 6ba3b47754..ddb7bf2217 100644 --- a/Items/Accessories/AsgardianAegis.cs +++ b/Items/Accessories/AsgardianAegis.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Accessories DisplayName.SetDefault("Asgardian Aegis"); Tooltip.SetDefault("Grants immunity to fire blocks and knockback\n" + "Immune to most debuffs\n" + - "+40 max life\n" + + "+40 max life and increased life regeneration\n" + "Grants a supreme holy flame dash\n" + "Can be used to ram enemies\n" + "TOOLTIP LINE HERE\n" + @@ -54,6 +54,7 @@ namespace CalamityMod.Items.Accessories player.noKnockback = true; player.fireWalk = true; player.statLifeMax2 += 40; + player.lifeRegen++; player.buffImmune[BuffID.Chilled] = true; player.buffImmune[BuffID.Frostburn] = true; player.buffImmune[BuffID.Weak] = true; diff --git a/Items/Accessories/ElysianAegis.cs b/Items/Accessories/ElysianAegis.cs index 6554f9bf85..dc40cf60a5 100644 --- a/Items/Accessories/ElysianAegis.cs +++ b/Items/Accessories/ElysianAegis.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Accessories DisplayName.SetDefault("Elysian Aegis"); Tooltip.SetDefault("Blessed by the Profaned Flame\n" + "Grants immunity to fire blocks, knockback, and Holy Flames\n" + - "+40 max life and increased life regen\n" + + "+30 max life\n" + "Grants a supreme holy flame dash\n" + "Can be used to ram enemies\n" + "TOOLTIP LINE HERE\n" + @@ -53,8 +53,7 @@ namespace CalamityMod.Items.Accessories player.buffImmune[ModContent.BuffType()] = true; player.noKnockback = true; player.fireWalk = true; - player.lifeRegen += 2; - player.statLifeMax2 += 40; + player.statLifeMax2 += 30; } } } From 5f8817cc1b26586be9bbbdcbc6b36695ca8f8c1a Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+termigator1359@users.noreply.github.com> Date: Tue, 5 Jan 2021 20:21:19 -0500 Subject: [PATCH 05/22] right --- CalPlayer/CalamityPlayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index a4d0442171..73c6d63838 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -8336,7 +8336,7 @@ namespace CalamityMod.CalPlayer } else if (dashMod == 3) //Elysian Aegis { - if (DoADash(22f)) + if (DoADash(21.5f)) { for (int d = 0; d < 40; d++) { From 46d114782be3995f5dcd51b1996f6f8f0269c251 Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+termigator1359@users.noreply.github.com> Date: Tue, 5 Jan 2021 20:22:48 -0500 Subject: [PATCH 06/22] adamantite no longer does weird shit to bosses --- CalPlayer/CalamityPlayer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 699099e34a..0d7c59d3fc 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -4640,6 +4640,8 @@ namespace CalamityMod.CalPlayer break; case ItemID.AdamantiteSword: + if (CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) + return; target.velocity *= 0.5f; break; @@ -4732,6 +4734,8 @@ namespace CalamityMod.CalPlayer break; case ProjectileID.AdamantiteGlaive: + if (CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) + return; target.velocity *= 0.5f; break; From 9547065545b59246752a692ffa0e229f6bec6f25 Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+termigator1359@users.noreply.github.com> Date: Tue, 5 Jan 2021 21:21:52 -0500 Subject: [PATCH 07/22] adamantite change --- CalPlayer/CalamityPlayer.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 0d7c59d3fc..0984fc7ef8 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -4640,9 +4640,10 @@ namespace CalamityMod.CalPlayer break; case ItemID.AdamantiteSword: + float slowDownMult = 0.5f; if (CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) - return; - target.velocity *= 0.5f; + slowDownMult = 0.95f; + target.velocity *= slowDownMult; break; case ItemID.CandyCaneSword: @@ -4734,9 +4735,10 @@ namespace CalamityMod.CalPlayer break; case ProjectileID.AdamantiteGlaive: + float slowDownMult = 0.5f; if (CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) - return; - target.velocity *= 0.5f; + slowDownMult = 0.95f; + target.velocity *= slowDownMult; break; case ProjectileID.FruitcakeChakram: From b0c5a4a890b0a93b60e5b6c59e476328b2124ce4 Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+termigator1359@users.noreply.github.com> Date: Thu, 7 Jan 2021 06:40:05 -0500 Subject: [PATCH 08/22] patron npc name --- NPCs/CalamityGlobalTownNPC.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index ea1957055d..835c08f0d2 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -121,7 +121,8 @@ namespace CalamityMod.NPCs private static readonly string[] WitchDoctorNames = { "Sok'ar", - "Toxin", // <@!348174404984766465> (Toxin#9598) + "Toxin", // <@!348174404984766465> (Toxin#9598), + "Mixcoatl", // <@!284775927294984203> (SharZz#7777) }; private const int WizardVanillaNames = 22; private static readonly string[] WizardNames = From abd1ec02d960f59debcdd61f1a690976e926f5bc Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+termigator1359@users.noreply.github.com> Date: Mon, 11 Jan 2021 18:07:52 -0500 Subject: [PATCH 09/22] sparkling empress no longer checks Main.time --- Projectiles/Magic/SparklingBeam.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projectiles/Magic/SparklingBeam.cs b/Projectiles/Magic/SparklingBeam.cs index 4cc901c557..fc64d9cb5f 100644 --- a/Projectiles/Magic/SparklingBeam.cs +++ b/Projectiles/Magic/SparklingBeam.cs @@ -234,7 +234,7 @@ namespace CalamityMod.Projectiles.Magic } else { // Do we still have enough mana? If not, we kill the projectile because we cannot use it anymore - if (Main.time % 10 < 1 && !player.CheckMana(player.ActiveItem().mana, true)) + if (Main.player[projectile.owner].miscCounter % 10 == 0 && !player.CheckMana(player.ActiveItem().mana, true)) { projectile.Kill(); } From d4898c6b42d88202a9fe2fb632cfeeb796798ed2 Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+termigator1359@users.noreply.github.com> Date: Sun, 17 Jan 2021 00:03:53 -0500 Subject: [PATCH 10/22] fixed some sell prices --- Items/Weapons/Rogue/Equanimity.cs | 2 +- Items/Weapons/Rogue/Exorcism.cs | 2 +- Items/Weapons/Rogue/StormfrontRazor.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Items/Weapons/Rogue/Equanimity.cs b/Items/Weapons/Rogue/Equanimity.cs index 88517b6f66..3aa4db6b4a 100644 --- a/Items/Weapons/Rogue/Equanimity.cs +++ b/Items/Weapons/Rogue/Equanimity.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.height = 36; item.maxStack = 1; item.rare = 5; - item.value = Item.buyPrice(0, 4, 0, 0); + item.value = CalamityGlobalItem.Rarity5BuyPrice; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 30f; item.Calamity().rogue = true; diff --git a/Items/Weapons/Rogue/Exorcism.cs b/Items/Weapons/Rogue/Exorcism.cs index 7369d0d82b..4a30ebb43f 100644 --- a/Items/Weapons/Rogue/Exorcism.cs +++ b/Items/Weapons/Rogue/Exorcism.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.height = 42; item.maxStack = 1; item.rare = 5; - item.value = Item.buyPrice(0, 16, 0, 0); + item.value = CalamityGlobalItem.Rarity5BuyPrice; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; item.Calamity().rogue = true; diff --git a/Items/Weapons/Rogue/StormfrontRazor.cs b/Items/Weapons/Rogue/StormfrontRazor.cs index 9902d29b09..ea36415fce 100644 --- a/Items/Weapons/Rogue/StormfrontRazor.cs +++ b/Items/Weapons/Rogue/StormfrontRazor.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.UseSound = SoundID.Item1; item.autoReuse = true; item.useStyle = ItemUseStyleID.SwingThrow; - item.value = Item.buyPrice(0, 30, 0, 0); + item.value = CalamityGlobalItem.Rarity5BuyPrice; item.rare = 5; item.useAnimation = 15; From 0e6c3dbddb1f036621ddf6b9a5d9c6d338f3192c Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+termigator1359@users.noreply.github.com> Date: Tue, 19 Jan 2021 12:05:34 -0500 Subject: [PATCH 11/22] stuff like marked and armor crunch should no longer ignore armor pen --- NPCs/CalamityGlobalNPC.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 2a125ade32..967e6246ff 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1576,7 +1576,8 @@ namespace CalamityMod.NPCs (wCleave > 0 ? WarCleave.DefenseReduction : 0) - (gState > 0 ? GlacialState.DefenseReduction : 0) - (aCrunch > 0 ? ArmorCrunch.DefenseReduction : 0) - - (marked > 0 && DR <= 0f ? MarkedforDeath.DefenseReduction : 0); + (marked > 0 && DR <= 0f ? MarkedforDeath.DefenseReduction : 0) - + Main.LocalPlayer.armorPenetration; // Defense can never be negative and has a minimum value of zero. if (effectiveDefense < 0) From b1be239fe57ddf65499d7fae8eb3c97a8c4c1472 Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+termigator1359@users.noreply.github.com> Date: Wed, 27 Jan 2021 21:17:08 -0500 Subject: [PATCH 12/22] fixed orichalcum spiked gemstone SS effects happening 24/7 --- .../Rogue/OrichalcumSpikedGemstoneProjectile.cs | 2 +- .../Rogue/OrichalcumSpikedGemstoneProjectile.png | Bin 585 -> 0 bytes 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 Projectiles/Rogue/OrichalcumSpikedGemstoneProjectile.png diff --git a/Projectiles/Rogue/OrichalcumSpikedGemstoneProjectile.cs b/Projectiles/Rogue/OrichalcumSpikedGemstoneProjectile.cs index f341125da8..d9368777f3 100644 --- a/Projectiles/Rogue/OrichalcumSpikedGemstoneProjectile.cs +++ b/Projectiles/Rogue/OrichalcumSpikedGemstoneProjectile.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Rogue private void OnHitEffect(Vector2 targetPos) { - if (Main.myPlayer != projectile.owner) + if (Main.myPlayer != projectile.owner || !projectile.Calamity().stealthStrike) return; for (int i = 0; i < 2; i++) diff --git a/Projectiles/Rogue/OrichalcumSpikedGemstoneProjectile.png b/Projectiles/Rogue/OrichalcumSpikedGemstoneProjectile.png deleted file mode 100644 index 22503b272807fae30b9f1ce3ba8a63cf9c6ac9f5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 585 zcmV-P0=E5$P)Px%14%?dR7i=nl|e{UK^(?^6Kg26hm}f}-BvaW&1yTmY+*%IT-bvZxEa(%J=ndQ zMhj^qt>mRn9XfgPpdDgW1P?_JEV&2d-U*zRGF=u(`2fBhyFJSd{?acBmPEt+H(i@bGjy0GoXlp?~%a0H3p?u4LMXJh93v z0KEJ8K?1yuJ}Vh$h;}J53Gl~zR%j&>ja7+~Bx;Y8)Ltp2XP%>#=%0zojR@sNWPe;6 z3s4&i?2pa(8fJX${}UZmp3B~_07zz25@2wr6F4{>r+mXE0O|EN0EB!Yy{G0`+{wEZ zR0lUawa9!q)73Y>{sp~6;qx^B>7&JOv1IcU(fU@8z01{W@nu+qof&_Sc zuOEPck(ABwJGbB(eEsSr0GZ*BQZLbAg|@PL`nqPADYa`kP X6YZ549Q7iN00000NkvXXu0mjf@Vy4< From e4bf8f1d445a1d6702fef66461c4728bb68f4b72 Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+termigator1359@users.noreply.github.com> Date: Sat, 20 Feb 2021 09:26:38 -0500 Subject: [PATCH 13/22] added lazure's barrier platform to tracers recipe --- Utilities/CalamityRecipes.cs | 100 +++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 45 deletions(-) diff --git a/Utilities/CalamityRecipes.cs b/Utilities/CalamityRecipes.cs index 9abe8ace3d..8f2253e59f 100644 --- a/Utilities/CalamityRecipes.cs +++ b/Utilities/CalamityRecipes.cs @@ -1101,51 +1101,61 @@ namespace CalamityMod group = new RecipeGroup(() => "Any Wings", new int[] { - ItemID.DemonWings, - ItemID.AngelWings, - ItemID.RedsWings, - ItemID.ButterflyWings, - ItemID.FairyWings, - ItemID.HarpyWings, - ItemID.BoneWings, - ItemID.FlameWings, - ItemID.FrozenWings, - ItemID.GhostWings, - ItemID.SteampunkWings, - ItemID.LeafWings, - ItemID.BatWings, - ItemID.BeeWings, - ItemID.DTownsWings, - ItemID.WillsWings, - ItemID.CrownosWings, - ItemID.CenxsWings, - ItemID.TatteredFairyWings, - ItemID.SpookyWings, - ItemID.Hoverboard, - ItemID.FestiveWings, - ItemID.BeetleWings, - ItemID.FinWings, - ItemID.FishronWings, - ItemID.MothronWings, - ItemID.WingsSolar, - ItemID.WingsVortex, - ItemID.WingsNebula, - ItemID.WingsStardust, - ItemID.Yoraiz0rWings, - ItemID.JimsWings, - ItemID.SkiphsWings, - ItemID.LokisWings, - ItemID.BetsyWings, - ItemID.ArkhalisWings, - ItemID.LeinforsWings, - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType() + ItemID.DemonWings, + ItemID.AngelWings, + ItemID.RedsWings, + ItemID.ButterflyWings, + ItemID.FairyWings, + ItemID.HarpyWings, + ItemID.BoneWings, + ItemID.FlameWings, + ItemID.FrozenWings, + ItemID.GhostWings, + ItemID.SteampunkWings, + ItemID.LeafWings, + ItemID.BatWings, + ItemID.BeeWings, + ItemID.DTownsWings, + ItemID.WillsWings, + ItemID.CrownosWings, + ItemID.CenxsWings, + ItemID.TatteredFairyWings, + ItemID.SpookyWings, + ItemID.Hoverboard, + ItemID.FestiveWings, + ItemID.BeetleWings, + ItemID.FinWings, + ItemID.FishronWings, + ItemID.MothronWings, + ItemID.WingsSolar, + ItemID.WingsVortex, + ItemID.WingsNebula, + ItemID.WingsStardust, + ItemID.Yoraiz0rWings, + ItemID.JimsWings, + ItemID.SkiphsWings, + ItemID.LokisWings, + ItemID.BetsyWings, + ItemID.ArkhalisWings, + ItemID.LeinforsWings, + ItemID.BejeweledValkyrieWing, + /* + ItemID.GhostarsWings, + ItemID.GroxTheGreatWings, + ItemID.FoodBarbarianWings, + ItemID.SafemanWings, + ItemID.CreativeWings, + ItemID.RainbowWings, + ItemID.LongRainbowTrailWings, + */ + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() }); RecipeGroup.RegisterGroup("WingsGroup", group); } From d3349fc62902ce1c3d4aa3f8d881f06d8401e4b0 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sat, 27 Feb 2021 17:22:56 -0500 Subject: [PATCH 14/22] Made Providence's healing shots even more visible. --- Projectiles/Boss/HolyBurnOrb.cs | 106 ++++++++++++++++---------------- Projectiles/Boss/HolyLight.cs | 4 +- 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/Projectiles/Boss/HolyBurnOrb.cs b/Projectiles/Boss/HolyBurnOrb.cs index ce59200dd1..1c083da68e 100644 --- a/Projectiles/Boss/HolyBurnOrb.cs +++ b/Projectiles/Boss/HolyBurnOrb.cs @@ -6,9 +6,8 @@ using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.DataStructures; -using Terraria.ModLoader; using Terraria.ID; -using CalamityMod.Events; +using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { @@ -27,36 +26,36 @@ namespace CalamityMod.Projectiles.Boss projectile.hostile = true; projectile.ignoreWater = true; projectile.tileCollide = false; - projectile.alpha = 255; + projectile.alpha = 255; projectile.penetrate = 1; projectile.timeLeft = 200; } public override void AI() { - if (projectile.ai[0] < 240f) - { - projectile.ai[0] += 1f; + if (projectile.ai[0] < 240f) + { + projectile.ai[0] += 1f; - if (projectile.timeLeft < 160) - projectile.timeLeft = 160; - } + if (projectile.timeLeft < 160) + projectile.timeLeft = 160; + } - if (projectile.velocity.Length() < 16f) - projectile.velocity *= 1.01f; + if (projectile.velocity.Length() < 16f) + projectile.velocity *= 1.01f; - int index = Player.FindClosest(projectile.Center, projectile.width, projectile.height); - Player player = Main.player[index]; - if (player is null || player.Calamity().lol) - return; + int index = Player.FindClosest(projectile.Center, projectile.width, projectile.height); + Player player = Main.player[index]; + if (player is null || player.Calamity().lol) + return; - float playerDist = Vector2.Distance(player.Center, projectile.Center); + float playerDist = Vector2.Distance(player.Center, projectile.Center); if (playerDist < 50f && !player.dead && projectile.position.X < player.position.X + player.width && projectile.position.X + projectile.width > player.position.X && projectile.position.Y < player.Bottom.Y && projectile.Bottom.Y > player.position.Y) { int dmgAmt = (int)projectile.ai[1]; player.HealEffect(dmgAmt, false); player.statLife += dmgAmt; - player.Calamity().adrenaline = player.Calamity().stressPills ? player.Calamity().adrenaline / 2 : 0; + player.Calamity().adrenaline = player.Calamity().stressPills ? player.Calamity().adrenaline / 2 : 0; if (player.statLife > player.statLifeMax2) { player.statLife = player.statLifeMax2; @@ -70,45 +69,48 @@ namespace CalamityMod.Projectiles.Boss } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - float lerpMult = Utils.InverseLerp(15f, 30f, projectile.timeLeft, clamped: true) * Utils.InverseLerp(240f, 200f, projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTime % 30f / 0.5f * (MathHelper.Pi * 2f) * 3f)) * 0.8f; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + float lerpMult = Utils.InverseLerp(15f, 30f, projectile.timeLeft, clamped: true) * Utils.InverseLerp(240f, 200f, projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTime % 30f / 0.5f * (MathHelper.Pi * 2f) * 3f)) * 0.8f; - Texture2D texture = Main.projectileTexture[projectile.type]; - Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); - Color baseColor = Main.dayTime ? new Color(255, 200, 100, 255) : new Color(100, 200, 255, 255); - baseColor *= 0.5f; - baseColor.A = 0; - Color colorA = baseColor; - Color colorB = baseColor * 0.5f; - colorA *= lerpMult; - colorB *= lerpMult; - Vector2 origin = texture.Size() / 2f; - Vector2 scale = new Vector2(0.5f, 1.5f) * lerpMult; + Texture2D texture = Main.projectileTexture[projectile.type]; + Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Color baseColor = Main.dayTime ? new Color(255, 200, 100, 255) : new Color(100, 200, 255, 255); + baseColor *= 0.5f; + baseColor.A = 0; + Color colorA = baseColor; + Color colorB = baseColor * 0.5f; + colorA *= lerpMult; + colorB *= lerpMult; + Vector2 origin = texture.Size() / 2f; + Vector2 scale = new Vector2(0.5f, 1.5f) * lerpMult; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver2, origin, scale, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorA, 0f, origin, scale, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver2, origin, scale * 0.6f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, 0f, origin, scale * 0.6f, spriteEffects, 0); + float upRight = MathHelper.PiOver4; + float up = MathHelper.PiOver2; + float upLeft = 3f * MathHelper.PiOver4; + float left = MathHelper.Pi; + spriteBatch.Draw(texture, drawPos, null, colorA, upLeft, origin, scale, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, upRight, origin, scale, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, upLeft, origin, scale * 0.6f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, upRight, origin, scale * 0.6f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, up, origin, scale * 0.6f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, left, origin, scale * 0.6f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, up, origin, scale * 0.36f, spriteEffects, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, left, origin, scale * 0.36f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4, origin, scale * 0.6f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f, origin, scale * 0.6f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4, origin, scale * 0.36f, spriteEffects, 0); - spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f, origin, scale * 0.36f, spriteEffects, 0); + return false; + } - return false; - } - - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item14, projectile.Center); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 50); - int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; - for (int d = 0; d < 5; d++) + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 50); + int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + for (int d = 0; d < 5; d++) { int holy = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); Main.dust[holy].velocity *= 3f; @@ -130,8 +132,8 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - int buffType = Main.dayTime ? ModContent.BuffType() : ModContent.BuffType(); - target.AddBuff(buffType, 60); - } + int buffType = Main.dayTime ? ModContent.BuffType() : ModContent.BuffType(); + target.AddBuff(buffType, 60); + } } } diff --git a/Projectiles/Boss/HolyLight.cs b/Projectiles/Boss/HolyLight.cs index 6489470224..7dfc311d8c 100644 --- a/Projectiles/Boss/HolyLight.cs +++ b/Projectiles/Boss/HolyLight.cs @@ -66,9 +66,7 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D value = Main.projectileTexture[projectile.type]; - Color baseColor = new Color(100, 255, 100, 255); - Color color33 = baseColor; - color33.A = 0; + Color color33 = new Color(54, 209, 54, 0); Vector2 vector28 = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); Color color34 = color33; Vector2 origin5 = value.Size() / 2f; From 5c4daa8634b63323c2dd391e2b8dc6cc4e77ff40 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sat, 27 Feb 2021 17:29:01 -0500 Subject: [PATCH 15/22] Minor cleanups to dodge code. More will come soon. --- CalPlayer/CalamityPlayer.cs | 24 +++++------------------- Items/Accessories/AbyssalMirror.cs | 3 +-- Items/Accessories/EclipseMirror.cs | 5 ++--- Items/Accessories/StatisBeltOfCurses.cs | 2 +- Items/Accessories/StatisNinjaBelt.cs | 8 +++----- Items/CalamityGlobalItem.cs | 7 ++----- 6 files changed, 14 insertions(+), 35 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index be221d1277..71be549317 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -3846,20 +3846,23 @@ namespace CalamityMod.CalPlayer SpectralVeil(); return true; } - // Scarf cooldowns affect each other + + // Neither scarf can be used if either is on cooldown bool playerDashing = player.pulley || player.grappling[0] == -1 && !player.tongued; if (playerDashing && dashMod == 1 && player.dashDelay < 0 && dodgeScarf && !scarfCooldown && !eScarfCooldown) { OnDodge(); return true; } - // Mirror cooldowns affect each other + + // Neither mirror can be used if either is on cooldown bool isImmune = false; for (int j = 0; j < player.hurtCooldowns.Length; j++) { if (player.hurtCooldowns[j] > 0) isImmune = true; } + if (dodgeCooldownTimer == 0 && !isImmune && !eclipseMirrorCooldown && !abyssalMirrorCooldown) { if (eclipseMirror) @@ -7057,18 +7060,6 @@ namespace CalamityMod.CalPlayer if (HandleDodges()) return false; - // New Black Belt and Master Ninja Gear code. - if (dodgeCooldownTimer > 0) - { - player.blackBelt = false; - } - else if (player.blackBelt) - { - dodgeCooldownTimer = 3600; - player.NinjaDodge(); - return false; - } - // Lul makes the player completely invincible. if (lol) return false; @@ -7096,11 +7087,6 @@ namespace CalamityMod.CalPlayer KillPlayer(); } } - - // God Slayer Reflect gives a 2% chance to dodge any hit. - // This is intentionally after Armageddon so that the 2% random chance doesn't screw up no-hits. - if (godSlayerReflect && Main.rand.NextBool(50)) - return false; #endregion // diff --git a/Items/Accessories/AbyssalMirror.cs b/Items/Accessories/AbyssalMirror.cs index f5470d11fb..cd63a6dad5 100644 --- a/Items/Accessories/AbyssalMirror.cs +++ b/Items/Accessories/AbyssalMirror.cs @@ -15,8 +15,7 @@ namespace CalamityMod.Items.Accessories "Significantly reduces enemy aggression, even in the abyss\n" + "Stealth generates 30% faster when standing still and 20% faster while moving\n" + "Grants the ability to evade attacks, releasing a cloud of lumenyl fluid which damages and stuns nearby enemies\n" + - "Evading an attack grants a lot of stealth\n" + - "This evade has a 75s cooldown before it can occur again"); + "Evading an attack grants a lot of stealth but has a 75 second cooldown"); } public override void SetDefaults() diff --git a/Items/Accessories/EclipseMirror.cs b/Items/Accessories/EclipseMirror.cs index 6478781801..27c35bae9d 100644 --- a/Items/Accessories/EclipseMirror.cs +++ b/Items/Accessories/EclipseMirror.cs @@ -20,15 +20,14 @@ namespace CalamityMod.Items.Accessories "Stealth strikes have a 100% critical hit chance\n" + "Stealth strikes only expend 50% of your max stealth\n" + "Grants the ability to evade attacks in a blast of darksun light, which inflicts extreme damage in a wide area\n" + - "Evading an attack grants full stealth\n" + - "This evade has a 75s cooldown before it can occur again"); + "Evading an attack grants full stealth but has a 75 second cooldown"); } public override void SetDefaults() { item.width = 38; item.height = 38; - item.rare = ItemRarityID.Purple; + item.rare = ItemRarityID.Purple; item.value = CalamityGlobalItem.Rarity14BuyPrice; item.Calamity().customRarity = CalamityRarity.DarkBlue; item.accessory = true; diff --git a/Items/Accessories/StatisBeltOfCurses.cs b/Items/Accessories/StatisBeltOfCurses.cs index c40e1028a3..f9089ce596 100644 --- a/Items/Accessories/StatisBeltOfCurses.cs +++ b/Items/Accessories/StatisBeltOfCurses.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Accessories Tooltip.SetDefault("24% increased jump speed and allows constant jumping\n" + "Grants immunity to fall damage\n" + "Can climb walls, dash, and dodge attacks\n" + - "The dodge has a 60s cooldown\n" + + "The dodge has a 60 second cooldown\n" + "Dashes leave homing scythes in your wake"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(8, 3)); } diff --git a/Items/Accessories/StatisNinjaBelt.cs b/Items/Accessories/StatisNinjaBelt.cs index 9e5f311329..3b1ee518ed 100644 --- a/Items/Accessories/StatisNinjaBelt.cs +++ b/Items/Accessories/StatisNinjaBelt.cs @@ -1,4 +1,3 @@ -using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; @@ -12,9 +11,9 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Statis' Ninja Belt"); Tooltip.SetDefault("12% increased jump speed and allows constant jumping\n" + - "Increased fall damage resistance by 35 blocks\n" + + "Increased fall damage resistance by 35 blocks\n" + "Can climb walls, dash, and dodge attacks\n" + - "The dodge has a 60s cooldown"); + "The dodge has a 60 second cooldown"); } public override void SetDefaults() @@ -28,12 +27,11 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - CalamityPlayer modPlayer = player.Calamity(); player.autoJump = true; player.jumpSpeedBoost += 0.6f; player.extraFall += 35; player.blackBelt = true; - player.dash = 1; + player.dash = 1; player.spikedBoots = 2; } diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 67e0e2d7ef..401ca6c008 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -4,9 +4,6 @@ using CalamityMod.CalPlayer; using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor; -using CalamityMod.Items.DifficultyItems; -using CalamityMod.Items.Materials; -using CalamityMod.Items.PermanentBoosters; using CalamityMod.Items.Placeables.Furniture.Fountains; using CalamityMod.Items.Potions; using CalamityMod.Items.Tools; @@ -1256,7 +1253,7 @@ namespace CalamityMod.Items { if (line2.mod == "Terraria" && line2.Name == "Tooltip0") line2.text = "Grants the ability to dodge attacks\n" + - "This dodge has a 60s cooldown"; + "The dodge has a 60 second cooldown"; } } if (item.type == ItemID.MasterNinjaGear) @@ -1265,7 +1262,7 @@ namespace CalamityMod.Items { if (line2.mod == "Terraria" && line2.Name == "Tooltip1") line2.text = "Grants the ability to dodge attacks\n" + - "This dodge has a 60s cooldown"; + "The dodge has a 60 second cooldown"; } } if (item.type == ItemID.CobaltSword || item.type == ItemID.CobaltNaginata) From 614655bd1484af8382cc93f0de92e59ef570e78f Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Wed, 27 Jan 2021 18:36:40 -0600 Subject: [PATCH 16/22] Fixed various Providence desync problems --- NPCs/Providence/Providence.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 8c0230716d..b9b2090e4f 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -127,6 +127,8 @@ namespace CalamityMod.NPCs.Providence writer.Write(npc.chaseable); writer.Write(npc.canGhostHeal); writer.Write(npc.localAI[2]); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); } public override void ReceiveExtraAI(BinaryReader reader) @@ -143,7 +145,9 @@ namespace CalamityMod.NPCs.Providence npc.chaseable = reader.ReadBoolean(); npc.canGhostHeal = reader.ReadBoolean(); npc.localAI[2] = reader.ReadSingle(); - } + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } public override void AI() { @@ -199,6 +203,7 @@ namespace CalamityMod.NPCs.Providence calamityGlobalNPC.newAI[1] = 0f; calamityGlobalNPC.newAI[2] = 0f; calamityGlobalNPC.newAI[3] = 0f; + npc.netUpdate = true; } // Difficulty bools @@ -673,6 +678,7 @@ namespace CalamityMod.NPCs.Providence npc.ai[3] = 0f; calamityGlobalNPC.newAI[1] = 0f; calamityGlobalNPC.newAI[2] = 0f; + npc.netUpdate = true; break; case (int)Phase.HolyBlast: @@ -885,6 +891,7 @@ namespace CalamityMod.NPCs.Providence // Radial offset npc.ai[2] += 10f; } + npc.netUpdate = true; } else { From 9e0125d267b888439bebaeda5870667d4207bf98 Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Wed, 24 Feb 2021 11:30:20 -0600 Subject: [PATCH 17/22] Fixed deus lag problems --- NPCs/CalamityAI.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index caf58d420f..4bea08c32d 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -3218,10 +3218,13 @@ namespace CalamityMod.NPCs if (npc.type != ModContent.NPCType()) { bool shouldDespawn = true; + int headType = ModContent.NPCType(); for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - shouldDespawn = false; + if (Main.npc[i].type != headType || !Main.npc[i].active) + continue; + shouldDespawn = false; + break; } if (!shouldDespawn) { @@ -3376,12 +3379,18 @@ namespace CalamityMod.NPCs npc.velocity.Y -= velocity; } + int headType = ModContent.NPCType(); + int bodyType = ModContent.NPCType(); + int tailType = ModContent.NPCType(); if ((double)npc.position.Y < Main.topWorld + 16f) { for (int num957 = 0; num957 < Main.maxNPCs; num957++) { - if (Main.npc[num957].type == ModContent.NPCType() || Main.npc[num957].type == ModContent.NPCType() || Main.npc[num957].type == ModContent.NPCType()) + if (Main.npc[num957].type == headType || Main.npc[num957].type == bodyType || Main.npc[num957].type == tailType) + { Main.npc[num957].active = false; + Main.npc[num957].netUpdate = true; + } } } } From c729056e750b6a4c3d897a19aee08efa878276f4 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sat, 27 Feb 2021 18:37:34 -0500 Subject: [PATCH 18/22] reorganized netcode and removed unnecessary packets --- CalPlayer/CalamityPlayer.cs | 22 -- CalPlayer/CalamityPlayerMiscEffects.cs | 1 - CalamityNetcode.cs | 327 ++++++++++++------------- Events/AcidRainEvent.cs | 8 - Items/Weapons/Melee/GaelsGreatsword.cs | 8 - Utilities/NPCUtils.cs | 34 +++ World/CalamityWorld.cs | 1 - 7 files changed, 194 insertions(+), 207 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 71be549317..a83e19722e 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -9243,19 +9243,6 @@ namespace CalamityMod.CalPlayer packet.Send(-1, player.whoAmI); } - public void AquaticBoostPacket(bool server) - { - ModPacket packet = mod.GetPacket(256); - packet.Write((byte)CalamityModMessageType.AquaticBoostSync); - packet.Write(player.whoAmI); - packet.Write(aquaticBoost); - - if (!server) - packet.Send(); - else - packet.Send(-1, player.whoAmI); - } - public void MoveSpeedStatPacket(bool server) { ModPacket packet = mod.GetPacket(256); @@ -9381,13 +9368,6 @@ namespace CalamityMod.CalPlayer ReforgeTierSafetyPacket(true); } - internal void HandleAquaticBoost(BinaryReader reader) - { - aquaticBoost = reader.ReadSingle(); - if (Main.netMode == NetmodeID.Server) - AquaticBoostPacket(true); - } - internal void HandleMoveSpeedStat(BinaryReader reader) { moveSpeedStat = reader.ReadInt32(); @@ -9421,9 +9401,7 @@ namespace CalamityMod.CalPlayer DeathPacket(false); DeathModeUnderworldTimePacket(false); DeathModeBlizzardTimePacket(false); - ItemTypeLastReforgedPacket(false); ReforgeTierSafetyPacket(false); - AquaticBoostPacket(false); MoveSpeedStatPacket(false); DefenseDamagePacket(false); } diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 5f35eeb857..52abf3a54e 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -266,7 +266,6 @@ namespace CalamityMod.CalPlayer modPlayer.AdrenalinePacket(false); modPlayer.DeathModeUnderworldTimePacket(false); modPlayer.DeathModeBlizzardTimePacket(false); - modPlayer.AquaticBoostPacket(false); modPlayer.MoveSpeedStatPacket(false); modPlayer.DefenseDamagePacket(false); } diff --git a/CalamityNetcode.cs b/CalamityNetcode.cs index b2da105d12..cd9009e9ee 100644 --- a/CalamityNetcode.cs +++ b/CalamityNetcode.cs @@ -1,7 +1,6 @@ using CalamityMod.Events; using CalamityMod.NPCs; using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.Providence; using CalamityMod.TileEntities; using CalamityMod.World; @@ -22,6 +21,10 @@ namespace CalamityMod CalamityModMessageType msgType = (CalamityModMessageType)reader.ReadByte(); switch (msgType) { + // + // Proficiency levels + // + case CalamityModMessageType.MeleeLevelSync: Main.player[reader.ReadInt32()].Calamity().HandleLevels(reader, 0); break; @@ -52,116 +55,31 @@ namespace CalamityMod case CalamityModMessageType.ExactRogueLevelSync: Main.player[reader.ReadInt32()].Calamity().HandleExactLevels(reader, 4); break; + + // + // Core stat syncs + // + + case CalamityModMessageType.MoveSpeedStatSync: + Main.player[reader.ReadInt32()].Calamity().HandleMoveSpeedStat(reader); + break; + case CalamityModMessageType.DefenseDamageSync: + Main.player[reader.ReadInt32()].Calamity().HandleDefenseDamage(reader); + break; case CalamityModMessageType.RageSync: Main.player[reader.ReadInt32()].Calamity().HandleRage(reader); break; - case CalamityModMessageType.BossRushStage: - int stage = reader.ReadInt32(); - BossRushEvent.BossRushStage = stage; - break; case CalamityModMessageType.AdrenalineSync: Main.player[reader.ReadInt32()].Calamity().HandleAdrenaline(reader); break; - case CalamityModMessageType.TeleportPlayer: - Main.player[reader.ReadInt32()].Calamity().HandleTeleport(reader.ReadInt32(), true, whoAmI); - break; - case CalamityModMessageType.DoGCountdownSync: - int countdown = reader.ReadInt32(); - CalamityWorld.DoGSecondStageCountdown = countdown; - break; - case CalamityModMessageType.BossSpawnCountdownSync: - int countdown2 = reader.ReadInt32(); - CalamityWorld.bossSpawnCountdown = countdown2; - break; - case CalamityModMessageType.BRHostileProjKillSync: - int countdown3 = reader.ReadInt32(); - CalamityWorld.bossRushHostileProjKillCounter = countdown3; - break; - case CalamityModMessageType.DeathBossSpawnCountdownSync: - int countdown4 = reader.ReadInt32(); - CalamityWorld.deathBossSpawnCooldown = countdown4; - break; - case CalamityModMessageType.ArmoredDiggerCountdownSync: - int countdown5 = reader.ReadInt32(); - CalamityWorld.ArmoredDiggerSpawnCooldown = countdown5; - break; - case CalamityModMessageType.BossTypeSync: - int type = reader.ReadInt32(); - CalamityWorld.bossType = type; - break; case CalamityModMessageType.DeathCountSync: Main.player[reader.ReadInt32()].Calamity().HandleDeathCount(reader); break; - case CalamityModMessageType.DeathModeUnderworldTimeSync: - Main.player[reader.ReadInt32()].Calamity().HandleDeathModeUnderworldTime(reader); - break; - case CalamityModMessageType.DeathModeBlizzardTimeSync: - Main.player[reader.ReadInt32()].Calamity().HandleDeathModeBlizzardTime(reader); - break; - case CalamityModMessageType.ItemTypeLastReforgedSync: - Main.player[reader.ReadInt32()].Calamity().HandleItemTypeLastReforged(reader); - break; - case CalamityModMessageType.ReforgeTierSafetySync: - Main.player[reader.ReadInt32()].Calamity().HandleReforgeTierSafety(reader); - break; - /*case CalamityModMessageType.AquaticBoostSync: - Main.player[reader.ReadInt32()].Calamity().HandleAquaticBoost(reader); - break;*/ - case CalamityModMessageType.MoveSpeedStatSync: - Main.player[reader.ReadInt32()].Calamity().HandleMoveSpeedStat(reader); - break; - case CalamityModMessageType.DefenseDamageSync: - Main.player[reader.ReadInt32()].Calamity().HandleDefenseDamage(reader); - break; - case CalamityModMessageType.NPCRegenerationSync: - byte npcIndex = reader.ReadByte(); - Main.npc[npcIndex].lifeRegen = reader.ReadInt32(); - break; - case CalamityModMessageType.AcidRainSync: - CalamityWorld.rainingAcid = reader.ReadBoolean(); - CalamityWorld.acidRainPoints = reader.ReadInt32(); - CalamityWorld.timeSinceAcidRainKill = reader.ReadInt32(); - break; - case CalamityModMessageType.AcidRainUIDrawFadeSync: - CalamityWorld.acidRainExtraDrawTime = reader.ReadInt32(); - break; - case CalamityModMessageType.AcidRainOldDukeSummonSync: - CalamityWorld.triedToSummonOldDuke = reader.ReadBoolean(); - break; - case CalamityModMessageType.EncounteredOldDukeSync: - CalamityWorld.encounteredOldDuke = reader.ReadBoolean(); - break; - case CalamityModMessageType.GaelsGreatswordSwingSync: - byte playerIndex = reader.ReadByte(); - Main.player[playerIndex].Calamity().gaelSwipes = reader.ReadInt32(); - break; - case CalamityModMessageType.SpawnSuperDummy: - int x = reader.ReadInt32(); - int y = reader.ReadInt32(); - // Not strictly necessary, but helps prevent unnecessary packetstorm in MP - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.NewNPC(x, y, ModContent.NPCType()); - break; - // - // Ozzatron's packets + // Syncs for specific bosses or entities // - case CalamityModMessageType.PowerCellFactory: - TEPowerCellFactory.ReadSyncPacket(mod, reader); - break; - case CalamityModMessageType.ChargingStationStandard: - TEChargingStation.ReadSyncPacket(mod, reader); - break; - case CalamityModMessageType.ChargingStationItemChange: - TEChargingStation.ReadItemSyncPacket(mod, reader); - break; - case CalamityModMessageType.Turret: - TEBaseTurret.ReadSyncPacket(mod, reader); - break; - case CalamityModMessageType.LabHologramProjector: - TELabHologramProjector.ReadSyncPacket(mod, reader); - break; + // This code has been edited to fail gracefully when trying to provide data for an invalid NPC. case CalamityModMessageType.SyncCalamityNPCAIArray: // Read the entire packet regardless of anything @@ -182,8 +100,25 @@ namespace CalamityMod cgn.newAI[2] = ai2; cgn.newAI[3] = ai3; break; - - + case CalamityModMessageType.SpawnSuperDummy: + int x = reader.ReadInt32(); + int y = reader.ReadInt32(); + // Not strictly necessary, but helps prevent unnecessary packetstorm in MP + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPC(x, y, ModContent.NPCType()); + break; + case CalamityModMessageType.ServersideSpawnOldDuke: + byte playerIndex2 = reader.ReadByte(); + CalamityUtils.SpawnOldDuke(playerIndex2); + break; + case CalamityModMessageType.DoGCountdownSync: + int countdown = reader.ReadInt32(); + CalamityWorld.DoGSecondStageCountdown = countdown; + break; + case CalamityModMessageType.ArmoredDiggerCountdownSync: + int countdown5 = reader.ReadInt32(); + CalamityWorld.ArmoredDiggerSpawnCooldown = countdown5; + break; case CalamityModMessageType.ProvidenceDyeConditionSync: byte npcIndex3 = reader.ReadByte(); (Main.npc[npcIndex3].modNPC as Providence).hasTakenDaytimeDamage = reader.ReadBoolean(); @@ -193,37 +128,99 @@ namespace CalamityMod (Main.npc[npcIndex4].modNPC as Providence).challenge = reader.ReadBoolean(); break; - case CalamityModMessageType.ServersideSpawnOldDuke: - byte playerIndex2 = reader.ReadByte(); + // + // Tile Entities + // - if (Main.netMode != NetmodeID.Server) - break; - - Player player = Main.player[playerIndex2]; - if (!player.active || player.dead) - return; - - Projectile projectile = null; - for (int i = 0; i < Main.maxProjectiles; i++) - { - projectile = Main.projectile[i]; - if (Main.projectile[i].active && Main.projectile[i].bobber && Main.projectile[i].owner == playerIndex2) - { - projectile = Main.projectile[i]; - break; - } - } - - if (projectile is null) - return; - - int oldDuke = NPC.NewNPC((int)projectile.Center.X, (int)projectile.Center.Y + 100, ModContent.NPCType()); - CalamityUtils.BossAwakenMessage(oldDuke); + case CalamityModMessageType.PowerCellFactory: + TEPowerCellFactory.ReadSyncPacket(mod, reader); + break; + case CalamityModMessageType.ChargingStationStandard: + TEChargingStation.ReadSyncPacket(mod, reader); + break; + case CalamityModMessageType.ChargingStationItemChange: + TEChargingStation.ReadItemSyncPacket(mod, reader); + break; + case CalamityModMessageType.Turret: + TEBaseTurret.ReadSyncPacket(mod, reader); + break; + case CalamityModMessageType.LabHologramProjector: + TELabHologramProjector.ReadSyncPacket(mod, reader); break; + // + // Boss Rush + // + + case CalamityModMessageType.BossRushStage: + int stage = reader.ReadInt32(); + BossRushEvent.BossRushStage = stage; + break; + case CalamityModMessageType.BossSpawnCountdownSync: + int countdown2 = reader.ReadInt32(); + CalamityWorld.bossSpawnCountdown = countdown2; + break; + case CalamityModMessageType.BossTypeSync: + int type = reader.ReadInt32(); + CalamityWorld.bossType = type; + break; + case CalamityModMessageType.BRHostileProjKillSync: + int countdown3 = reader.ReadInt32(); + CalamityWorld.bossRushHostileProjKillCounter = countdown3; + break; + case CalamityModMessageType.TeleportPlayer: + Main.player[reader.ReadInt32()].Calamity().HandleTeleport(reader.ReadInt32(), true, whoAmI); + break; + + // + // Acid Rain + // + + case CalamityModMessageType.AcidRainSync: + CalamityWorld.rainingAcid = reader.ReadBoolean(); + CalamityWorld.acidRainPoints = reader.ReadInt32(); + CalamityWorld.timeSinceAcidRainKill = reader.ReadInt32(); + break; + case CalamityModMessageType.AcidRainOldDukeSummonSync: + CalamityWorld.triedToSummonOldDuke = reader.ReadBoolean(); + break; + case CalamityModMessageType.EncounteredOldDukeSync: + CalamityWorld.encounteredOldDuke = reader.ReadBoolean(); + break; + + // + // Death Mode environmental syncs + // + + case CalamityModMessageType.DeathModeUnderworldTimeSync: + Main.player[reader.ReadInt32()].Calamity().HandleDeathModeUnderworldTime(reader); + break; + case CalamityModMessageType.DeathModeBlizzardTimeSync: + Main.player[reader.ReadInt32()].Calamity().HandleDeathModeBlizzardTime(reader); + break; + case CalamityModMessageType.DeathBossSpawnCountdownSync: + int countdown4 = reader.ReadInt32(); + CalamityWorld.deathBossSpawnCooldown = countdown4; + break; + + // + // Reforge syncs + // + + case CalamityModMessageType.ItemTypeLastReforgedSync: + Main.player[reader.ReadInt32()].Calamity().HandleItemTypeLastReforged(reader); + break; + case CalamityModMessageType.ReforgeTierSafetySync: + Main.player[reader.ReadInt32()].Calamity().HandleReforgeTierSafety(reader); + break; + + // + // Default case: with no idea how long the packet is, we can't safely read data. + // Throw an exception now instead of allowing the network stream to corrupt. + // default: CalamityMod.Instance.Logger.Error($"Failed to parse Calamity packet: No Calamity packet exists with ID {msgType}."); - break; + throw new Exception("Failed to parse Calamity packet: Invalid Calamity packet ID."); } } catch (Exception e) @@ -248,65 +245,61 @@ namespace CalamityMod public enum CalamityModMessageType : byte { + // Proficiency levels + // TODO -- simplify proficiency netcode, there do not need to be this many separate packet types MeleeLevelSync, RangedLevelSync, MagicLevelSync, SummonLevelSync, RogueLevelSync, - ExactMeleeLevelSync, ExactRangedLevelSync, ExactMagicLevelSync, ExactSummonLevelSync, ExactRogueLevelSync, - MoveSpeedStatSync, + // Core stat syncs + MoveSpeedStatSync, // TODO -- this can't be synced every 60 frames, it needs to be synced every time the player is + DefenseDamageSync, // TODO -- this can't be synced every 60 frames, it needs to be synced when the player gets hit, or every time it heals up + RageSync, // TODO -- this can't be synced every 60 frames, it needs to be synced every time the player is + AdrenalineSync, // TODO -- this can't be synced every 60 frames, it needs to be synced every time the player is + DeathCountSync, // TODO -- this is synced in numerous incorrect places, Armageddon deaths count twice, and it supposedly counts every time you log in - DefenseDamageSync, - - RageSync, - AdrenalineSync, - - AquaticBoostSync, - - TeleportPlayer, - BossRushStage, - DoGCountdownSync, - BossSpawnCountdownSync, - BRHostileProjKillSync, - ArmoredDiggerCountdownSync, - BossTypeSync, - DeathCountSync, - - NPCRegenerationSync, - - DeathModeUnderworldTimeSync, - DeathModeBlizzardTimeSync, - DeathBossSpawnCountdownSync, - - ItemTypeLastReforgedSync, - ReforgeTierSafetySync, - - AcidRainSync, - AcidRainUIDrawFadeSync, - AcidRainOldDukeSummonSync, - EncounteredOldDukeSync, - - GaelsGreatswordSwingSync, - - SpawnSuperDummy, + // Syncs for specific bosses or entities SyncCalamityNPCAIArray, + SpawnSuperDummy, // TODO -- super dummies STILL don't work in multiplayer + ServersideSpawnOldDuke, + DoGCountdownSync, // TODO -- this gets written in about six thousand places which all need to be individually evaluated + ArmoredDiggerCountdownSync, // TODO -- remove this mechanic entirely + ProvidenceDyeConditionSync, // TODO -- this packetstorms if you hit Provi with spam weapons. It should ONLY send a packet if the status changes. + PSCChallengeSync, // TODO -- once you've failed the PSC challenge this packetstorms - ProvidenceDyeConditionSync, // We shouldn't fucking need this. Die in a hole, Multiplayer. - PSCChallengeSync, // See above - - // These message types were written by Ozz. They are Ozz's working tile entity netcode. Do not touch them. + // Tile Entities PowerCellFactory, ChargingStationStandard, ChargingStationItemChange, Turret, LabHologramProjector, - ServersideSpawnOldDuke + // Boss Rush + BossRushStage, + BossSpawnCountdownSync, + BossTypeSync, + BRHostileProjKillSync, // TODO -- Simplify this. Only one packet needs be sent: "kill all hostile projectiles for N frames". + TeleportPlayer, // also used by Astral Arcanum. + + // Acid Rain + AcidRainSync, + AcidRainOldDukeSummonSync, + EncounteredOldDukeSync, + + // Death Mode environmental syncs + DeathModeUnderworldTimeSync, // TODO -- Rename to heat time. This should be synced every 15 frames. + DeathModeBlizzardTimeSync, // TODO -- Rename to cold time. This should be synced every 15 frames. + DeathBossSpawnCountdownSync, // TODO -- This currently syncs every frame and shouldn't. It only needs to sync once, when the countdown starts. + + // Reforge syncs + ItemTypeLastReforgedSync, // TODO -- there has to be a better way to do this, but I don't know what it is + ReforgeTierSafetySync, } } diff --git a/Events/AcidRainEvent.cs b/Events/AcidRainEvent.cs index 66756cda49..c5b5a8489a 100644 --- a/Events/AcidRainEvent.cs +++ b/Events/AcidRainEvent.cs @@ -189,7 +189,6 @@ namespace CalamityMod.Events { CalamityWorld.rainingAcid = false; BroadcastEventText("Mods.CalamityMod.AcidRainEnd"); // The sulphuric skies begin to clear... - CalamityWorld.acidRainExtraDrawTime = 40; // Turn off the rain from the event Main.numCloudsTemp = Main.rand.Next(5, 20 + 1); @@ -221,13 +220,6 @@ namespace CalamityMod.Events netMessage.Send(); } if (Main.netMode == NetmodeID.Server) - { - var netMessage = CalamityMod.Instance.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.AcidRainUIDrawFadeSync); - netMessage.Write(CalamityWorld.acidRainExtraDrawTime); - netMessage.Send(); - } - if (Main.netMode == NetmodeID.Server) { var netMessage = CalamityMod.Instance.GetPacket(); netMessage.Write((byte)CalamityModMessageType.AcidRainOldDukeSummonSync); diff --git a/Items/Weapons/Melee/GaelsGreatsword.cs b/Items/Weapons/Melee/GaelsGreatsword.cs index 2296711bd5..0539848f88 100644 --- a/Items/Weapons/Melee/GaelsGreatsword.cs +++ b/Items/Weapons/Melee/GaelsGreatsword.cs @@ -118,14 +118,6 @@ namespace CalamityMod.Items.Weapons.Melee } } } - if (Main.netMode == NetmodeID.Server) - { - var netMessage = CalamityMod.Instance.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.GaelsGreatswordSwingSync); - netMessage.Write((byte)player.whoAmI); - netMessage.Write(player.Calamity().gaelSwipes); - netMessage.Send(); - } } } public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit) diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index 132190c7f4..2c6e79b11b 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -4,6 +4,7 @@ using CalamityMod.Events; using CalamityMod.NPCs.HiveMind; using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.Perforator; using CalamityMod.NPCs.Providence; using CalamityMod.NPCs.SlimeGod; @@ -13,6 +14,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.Localization; +using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; namespace CalamityMod @@ -441,5 +443,37 @@ namespace CalamityMod target.AddBuff(BuffID.Frostburn, (int)(120 * multiplier)); target.AddBuff(BuffID.OnFire, (int)(120 * multiplier)); } + + /// + /// Spawns Old Duke on a player. Only works server side, and only works if the player owns a fishing bobber.
+ /// Old Duke will spawn above the fishing bobber if one is found. + ///
+ /// The index of the player who will spawn Old Duke. + internal static void SpawnOldDuke(int playerIndex) + { + if (Main.netMode != NetmodeID.Server) + return; + + Player player = Main.player[playerIndex]; + if (!player.active || player.dead) + return; + + Projectile projectile = null; + for (int i = 0; i < Main.maxProjectiles; i++) + { + projectile = Main.projectile[i]; + if (Main.projectile[i].active && Main.projectile[i].bobber && Main.projectile[i].owner == playerIndex) + { + projectile = Main.projectile[i]; + break; + } + } + + if (projectile is null) + return; + + int oldDuke = NPC.NewNPC((int)projectile.Center.X, (int)projectile.Center.Y + 100, NPCType()); + BossAwakenMessage(oldDuke); + } } } diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index 1a2d35d747..ab4381055c 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -92,7 +92,6 @@ namespace CalamityMod.World public static int abyssChasmBottom = 0; public static bool rainingAcid; public static int acidRainPoints = 0; - public static int acidRainExtraDrawTime = 0; public static bool triedToSummonOldDuke = false; public static bool startAcidicDownpour = false; public static bool forcedRainAlready = false; From 301255491d3ccee00e453b4343ed5c644a131109 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sat, 27 Feb 2021 19:16:47 -0500 Subject: [PATCH 19/22] Refactored player netcode. Added dodge cooldown packet. --- CalPlayer/CalamityPlayer.cs | 368 ++----------------------- CalPlayer/CalamityPlayerMiscEffects.cs | 28 +- CalPlayer/CalamityPlayerNetcode.cs | 323 ++++++++++++++++++++++ CalamityNetcode.cs | 4 + Utilities/PlayerUtils.cs | 21 +- 5 files changed, 384 insertions(+), 360 deletions(-) create mode 100644 CalPlayer/CalamityPlayerNetcode.cs diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index a83e19722e..0cc6510202 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -3970,10 +3970,15 @@ namespace CalamityMod.CalPlayer Main.projectile[lumenyl].frame = Main.rand.Next(0, 4); } + // TODO -- Calamity dodges should probably not send a vanilla dodge packet considering that causes Tabi dust if (player.whoAmI == Main.myPlayer) { NetMessage.SendData(MessageID.Dodge, -1, -1, null, player.whoAmI, 1f, 0f, 0f, 0, 0, 0); } + + // Send a Calamity dodge cooldown packet. + if (Main.netMode == NetmodeID.MultiplayerClient && player.whoAmI == Main.myPlayer) + SyncDodgeCooldown(false); } } @@ -3996,10 +4001,15 @@ namespace CalamityMod.CalPlayer Main.PlaySound(SoundID.Item68, player.Center); Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(5500 * player.RogueDamage()), 0, player.whoAmI); + // TODO -- Calamity dodges should probably not send a vanilla dodge packet considering that causes Tabi dust if (player.whoAmI == Main.myPlayer) { NetMessage.SendData(MessageID.Dodge, -1, -1, null, player.whoAmI, 1f, 0f, 0f, 0, 0, 0); } + + // Send a Calamity dodge cooldown packet. + if (Main.netMode == NetmodeID.MultiplayerClient && player.whoAmI == Main.myPlayer) + SyncDodgeCooldown(false); } } #endregion @@ -4350,7 +4360,7 @@ namespace CalamityMod.CalPlayer deathCount++; if (player.whoAmI == Main.myPlayer && Main.netMode == NetmodeID.MultiplayerClient) { - DeathPacket(false); + SyncDeathCount(false); } return true; @@ -5191,7 +5201,7 @@ namespace CalamityMod.CalPlayer shootFireworksLevelUpMelee = true; if (Main.netMode == NetmodeID.MultiplayerClient) - LevelPacket(false, (int)ClassType.Melee); + SyncLevel(false, (int)ClassType.Melee); } } } @@ -5470,7 +5480,7 @@ namespace CalamityMod.CalPlayer shootFireworksLevelUpMelee = true; if (Main.netMode == NetmodeID.MultiplayerClient) - LevelPacket(false, (int)ClassType.Melee); + SyncLevel(false, (int)ClassType.Melee); } else if (proj.ranged && rangedLevel <= 12500) { @@ -5491,7 +5501,7 @@ namespace CalamityMod.CalPlayer shootFireworksLevelUpRanged = true; if (Main.netMode == NetmodeID.MultiplayerClient) - LevelPacket(false, (int)ClassType.Ranged); + SyncLevel(false, (int)ClassType.Ranged); } else if (proj.magic && magicLevel <= 12500) { @@ -5512,7 +5522,7 @@ namespace CalamityMod.CalPlayer shootFireworksLevelUpMagic = true; if (Main.netMode == NetmodeID.MultiplayerClient) - LevelPacket(false, (int)ClassType.Magic); + SyncLevel(false, (int)ClassType.Magic); } else if (proj.IsSummon() && summonLevel <= 12500) { @@ -5533,7 +5543,7 @@ namespace CalamityMod.CalPlayer shootFireworksLevelUpSummon = true; if (Main.netMode == NetmodeID.MultiplayerClient) - LevelPacket(false, (int)ClassType.Summon); + SyncLevel(false, (int)ClassType.Summon); } else if (proj.Calamity().rogue && rogueLevel <= 12500) { @@ -5554,7 +5564,7 @@ namespace CalamityMod.CalPlayer shootFireworksLevelUpRogue = true; if (Main.netMode == NetmodeID.MultiplayerClient) - LevelPacket(false, (int)ClassType.Rogue); + SyncLevel(false, (int)ClassType.Rogue); } } } @@ -7805,7 +7815,7 @@ namespace CalamityMod.CalPlayer deathCount++; if (player.whoAmI == Main.myPlayer && Main.netMode == NetmodeID.MultiplayerClient) { - DeathPacket(false); + SyncDeathCount(false); } player.lastDeathPostion = player.Center; player.lastDeathTime = DateTime.Now; @@ -9075,339 +9085,6 @@ namespace CalamityMod.CalPlayer } #endregion - #region Packet Stuff - private void ExactLevelPacket(bool server, int levelType) - { - ModPacket packet = mod.GetPacket(256); - switch (levelType) - { - case 0: - packet.Write((byte)CalamityModMessageType.ExactMeleeLevelSync); - packet.Write(player.whoAmI); - packet.Write(exactMeleeLevel); - break; - case 1: - packet.Write((byte)CalamityModMessageType.ExactRangedLevelSync); - packet.Write(player.whoAmI); - packet.Write(exactRangedLevel); - break; - case 2: - packet.Write((byte)CalamityModMessageType.ExactMagicLevelSync); - packet.Write(player.whoAmI); - packet.Write(exactMagicLevel); - break; - case 3: - packet.Write((byte)CalamityModMessageType.ExactSummonLevelSync); - packet.Write(player.whoAmI); - packet.Write(exactSummonLevel); - break; - case 4: - packet.Write((byte)CalamityModMessageType.ExactRogueLevelSync); - packet.Write(player.whoAmI); - packet.Write(exactRogueLevel); - break; - } - - if (!server) - packet.Send(); - else - packet.Send(-1, player.whoAmI); - } - - private void LevelPacket(bool server, int levelType) - { - ModPacket packet = mod.GetPacket(256); - switch (levelType) - { - case 0: - packet.Write((byte)CalamityModMessageType.MeleeLevelSync); - packet.Write(player.whoAmI); - packet.Write(meleeLevel); - break; - case 1: - packet.Write((byte)CalamityModMessageType.RangedLevelSync); - packet.Write(player.whoAmI); - packet.Write(rangedLevel); - break; - case 2: - packet.Write((byte)CalamityModMessageType.MagicLevelSync); - packet.Write(player.whoAmI); - packet.Write(magicLevel); - break; - case 3: - packet.Write((byte)CalamityModMessageType.SummonLevelSync); - packet.Write(player.whoAmI); - packet.Write(summonLevel); - break; - case 4: - packet.Write((byte)CalamityModMessageType.RogueLevelSync); - packet.Write(player.whoAmI); - packet.Write(rogueLevel); - break; - } - - if (!server) - packet.Send(); - else - packet.Send(-1, player.whoAmI); - } - - public void RagePacket(bool server) - { - ModPacket packet = mod.GetPacket(256); - packet.Write((byte)CalamityModMessageType.RageSync); - packet.Write(player.whoAmI); - packet.Write(rage); - - if (!server) - packet.Send(); - else - packet.Send(-1, player.whoAmI); - } - - public void AdrenalinePacket(bool server) - { - ModPacket packet = mod.GetPacket(256); - packet.Write((byte)CalamityModMessageType.AdrenalineSync); - packet.Write(player.whoAmI); - packet.Write(adrenaline); - - if (!server) - packet.Send(); - else - packet.Send(-1, player.whoAmI); - } - - private void DeathPacket(bool server) - { - ModPacket packet = mod.GetPacket(256); - packet.Write((byte)CalamityModMessageType.DeathCountSync); - packet.Write(player.whoAmI); - packet.Write(deathCount); - - if (!server) - packet.Send(); - else - packet.Send(-1, player.whoAmI); - } - - public void DeathModeUnderworldTimePacket(bool server) - { - ModPacket packet = mod.GetPacket(256); - packet.Write((byte)CalamityModMessageType.DeathModeUnderworldTimeSync); - packet.Write(player.whoAmI); - packet.Write(deathModeUnderworldTime); - - if (!server) - packet.Send(); - else - packet.Send(-1, player.whoAmI); - } - - public void DeathModeBlizzardTimePacket(bool server) - { - ModPacket packet = mod.GetPacket(256); - packet.Write((byte)CalamityModMessageType.DeathModeBlizzardTimeSync); - packet.Write(player.whoAmI); - packet.Write(deathModeBlizzardTime); - - if (!server) - packet.Send(); - else - packet.Send(-1, player.whoAmI); - } - - public void ItemTypeLastReforgedPacket(bool server) - { - ModPacket packet = mod.GetPacket(256); - packet.Write((byte)CalamityModMessageType.ItemTypeLastReforgedSync); - packet.Write(player.whoAmI); - packet.Write(itemTypeLastReforged); - - if (!server) - packet.Send(); - else - packet.Send(-1, player.whoAmI); - } - - public void ReforgeTierSafetyPacket(bool server) - { - ModPacket packet = mod.GetPacket(256); - packet.Write((byte)CalamityModMessageType.ReforgeTierSafetySync); - packet.Write(player.whoAmI); - packet.Write(reforgeTierSafety); - - if (!server) - packet.Send(); - else - packet.Send(-1, player.whoAmI); - } - - public void MoveSpeedStatPacket(bool server) - { - ModPacket packet = mod.GetPacket(256); - packet.Write((byte)CalamityModMessageType.MoveSpeedStatSync); - packet.Write(player.whoAmI); - packet.Write(moveSpeedStat); - - if (!server) - packet.Send(); - else - packet.Send(-1, player.whoAmI); - } - - public void DefenseDamagePacket(bool server) - { - ModPacket packet = mod.GetPacket(256); - packet.Write((byte)CalamityModMessageType.DefenseDamageSync); - packet.Write(player.whoAmI); - packet.Write(defenseDamage); - - if (!server) - packet.Send(); - else - packet.Send(-1, player.whoAmI); - } - - internal void HandleExactLevels(BinaryReader reader, int levelType) - { - switch (levelType) - { - case 0: - exactMeleeLevel = reader.ReadInt32(); - break; - case 1: - exactRangedLevel = reader.ReadInt32(); - break; - case 2: - exactMagicLevel = reader.ReadInt32(); - break; - case 3: - exactSummonLevel = reader.ReadInt32(); - break; - case 4: - exactRogueLevel = reader.ReadInt32(); - break; - } - - if (Main.netMode == NetmodeID.Server) - ExactLevelPacket(true, levelType); - } - - internal void HandleLevels(BinaryReader reader, int levelType) - { - switch (levelType) - { - case 0: - meleeLevel = reader.ReadInt32(); - break; - case 1: - rangedLevel = reader.ReadInt32(); - break; - case 2: - magicLevel = reader.ReadInt32(); - break; - case 3: - summonLevel = reader.ReadInt32(); - break; - case 4: - rogueLevel = reader.ReadInt32(); - break; - } - - if (Main.netMode == NetmodeID.Server) - LevelPacket(true, levelType); - } - - internal void HandleRage(BinaryReader reader) - { - rage = reader.ReadInt32(); - if (Main.netMode == NetmodeID.Server) - RagePacket(true); - } - - internal void HandleAdrenaline(BinaryReader reader) - { - adrenaline = reader.ReadInt32(); - if (Main.netMode == NetmodeID.Server) - AdrenalinePacket(true); - } - - internal void HandleDeathCount(BinaryReader reader) - { - deathCount = reader.ReadInt32(); - if (Main.netMode == NetmodeID.Server) - DeathPacket(true); - } - - internal void HandleDeathModeUnderworldTime(BinaryReader reader) - { - deathModeUnderworldTime = reader.ReadInt32(); - if (Main.netMode == NetmodeID.Server) - DeathModeUnderworldTimePacket(true); - } - - internal void HandleDeathModeBlizzardTime(BinaryReader reader) - { - deathModeBlizzardTime = reader.ReadInt32(); - if (Main.netMode == NetmodeID.Server) - DeathModeBlizzardTimePacket(true); - } - - internal void HandleItemTypeLastReforged(BinaryReader reader) - { - itemTypeLastReforged = reader.ReadInt32(); - if (Main.netMode == NetmodeID.Server) - ItemTypeLastReforgedPacket(true); - } - - internal void HandleReforgeTierSafety(BinaryReader reader) - { - reforgeTierSafety = reader.ReadInt32(); - if (Main.netMode == NetmodeID.Server) - ReforgeTierSafetyPacket(true); - } - - internal void HandleMoveSpeedStat(BinaryReader reader) - { - moveSpeedStat = reader.ReadInt32(); - if (Main.netMode == NetmodeID.Server) - MoveSpeedStatPacket(true); - } - - internal void HandleDefenseDamage(BinaryReader reader) - { - defenseDamage = reader.ReadInt32(); - if (Main.netMode == NetmodeID.Server) - DefenseDamagePacket(true); - } - - public override void OnEnterWorld(Player player) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - { - ExactLevelPacket(false, 0); - ExactLevelPacket(false, 1); - ExactLevelPacket(false, 2); - ExactLevelPacket(false, 3); - ExactLevelPacket(false, 4); - LevelPacket(false, 0); - LevelPacket(false, 1); - LevelPacket(false, 2); - LevelPacket(false, 3); - LevelPacket(false, 4); - RagePacket(false); - AdrenalinePacket(false); - DeathPacket(false); - DeathModeUnderworldTimePacket(false); - DeathModeBlizzardTimePacket(false); - ReforgeTierSafetyPacket(false); - MoveSpeedStatPacket(false); - DefenseDamagePacket(false); - } - } - #endregion - #region Proficiency Stuff private bool ReduceCooldown(int classType) { @@ -9874,7 +9551,7 @@ namespace CalamityMod.CalPlayer } if (Main.netMode == NetmodeID.MultiplayerClient) { - ExactLevelPacket(false, levelUpType); + SyncExactLevel(false, levelUpType); } } @@ -10437,6 +10114,13 @@ namespace CalamityMod.CalPlayer #region Misc Stuff + // Triggers effects that must occur when the player enters the world. This sends a bunch of packets in multiplayer. + public override void OnEnterWorld(Player player) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + EnterWorldSync(); + } + /// /// Returns the range at which an abyss enemy can detect the player /// diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 52abf3a54e..5822e1f97b 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -109,6 +109,17 @@ namespace CalamityMod.CalPlayer // Potions (Quick Buff && Potion Sickness) HandlePotions(player, modPlayer); + + // Regularly sync player stats during multiplayer + if (player.whoAmI == Main.myPlayer && Main.netMode == NetmodeID.MultiplayerClient) + { + modPlayer.packetTimer++; + if (modPlayer.packetTimer == CalamityPlayer.GlobalSyncPacketTimer) + { + modPlayer.packetTimer = 0; + modPlayer.StandardSync(); + } + } } #endregion @@ -253,23 +264,6 @@ namespace CalamityMod.CalPlayer modPlayer.rage = 0; modPlayer.adrenaline = 0; } - - // Send info packets during multiplayer - // TODO -- this should be moved to its own update step - if (player.whoAmI == Main.myPlayer && Main.netMode == NetmodeID.MultiplayerClient) - { - modPlayer.packetTimer++; - if (modPlayer.packetTimer == 60) - { - modPlayer.packetTimer = 0; - modPlayer.RagePacket(false); - modPlayer.AdrenalinePacket(false); - modPlayer.DeathModeUnderworldTimePacket(false); - modPlayer.DeathModeBlizzardTimePacket(false); - modPlayer.MoveSpeedStatPacket(false); - modPlayer.DefenseDamagePacket(false); - } - } } private static void UpdateRippers(Mod mod, Player player, CalamityPlayer modPlayer) diff --git a/CalPlayer/CalamityPlayerNetcode.cs b/CalPlayer/CalamityPlayerNetcode.cs new file mode 100644 index 0000000000..bdfc07c5a9 --- /dev/null +++ b/CalPlayer/CalamityPlayerNetcode.cs @@ -0,0 +1,323 @@ +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.CalPlayer +{ + public partial class CalamityPlayer + { + #region Standard Syncs + internal const int GlobalSyncPacketTimer = 15; + + internal void StandardSync() + { + SyncRage(false); + SyncAdrenaline(false); + SyncDeathModeUnderworldTime(false); + SyncDeathModeBlizzardTime(false); + SyncMoveSpeed(false); + SyncDefenseDamage(false); + SyncDodgeCooldown(false); + } + + private void EnterWorldSync() + { + StandardSync(); + SyncExactLevel(false, 0); + SyncExactLevel(false, 1); + SyncExactLevel(false, 2); + SyncExactLevel(false, 3); + SyncExactLevel(false, 4); + SyncLevel(false, 0); + SyncLevel(false, 1); + SyncLevel(false, 2); + SyncLevel(false, 3); + SyncLevel(false, 4); + SyncRage(false); + } + #endregion + + #region Creating and Sending Packets + private void SyncExactLevel(bool server, int levelType) + { + ModPacket packet = mod.GetPacket(); + switch (levelType) + { + case 0: + packet.Write((byte)CalamityModMessageType.ExactMeleeLevelSync); + packet.Write(player.whoAmI); + packet.Write(exactMeleeLevel); + break; + case 1: + packet.Write((byte)CalamityModMessageType.ExactRangedLevelSync); + packet.Write(player.whoAmI); + packet.Write(exactRangedLevel); + break; + case 2: + packet.Write((byte)CalamityModMessageType.ExactMagicLevelSync); + packet.Write(player.whoAmI); + packet.Write(exactMagicLevel); + break; + case 3: + packet.Write((byte)CalamityModMessageType.ExactSummonLevelSync); + packet.Write(player.whoAmI); + packet.Write(exactSummonLevel); + break; + case 4: + packet.Write((byte)CalamityModMessageType.ExactRogueLevelSync); + packet.Write(player.whoAmI); + packet.Write(exactRogueLevel); + break; + } + player.SendPacket(packet, server); + } + + private void SyncLevel(bool server, int levelType) + { + ModPacket packet = mod.GetPacket(256); + switch (levelType) + { + case 0: + packet.Write((byte)CalamityModMessageType.MeleeLevelSync); + packet.Write(player.whoAmI); + packet.Write(meleeLevel); + break; + case 1: + packet.Write((byte)CalamityModMessageType.RangedLevelSync); + packet.Write(player.whoAmI); + packet.Write(rangedLevel); + break; + case 2: + packet.Write((byte)CalamityModMessageType.MagicLevelSync); + packet.Write(player.whoAmI); + packet.Write(magicLevel); + break; + case 3: + packet.Write((byte)CalamityModMessageType.SummonLevelSync); + packet.Write(player.whoAmI); + packet.Write(summonLevel); + break; + case 4: + packet.Write((byte)CalamityModMessageType.RogueLevelSync); + packet.Write(player.whoAmI); + packet.Write(rogueLevel); + break; + } + player.SendPacket(packet, server); + } + + public void SyncMoveSpeed(bool server) + { + ModPacket packet = mod.GetPacket(256); + packet.Write((byte)CalamityModMessageType.MoveSpeedStatSync); + packet.Write(player.whoAmI); + packet.Write(moveSpeedStat); + player.SendPacket(packet, server); + } + + public void SyncDefenseDamage(bool server) + { + ModPacket packet = mod.GetPacket(256); + packet.Write((byte)CalamityModMessageType.DefenseDamageSync); + packet.Write(player.whoAmI); + packet.Write(defenseDamage); + player.SendPacket(packet, server); + } + + public void SyncRage(bool server) + { + ModPacket packet = mod.GetPacket(256); + packet.Write((byte)CalamityModMessageType.RageSync); + packet.Write(player.whoAmI); + packet.Write(rage); + player.SendPacket(packet, server); + } + + public void SyncAdrenaline(bool server) + { + ModPacket packet = mod.GetPacket(256); + packet.Write((byte)CalamityModMessageType.AdrenalineSync); + packet.Write(player.whoAmI); + packet.Write(adrenaline); + player.SendPacket(packet, server); + } + + internal void SyncDodgeCooldown(bool server) + { + ModPacket packet = mod.GetPacket(); + packet.Write((byte)CalamityModMessageType.DodgeCooldown); + packet.Write(player.whoAmI); + packet.Write(dodgeCooldownTimer); + player.SendPacket(packet, server); + } + + private void SyncDeathCount(bool server) + { + ModPacket packet = mod.GetPacket(256); + packet.Write((byte)CalamityModMessageType.DeathCountSync); + packet.Write(player.whoAmI); + packet.Write(deathCount); + player.SendPacket(packet, server); + } + + public void SyncDeathModeUnderworldTime(bool server) + { + ModPacket packet = mod.GetPacket(256); + packet.Write((byte)CalamityModMessageType.DeathModeUnderworldTimeSync); + packet.Write(player.whoAmI); + packet.Write(deathModeUnderworldTime); + player.SendPacket(packet, server); + } + + public void SyncDeathModeBlizzardTime(bool server) + { + ModPacket packet = mod.GetPacket(256); + packet.Write((byte)CalamityModMessageType.DeathModeBlizzardTimeSync); + packet.Write(player.whoAmI); + packet.Write(deathModeBlizzardTime); + player.SendPacket(packet, server); + } + + public void SyncItemTypeLastReforged(bool server) + { + ModPacket packet = mod.GetPacket(256); + packet.Write((byte)CalamityModMessageType.ItemTypeLastReforgedSync); + packet.Write(player.whoAmI); + packet.Write(itemTypeLastReforged); + player.SendPacket(packet, server); + } + + public void SyncReforgeTierSafety(bool server) + { + ModPacket packet = mod.GetPacket(256); + packet.Write((byte)CalamityModMessageType.ReforgeTierSafetySync); + packet.Write(player.whoAmI); + packet.Write(reforgeTierSafety); + player.SendPacket(packet, server); + } + #endregion + + #region Reading and Handling Packets + internal void HandleExactLevels(BinaryReader reader, int levelType) + { + switch (levelType) + { + case 0: + exactMeleeLevel = reader.ReadInt32(); + break; + case 1: + exactRangedLevel = reader.ReadInt32(); + break; + case 2: + exactMagicLevel = reader.ReadInt32(); + break; + case 3: + exactSummonLevel = reader.ReadInt32(); + break; + case 4: + exactRogueLevel = reader.ReadInt32(); + break; + } + + if (Main.netMode == NetmodeID.Server) + SyncExactLevel(true, levelType); + } + + internal void HandleLevels(BinaryReader reader, int levelType) + { + switch (levelType) + { + case 0: + meleeLevel = reader.ReadInt32(); + break; + case 1: + rangedLevel = reader.ReadInt32(); + break; + case 2: + magicLevel = reader.ReadInt32(); + break; + case 3: + summonLevel = reader.ReadInt32(); + break; + case 4: + rogueLevel = reader.ReadInt32(); + break; + } + + if (Main.netMode == NetmodeID.Server) + SyncLevel(true, levelType); + } + + internal void HandleRage(BinaryReader reader) + { + rage = reader.ReadInt32(); + if (Main.netMode == NetmodeID.Server) + SyncRage(true); + } + + internal void HandleAdrenaline(BinaryReader reader) + { + adrenaline = reader.ReadInt32(); + if (Main.netMode == NetmodeID.Server) + SyncAdrenaline(true); + } + + internal void HandleDeathCount(BinaryReader reader) + { + deathCount = reader.ReadInt32(); + if (Main.netMode == NetmodeID.Server) + SyncDeathCount(true); + } + + internal void HandleDeathModeUnderworldTime(BinaryReader reader) + { + deathModeUnderworldTime = reader.ReadInt32(); + if (Main.netMode == NetmodeID.Server) + SyncDeathModeUnderworldTime(true); + } + + internal void HandleDeathModeBlizzardTime(BinaryReader reader) + { + deathModeBlizzardTime = reader.ReadInt32(); + if (Main.netMode == NetmodeID.Server) + SyncDeathModeBlizzardTime(true); + } + + internal void HandleItemTypeLastReforged(BinaryReader reader) + { + itemTypeLastReforged = reader.ReadInt32(); + if (Main.netMode == NetmodeID.Server) + SyncItemTypeLastReforged(true); + } + + internal void HandleReforgeTierSafety(BinaryReader reader) + { + reforgeTierSafety = reader.ReadInt32(); + if (Main.netMode == NetmodeID.Server) + SyncReforgeTierSafety(true); + } + + internal void HandleMoveSpeedStat(BinaryReader reader) + { + moveSpeedStat = reader.ReadInt32(); + if (Main.netMode == NetmodeID.Server) + SyncMoveSpeed(true); + } + + internal void HandleDefenseDamage(BinaryReader reader) + { + defenseDamage = reader.ReadInt32(); + if (Main.netMode == NetmodeID.Server) + SyncDefenseDamage(true); + } + + internal void HandleDodgeCooldown(BinaryReader reader) + { + dodgeCooldownTimer = reader.ReadInt32(); + if (Main.netMode == NetmodeID.Server) + SyncDodgeCooldown(true); + } + #endregion + } +} diff --git a/CalamityNetcode.cs b/CalamityNetcode.cs index cd9009e9ee..88e29c1b2a 100644 --- a/CalamityNetcode.cs +++ b/CalamityNetcode.cs @@ -72,6 +72,9 @@ namespace CalamityMod case CalamityModMessageType.AdrenalineSync: Main.player[reader.ReadInt32()].Calamity().HandleAdrenaline(reader); break; + case CalamityModMessageType.DodgeCooldown: + Main.player[reader.ReadInt32()].Calamity().HandleDodgeCooldown(reader); + break; case CalamityModMessageType.DeathCountSync: Main.player[reader.ReadInt32()].Calamity().HandleDeathCount(reader); break; @@ -263,6 +266,7 @@ namespace CalamityMod DefenseDamageSync, // TODO -- this can't be synced every 60 frames, it needs to be synced when the player gets hit, or every time it heals up RageSync, // TODO -- this can't be synced every 60 frames, it needs to be synced every time the player is AdrenalineSync, // TODO -- this can't be synced every 60 frames, it needs to be synced every time the player is + DodgeCooldown, DeathCountSync, // TODO -- this is synced in numerous incorrect places, Armageddon deaths count twice, and it supposedly counts every time you log in // Syncs for specific bosses or entities diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index 1a81e2d7a4..3e35ae3c37 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -4,7 +4,7 @@ using CalamityMod.CalPlayer; using System.Linq; using Terraria; using Terraria.ID; - +using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; namespace CalamityMod @@ -152,5 +152,24 @@ namespace CalamityMod target.AddBuff(BuffID.OnFire, (int)(120 * multiplier)); target.AddBuff(BuffID.Ichor, (int)(120 * multiplier)); } + + /// + /// Makes the given player send the given packet to all appropriate receivers.
+ /// If server is false, the packet is sent only to the multiplayer host.
+ /// If server is true, the packet is sent to all clients except the player it pertains to. + ///
+ /// The player to whom the packet's data pertains. + /// The packet to send with certain parameters. + /// True if a dedicated server is broadcasting information to all players. + public static void SendPacket(this Player player, ModPacket packet, bool server) + { + // Client: Send the packet only to the host. + if (!server) + packet.Send(); + + // Server: Send the packet to every OTHER client. + else + packet.Send(-1, player.whoAmI); + } } } From 6e7e184b5d5b548ed19b4f50a01b9ff0115603fe Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sat, 27 Feb 2021 20:19:39 -0500 Subject: [PATCH 20/22] Black Belt is no longer RNG and respects Calamity's dodge cooldown. The dodge cooldown packet is sent immediately when the Black Belt is used. --- CalPlayer/CalamityPlayer.cs | 12 +++++--- CalPlayer/CalamityPlayerNetcode.cs | 3 +- ILEditing/ILChanges.cs | 44 ++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 0cc6510202..eafc710341 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -69,7 +69,7 @@ using Terraria.ModLoader.IO; namespace CalamityMod.CalPlayer { - public class CalamityPlayer : ModPlayer + public partial class CalamityPlayer : ModPlayer { #region Variables @@ -222,7 +222,11 @@ namespace CalamityMod.CalPlayer public int auralisAurora = 0; public int fungalSymbioteTimer = 0; public int aBulwarkRareTimer = 0; - public int dodgeCooldownTimer = 0; + + public const int BeltDodgeCooldown = 3600; + public const int MirrorDodgeCooldown = 4500; + public int dodgeCooldownTimer = 0; + public bool canFireAtaxiaRangedProjectile = false; public bool canFireAtaxiaRogueProjectile = false; public bool canFireGodSlayerRangedProjectile = false; @@ -3949,7 +3953,7 @@ namespace CalamityMod.CalPlayer { if (player.whoAmI == Main.myPlayer && abyssalMirror && !abyssalMirrorCooldown && !eclipseMirror) { - dodgeCooldownTimer = 4500; + dodgeCooldownTimer = MirrorDodgeCooldown; player.AddBuff(ModContent.BuffType(), dodgeCooldownTimer); player.immune = true; player.immuneTime = player.longInvince ? 100 : 60; @@ -3986,7 +3990,7 @@ namespace CalamityMod.CalPlayer { if (player.whoAmI == Main.myPlayer && eclipseMirror && !eclipseMirrorCooldown) { - dodgeCooldownTimer = 4500; + dodgeCooldownTimer = MirrorDodgeCooldown; player.AddBuff(ModContent.BuffType(), dodgeCooldownTimer); player.immune = true; player.immuneTime = player.longInvince ? 100 : 60; diff --git a/CalPlayer/CalamityPlayerNetcode.cs b/CalPlayer/CalamityPlayerNetcode.cs index bdfc07c5a9..99942f33bc 100644 --- a/CalPlayer/CalamityPlayerNetcode.cs +++ b/CalPlayer/CalamityPlayerNetcode.cs @@ -5,7 +5,7 @@ using Terraria.ModLoader; namespace CalamityMod.CalPlayer { - public partial class CalamityPlayer + public partial class CalamityPlayer : ModPlayer { #region Standard Syncs internal const int GlobalSyncPacketTimer = 15; @@ -34,7 +34,6 @@ namespace CalamityMod.CalPlayer SyncLevel(false, 2); SyncLevel(false, 3); SyncLevel(false, 4); - SyncRage(false); } #endregion diff --git a/ILEditing/ILChanges.cs b/ILEditing/ILChanges.cs index a361f46e9d..ed6959381d 100644 --- a/ILEditing/ILChanges.cs +++ b/ILEditing/ILChanges.cs @@ -1,3 +1,4 @@ +using CalamityMod.CalPlayer; using CalamityMod.Tiles.DraedonStructures; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -9,6 +10,7 @@ using System.Reflection; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Terraria.Utilities; using Terraria.World.Generation; namespace CalamityMod.ILEditing @@ -50,6 +52,7 @@ namespace CalamityMod.ILEditing aLabDoorClosed = ModContent.TileType(); ApplyLifeBytesChanges(); + RemoveRNGFromBlackBelt(); ApplyBossZenDuringSlimeRain(); PreventDungeonAbyssInteraction(); BlockLivingTreesNearOcean(); @@ -69,6 +72,47 @@ namespace CalamityMod.ILEditing #region IL Editing Routines private static void ApplyLifeBytesChanges() => On.Terraria.Main.InitLifeBytes += BossRushLifeBytes; + private static void RemoveRNGFromBlackBelt() + { + // Change the random chance of the Black Belt to 100%, but don't let it work if Calamity's cooldown is active. + IL.Terraria.Player.Hurt += (il) => + { + var cursor = new ILCursor(il); + cursor.GotoNext(MoveType.Before, i => i.MatchLdcI4(10)); // 1 in 10 Main.rand call for Black Belt activation + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_I4_1); // Replace with Main.rand.Next(1), aka 100% chance + + // Move forwards past the Main.rand.Next call now that it has been edited + cursor.GotoNext(MoveType.After, i => i.MatchCallvirt("Next")); + + // Load the player itself onto the stack so that it becomes an argument for the following delegate. + cursor.Emit(OpCodes.Ldarg_0); + + // Emit a delegate which places the player's Calamity dodge cooldown onto the stack. + cursor.EmitDelegate>((Player p) => p.Calamity().dodgeCooldownTimer); + + // Bitwise OR the "RNG result" (always zero) with the dodge cooldown. This will only return zero if both values were zero. + // The code path which calls NinjaDodge can ONLY occur if the result of this operation is zero, + // because it is now the value checked by the immediately following branch-if-true. + cursor.Emit(OpCodes.Or); + + // Move forwards past the NinjaDodge call. We need to set the dodge cooldown here. + cursor.GotoNext(MoveType.After, i => i.MatchCall("NinjaDodge")); + + // Load the player itself onto the stack so that it becomes an argument for the following delegate. + cursor.Emit(OpCodes.Ldarg_0); + + // Emit a delegate which sets the player's Calamity dodge cooldown and sends a sync packet appropriately. + cursor.EmitDelegate>((Player p) => + { + CalamityPlayer calPlayer = p.Calamity(); + calPlayer.dodgeCooldownTimer = CalamityPlayer.BeltDodgeCooldown; + if (Main.netMode == NetmodeID.MultiplayerClient) + calPlayer.SyncDodgeCooldown(false); + }); + }; + } + private static void ApplyBossZenDuringSlimeRain() => On.Terraria.NPC.SlimeRainSpawns += PreventBossSlimeRainSpawns; private static void PreventDungeonAbyssInteraction() From 0934a61809af659a7ce6a3dd6624732828511f54 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sat, 27 Feb 2021 22:56:51 -0600 Subject: [PATCH 21/22] Killed some compilation errors --- CalPlayer/CalamityPlayer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index b09756694c..80df85e848 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -4711,7 +4711,7 @@ namespace CalamityMod.CalPlayer case ItemID.AdamantiteSword: float slowDownMult = 0.5f; - if (CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) + if (CalamityLists.enemyImmunityList.Contains(target.type) || target.boss) slowDownMult = 0.95f; target.velocity *= slowDownMult; break; @@ -4812,7 +4812,7 @@ namespace CalamityMod.CalPlayer case ProjectileID.AdamantiteGlaive: float slowDownMult = 0.5f; - if (CalamityLists.enemyImmunityList.Contains(npc.type) || npc.boss) + if (CalamityLists.enemyImmunityList.Contains(target.type) || target.boss) slowDownMult = 0.95f; target.velocity *= slowDownMult; break; From 8d49d0147de64814c0b0e663843646f76393d181 Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+termigator1359@users.noreply.github.com> Date: Sun, 28 Feb 2021 23:50:19 -0500 Subject: [PATCH 22/22] name change --- CalamityLists.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CalamityLists.cs b/CalamityLists.cs index de12e3d51c..e2a6492674 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -254,7 +254,7 @@ namespace CalamityMod "Vroomy Has -3,000 IQ", "The Goliath", "DaPyRo", - "Termi", + "Takeru", "Circuit-Jay", "Commmander Frostbite", "cytokat",