diff --git a/Buffs/Summon/MutatedTruffleBuff.cs b/Buffs/Summon/MutatedTruffleBuff.cs new file mode 100644 index 0000000000..44679632b7 --- /dev/null +++ b/Buffs/Summon/MutatedTruffleBuff.cs @@ -0,0 +1,36 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class MutatedTruffleBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Mini Old Duke"); + Description.SetDefault("The young duke will protect you"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + modPlayer.youngDuke = true; + } + if (!modPlayer.youngDuke) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/MutatedTruffleBuff.png b/Buffs/Summon/MutatedTruffleBuff.png new file mode 100644 index 0000000000..58ce4bfa8a Binary files /dev/null and b/Buffs/Summon/MutatedTruffleBuff.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 6722aea72d..1b20452465 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -735,6 +735,7 @@ namespace CalamityMod.CalPlayer public bool radiantResolution = false; public bool plaguebringerMK2 = false; public bool igneousExaltation = false; + public bool youngDuke = false; // Biome public bool ZoneCalamity = false; @@ -1524,6 +1525,7 @@ namespace CalamityMod.CalPlayer cSpirit = false; rOrb = false; dCrystal = false; + youngDuke = false; sandWaifu = false; sandBoobWaifu = false; cloudWaifu = false; diff --git a/Items/Accessories/MutatedTruffle.cs b/Items/Accessories/MutatedTruffle.cs index e191db698d..10382756db 100644 --- a/Items/Accessories/MutatedTruffle.cs +++ b/Items/Accessories/MutatedTruffle.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; @@ -30,6 +31,10 @@ namespace CalamityMod.Items.Accessories modPlayer.miniOldDuke = true; if (player.whoAmI == Main.myPlayer) { + if (player.FindBuffIndex(ModContent.BuffType()) == -1) + { + player.AddBuff(ModContent.BuffType(), 3600, true); + } const int damage = 1800; if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { diff --git a/Projectiles/Summon/YoungDuke.cs b/Projectiles/Summon/YoungDuke.cs index fb2948aa31..61697e20d2 100644 --- a/Projectiles/Summon/YoungDuke.cs +++ b/Projectiles/Summon/YoungDuke.cs @@ -39,6 +39,24 @@ namespace CalamityMod.Projectiles.Summon { Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); + if (!modPlayer.miniOldDuke) + { + projectile.active = false; + return; + } + + bool correctMinion = projectile.type == ModContent.ProjectileType(); + if (correctMinion) + { + if (player.dead) + { + modPlayer.youngDuke = false; + } + if (modPlayer.youngDuke) + { + projectile.timeLeft = 2; + } + } // Adjust damage as needed if (projectile.localAI[0] == 0f) @@ -77,18 +95,6 @@ namespace CalamityMod.Projectiles.Summon projectile.frame -= Main.projFrames[projectile.type] / 2; } - bool correctMinion = projectile.type == ModContent.ProjectileType(); - if (correctMinion) - { - if (player.dead) - { - modPlayer.miniOldDuke = false; - } - if (modPlayer.miniOldDuke) - { - projectile.timeLeft = 2; - } - } NPC potentialTarget = projectile.Center.ClosestNPCAt(1600f); if (potentialTarget != null) {