diff --git a/Buffs/Summon/VictideSummonSetBuff.cs b/Buffs/Summon/VictideSummonSetBuff.cs index 06d6e1fb52..a2d81dfa9b 100644 --- a/Buffs/Summon/VictideSummonSetBuff.cs +++ b/Buffs/Summon/VictideSummonSetBuff.cs @@ -1,4 +1,4 @@ -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Summon; using Terraria; using Terraria.ModLoader; @@ -9,8 +9,8 @@ namespace CalamityMod.Buffs.Summon { public override void SetStaticDefaults() { - DisplayName.SetDefault("Urchin"); - Description.SetDefault("The urchin will protect you"); + DisplayName.SetDefault("Sea Snail"); + Description.SetDefault("Meow?"); Main.buffNoTimeDisplay[Type] = true; Main.buffNoSave[Type] = true; //Main.persistentBuff[Type] = true; @@ -19,11 +19,14 @@ namespace CalamityMod.Buffs.Summon public override void Update(Player player, ref int buffIndex) { CalamityPlayer modPlayer = player.Calamity(); - if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + + + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) { - modPlayer.vUrchin = true; + modPlayer.victideSnail = true; } - if (!modPlayer.vUrchin) + + if (!modPlayer.victideSnail) { player.DelBuff(buffIndex); buffIndex--; diff --git a/Buffs/Summon/VictideSummonSetBuff.png b/Buffs/Summon/VictideSummonSetBuff.png index 9f8e4d0f53..7cba0b35e8 100644 Binary files a/Buffs/Summon/VictideSummonSetBuff.png and b/Buffs/Summon/VictideSummonSetBuff.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 5d6fea6d6e..8c4e0d9484 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -617,6 +617,7 @@ namespace CalamityMod.CalPlayer public bool eskimoSet = false; //vanilla armor public bool meteorSet = false; //vanilla armor, for space gun nerf public bool victideSet = false; + public bool victideSummoner = false; public bool sulfurSet = false; public bool sulfurJump = false; public bool jumpAgainSulfur = false; @@ -715,7 +716,6 @@ namespace CalamityMod.CalPlayer public bool omegaBlueChestplate = false; public bool omegaBlueSet = false; public bool omegaBlueHentai = false; - public bool urchin = false; public bool valkyrie = false; public bool slimeGod = false; public bool molluskSet = false; @@ -941,7 +941,7 @@ namespace CalamityMod.CalPlayer public bool hauntedDishes = false; public bool stormjaw = false; public bool sGod = false; - public bool vUrchin = false; + public bool victideSnail = false; public bool cSpirit = false; public bool rOrb = false; public bool dCrystal = false; @@ -1778,6 +1778,7 @@ namespace CalamityMod.CalPlayer meteorSet = false; //vanilla armor, for Space Gun nerf victideSet = false; + victideSummoner = false; sulfurSet = false; sulfurJump = false; @@ -2021,7 +2022,7 @@ namespace CalamityMod.CalPlayer sandnado = false; plantera = false; aProbe = false; - vUrchin = false; + victideSnail = false; cSpirit = false; rOrb = false; dCrystal = false; @@ -2038,7 +2039,6 @@ namespace CalamityMod.CalPlayer redDevil = false; valkyrie = false; slimeGod = false; - urchin = false; chaosSpirit = false; daedalusCrystal = false; shellfish = false; @@ -5807,6 +5807,21 @@ namespace CalamityMod.CalPlayer Player.back = (sbyte)EquipLoader.GetEquipSlot(Mod, "XerocPlateMail", EquipType.Back); Player.neck = (sbyte)EquipLoader.GetEquipSlot(Mod, "XerocPlateMail", EquipType.Neck); } + + bool victideBreastplateVisible = Player.body == EquipLoader.GetEquipSlot(Mod, "VictideBreastplate", EquipType.Body); + //Give the player faulds if either the body armor or the leggings are equipped + if (victideBreastplateVisible || Player.legs == EquipLoader.GetEquipSlot(Mod, "VictideGreaves", EquipType.Legs)) + { + Player.waist = (sbyte)EquipLoader.GetEquipSlot(Mod, "VictideFaulds", EquipType.Waist); + + //Also prevent the player from having any front drawing accs which would be wildly offset because of the different proportions. + if (victideBreastplateVisible) + { + Player.front = -1; + Player.handoff = -1; + Player.handon = -1; + } + } } #endregion diff --git a/CalPlayer/DrawLayers/BodyBulkLayer.cs b/CalPlayer/DrawLayers/BodyBulkLayer.cs new file mode 100644 index 0000000000..b8fc7e7a33 --- /dev/null +++ b/CalPlayer/DrawLayers/BodyBulkLayer.cs @@ -0,0 +1,58 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.DataStructures; +using Terraria.ModLoader; + +namespace CalamityMod.CalPlayer.DrawLayers +{ + + //Extends the player's body sprite to draw over the head, useful for bulky chestplates such as the victide breastplate. + public class BodyBulkLayer : PlayerDrawLayer + { + public override Position GetDefaultPosition() => new AfterParent(PlayerDrawLayers.Head); + + public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) => drawInfo.shadow == 0f || !drawInfo.drawPlayer.dead; + + protected override void Draw(ref PlayerDrawSet drawInfo) + { + //While the extra bulk draws over the players head position, we don't want to have it drawn when the head alone is being drawn. + if (drawInfo.headOnlyRender) + return; + + Player drawPlayer = drawInfo.drawPlayer; + int bodyItem = drawPlayer.armor[1].type; + if (drawPlayer.armor[11].type > ItemID.None) + bodyItem = drawPlayer.armor[11].type; + + if (ModContent.GetModItem(bodyItem) is IBulkyArmor chestplateBulkDrawer) + { + int dyeShader = drawPlayer.dye?[1].dye ?? 0; + Vector2 drawPosition = drawInfo.Position - Main.screenPosition; + + // Using drawPlayer to get width & height and such is perfectly fine, on the other hand. Just center everything + drawPosition += new Vector2((drawPlayer.width - drawPlayer.bodyFrame.Width) / 2f, drawPlayer.height - drawPlayer.bodyFrame.Height + 4f); + + //Convert to int to remove the jitter. + drawPosition = new Vector2((int)drawPosition.X, (int)drawPosition.Y); + + //Some dispalcements + drawPosition += drawPlayer.bodyPosition + drawInfo.bodyVect; + + //Grab the extension texture + Texture2D extraPieceTexture = ModContent.Request(chestplateBulkDrawer.BulkTexture).Value; + + //Get the frame of the extension based on the players body frame + Rectangle frame = extraPieceTexture.Frame(1, 20, 0, drawPlayer.bodyFrame.Y / drawPlayer.bodyFrame.Height); + + DrawData pieceDrawData = new DrawData(extraPieceTexture, drawPosition, frame, drawInfo.colorArmorBody, drawPlayer.fullRotation, drawInfo.bodyVect, 1f, drawInfo.playerEffect, 0) + { + shader = dyeShader + }; + drawInfo.DrawDataCache.Add(pieceDrawData); + + } + } + } +} diff --git a/CalPlayer/DrawLayers/IBulkyArmor.cs b/CalPlayer/DrawLayers/IBulkyArmor.cs new file mode 100644 index 0000000000..ce7f54a912 --- /dev/null +++ b/CalPlayer/DrawLayers/IBulkyArmor.cs @@ -0,0 +1,14 @@ +using Microsoft.Xna.Framework; +using Terraria.DataStructures; + +/// +/// Interface that can be used by chestplates to appear extra bulky, by drawing partly over the players helmet with an extra layer +/// +public interface IBulkyArmor +{ + /// + /// The texture of the part that goes above the helmet + /// This should be the same size as a regular equipped sprite (20 x 560 in 1x1) + /// + string BulkTexture { get; } +} diff --git a/CalamityLists.cs b/CalamityLists.cs index d18e4ab44e..7839ad3076 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -1352,7 +1352,7 @@ namespace CalamityMod ItemType(), ItemType(), ItemType(), - ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), @@ -1383,7 +1383,7 @@ namespace CalamityMod ProjectileType(), ProjectileType(), ProjectileType(), - ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), diff --git a/Items/Accessories/EnchantedPearl.cs b/Items/Accessories/EnchantedPearl.cs index eab88983a1..063d39bacd 100644 --- a/Items/Accessories/EnchantedPearl.cs +++ b/Items/Accessories/EnchantedPearl.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Items.Accessories AddIngredient(ItemID.CratePotion, 8). AddRecipeGroup("Boss2Material", 5). AddIngredient(10). - AddIngredient(3). + AddIngredient(3). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Accessories/ShieldoftheOcean.cs b/Items/Accessories/ShieldoftheOcean.cs index ac0d2cf658..56de6175fe 100644 --- a/Items/Accessories/ShieldoftheOcean.cs +++ b/Items/Accessories/ShieldoftheOcean.cs @@ -32,10 +32,7 @@ namespace CalamityMod.Items.Accessories { player.statDefense += 5; } - if ((player.armor[0].type == ModContent.ItemType() || player.armor[0].type == ModContent.ItemType() || - player.armor[0].type == ModContent.ItemType() || player.armor[0].type == ModContent.ItemType() || - player.armor[0].type == ModContent.ItemType()) && - player.armor[1].type == ModContent.ItemType() && player.armor[2].type == ModContent.ItemType()) + if (player.Calamity().victideSet) { player.moveSpeed += 0.1f; player.lifeRegen += 2; @@ -45,7 +42,7 @@ namespace CalamityMod.Items.Accessories public override void AddRecipes() { CreateRecipe(). - AddIngredient(5). + AddIngredient(5). AddIngredient(ItemID.Coral, 5). AddTile(TileID.Anvils). Register(); diff --git a/Items/Accessories/ShieldoftheOcean.png b/Items/Accessories/ShieldoftheOcean.png index 980b833da7..94cb248b27 100644 Binary files a/Items/Accessories/ShieldoftheOcean.png and b/Items/Accessories/ShieldoftheOcean.png differ diff --git a/Items/Armor/FathomSwarmerBoots.cs b/Items/Armor/FathomSwarmerBoots.cs index 23dabecdf1..2b312e3582 100644 --- a/Items/Armor/FathomSwarmerBoots.cs +++ b/Items/Armor/FathomSwarmerBoots.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Items.Armor { CreateRecipe(). AddIngredient(ItemID.SpiderGreaves). - AddIngredient(9). + AddIngredient(9). AddIngredient(8). AddIngredient(15). AddIngredient(4). diff --git a/Items/Armor/FathomSwarmerBreastplate.cs b/Items/Armor/FathomSwarmerBreastplate.cs index 75ebe8142b..0a7033a455 100644 --- a/Items/Armor/FathomSwarmerBreastplate.cs +++ b/Items/Armor/FathomSwarmerBreastplate.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Items.Armor { CreateRecipe(). AddIngredient(ItemID.SpiderBreastplate). - AddIngredient(12). + AddIngredient(12). AddIngredient(10). AddIngredient(18). AddIngredient(5). diff --git a/Items/Armor/FathomSwarmerVisage.cs b/Items/Armor/FathomSwarmerVisage.cs index e03cb23018..741ac3f905 100644 --- a/Items/Armor/FathomSwarmerVisage.cs +++ b/Items/Armor/FathomSwarmerVisage.cs @@ -69,7 +69,7 @@ namespace CalamityMod.Items.Armor { CreateRecipe(). AddIngredient(ItemID.SpiderMask). - AddIngredient(5). + AddIngredient(5). AddIngredient(6). AddIngredient(11). AddIngredient(3). diff --git a/Items/Armor/VictideBreastplate.cs b/Items/Armor/VictideBreastplate.cs index daebf4a042..03543ed328 100644 --- a/Items/Armor/VictideBreastplate.cs +++ b/Items/Armor/VictideBreastplate.cs @@ -6,14 +6,32 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { [AutoloadEquip(EquipType.Body)] - public class VictideBreastplate : ModItem + public class VictideBreastplate : ModItem, IBulkyArmor { + public string BulkTexture => "CalamityMod/Items/Armor/VictideBreastplate_Bulk"; + + public override void Load() + { + if (Main.netMode != NetmodeID.Server) + { + //register the faulds texture. This appears either when the leggings or the chestplate is equipped (both works) + EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Armor/VictideFaulds_Waist", EquipType.Waist, name: "VictideFaulds"); + } + } + public override void SetStaticDefaults() { SacrificeTotal = 1; DisplayName.SetDefault("Victide Breastplate"); Tooltip.SetDefault("5% increased damage reduction and critical strike chance\n" + "+5 defense and 10% increased damage reduction while submerged in liquid"); + + if (Main.netMode != NetmodeID.Server) + { + int equipSlot = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); + ArmorIDs.Body.Sets.HidesArms[equipSlot] = true; + ArmorIDs.Body.Sets.HidesTopSkin[equipSlot] = true; + } } public override void SetDefaults() @@ -39,7 +57,7 @@ namespace CalamityMod.Items.Armor public override void AddRecipes() { CreateRecipe(). - AddIngredient(5). + AddIngredient(5). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Armor/VictideBreastplate.png b/Items/Armor/VictideBreastplate.png index 47ea04a593..63290748c1 100644 Binary files a/Items/Armor/VictideBreastplate.png and b/Items/Armor/VictideBreastplate.png differ diff --git a/Items/Armor/VictideBreastplate_Body.png b/Items/Armor/VictideBreastplate_Body.png index a506265978..febaa6a90f 100644 Binary files a/Items/Armor/VictideBreastplate_Body.png and b/Items/Armor/VictideBreastplate_Body.png differ diff --git a/Items/Armor/VictideBreastplate_Bulk.png b/Items/Armor/VictideBreastplate_Bulk.png new file mode 100644 index 0000000000..d9f2ae53e0 Binary files /dev/null and b/Items/Armor/VictideBreastplate_Bulk.png differ diff --git a/Items/Armor/VictideFaulds_Waist.png b/Items/Armor/VictideFaulds_Waist.png new file mode 100644 index 0000000000..44376659c8 Binary files /dev/null and b/Items/Armor/VictideFaulds_Waist.png differ diff --git a/Items/Armor/VictideLeggings.cs b/Items/Armor/VictideGreaves.cs similarity index 71% rename from Items/Armor/VictideLeggings.cs rename to Items/Armor/VictideGreaves.cs index e40d42276b..d067bb0c63 100644 --- a/Items/Armor/VictideLeggings.cs +++ b/Items/Armor/VictideGreaves.cs @@ -6,14 +6,21 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { [AutoloadEquip(EquipType.Legs)] - public class VictideLeggings : ModItem + [LegacyName("VictideLeggings")] + public class VictideGreaves : ModItem { public override void SetStaticDefaults() { SacrificeTotal = 1; - DisplayName.SetDefault("Victide Leggings"); + DisplayName.SetDefault("Victide Greaves"); Tooltip.SetDefault("Movement speed increased by 8%\n" + "Movement speed increased by 30% while submerged in liquid"); + + if (Main.netMode != NetmodeID.Server) + { + int equipSlot = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); + ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlot] = true; + } } public override void SetDefaults() @@ -33,7 +40,7 @@ namespace CalamityMod.Items.Armor public override void AddRecipes() { CreateRecipe(). - AddIngredient(4). + AddIngredient(4). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Armor/VictideGreaves.png b/Items/Armor/VictideGreaves.png new file mode 100644 index 0000000000..b8a03d4459 Binary files /dev/null and b/Items/Armor/VictideGreaves.png differ diff --git a/Items/Armor/VictideGreaves_Legs.png b/Items/Armor/VictideGreaves_Legs.png new file mode 100644 index 0000000000..4fa451f604 Binary files /dev/null and b/Items/Armor/VictideGreaves_Legs.png differ diff --git a/Items/Armor/VictideMask.cs b/Items/Armor/VictideHeadMagic.cs similarity index 88% rename from Items/Armor/VictideMask.cs rename to Items/Armor/VictideHeadMagic.cs index ae3074a3e1..27f7d0ed05 100644 --- a/Items/Armor/VictideMask.cs +++ b/Items/Armor/VictideHeadMagic.cs @@ -7,12 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { [AutoloadEquip(EquipType.Head)] - public class VictideMask : ModItem + [LegacyName("VictideMask")] + public class VictideHeadMagic : ModItem { public override void SetStaticDefaults() { SacrificeTotal = 1; - DisplayName.SetDefault("Victide Mask"); + DisplayName.SetDefault("Victide Hermit Helmet"); Tooltip.SetDefault("5% increased magic damage"); } @@ -27,7 +28,7 @@ namespace CalamityMod.Items.Armor public override bool IsArmorSet(Item head, Item body, Item legs) { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); } public override void UpdateArmorSet(Player player) @@ -54,7 +55,7 @@ namespace CalamityMod.Items.Armor public override void AddRecipes() { CreateRecipe(). - AddIngredient(3). + AddIngredient(3). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Armor/VictideHeadMagic.png b/Items/Armor/VictideHeadMagic.png new file mode 100644 index 0000000000..89ae4b2b0e Binary files /dev/null and b/Items/Armor/VictideHeadMagic.png differ diff --git a/Items/Armor/VictideHeadMagic_Head.png b/Items/Armor/VictideHeadMagic_Head.png new file mode 100644 index 0000000000..0ed84c4efd Binary files /dev/null and b/Items/Armor/VictideHeadMagic_Head.png differ diff --git a/Items/Armor/VictideHelm.cs b/Items/Armor/VictideHeadMelee.cs similarity index 89% rename from Items/Armor/VictideHelm.cs rename to Items/Armor/VictideHeadMelee.cs index 2c0e6f4c9a..7e01621dde 100644 --- a/Items/Armor/VictideHelm.cs +++ b/Items/Armor/VictideHeadMelee.cs @@ -7,12 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { [AutoloadEquip(EquipType.Head)] - public class VictideHelm : ModItem + [LegacyName("VictideHelm")] + public class VictideHeadMelee : ModItem { public override void SetStaticDefaults() { SacrificeTotal = 1; - DisplayName.SetDefault("Victide Helm"); + DisplayName.SetDefault("Victide Shellmet"); Tooltip.SetDefault("5% increased melee damage"); } @@ -27,7 +28,7 @@ namespace CalamityMod.Items.Armor public override bool IsArmorSet(Item head, Item body, Item legs) { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); } public override void UpdateArmorSet(Player player) @@ -56,7 +57,7 @@ namespace CalamityMod.Items.Armor public override void AddRecipes() { CreateRecipe(). - AddIngredient(3). + AddIngredient(3). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Armor/VictideHeadMelee.png b/Items/Armor/VictideHeadMelee.png new file mode 100644 index 0000000000..812d19bf95 Binary files /dev/null and b/Items/Armor/VictideHeadMelee.png differ diff --git a/Items/Armor/VictideHeadMelee_Head.png b/Items/Armor/VictideHeadMelee_Head.png new file mode 100644 index 0000000000..35dd8c3a65 Binary files /dev/null and b/Items/Armor/VictideHeadMelee_Head.png differ diff --git a/Items/Armor/VictideVisage.cs b/Items/Armor/VictideHeadRanged.cs similarity index 88% rename from Items/Armor/VictideVisage.cs rename to Items/Armor/VictideHeadRanged.cs index 3ed1dbe514..07d6549ed1 100644 --- a/Items/Armor/VictideVisage.cs +++ b/Items/Armor/VictideHeadRanged.cs @@ -7,12 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { [AutoloadEquip(EquipType.Head)] - public class VictideVisage : ModItem + [LegacyName("VictideVisage")] + public class VictideHeadRanged : ModItem { public override void SetStaticDefaults() { SacrificeTotal = 1; - DisplayName.SetDefault("Victide Visage"); + DisplayName.SetDefault("Victide Coral Turban"); Tooltip.SetDefault("5% increased ranged damage"); } @@ -27,7 +28,7 @@ namespace CalamityMod.Items.Armor public override bool IsArmorSet(Item head, Item body, Item legs) { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); } public override void UpdateArmorSet(Player player) @@ -54,7 +55,7 @@ namespace CalamityMod.Items.Armor public override void AddRecipes() { CreateRecipe(). - AddIngredient(3). + AddIngredient(3). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Armor/VictideHeadRanged.png b/Items/Armor/VictideHeadRanged.png new file mode 100644 index 0000000000..fc8f925555 Binary files /dev/null and b/Items/Armor/VictideHeadRanged.png differ diff --git a/Items/Armor/VictideHeadRanged_Head.png b/Items/Armor/VictideHeadRanged_Head.png new file mode 100644 index 0000000000..6558698622 Binary files /dev/null and b/Items/Armor/VictideHeadRanged_Head.png differ diff --git a/Items/Armor/VictideHeadgear.cs b/Items/Armor/VictideHeadRogue.cs similarity index 90% rename from Items/Armor/VictideHeadgear.cs rename to Items/Armor/VictideHeadRogue.cs index 76842b1bbe..8bccee598e 100644 --- a/Items/Armor/VictideHeadgear.cs +++ b/Items/Armor/VictideHeadRogue.cs @@ -7,12 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { [AutoloadEquip(EquipType.Head)] - public class VictideHeadgear : ModItem + [LegacyName("VictideHeadgear")] + public class VictideHeadRogue : ModItem { public override void SetStaticDefaults() { SacrificeTotal = 1; - DisplayName.SetDefault("Victide Headgear"); + DisplayName.SetDefault("Victide Headcrab"); Tooltip.SetDefault("5% increased rogue damage"); } @@ -27,7 +28,7 @@ namespace CalamityMod.Items.Armor public override bool IsArmorSet(Item head, Item body, Item legs) { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); } public override void UpdateArmorSet(Player player) @@ -60,7 +61,7 @@ namespace CalamityMod.Items.Armor public override void AddRecipes() { CreateRecipe(). - AddIngredient(3). + AddIngredient(3). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Armor/VictideHeadRogue.png b/Items/Armor/VictideHeadRogue.png new file mode 100644 index 0000000000..2c54150300 Binary files /dev/null and b/Items/Armor/VictideHeadRogue.png differ diff --git a/Items/Armor/VictideHeadRogue_Head.png b/Items/Armor/VictideHeadRogue_Head.png new file mode 100644 index 0000000000..8713a70a38 Binary files /dev/null and b/Items/Armor/VictideHeadRogue_Head.png differ diff --git a/Items/Armor/VictideHelmet.cs b/Items/Armor/VictideHeadSummon.cs similarity index 87% rename from Items/Armor/VictideHelmet.cs rename to Items/Armor/VictideHeadSummon.cs index 024a4ef912..84073b1880 100644 --- a/Items/Armor/VictideHelmet.cs +++ b/Items/Armor/VictideHeadSummon.cs @@ -10,12 +10,14 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Armor { [AutoloadEquip(EquipType.Head)] - public class VictideHelmet : ModItem + [LegacyName("VictideHelmet")] + public class VictideHeadSummon : ModItem { + public override void SetStaticDefaults() { SacrificeTotal = 1; - DisplayName.SetDefault("Victide Helmet"); + DisplayName.SetDefault("Victide Mask"); Tooltip.SetDefault("10% increased minion damage"); } @@ -30,7 +32,7 @@ namespace CalamityMod.Items.Armor public override bool IsArmorSet(Item head, Item body, Item legs) { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); } public override void UpdateArmorSet(Player player) @@ -43,7 +45,7 @@ namespace CalamityMod.Items.Armor "+1 max minion"; CalamityPlayer modPlayer = player.Calamity(); modPlayer.victideSet = true; - modPlayer.urchin = true; + modPlayer.victideSummoner = true; player.maxMinions++; if (player.whoAmI == Main.myPlayer) { @@ -52,11 +54,11 @@ namespace CalamityMod.Items.Armor player.AddBuff(ModContent.BuffType(), 3600, true); } var source = player.GetSource_ItemUse(Item); - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { int baseDamage = 7; int minionDamage = (int)player.GetDamage().CombineWith(player.GetDamage()).ApplyTo(baseDamage); - int p = Projectile.NewProjectile(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), minionDamage, 0f, Main.myPlayer, 0f, 0f); + int p = Projectile.NewProjectile(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), minionDamage, 0f, Main.myPlayer, 0f, 0f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = baseDamage; } @@ -77,7 +79,7 @@ namespace CalamityMod.Items.Armor public override void AddRecipes() { CreateRecipe(). - AddIngredient(3). + AddIngredient(3). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Armor/VictideHeadSummon.png b/Items/Armor/VictideHeadSummon.png new file mode 100644 index 0000000000..15bf104931 Binary files /dev/null and b/Items/Armor/VictideHeadSummon.png differ diff --git a/Items/Armor/VictideHeadSummon_Head.png b/Items/Armor/VictideHeadSummon_Head.png new file mode 100644 index 0000000000..f612bc47e5 Binary files /dev/null and b/Items/Armor/VictideHeadSummon_Head.png differ diff --git a/Items/Armor/VictideHeadgear.png b/Items/Armor/VictideHeadgear.png deleted file mode 100644 index d08f35078b..0000000000 Binary files a/Items/Armor/VictideHeadgear.png and /dev/null differ diff --git a/Items/Armor/VictideHeadgear_Head.png b/Items/Armor/VictideHeadgear_Head.png deleted file mode 100644 index c6b67fd783..0000000000 Binary files a/Items/Armor/VictideHeadgear_Head.png and /dev/null differ diff --git a/Items/Armor/VictideHelm.png b/Items/Armor/VictideHelm.png deleted file mode 100644 index a0dc8cdd11..0000000000 Binary files a/Items/Armor/VictideHelm.png and /dev/null differ diff --git a/Items/Armor/VictideHelm_Head.png b/Items/Armor/VictideHelm_Head.png deleted file mode 100644 index debf620aab..0000000000 Binary files a/Items/Armor/VictideHelm_Head.png and /dev/null differ diff --git a/Items/Armor/VictideHelmet.png b/Items/Armor/VictideHelmet.png deleted file mode 100644 index a52ccecf57..0000000000 Binary files a/Items/Armor/VictideHelmet.png and /dev/null differ diff --git a/Items/Armor/VictideHelmet_Head.png b/Items/Armor/VictideHelmet_Head.png deleted file mode 100644 index e4901eaecf..0000000000 Binary files a/Items/Armor/VictideHelmet_Head.png and /dev/null differ diff --git a/Items/Armor/VictideLeggings.png b/Items/Armor/VictideLeggings.png deleted file mode 100644 index 50d79a9707..0000000000 Binary files a/Items/Armor/VictideLeggings.png and /dev/null differ diff --git a/Items/Armor/VictideLeggings_Legs.png b/Items/Armor/VictideLeggings_Legs.png deleted file mode 100644 index 58ae99512f..0000000000 Binary files a/Items/Armor/VictideLeggings_Legs.png and /dev/null differ diff --git a/Items/Armor/VictideMask.png b/Items/Armor/VictideMask.png deleted file mode 100644 index 223b316ac5..0000000000 Binary files a/Items/Armor/VictideMask.png and /dev/null differ diff --git a/Items/Armor/VictideMask_Head.png b/Items/Armor/VictideMask_Head.png deleted file mode 100644 index 633c427676..0000000000 Binary files a/Items/Armor/VictideMask_Head.png and /dev/null differ diff --git a/Items/Armor/VictideVisage.png b/Items/Armor/VictideVisage.png deleted file mode 100644 index 0bc956740e..0000000000 Binary files a/Items/Armor/VictideVisage.png and /dev/null differ diff --git a/Items/Armor/VictideVisage_Head.png b/Items/Armor/VictideVisage_Head.png deleted file mode 100644 index ae98fd02a4..0000000000 Binary files a/Items/Armor/VictideVisage_Head.png and /dev/null differ diff --git a/Items/Materials/VictideBar.cs b/Items/Materials/SeaRemains.cs similarity index 87% rename from Items/Materials/VictideBar.cs rename to Items/Materials/SeaRemains.cs index 57c39ec813..33d0c1d557 100644 --- a/Items/Materials/VictideBar.cs +++ b/Items/Materials/SeaRemains.cs @@ -4,12 +4,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Materials { - public class VictideBar : ModItem + [LegacyName("VictideBar")] + public class SeaRemains : ModItem { public override void SetStaticDefaults() { SacrificeTotal = 25; - DisplayName.SetDefault("Victide Bar"); + DisplayName.SetDefault("Sea Remains"); } public override void SetDefaults() diff --git a/Items/Materials/SeaRemains.png b/Items/Materials/SeaRemains.png new file mode 100644 index 0000000000..295a69bc3f Binary files /dev/null and b/Items/Materials/SeaRemains.png differ diff --git a/Items/Materials/VictideBar.png b/Items/Materials/VictideBar.png deleted file mode 100644 index cc6e11e2d5..0000000000 Binary files a/Items/Materials/VictideBar.png and /dev/null differ diff --git a/Items/Tools/GreatbayPickaxe.cs b/Items/Tools/GreatbayPickaxe.cs index cab4041ff5..d58d84a232 100644 --- a/Items/Tools/GreatbayPickaxe.cs +++ b/Items/Tools/GreatbayPickaxe.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Tools public override void AddRecipes() { CreateRecipe(). - AddIngredient(3). + AddIngredient(3). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Tools/GreatbayPickaxe.png b/Items/Tools/GreatbayPickaxe.png index c8d1b9beb6..8dbf9d1c23 100644 Binary files a/Items/Tools/GreatbayPickaxe.png and b/Items/Tools/GreatbayPickaxe.png differ diff --git a/Items/Tools/ReefclawHamaxe.cs b/Items/Tools/ReefclawHamaxe.cs index fc7afb73e0..edca6a89e2 100644 --- a/Items/Tools/ReefclawHamaxe.cs +++ b/Items/Tools/ReefclawHamaxe.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Tools public override void AddRecipes() { CreateRecipe(). - AddIngredient(2). + AddIngredient(2). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Tools/ReefclawHamaxe.png b/Items/Tools/ReefclawHamaxe.png index bb7f8bc105..51eb404d79 100644 Binary files a/Items/Tools/ReefclawHamaxe.png and b/Items/Tools/ReefclawHamaxe.png differ diff --git a/Items/Weapons/Magic/CoralSpout.cs b/Items/Weapons/Magic/CoralSpout.cs index 888df0b5c4..663d81b415 100644 --- a/Items/Weapons/Magic/CoralSpout.cs +++ b/Items/Weapons/Magic/CoralSpout.cs @@ -1,6 +1,9 @@ -using CalamityMod.Items.Materials; +using System.Linq; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -8,37 +11,81 @@ namespace CalamityMod.Items.Weapons.Magic { public class CoralSpout : ModItem { + public static readonly SoundStyle ChargeSound = SoundID.LiquidsHoneyWater with { Type = SoundType.Sound }; + public override void SetStaticDefaults() { DisplayName.SetDefault("Coral Spout"); - Tooltip.SetDefault("Casts coral water spouts that lay on the ground and damage enemies"); + Tooltip.SetDefault("Casts a shotgun-like blast of coral shards\n" + + "Keep the attack button held down to narrow the spread\n" + + "Fully charging the attack releases a single, bigger chunk of coral that sticks to enemies\n" + + "Grabbing the chunk of coral after it falls from the enemy replenishes 100 mana\n" + + //Lore tooltip time. Sekiro. + "[c/5C95A1:Knowledge is important, and the Old Sea Kingdom’s many scribes knew it had to be preserved at any cost.]\n" + + "[c/5C95A1:Their libraries were much larger than most, because of the water-proof stone tablets occupying them.]" + ); SacrificeTotal = 1; } public override void SetDefaults() { - Item.damage = 17; + Item.damage = 7; Item.DamageType = DamageClass.Magic; - Item.mana = 4; + Item.mana = 7; Item.width = 28; Item.height = 30; Item.useTime = 26; Item.useAnimation = 26; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; + Item.channel = true; Item.knockBack = 2f; Item.value = Item.buyPrice(0, 2, 0, 0); Item.rare = ItemRarityID.Green; Item.UseSound = SoundID.Item17; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 16f; } + public override void HoldItem(Player player) + { + player.Calamity().mouseWorldListener = true; + } + + public override bool CanUseItem(Player player) + { + return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI && n.type == ModContent.ProjectileType()); + } + + public override void UseItemFrame(Player player) + { + //Calculate the dirction in which the players arms should be pointing at. + Vector2 playerToCursor = (player.Calamity().mouseWorld - player.Center).SafeNormalize(Vector2.UnitX); + float armPointingDirection = (playerToCursor.ToRotation()); + + player.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, armPointingDirection - MathHelper.PiOver2); + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, armPointingDirection - MathHelper.PiOver2); + } + + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + if (player.Calamity().mouseWorld.X > player.Center.X) + { + player.ChangeDir(1); + } + else + { + player.ChangeDir(-1); + } + + CalamityUtils.CleanHoldStyle(player, player.compositeFrontArm.rotation + MathHelper.PiOver2, player.GetFrontHandPosition(player.compositeFrontArm.stretch, player.compositeFrontArm.rotation).Floor(), new Vector2(32, 0), new Vector2(-10, 8)); + } + public override void AddRecipes() { CreateRecipe(). - AddIngredient(2). + AddIngredient(2). AddIngredient(ItemID.Coral, 5). AddTile(TileID.Bookcases). Register(); diff --git a/Items/Weapons/Magic/CoralSpout.png b/Items/Weapons/Magic/CoralSpout.png index bb3c96dc78..6e2997f649 100644 Binary files a/Items/Weapons/Magic/CoralSpout.png and b/Items/Weapons/Magic/CoralSpout.png differ diff --git a/Items/Weapons/Melee/Cnidarian.cs b/Items/Weapons/Melee/Cnidarian.cs index 958f29f260..32a798c2d5 100644 --- a/Items/Weapons/Melee/Cnidarian.cs +++ b/Items/Weapons/Melee/Cnidarian.cs @@ -1,21 +1,28 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Melee.Yoyos; +using System.Linq; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Melee { public class Cnidarian : ModItem { + public override string Texture => "CalamityMod/Items/Weapons/Melee/CnidarianFishingRod"; + public override void SetStaticDefaults() { DisplayName.SetDefault("Cnidarian"); - Tooltip.SetDefault("Fires a seashell when enemies are near\n" + - "A very agile yoyo"); - ItemID.Sets.Yoyo[Item.type] = true; - ItemID.Sets.GamepadExtraRange[Item.type] = 15; - ItemID.Sets.GamepadSmartQuickReach[Item.type] = true; + Tooltip.SetDefault("Fishes up an electric jellyfish\n" + + "Periodically sends out sparks to electrocute nearby enemies.\n" + + //Lore tooltip time. Elden Ring. + "[c/5C95A1:From looking at their less sapient brethren, the Old Kingdom’s inhabitants adapted tools and weapons designed for underwater efficiency.]\n" + + "[c/5C95A1:The electric properties of ghost bells remain useful even after death, having been commonly used as conduits.]" + ); SacrificeTotal = 1; } @@ -30,25 +37,122 @@ namespace CalamityMod.Items.Weapons.Melee Item.useAnimation = 25; Item.autoReuse = true; + Item.holdStyle = 16; //Custom hold style Item.useStyle = ItemUseStyleID.Shoot; Item.UseSound = SoundID.Item1; Item.channel = true; - Item.noUseGraphic = true; + //Item.noUseGraphic = true; Item.noMelee = true; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 10f; Item.rare = ItemRarityID.Green; Item.value = Item.buyPrice(gold: 2); } + public override bool CanUseItem(Player player) + { + return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI && n.type == ProjectileType()); + } + public override void AddRecipes() { CreateRecipe(). - AddIngredient(2). + AddIngredient(2). AddTile(TileID.Anvils). Register(); } + + public override void HoldItem(Player player) + { + player.Calamity().mouseWorldListener = true; + } + + + #region drawing stuff + public void SetItemInHand(Player player, Rectangle heldItemFrame) + { + //Make the player face where they're aiming. + if (player.Calamity().mouseWorld.X > player.Center.X) + { + player.ChangeDir(1); + } + else + { + player.ChangeDir(-1); + } + + CalamityUtils.CleanHoldStyle(player, player.compositeFrontArm.rotation + MathHelper.PiOver2, player.GetFrontHandPosition(player.compositeFrontArm.stretch, player.compositeFrontArm.rotation).Floor(), new Vector2(42, 34), new Vector2(-15, 11)); + } + + + public void SetPlayerArms(Player player) + { + //Calculate the dirction in which the players arms should be pointing at. + Vector2 playerToCursor = (player.Calamity().mouseWorld - player.Center).SafeNormalize(Vector2.UnitX); + float armPointingDirection = (playerToCursor.ToRotation()); + + + //"crop" the rotation so the player only tilts the fishing rod slightly up and slightly down. + if (armPointingDirection < MathHelper.PiOver2 && armPointingDirection >= -MathHelper.PiOver2) + { + armPointingDirection = -MathHelper.PiOver2 + MathHelper.PiOver4 + MathHelper.PiOver2 * Utils.GetLerpValue(0f, MathHelper.Pi, armPointingDirection + MathHelper.PiOver2, true); + } + + //It gets a bit harder if its pointing left; ouch + else + { + if (armPointingDirection > 0) + armPointingDirection = MathHelper.PiOver2 + MathHelper.PiOver4 + MathHelper.PiOver4 * Utils.GetLerpValue(0f, MathHelper.PiOver2, armPointingDirection - MathHelper.PiOver2, true); + else + armPointingDirection = -MathHelper.Pi + MathHelper.PiOver4 * Utils.GetLerpValue(-MathHelper.Pi, -MathHelper.PiOver4, armPointingDirection, true); + } + + player.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, armPointingDirection - MathHelper.PiOver2); + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, armPointingDirection - MathHelper.PiOver2); + } + + public override void HoldStyle(Player player, Rectangle heldItemFrame) + { + SetItemInHand(player, heldItemFrame); + } + + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + SetItemInHand(player, heldItemFrame); + } + + public override void HoldItemFrame(Player player) + { + SetPlayerArms(player); + } + + public override void UseItemFrame(Player player) + { + SetPlayerArms(player); + } + + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D properSprite = ModContent.Request("CalamityMod/Items/Weapons/Melee/Cnidarian").Value; + + //Scale the jellyfish sprite properly, since its larger than the fishing rod (Largest dimension of the jellyfish sprite : 52. Largest dimension of the fishing rod : 42) + float scaleRatio = 42 / 52f; + //Offset the jellyfish sprite properly, since the fishing rod is larger than the jellyfish (Jellyfish width : 28px, Fishing rod width : 42) + Vector2 positionOffset = new Vector2(21 - 14, 0) * scale; + + spriteBatch.Draw(properSprite, position + positionOffset, null, drawColor, 0f, origin, scale * scaleRatio, 0, 0); + return false; + } + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D properSprite = ModContent.Request("CalamityMod/Items/Weapons/Melee/Cnidarian").Value; + + spriteBatch.Draw(properSprite, Item.position - Main.screenPosition, null, lightColor, rotation, properSprite.Size() / 2f, scale, 0, 0); + return false; + } + #endregion } } diff --git a/Items/Weapons/Melee/Cnidarian.png b/Items/Weapons/Melee/Cnidarian.png index 773a60fe4f..f397ea9d70 100644 Binary files a/Items/Weapons/Melee/Cnidarian.png and b/Items/Weapons/Melee/Cnidarian.png differ diff --git a/Items/Weapons/Melee/CnidarianFishingRod.png b/Items/Weapons/Melee/CnidarianFishingRod.png new file mode 100644 index 0000000000..5dce3480c8 Binary files /dev/null and b/Items/Weapons/Melee/CnidarianFishingRod.png differ diff --git a/Items/Weapons/Melee/Floodtide.cs b/Items/Weapons/Melee/Floodtide.cs index e0b01e7d9e..6ca9e4e679 100644 --- a/Items/Weapons/Melee/Floodtide.cs +++ b/Items/Weapons/Melee/Floodtide.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void AddRecipes() { CreateRecipe(). - AddIngredient(5). + AddIngredient(5). AddIngredient(ItemID.SharkFin, 2). AddRecipeGroup("AnyAdamantiteBar", 5). AddIngredient(10). diff --git a/Items/Weapons/Melee/UrchinSpear.cs b/Items/Weapons/Melee/RedtideSpear.cs similarity index 50% rename from Items/Weapons/Melee/UrchinSpear.cs rename to Items/Weapons/Melee/RedtideSpear.cs index b8b29d9cdb..7e512bd277 100644 --- a/Items/Weapons/Melee/UrchinSpear.cs +++ b/Items/Weapons/Melee/RedtideSpear.cs @@ -6,42 +6,54 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class UrchinSpear : ModItem + [LegacyName("UrchinSpear")] + public class RedtideSpear : ModItem { public override void SetStaticDefaults() { - DisplayName.SetDefault("Urchin Spear"); - Tooltip.SetDefault("Poisons enemies and fires short-range stingers"); + DisplayName.SetDefault("Redtide Spear"); + Tooltip.SetDefault("Poisons enemies on hit\n"+ + "Aiming the spear in front of you while running holds it down with increased knockback\n"+ + "Releasing the attack button after the charge makes an upwards slash, sending enemies flying into the air\n"+ + //Lore tooltip time. Dark souls. + "[c/5C95A1:The people of the sea were adept hunters, but they abhorred unnecessary violence.]\n" + + "[c/5C95A1:Unfortunately, neighboring nations were brutish, so they fashioned their tools for war.]"); SacrificeTotal = 1; } public override void SetDefaults() { Item.width = 56; - Item.damage = 28; + Item.damage = 33; Item.DamageType = DamageClass.Melee; Item.noMelee = true; Item.useTurn = true; Item.noUseGraphic = true; Item.useAnimation = 25; Item.useStyle = ItemUseStyleID.Shoot; + Item.channel = true; Item.useTime = 25; Item.knockBack = 5f; - Item.UseSound = SoundID.Item1; + Item.UseSound = null; Item.autoReuse = true; Item.height = 56; Item.value = Item.buyPrice(0, 2, 0, 0); Item.rare = ItemRarityID.Green; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 4f; } + public override void HoldItem(Player player) + { + player.Calamity().mouseWorldListener = true; + } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; public override void AddRecipes() { CreateRecipe(). - AddIngredient(4). + AddIngredient(4). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Melee/RedtideSpear.png b/Items/Weapons/Melee/RedtideSpear.png new file mode 100644 index 0000000000..2f951da3ff Binary files /dev/null and b/Items/Weapons/Melee/RedtideSpear.png differ diff --git a/Items/Weapons/Melee/RedtideSword.png b/Items/Weapons/Melee/RedtideSword.png deleted file mode 100644 index ece69dc72e..0000000000 Binary files a/Items/Weapons/Melee/RedtideSword.png and /dev/null differ diff --git a/Items/Weapons/Melee/RedtideSword.cs b/Items/Weapons/Melee/UrchinMace.cs similarity index 53% rename from Items/Weapons/Melee/RedtideSword.cs rename to Items/Weapons/Melee/UrchinMace.cs index b640c67a5f..2dba577151 100644 --- a/Items/Weapons/Melee/RedtideSword.cs +++ b/Items/Weapons/Melee/UrchinMace.cs @@ -1,51 +1,57 @@ -using Terraria.DataStructures; +using System.Linq; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class RedtideSword : ModItem + [LegacyName("RedtideSword")] + public class UrchinMace : ModItem { public override void SetStaticDefaults() { - DisplayName.SetDefault("Redtide Sword"); - Tooltip.SetDefault("Throws short-range whirlpools"); + DisplayName.SetDefault("Urchin Mace"); + Tooltip.SetDefault("Throws out a whirlpool when released at full charge"); SacrificeTotal = 1; } public override void SetDefaults() { Item.width = 42; - Item.damage = 35; + Item.damage = 20; + Item.channel = true; + Item.noUseGraphic = true; + Item.noMelee = true; + Item.useTurn = true; Item.DamageType = DamageClass.Melee; Item.useAnimation = 19; Item.useStyle = ItemUseStyleID.Swing; Item.useTime = 19; - Item.useTurn = true; Item.knockBack = 4; Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - Item.height = 42; + Item.height = 48; Item.value = Item.buyPrice(0, 2, 0, 0); Item.rare = ItemRarityID.Green; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 9f; } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + public override void HoldItem(Player player) { - Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, type, damage / 2, knockback, player.whoAmI, 0f, 0f); - return false; + player.Calamity().mouseWorldListener = true; + } + + public override bool CanUseItem(Player player) + { + return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI && n.type == ModContent.ProjectileType()); } public override void AddRecipes() { CreateRecipe(). - AddIngredient(3). + AddIngredient(3). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Melee/UrchinMace.png b/Items/Weapons/Melee/UrchinMace.png new file mode 100644 index 0000000000..2e379e8a6e Binary files /dev/null and b/Items/Weapons/Melee/UrchinMace.png differ diff --git a/Items/Weapons/Melee/UrchinSpear.png b/Items/Weapons/Melee/UrchinSpear.png deleted file mode 100644 index fd210ae426..0000000000 Binary files a/Items/Weapons/Melee/UrchinSpear.png and /dev/null differ diff --git a/Items/Weapons/Ranged/AquashardShotgun.cs b/Items/Weapons/Ranged/AquashardShotgun.cs index 24be343d4d..ae302784fd 100644 --- a/Items/Weapons/Ranged/AquashardShotgun.cs +++ b/Items/Weapons/Ranged/AquashardShotgun.cs @@ -70,7 +70,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(2). AddIngredient(10). AddIngredient(15). - AddIngredient(5). + AddIngredient(5). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Ranged/ReedBlowgun.cs b/Items/Weapons/Ranged/ReedBlowgun.cs new file mode 100644 index 0000000000..fba563fb8a --- /dev/null +++ b/Items/Weapons/Ranged/ReedBlowgun.cs @@ -0,0 +1,131 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Ranged +{ + [LegacyName("Seabow")] + public class ReedBlowgun : ModItem + { + public static readonly SoundStyle BubbleBurstSound = new ("CalamityMod/Sounds/Custom/PistolShrimpBubbleBurst") { PitchVariance = 0.15f, Volume = 0.2f}; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Reed Blowgun"); + Tooltip.SetDefault("Fires a high-pressure stream of bubbles\n" + + //Lore tooltip time. King's field + "[c/5C95A1:The Old Sea Kingdom never truly sought to expand beyond its initial borders.]\n" + + "[c/5C95A1:However, they had a perfect track record of repelling any invasions, thanks to their insurmountable advantage in the water.]" + ); + + SacrificeTotal = 1; + } + + public override void SetDefaults() + { + Item.damage = 19; + Item.DamageType = DamageClass.Ranged; + Item.width = 22; + Item.height = 46; + Item.useTime = 25; + Item.useAnimation = 25; + Item.useStyle = ItemUseStyleID.Shoot; + Item.holdStyle = 16; + Item.noMelee = true; + Item.knockBack = 13.5f; + Item.value = Item.buyPrice(0, 2, 0, 0); + Item.rare = ItemRarityID.Green; + Item.UseSound = null; + Item.autoReuse = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 16f; + Item.Calamity().canFirePointBlankShots = true; + } + + public override void HoldItem(Player player) + { + player.Calamity().mouseWorldListener = true; + } + + public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) + { + velocity = velocity.RotatedByRandom(0.01f); + } + + public void SetItemInHand(Player player, Rectangle heldItemFrame) + { + //Make the player face where they're aiming. + if (Main.MouseWorld.X > player.Center.X) + { + player.ChangeDir(1); + } + else + { + player.ChangeDir(-1); + } + + float blowpipeRotation = player.compositeBackArm.rotation + MathHelper.PiOver2 + player.direction * MathHelper.PiOver4 / 3f; + + Vector2 blowpipePosition = player.GetBackHandPosition(player.compositeBackArm.stretch, player.compositeBackArm.rotation).Floor() + Vector2.UnitY * 7f; + if (player.direction > 0) + blowpipePosition += Vector2.UnitX * -9f; + + CalamityUtils.CleanHoldStyle(player, blowpipeRotation, blowpipePosition, new Vector2(50, 18), new Vector2(-17, 6)); + } + + + public void SetPlayerArms(Player player, bool frontArm = false) + { + //Make the player face where they're aiming. + if (player.Calamity().mouseWorld.X > player.Center.X) + { + player.ChangeDir(1); + } + else + { + player.ChangeDir(-1); + } + + //Calculate the dirction in which the players arms should be pointing at. + Vector2 playerToCursor = (player.Calamity().mouseWorld - player.Center).SafeNormalize(Vector2.UnitX); + float pointingDirection = (playerToCursor.ToRotation()); + + if (frontArm) + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, pointingDirection - MathHelper.PiOver2); + player.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, pointingDirection - MathHelper.PiOver2); + player.headRotation = pointingDirection; + } + + public override void HoldStyle(Player player, Rectangle heldItemFrame) + { + SetItemInHand(player, heldItemFrame); + } + + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + SetItemInHand(player, heldItemFrame); + } + + public override void HoldItemFrame(Player player) + { + SetPlayerArms(player); + } + + public override void UseItemFrame(Player player) + { + SetPlayerArms(player, true); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(2). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Weapons/Ranged/ReedBlowgun.png b/Items/Weapons/Ranged/ReedBlowgun.png new file mode 100644 index 0000000000..fabaab6ee0 Binary files /dev/null and b/Items/Weapons/Ranged/ReedBlowgun.png differ diff --git a/Items/Weapons/Ranged/Seabow.cs b/Items/Weapons/Ranged/Seabow.cs deleted file mode 100644 index 1c4790117a..0000000000 --- a/Items/Weapons/Ranged/Seabow.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Terraria.DataStructures; -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Ranged; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Ranged -{ - public class Seabow : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Seabow"); - Tooltip.SetDefault("Fires slow-moving water blasts"); - SacrificeTotal = 1; - } - - public override void SetDefaults() - { - Item.damage = 12; - Item.DamageType = DamageClass.Ranged; - Item.width = 22; - Item.height = 46; - Item.useTime = 25; - Item.useAnimation = 25; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.knockBack = 2.5f; - Item.value = Item.buyPrice(0, 2, 0, 0); - Item.rare = ItemRarityID.Green; - Item.UseSound = SoundID.Item5; - Item.autoReuse = true; - Item.shoot = ProjectileID.PurificationPowder; - Item.shootSpeed = 16f; - Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - float SpeedX = velocity.X + (float)Main.rand.Next(-30, 31) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-30, 31) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX * 0.5f, SpeedY * 0.5f, ModContent.ProjectileType(), (int)(damage * 0.4), 0f, player.whoAmI); - return true; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(2). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/Weapons/Ranged/Seabow.png b/Items/Weapons/Ranged/Seabow.png deleted file mode 100644 index f09a632c6f..0000000000 Binary files a/Items/Weapons/Ranged/Seabow.png and /dev/null differ diff --git a/Items/Weapons/Rogue/SeashellBoomerang.cs b/Items/Weapons/Rogue/FishboneBoomerang.cs similarity index 58% rename from Items/Weapons/Rogue/SeashellBoomerang.cs rename to Items/Weapons/Rogue/FishboneBoomerang.cs index 93866eb592..0ac9d43dc7 100644 --- a/Items/Weapons/Rogue/SeashellBoomerang.cs +++ b/Items/Weapons/Rogue/FishboneBoomerang.cs @@ -1,39 +1,51 @@ -using Terraria.DataStructures; +using System.Linq; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class SeashellBoomerang : ModItem + [LegacyName("SeashellBoomerang")] + public class FishboneBoomerang : ModItem { public override void SetStaticDefaults() { - DisplayName.SetDefault("Seashell Boomerang"); - Tooltip.SetDefault("Stealth strikes fire seashells at nearby enemies"); + DisplayName.SetDefault("Fishbone Boomerang"); + Tooltip.SetDefault("Stealth strikes make the boomerang ricochet between enemies\n" + + //lore tooltip u get the thing + "[c/5C95A1:Though the evaporating Sea Kingdom fought a losing battle, its proud inhabitants did not go down easily.]\n" + + "[c/5C95A1:As a last resort, they had to fashion weapons from the skeletons of dead animals.]" + ); SacrificeTotal = 1; } public override void SetDefaults() { Item.width = 18; - Item.damage = 15; + Item.damage = 24; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = 15; Item.useStyle = ItemUseStyleID.Swing; Item.useTime = 15; Item.knockBack = 5.5f; - Item.UseSound = SoundID.Item1; + Item.UseSound = null; Item.height = 34; Item.value = Item.buyPrice(0, 2, 0, 0); Item.rare = ItemRarityID.Green; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 11.5f; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 3f; Item.DamageType = RogueDamageClass.Instance; + Item.autoReuse = true; + } + + public override bool CanUseItem(Player player) + { + return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI && n.type == ModContent.ProjectileType()); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) @@ -47,7 +59,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void AddRecipes() { CreateRecipe(). - AddIngredient(2). + AddIngredient(2). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Rogue/FishboneBoomerang.png b/Items/Weapons/Rogue/FishboneBoomerang.png new file mode 100644 index 0000000000..4fe585981b Binary files /dev/null and b/Items/Weapons/Rogue/FishboneBoomerang.png differ diff --git a/Items/Weapons/Rogue/SeashellBoomerang.png b/Items/Weapons/Rogue/SeashellBoomerang.png deleted file mode 100644 index 4e0fba13e0..0000000000 Binary files a/Items/Weapons/Rogue/SeashellBoomerang.png and /dev/null differ diff --git a/Items/Weapons/Rogue/TerraDisk.cs b/Items/Weapons/Rogue/TerraDisk.cs index 42b00eb29b..d0ed9712b9 100644 --- a/Items/Weapons/Rogue/TerraDisk.cs +++ b/Items/Weapons/Rogue/TerraDisk.cs @@ -83,7 +83,7 @@ Stealth strikes travel slower and are rapidly orbited by the smaller disks"); public override void AddRecipes() { CreateRecipe(). - AddIngredient(). + AddIngredient(). AddIngredient(). AddIngredient(ItemID.ThornChakram). AddIngredient(8). diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index f0131d3f28..49a97b0a4e 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -544,7 +544,7 @@ namespace CalamityMod // Victide if (setBonus == "victide_summon" || setBonus == "victide summon") - return mp.urchin; // the bool set directly by VictideHelmet.UpdateArmorSet + return mp.victideSummoner; // the bool set directly by VictideHelmet.UpdateArmorSet else if (setBonus == "victide" || setBonus.StartsWith("victide_") || setBonus.StartsWith("victide ")) return mp.victideSet; @@ -862,7 +862,7 @@ namespace CalamityMod if (setBonus == "victide_summon" || setBonus == "victide summon") { mp.victideSet = enabled; - mp.urchin = enabled; // LATER -- remove this when player.urchin actually controls victide summoner + mp.victideSummoner = enabled; return true; } else if (setBonus == "victide" || setBonus.StartsWith("victide_") || setBonus.StartsWith("victide ")) diff --git a/NPCs/CalamityFallDamageNPC.cs b/NPCs/CalamityFallDamageNPC.cs new file mode 100644 index 0000000000..6aa61324e3 --- /dev/null +++ b/NPCs/CalamityFallDamageNPC.cs @@ -0,0 +1,109 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs +{ + public class CalamityFallDamageNPC : GlobalNPC + { + /// + /// How much "gravity damage" is this npc slated to recieve once it hits the ground. + /// + private int potentialEnergyDamage = 0; + /// + /// This keeps track of the last recorded velocity, so that we can dispel the potential fall damage if the enemy slows their fall down by any means + /// + private Vector2 OldVelocity = Vector2.Zero; + /// + /// This keeps track of the last recorded velocity, because terraria is dumb and we need two of them + /// + private Vector2 OlderVelocity = Vector2.Zero; + private float terminalVelocityForFullFallDamage = 0; + + public int PotentialEnergyDamage + { + get + { + return potentialEnergyDamage; + } + + private set + { + //You can't stack gravity damage. Higher "gravity" simply replaces the gravity damage. + potentialEnergyDamage = value == 0 ? 0 : Math.Max(potentialEnergyDamage, value); + } + } + + public bool FallDamageSusceptible => PotentialEnergyDamage > 0; + + public override bool InstancePerEntity => true; + + public override GlobalNPC Clone(NPC npc, NPC npcClone) + { + CalamityFallDamageNPC myClone = (CalamityFallDamageNPC)base.Clone(npc, npcClone); + + myClone.potentialEnergyDamage = potentialEnergyDamage; + myClone.OldVelocity = OldVelocity; + myClone.OlderVelocity = OlderVelocity; + myClone.terminalVelocityForFullFallDamage = terminalVelocityForFullFallDamage; + + return myClone; + } + + public override void SetDefaults(NPC npc) + { + PotentialEnergyDamage = 0; + OldVelocity = Vector2.Zero; + OlderVelocity = Vector2.Zero; + } + + /// + /// Sets up a NPC to recieve fall damage when they hit the ground. + /// + /// The npc to apply fall damage to + /// The maximum fall damage taken by the npc once they hit the ground + /// The downwards velocity necessary to recieve the full fall damage. By default 10, the npc max fall speed + public void ApplyFallDamage(NPC npc, int potentialDamage, float terminalVelocityForFullDamage = 10f) + { + //NPCs that don't collide with tiles simply don't get fall damage, lol. + if (npc.noTileCollide) + return; + + PotentialEnergyDamage = potentialDamage; + OldVelocity = npc.velocity; + OlderVelocity = npc.velocity; + terminalVelocityForFullFallDamage = terminalVelocityForFullDamage; + } + + public override void PostAI(NPC npc) + { + if (FallDamageSusceptible) + { + float newVerticalVelocity = npc.velocity.Y; + float oldVerticalVelocity = OldVelocity.Y; + float olderVerticalVelocity = OlderVelocity.Y; + + //If the thing flies back up, cancel the fall dmg + if (newVerticalVelocity < 0 && oldVerticalVelocity >= 0) + PotentialEnergyDamage = 0; + + //Same goes for if it slows its fall. + //We use 3 variables cuz there is a frame inbetween the fall and the landing where the velocity is still set to something. + if (newVerticalVelocity > 0 && olderVerticalVelocity > 0 && oldVerticalVelocity < olderVerticalVelocity) + PotentialEnergyDamage = 0; + + //If the npc hit a tile/Came to a stop after falling + if (newVerticalVelocity == 0 && oldVerticalVelocity > 0) + { + //I don't think a tile check below the npc is necessary but if we find weird edge cases ill add it + npc.StrikeNPC((int)(PotentialEnergyDamage * Math.Clamp(olderVerticalVelocity / terminalVelocityForFullFallDamage, 0f, 1f)), 0f, 1, fromNet: true); + PotentialEnergyDamage = 0; + } + + OlderVelocity = OldVelocity; + OldVelocity = npc.velocity; + } + } + } +} diff --git a/Particles/Bubble.png b/Particles/Bubble.png new file mode 100644 index 0000000000..b804a98405 Binary files /dev/null and b/Particles/Bubble.png differ diff --git a/Particles/CuteManaStarParticle.cs b/Particles/CuteManaStarParticle.cs new file mode 100644 index 0000000000..94ec2f32e1 --- /dev/null +++ b/Particles/CuteManaStarParticle.cs @@ -0,0 +1,40 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class CuteManaStarParticle : Particle + { + public override string Texture => "CalamityMod/Particles/CuteStars"; + public override bool UseCustomDraw => false; + public override bool SetLifetime => true; + public override int FrameVariants => 2; + + public float Opacity; + + public CuteManaStarParticle(Vector2 position, Vector2 speed, float scale = 1f, float opacity = 1f, int lifetime = 20) + { + Position = position; + Scale = scale; + Color = Color.White; + Opacity = opacity; + Velocity = speed; + Rotation = Main.rand.NextFloat(MathHelper.TwoPi); + Lifetime = lifetime; + Variant = Main.rand.Next(2); + } + + public override void Update() + { + Opacity *= 0.96f; + Color = Color.White * Opacity; + Lighting.AddLight(Position, Color.DodgerBlue.ToVector3()); + Velocity *= 0.9f; + if (Velocity.Length() <= 0.01f) + GeneralParticleHandler.RemoveParticle(this); + } + } +} diff --git a/Particles/CuteStars.png b/Particles/CuteStars.png new file mode 100644 index 0000000000..6854b3beab Binary files /dev/null and b/Particles/CuteStars.png differ diff --git a/Particles/DirectionalPulseRing.cs b/Particles/DirectionalPulseRing.cs new file mode 100644 index 0000000000..5e22c895b4 --- /dev/null +++ b/Particles/DirectionalPulseRing.cs @@ -0,0 +1,55 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using static CalamityMod.CalamityUtils; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class DirectionalPulseRing : Particle + { + public override string Texture => "CalamityMod/Particles/HollowCircleHardEdge"; + public override bool UseAdditiveBlend => true; + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + + private float OriginalScale; + private float FinalScale; + private float opacity; + private Vector2 Squish; + private Color BaseColor; + + public DirectionalPulseRing(Vector2 position, Vector2 velocity, Color color, Vector2 squish, float rotation, float originalScale, float finalScale, int lifeTime) + { + Position = position; + Velocity = velocity; + BaseColor = color; + OriginalScale = originalScale; + FinalScale = finalScale; + Scale = originalScale; + Lifetime = lifeTime; + Squish = squish; + Rotation = rotation; + } + + public override void Update() + { + float pulseProgress = PiecewiseAnimation(LifetimeCompletion, new CurveSegment[] { new CurveSegment(EasingType.PolyOut, 0f, 0f, 1f, 4) }); + Scale = MathHelper.Lerp(OriginalScale, FinalScale, pulseProgress); + + opacity = (float)Math.Sin(MathHelper.PiOver2 + LifetimeCompletion * MathHelper.PiOver2); + + Color = BaseColor * opacity; + Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f); + Velocity *= 0.95f; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D tex = ModContent.Request(Texture).Value; + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * opacity, Rotation, tex.Size() / 2f, Scale * Squish, SpriteEffects.None, 0); + } + + } +} diff --git a/Particles/GenericBubbleParticle.cs b/Particles/GenericBubbleParticle.cs new file mode 100644 index 0000000000..b20f7cafa4 --- /dev/null +++ b/Particles/GenericBubbleParticle.cs @@ -0,0 +1,25 @@ +using Microsoft.Xna.Framework; +using Terraria; + + +namespace CalamityMod.Particles +{ + //This is mostly so i can easily get it to draw over the reed blowgun. + public class GenericBubbleParticle : Particle + { + public override string Texture => "CalamityMod/Particles/Bubble"; + public override bool UseHalfTransparency => true; + public override bool SetLifetime => true; + public override bool Important => true; + + public GenericBubbleParticle(Vector2 position, Vector2 velocity, float scale, float rotation, int lifeTime = 50) + { + Position = position; + Velocity = velocity; + Color = Color.White; + Scale = scale; + Rotation = rotation; + Lifetime = lifeTime; + } + } +} diff --git a/Particles/UrchinSpikeParticle.cs b/Particles/UrchinSpikeParticle.cs new file mode 100644 index 0000000000..ce66863143 --- /dev/null +++ b/Particles/UrchinSpikeParticle.cs @@ -0,0 +1,46 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class UrchinSpikeParticle : Particle + { + public override string Texture => "CalamityMod/Particles/UrchinSpikes"; + public override bool UseCustomDraw => true; + public override bool SetLifetime => true; + public override int FrameVariants => 6; + + public float Opacity; + + public UrchinSpikeParticle(Vector2 position, Vector2 speed, float rotation, float scale = 1f, float opacity = 1f, int lifetime = 20) + { + Position = position; + Scale = scale; + Color = Color.White; + Opacity = opacity; + Velocity = speed; + Rotation = rotation; + Lifetime = lifetime; + Variant = Main.rand.Next(6); + } + + public override void Update() + { + Opacity *= 0.98f; + Color = Lighting.GetColor((int)Position.X / 16, (int)Position.Y / 16) * Opacity; + Velocity *= 0.9f; + if (Velocity.Length() <= 0.01f) + GeneralParticleHandler.RemoveParticle(this); + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D texture = GeneralParticleHandler.GetTexture(Type); + Rectangle frame = new Rectangle(8 * Variant, 0, 6, 10); + spriteBatch.Draw(texture, Position - Main.screenPosition, frame, Color, Rotation, frame.Size() * 0.5f, Scale, SpriteEffects.None, 0f); + } + } +} diff --git a/Particles/UrchinSpikes.png b/Particles/UrchinSpikes.png new file mode 100644 index 0000000000..852ce2cf3d Binary files /dev/null and b/Particles/UrchinSpikes.png differ diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 90517ce2a2..022b8fdc0f 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -2937,12 +2937,12 @@ namespace CalamityMod.Projectiles { int projectile2 = Projectile.NewProjectile(projectile.GetSource_FromThis(), spawnPos, velocity, spawnedProjectile, (int)(projectile.damage * damageMult), projectile.knockBack, projectile.owner, 0f, 0f); - if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || + if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType()) if (projectile2.WithinBounds(Main.maxProjectiles)) Main.projectile[projectile2].Calamity().forceMelee = true; - if (projectile.type == ProjectileType()) + if (projectile.type == ProjectileType()) if (projectile2.WithinBounds(Main.maxProjectiles)) Main.projectile[projectile2].Calamity().forceRogue = true; } diff --git a/Projectiles/Magic/CoralSpike.cs b/Projectiles/Magic/CoralSpike.cs index 5990df80d9..5a65fe0b07 100644 --- a/Projectiles/Magic/CoralSpike.cs +++ b/Projectiles/Magic/CoralSpike.cs @@ -1,9 +1,19 @@ -using System; +using System; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Magic { public class CoralSpike : ModProjectile { + public ref float ChargeCompletion => ref Projectile.ai[0]; + + public static int DustPick => Main.rand.NextBool(2) ? 255 : Main.rand.NextBool() ? 282 : Main.rand.NextBool() ? 281 : 280; + public override void SetStaticDefaults() { DisplayName.SetDefault("Coral Spike"); @@ -14,17 +24,51 @@ namespace CalamityMod.Projectiles.Magic Projectile.width = 30; Projectile.height = 30; Projectile.friendly = true; - Projectile.aiStyle = 14; - Projectile.penetrate = 4; + Projectile.penetrate = 1; Projectile.timeLeft = 360; + Projectile.tileCollide = true; + Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Magic; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; } public override void AI() { - Projectile.velocity.X *= 0.9f; - Projectile.velocity.Y *= 0.99f; - Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + 1.57f; + Projectile.velocity *= 0.96f; + Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + 1.57f; + + if (Projectile.velocity.Length() < 2f) + Projectile.Kill(); + + int dustOpacity = (int)(200 * (1 - ChargeCompletion)); + float dustScale = Main.rand.NextFloat(1f, 1.4f) * (0.6f + 0.4f * ChargeCompletion); + Vector2 dustVelocity = Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.PiOver4 * 0.6f) * 4f + Main.rand.NextVector2Circular(4f, 4f); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustPick, dustVelocity, Alpha: dustOpacity, Scale : dustScale); + dust.noGravity = true; + } + + public override void Kill(int timeLeft) + { + if (timeLeft != 0) + SoundEngine.PlaySound(SoundID.Dig with { Volume = SoundID.Dig.Volume * 0.4f}, Projectile.Center); + + for (int i = 0; i < 3; i++) + { + float angle = Main.rand.NextFloat(MathHelper.TwoPi); + + Particle spike = new UrchinSpikeParticle(Projectile.Center + angle.ToRotationVector2() * 2f, angle.ToRotationVector2() * 6f, angle + MathHelper.PiOver2, Main.rand.NextFloat(1f, 1.3f), lifetime: Main.rand.Next(10) + 25); + GeneralParticleHandler.SpawnParticle(spike); + } + + int dustCount = Main.rand.Next(7); + for (int i = 0; i < dustCount; i++) + { + int dustOpacity = (int)(200 * (1 - ChargeCompletion)); + float dustScale = Main.rand.NextFloat(1f, 1.4f) * (0.6f + 0.4f * ChargeCompletion); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustPick, Main.rand.NextVector2Circular(7f, 7f), Alpha: dustOpacity, Scale: dustScale); + dust.noGravity = true; + } } } } diff --git a/Projectiles/Magic/CoralSpike.png b/Projectiles/Magic/CoralSpike.png index f18261bd86..fb5acdd6d6 100644 Binary files a/Projectiles/Magic/CoralSpike.png and b/Projectiles/Magic/CoralSpike.png differ diff --git a/Projectiles/Magic/CoralSpoutHoldout.cs b/Projectiles/Magic/CoralSpoutHoldout.cs new file mode 100644 index 0000000000..735dcbf049 --- /dev/null +++ b/Projectiles/Magic/CoralSpoutHoldout.cs @@ -0,0 +1,146 @@ +using System; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + + +namespace CalamityMod.Projectiles.Magic +{ + //Holdout, but invisible. It may as well be named "CoralSpoutHandler" + public class CoralSpoutHoldout : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public static float MaxCharge = 50; + public static int ShotProjectiles = 5; + + public ref float Charge => ref Projectile.ai[0]; + public float ChargeProgress => MathHelper.Clamp(Charge, 0, MaxCharge) / MaxCharge; + public float FullChargeProgress => MathHelper.Clamp(Charge, 0, MaxCharge * 1.5f) / (MaxCharge * 1.5f); + public float Spread => MathHelper.PiOver2 * (1 - (float)Math.Pow(ChargeProgress, 1.5) * 0.95f); + + public Player Owner => Main.player[Projectile.owner]; + + + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Coral Spout"); + } + + public override void SetDefaults() + { + Projectile.width = 30; + Projectile.height = 30; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + } + + public override bool? CanDamage() + { + return false; + } + + public override bool ShouldUpdatePosition() + { + return false; + } + + public override void AI() + { + if (Owner.channel) + { + Projectile.timeLeft = 2; + Owner.itemTime = 25; + Owner.itemAnimation = 25; + Owner.heldProj = Projectile.whoAmI; + } + + float pointingRotation = (Owner.Calamity().mouseWorld - Owner.MountedCenter).ToRotation(); + Projectile.Center = Owner.MountedCenter + pointingRotation.ToRotationVector2() * 40f; + + if (Projectile.soundDelay <= 0) + { + SoundEngine.PlaySound(CoralSpout.ChargeSound with { Pitch = 0.5f * ChargeProgress}, Owner.MountedCenter); + Projectile.soundDelay = 10; + } + + if (Charge == (int)(MaxCharge * 1.5f) && Owner.whoAmI == Main.myPlayer) + { + SoundEngine.PlaySound(SoundID.MaxMana, Owner.MountedCenter); + } + + Charge++; + } + + public override bool PreDraw(ref Color lightColor) + { + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + Texture2D texture = ModContent.Request("CalamityMod/Projectiles/Summon/DeathstareBeam").Value; + + for (int i = -1; i <= 1; i += 2) + { + float angle = (Owner.MountedCenter - Owner.Calamity().mouseWorld).ToRotation() + (Spread / 2f) * i - MathHelper.PiOver2; + Vector2 scale = new Vector2(0.2f, 1f) * 3f; + Main.EntitySpriteDraw(texture, Owner.MountedCenter - Main.screenPosition, null, Color.DodgerBlue * 0.5f * (float)Math.Sqrt(ChargeProgress), angle, new Vector2(texture.Width / 2f, texture.Height), scale, 0, 0); + } + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + return false; + } + + public override void Kill(int timeLeft) + { + float mainAngle = (Projectile.Center - Owner.MountedCenter).ToRotation(); + + if (FullChargeProgress < 1) + { + SoundEngine.PlaySound(SoundID.Item167 with { Volume = SoundID.Item167.Volume * 0.4f + 0.2f * ChargeProgress }, Owner.MountedCenter); + + + for (int i = 0; i < ShotProjectiles; i++) + { + float angleOffset = MathHelper.Lerp(Spread * -0.5f, Spread * 0.5f, i / (float)ShotProjectiles); + Vector2 direction = (mainAngle + angleOffset).ToRotationVector2(); + + if (Owner.whoAmI == Main.myPlayer) + { + float speed = 10 + 15 * ChargeProgress; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.MountedCenter + direction * 30f, direction * speed, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Owner.whoAmI, ChargeProgress); + } + + Color pulseColor = Main.rand.NextBool() ? Color.Coral : Color.DeepSkyBlue; + Particle pulse = new DirectionalPulseRing(Owner.MountedCenter + direction * 44f, Vector2.Zero, pulseColor, new Vector2(0.5f, 1f), direction.ToRotation(), 0.04f, 0.2f, 30); + GeneralParticleHandler.SpawnParticle(pulse); + } + + } + + else + { + SoundEngine.PlaySound(SoundID.Item42, Owner.MountedCenter); + Vector2 direction = mainAngle.ToRotationVector2(); + + if (Owner.whoAmI == Main.myPlayer) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.MountedCenter + direction * 30f, direction * 35, ModContent.ProjectileType(), (int)Projectile.damage * (ShotProjectiles + 1), Projectile.knockBack, Owner.whoAmI); + } + + Color pulseColor = Main.rand.NextBool() ? Color.Coral : Color.DeepSkyBlue; + Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, pulseColor, new Vector2(0.5f, 1f), direction.ToRotation(), 0.05f, 0.34f + Main.rand.NextFloat(0.3f), 30); + GeneralParticleHandler.SpawnParticle(pulse); + } + } + } +} diff --git a/Projectiles/Magic/ManaChargedCoral.cs b/Projectiles/Magic/ManaChargedCoral.cs new file mode 100644 index 0000000000..77bc571a9a --- /dev/null +++ b/Projectiles/Magic/ManaChargedCoral.cs @@ -0,0 +1,278 @@ +using System; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class ManaChargedCoral : ModProjectile + { + public Player Owner => Main.player[Projectile.owner]; + public static float FullMana => 180f; + public ref float ManaCharge => ref Projectile.ai[0]; + public NPC StuckNPC => Projectile.numHits > 0 ? Main.npc[(int)Projectile.ai[1]] : null; + public ref float DetachmentEffectsComplete => ref Projectile.localAI[0]; + public bool Stuck => (StuckNPC != null && StuckNPC.active && ManaCharge < FullMana); + public bool HasStuck => (Projectile.numHits > 0); + + Vector2 offsetFromStuckNPC; + float rotationFromStuckNPC; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Mana-charged Coral"); + Main.projFrames[Projectile.type] = 3; + } + + public override void SetDefaults() + { + Projectile.width = 30; + Projectile.height = 30; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 360; + Projectile.DamageType = DamageClass.Magic; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + + public override bool ShouldUpdatePosition() + { + return !Stuck; + } + + public override bool? CanDamage() + { + return Projectile.numHits == 0; + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (HasStuck) + { + Projectile.velocity.X *= 0.86f; + return false; + } + return true; + } + + public override void AI() + { + if (Projectile.frame == 0) + Projectile.frame = Main.rand.Next(3) + 1; + + //Stay anchored to the enemy it's stuck in and emit charge particles. + if (Stuck) + { + Projectile.Center = StuckNPC.Center + offsetFromStuckNPC.RotatedBy(StuckNPC.rotation) * StuckNPC.scale; + Projectile.rotation = StuckNPC.rotation + rotationFromStuckNPC; + + Projectile.tileCollide = false; + Projectile.timeLeft++; + ManaCharge++; + + if (Main.rand.NextBool(5)) + { + Particle lilStar = new CuteManaStarParticle(Projectile.Center + Main.rand.NextVector2Circular(19f, 19f), Main.rand.NextVector2Circular(4f, 4f) - Vector2.UnitY * 6f * Main.rand.NextFloat(0.6f, 1.2f), Main.rand.NextFloat(0.8f, 1.8f), lifetime: Main.rand.Next(14) + 14); + GeneralParticleHandler.SpawnParticle(lilStar); + } + } + + //Act as a magnetized collectible. + else if (HasStuck) + { + if (DetachmentEffectsComplete != 1f) + { + Projectile.tileCollide = true; + Projectile.timeLeft = 360; + DetachmentEffectsComplete = 1f; + Projectile.velocity = Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2) * -1 * (Main.rand.NextFloat(5f) + 5f); + } + + if (Projectile.velocity.X != 0) + Projectile.rotation += 0.02f * Math.Sign(Projectile.velocity.X) * Math.Clamp(Projectile.velocity.Length(), 0f, 5f); + + Projectile.velocity.X *= 0.987f; + Projectile.velocity.Y += 0.8f; + + float distanceToOwner = (Owner.Center - Projectile.Center).Length(); + if (distanceToOwner < 170f) + { + Projectile.timeLeft++; + + Projectile.velocity = (Owner.Center - Projectile.Center).SafeNormalize(Vector2.Zero) * Math.Max(distanceToOwner * 0.09f, 8f); + + if (distanceToOwner < 10f) + Projectile.Kill(); + } + + //particles + + if (Main.rand.NextBool(2)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(15f, 15f), 45, Vector2.UnitY * -7f, Alpha: Main.rand.Next(100) + 120, Scale: Main.rand.NextFloat(1f, 2f)); + dust.noGravity = true; + } + + if (Main.rand.NextBool(5)) + { + Particle lilStar = new CuteManaStarParticle(Projectile.Center + Main.rand.NextVector2Circular(19f, 19f), -Vector2.UnitY * 6f * Main.rand.NextFloat(0.6f, 1.2f), Main.rand.NextFloat(0.8f, 1.8f), lifetime: Main.rand.Next(14) + 14); + GeneralParticleHandler.SpawnParticle(lilStar); + } + } + + //the flung state. + else + { + float fallSpeed = Projectile.velocity.Y; + if (Projectile.velocity.X != 0) + Projectile.rotation += 0.02f * Math.Sign(Projectile.velocity.X) * Math.Clamp(Projectile.velocity.Length(), 0f, 5f); + + if (Projectile.timeLeft < 345) + Projectile.velocity += Vector2.UnitY * 0.5f * (1 - Math.Clamp((Projectile.timeLeft - 310f) / 35f, 0f, 1f)); + + Projectile.velocity *= 0.98f; + + if (Projectile.velocity.Y > 0) + Projectile.velocity.Y = Math.Clamp(Projectile.velocity.Y, 0, Math.Max(18f, fallSpeed)); + + //Sharticles + if (Main.rand.NextBool(2)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(15f, 15f), 15, Projectile.velocity * 0.3f, Alpha: Main.rand.Next(100) + 120, Scale: Main.rand.NextFloat(1f, 2f)); + dust.noGravity = true; + } + + if (Main.rand.NextBool(3)) + { + Particle lilStar = new CuteManaStarParticle(Projectile.Center, Projectile.velocity * 0.2f + Main.rand.NextVector2Circular(5f, 5f) - Vector2.UnitY * 3f, Main.rand.NextFloat(0.8f, 1.8f), lifetime: Main.rand.Next(14) + 14); + GeneralParticleHandler.SpawnParticle(lilStar); + } + } + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + SoundEngine.PlaySound(SoundID.GlommerBounce, Projectile.Center); + Projectile.velocity = Vector2.Zero; + Projectile.ai[1] = target.whoAmI; //Assign the stuck npc. + offsetFromStuckNPC = (Projectile.Center - target.Center).RotatedBy(-target.rotation) / target.scale; + rotationFromStuckNPC = Projectile.rotation - target.rotation; + } + + public override void Kill(int timeLeft) + { + if ((Owner.Center - Projectile.Center).Length() < 10f && HasStuck) + { + SoundEngine.PlaySound(SoundID.Item28 with { Volume = SoundID.Item28.Volume * 0.8f }, Projectile.Center); + + //To reach full mana, it needs to have stayed at least half the time needed. If you just one shot an enemy with it, you'll only get 10 mana + int manaGained = Math.Max(10, (int)Math.Floor(100 * Math.Clamp(ManaCharge * 2f / FullMana, 0f, 1f))); + Owner.statMana += manaGained; + if (Main.myPlayer == Owner.whoAmI) + Owner.ManaEffect(manaGained); + + if (Owner.statMana > Owner.statManaMax2) + Owner.statMana = Owner.statManaMax2; + + return; + } + + //don't play the thuk sound & do the particles if it dies of natural causes + if (timeLeft != 0) + { + SoundEngine.PlaySound(SoundID.Item171, Projectile.Center); + + //Particles, with extra ones if it crashed chargeless + for (int i = 0; i < 8; i++) + { + float angle = Main.rand.NextFloat(MathHelper.TwoPi); + + Particle spike = new UrchinSpikeParticle(Projectile.Center + angle.ToRotationVector2() * 2f, angle.ToRotationVector2() * 6f, angle + MathHelper.PiOver2, Main.rand.NextFloat(1f, 1.3f), lifetime: Main.rand.Next(10) + 25); + GeneralParticleHandler.SpawnParticle(spike); + } + + int dustCount = Main.rand.Next(7); + for (int i = 0; i < dustCount; i++) + { + int dustOpacity = (int)(200 * Main.rand.NextFloat(0.5f, 1f)); + float dustScale = Main.rand.NextFloat(1f, 1.4f); + int dustType = CoralSpike.DustPick; //Epic reuse of static method babey + Vector2 dustVelocity = (dustType == 255 ? 1 : -1) * Projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * 0.6f + Main.rand.NextVector2Circular(7f, 7f); + + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustType, dustVelocity, Alpha: dustOpacity, Scale: dustScale); + dust.noGravity = true; + } + + int goreNumber = Main.rand.Next(4); + + for (int i = 0; i < goreNumber; i++) + { + int goreID = Main.rand.NextBool() ? 266 : Main.rand.NextBool() ? 971 : 972; + Gore bone = Gore.NewGorePerfect(Projectile.GetSource_FromAI(), Projectile.position, Projectile.velocity * -0.2f + Main.rand.NextVector2Circular(5f, 5f), goreID); + bone.scale = Main.rand.NextFloat(0.6f, 1f) * (goreID == 972 ? 0.7f : 1f); //Shrink the larger bones + bone.type = goreID; //Gotta do that or else itll spawn gores from the general pool :( + } + } + + else if (HasStuck) + { + for (int i = 0; i < 14; i++) + { + Vector2 direction = Main.rand.NextVector2Circular(10f, 10f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + direction, 45, direction + Vector2.UnitY * -7f, Alpha: Main.rand.Next(100) + 120, Scale: Main.rand.NextFloat(1f, 2f)); + dust.noGravity = true; + } + + SoundEngine.PlaySound(SoundID.Item29 with { Volume = SoundID.Item29.Volume * 0.4f, Pitch = -0.3f }, Projectile.Center); + } + + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 position = Projectile.Center - Main.screenPosition; + int variant = (int)(Projectile.frame - 1); + Rectangle frame = new Rectangle(0, 26 * variant, 24, 24); + float scale = 1.3f; + + Main.EntitySpriteDraw(texture, position, frame, lightColor, Projectile.rotation, frame.Size() / 2f, scale, 0, 0); + + if (Stuck || HasStuck) + { + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + Texture2D bloomTex = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + float bloomSize = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 3f) * 0.1f + 0.4f; + + float period = (int)(FullMana / 4f); + + float pulseProgress = Main.GlobalTimeWrappedHourly % period / period; + + if (Stuck) + { + pulseProgress = (ManaCharge % period) / period; + } + + float overimageSize = scale + (float)Math.Sqrt(pulseProgress) * 0.4f; + float overimageOpacity = (float)Math.Sin(pulseProgress * MathHelper.PiOver2 + MathHelper.PiOver2) * 0.7f; + + Main.EntitySpriteDraw(bloomTex, position, null, Color.DodgerBlue * 0.3f, 0, bloomTex.Size() / 2f, bloomSize, 0, 0); + + Main.EntitySpriteDraw(texture, position, frame, Color.DodgerBlue * overimageOpacity, Projectile.rotation, frame.Size() / 2f, overimageSize, 0, 0); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + } + + + return false; + } + } +} diff --git a/Projectiles/Magic/ManaChargedCoral.png b/Projectiles/Magic/ManaChargedCoral.png new file mode 100644 index 0000000000..e80f3219cf Binary files /dev/null and b/Projectiles/Magic/ManaChargedCoral.png differ diff --git a/Projectiles/Melee/CnidarianJellyfishOnTheString.cs b/Projectiles/Melee/CnidarianJellyfishOnTheString.cs new file mode 100644 index 0000000000..5e0575cef8 --- /dev/null +++ b/Projectiles/Melee/CnidarianJellyfishOnTheString.cs @@ -0,0 +1,330 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Melee +{ + public class VerletSimulatedSegment + { + public Vector2 position, oldPosition; + public bool locked; + + public VerletSimulatedSegment(Vector2 _position, bool _locked = false) + { + position = _position; + oldPosition = _position; + locked = _locked; + } + } + + public class CnidarianJellyfishOnTheString : ModProjectile + { + public const int SegmentCount = 10; + public const float SegmentDistance = 20; + public static int FadeoutTime = 20; + public static int ElectrifyTimer = 180; + public static float ZapDamageMultiplier = 0.75f; + + //Sounds + public static readonly SoundStyle ZapSound = SoundID.Item94 with { Volume = SoundID.Item94.Volume * 0.5f }; + public static readonly SoundStyle SlapSound = new("CalamityMod/Sounds/Custom/WetSlap", 4); + + internal PrimitiveTrail TrailRenderer; + + public List Segments; + public Player Owner => Main.player[Projectile.owner]; + public ref float Initialized => ref Projectile.ai[0]; + public ref float Timer => ref Projectile.ai[1]; + public Vector2 CnidarianPos => Segments[SegmentCount - 1].position; + public float TotalChainLength => (SegmentCount - 1) * SegmentCount; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cnidarian"); + ProjectileID.Sets.YoyosLifeTimeMultiplier[Projectile.type] = 7f; + ProjectileID.Sets.YoyosMaximumRange[Projectile.type] = 240f; + ProjectileID.Sets.YoyosTopSpeed[Projectile.type] = 11f; + } + + public override void SetDefaults() + { + Projectile.aiStyle = -1; + Projectile.width = 28; + Projectile.height = 28; + Projectile.scale = 1.15f; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Melee; + Projectile.penetrate = -1; + Projectile.MaxUpdates = 2; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 20; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + } + + public void SetOrigin(Vector2 position) + { + Projectile.Center = position; + if ((Projectile.Center - Owner.Center).Length() > 380f) + Projectile.Center = Owner.Center + (Projectile.Center - Owner.Center).SafeNormalize(Vector2.One) * 380f; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + return Collision.CheckAABBvAABBCollision(targetHitbox.TopLeft(), targetHitbox.Size(), CnidarianPos - Projectile.Hitbox.Size() / 2f, Projectile.Hitbox.Size()); + } + + public override bool? CanCutTiles() + { + return false; + } + + public void Initialize() + { + //Initialize the segments + SetOrigin(Owner.Calamity().mouseWorld); + + Segments = new List(SegmentCount); + for (int i = 0; i < SegmentCount; i++) + { + VerletSimulatedSegment segment = new VerletSimulatedSegment(Projectile.Center + Vector2.UnitY * SegmentDistance * i); + Segments.Add(segment); + } + + Segments[0].locked = true; + + int j = 0; + foreach (VerletSimulatedSegment segment in Segments) + { + CritSpark particle = new CritSpark(segment.position, Vector2.UnitY * (-1f * j / (float)SegmentCount), Color.White, Color.Cyan, 1f, 10); + GeneralParticleHandler.SpawnParticle(particle); + j++; + } + + + Initialized = 1f; + return; + } + + public override void AI() + { + Projectile.velocity = Vector2.Zero; + + if (Initialized == 0f) + Initialize(); + + if (Owner.channel) + Projectile.timeLeft = FadeoutTime; + + SetOrigin(Projectile.Center.MoveTowards(Owner.Calamity().mouseWorld, 10f)); + + SimulateSegments(); + + Electrify(3, 300f); + + + if ((Projectile.Center - Owner.Center).Length() > 3200f) //200 blocks + Projectile.Kill(); + + Timer++; + } + + public void Electrify(int maxTargets, float targettingDistance) + { + //The volt bunnys gores could be nice to look at, but may be too much for this. Maybe for a future ghost bell upgrade? + + float timeAfterZap = MathHelper.Clamp(20 - (Timer - 20f) % ElectrifyTimer, 0, 20); + float postZapTime = 1 - timeAfterZap / 20f; + + Lighting.AddLight(CnidarianPos, Color.DeepSkyBlue.ToVector3() * (1 - postZapTime)); + + if (Timer % ElectrifyTimer == ElectrifyTimer - 1) + { + + SoundEngine.PlaySound(ZapSound, CnidarianPos); + int maxDust = 2 + Main.rand.Next(3); + for (int i = 0; i < maxDust; i++) + { + Dust.NewDustDirect(Projectile.Center, 0, 0, 226, -3f + Main.rand.NextFloat(0, 6f), -5f, Scale: Main.rand.NextFloat(0.2f, 1f)); + + Dust.NewDustDirect(CnidarianPos, 0, 0, 226, -4f + Main.rand.NextFloat(0, 8f), -3f, Scale: Main.rand.NextFloat(0.2f, 1f)); + } + + int[] targetArray = new int[maxTargets]; + int targetsAquired = 0; + + for (int i = 0; i < Main.maxNPCs; i++) + { + if (targetsAquired == maxTargets) + break; + + if (Main.npc[i].CanBeChasedBy(Projectile)) + { + if ((CnidarianPos - Main.npc[i].Center).Length() < targettingDistance) + { + targetArray[targetsAquired] = i; + targetsAquired++; + } + } + } + + // If there is anything to actually shoot at, pick targets at random and fire. + if (targetsAquired > 0) + { + Vector2 velocity; + + for (int i = 0; i < targetsAquired; i++) + { + velocity = (Main.npc[targetArray[i]].Center - CnidarianPos).SafeNormalize(Vector2.Zero) * 10f; + + for (int j = 0; j < 3; j++) + { + Color bloomColor = Main.rand.NextBool() ? (Main.rand.NextBool() ? Color.Gold : Color.Cyan) : Color.SpringGreen; + ElectricSpark spark = new ElectricSpark(CnidarianPos, velocity.RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(0.2f, 1.3f), Color.Gold, bloomColor, 0.5f + Main.rand.NextFloat(0.5f), 30, bloomScale: 2) ; + GeneralParticleHandler.SpawnParticle(spark); + } + + if (Projectile.owner == Main.myPlayer) + { + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), CnidarianPos, velocity, ProjectileType(), (int)(Projectile.damage * ZapDamageMultiplier), Projectile.knockBack, Projectile.owner, targetArray[i], 0f); + } + } + } + } + } + + public void SimulateSegments() + { + Segments[0].oldPosition = Segments[0].position; + Segments[0].position = Projectile.Center; + + //https://youtu.be/PGk0rnyTa1U?t=400 we use verlet integration chains here + foreach (VerletSimulatedSegment segment in Segments) + { + if (!segment.locked) + { + Vector2 positionBeforeUpdate = segment.position; + + segment.position += (segment.position - segment.oldPosition); // This adds conservation of energy to the segments. This makes it super bouncy and shouldnt be used but it's really funny + segment.position += Vector2.UnitY * 0.3f; //=> This adds gravity to the segments. + + segment.oldPosition = positionBeforeUpdate; + } + } + + for (int k = 0; k < 10; k++) + { + for (int j = 0; j < SegmentCount - 1; j++) + { + VerletSimulatedSegment pointA = Segments[j]; + VerletSimulatedSegment pointB = Segments[j + 1]; + Vector2 segmentCenter = (pointA.position + pointB.position) / 2f; + Vector2 segmentDirection = Utils.SafeNormalize(pointA.position - pointB.position, Vector2.UnitY); + + if (!pointA.locked) + pointA.position = segmentCenter + segmentDirection * SegmentDistance / 2f; + + if (!pointB.locked) + pointB.position = segmentCenter - segmentDirection * SegmentDistance / 2f; + + Segments[j] = pointA; + Segments[j + 1] = pointB; + } + } + + Projectile.netUpdate = true; + Projectile.netSpam = 0; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + //Play a wet slap sound if you hit an enemy fast enough + float centrifugalForce = Math.Clamp((Segments[SegmentCount - 1].position - Segments[SegmentCount - 1].oldPosition).Length() * 2f, 0f, 130f) / 130f; + if (centrifugalForce > 0.2f) + SoundEngine.PlaySound(SlapSound with { Volume = SlapSound.Volume * centrifugalForce + 0.8f}, target.position); + + } + + //Squish animation keys + public CurveSegment anticipation = new CurveSegment(EasingType.PolyInOut, 0f, 1f, 0.35f, 3); + public CurveSegment contraction = new CurveSegment(EasingType.PolyOut, 0.5f, 1.35f, -0.85f, 5); + public CurveSegment retract = new CurveSegment(EasingType.SineInOut, 0.7f, 0.5f, 0.5f); + internal float StretchRatio() => PiecewiseAnimation(MathHelper.Clamp((Timer + 45) % ElectrifyTimer, 0, 80) / 80f, new CurveSegment[] { anticipation, contraction, retract }); + + public float PrimWidthFunction(float completionRatio) + { + return 1.6f; + } + + public Color PrimColorFunction(float completionRatio) + { + float timeAfterZap = MathHelper.Clamp( 20 - (Timer - 5 - completionRatio * 12f) % ElectrifyTimer, 0, 20); + float postZapTime = 1 - timeAfterZap / 20f; + + Color startingColor = Color.Lerp(Color.Cyan, Color.Maroon, (float)Math.Pow(postZapTime, 2f)) * (Projectile.timeLeft / (float)FadeoutTime); + Color endColor = Color.DarkCyan * 0f; + return Color.Lerp(endColor, startingColor, (float)Math.Pow(completionRatio, 1.5D)) * 0.7f; + } + + public override bool PreDraw(ref Color lightColor) + { + if (TrailRenderer is null) + TrailRenderer = new PrimitiveTrail(PrimWidthFunction, PrimColorFunction); + + Vector2[] segmentPositions = Segments.Select(x => x.position).ToArray(); + + TrailRenderer.Draw(segmentPositions, -Main.screenPosition, 66); + + + Texture2D tex = Request(Texture).Value; + + Vector2 squish = new Vector2(2 - StretchRatio(), StretchRatio()); + + float centrifugalForce = Math.Clamp((Segments[SegmentCount - 1].position - Segments[SegmentCount - 1].oldPosition).Length() * 2f - 10f, 0f, 130f) / 150f; + Vector2 centrifugalSquish = new Vector2(1 - centrifugalForce * 0.66f, 1 + centrifugalForce * 2.2f); + squish *= centrifugalSquish; + + float rotation = (Segments[SegmentCount - 1].position - Segments[SegmentCount - 2].position).ToRotation() - MathHelper.PiOver2; + lightColor = Lighting.GetColor((int)CnidarianPos.X / 16, (int)CnidarianPos.Y / 16); + + + Main.EntitySpriteDraw(tex, Segments[SegmentCount - 1].position - Main.screenPosition, null, Projectile.GetAlpha(lightColor) * (Projectile.timeLeft / (float)FadeoutTime), rotation, tex.Size() / 2f, Projectile.scale * squish, SpriteEffects.None, 0); + + //Add a blue glowing overlay quickly following a zap + float timeAfterZap = MathHelper.Clamp(20 - (Timer - 15f) % ElectrifyTimer, 0, 20); + float postZapTime = 1 - timeAfterZap / 20f; + + if (postZapTime < 1) + { + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + Main.EntitySpriteDraw(tex, Segments[SegmentCount - 1].position - Main.screenPosition, null, Color.DeepSkyBlue * (1 - postZapTime), rotation, tex.Size() / 2f, (Projectile.scale + postZapTime * 1.4f) * squish, 0f, 0); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + } + return false; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.WriteVector2(Segments[SegmentCount - 1].position); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + Segments[SegmentCount - 1].position = reader.ReadVector2(); + } + } +} diff --git a/Projectiles/Melee/CnidarianJellyfishOnTheString.png b/Projectiles/Melee/CnidarianJellyfishOnTheString.png new file mode 100644 index 0000000000..5859212ce2 Binary files /dev/null and b/Projectiles/Melee/CnidarianJellyfishOnTheString.png differ diff --git a/Projectiles/Melee/CnidarianSpark.cs b/Projectiles/Melee/CnidarianSpark.cs new file mode 100644 index 0000000000..ebce8453c4 --- /dev/null +++ b/Projectiles/Melee/CnidarianSpark.cs @@ -0,0 +1,69 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class CnidarianSpark : ModProjectile + { + public ref float Target => ref Projectile.ai[0]; + public Vector2 initialVelocity; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Spark"); + } + + public override void SetDefaults() + { + Projectile.width = 6; + Projectile.height = 6; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.DamageType = DamageClass.Melee; + Projectile.penetrate = 1; + Projectile.timeLeft = 15; + } + + + public override bool? CanHitNPC(NPC target) + { + if (Main.npc[(int)Target] != target) + return false; + + return base.CanHitNPC(target); + } + + public override void AI() + { + if (Projectile.velocity != Vector2.Zero) + initialVelocity = Projectile.velocity; + + Projectile.velocity = Vector2.Zero; + + if (Main.npc[(int)Target] != null) + { + Projectile.Center = Vector2.Lerp(Projectile.Center, Main.npc[(int)Target].Center, 0.4f); + Projectile.rotation = (Projectile.Center - Main.npc[(int)Target].Center).ToRotation() - MathHelper.PiOver2; + } + + Color bloomColor = Main.rand.NextBool() ? (Main.rand.NextBool() ? Color.Gold : Color.Cyan) : Color.SpringGreen; + CritSpark particle = new CritSpark(Projectile.Center, (Projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * 4f, Color.LightSkyBlue, bloomColor, 0.8f, 10, bloomScale: 2f); + GeneralParticleHandler.SpawnParticle(particle); + } + + public override void Kill(int timeLeft) + { + SoundEngine.PlaySound(CnidarianJellyfishOnTheString.ZapSound, Projectile.Center); + + for (int i = 0; i < 4; i++) + { + Color bloomColor = Main.rand.NextBool() ? (Main.rand.NextBool() ? Color.Gold : Color.Cyan) : Color.SpringGreen; + CritSpark particle = new CritSpark(Projectile.Center, initialVelocity * i, Color.LightSkyBlue, bloomColor, 0.8f, 10, bloomScale: 2f); + GeneralParticleHandler.SpawnParticle(particle); + } + } + } +} diff --git a/Projectiles/Melee/CnidarianSpark.png b/Projectiles/Melee/CnidarianSpark.png new file mode 100644 index 0000000000..3367e69f0d Binary files /dev/null and b/Projectiles/Melee/CnidarianSpark.png differ diff --git a/Projectiles/Melee/RedtideSpearShot.png b/Projectiles/Melee/RedtideSpearShot.png new file mode 100644 index 0000000000..c7e27ea825 Binary files /dev/null and b/Projectiles/Melee/RedtideSpearShot.png differ diff --git a/Projectiles/Melee/RedtideWhirlpool.cs b/Projectiles/Melee/RedtideWhirlpool.cs index 58596ade5b..9559418ff1 100644 --- a/Projectiles/Melee/RedtideWhirlpool.cs +++ b/Projectiles/Melee/RedtideWhirlpool.cs @@ -1,90 +1,76 @@ +using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; + namespace CalamityMod.Projectiles.Melee { public class RedtideWhirlpool : ModProjectile { - public override string Texture => "CalamityMod/Projectiles/Melee/BrinyTyphoonBubble"; + public Player Owner => Main.player[Projectile.owner]; public override void SetStaticDefaults() { DisplayName.SetDefault("Whirlpool"); - Main.projFrames[Projectile.type] = 3; } public override void SetDefaults() { Projectile.width = 60; Projectile.height = 60; - Projectile.scale = 0.5f; Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.penetrate = 2; Projectile.DamageType = DamageClass.Melee; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 40; } public override void AI() { - Lighting.AddLight(Projectile.Center, 0f, 0f, Projectile.scale * 1.5f); - int num626 = 6; - for (int num627 = 0; num627 < num626; num627++) + Projectile.velocity *= 0.97f; + Projectile.rotation += MathHelper.PiOver4 / 2.4f * Math.Sign(Projectile.velocity.X); + + int dustCount = Main.rand.Next(4); + float offset = Main.rand.NextFloat(MathHelper.TwoPi); + for (int i = 0; i < dustCount; i++) { - Vector2 vector45 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector45 = vector45.RotatedBy((double)(num627 - (num626 / 2 - 1)) * 3.1415926535897931 / (double)(float)num626, default) + Projectile.Center; - Vector2 value15 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); - int num628 = Dust.NewDust(vector45 + value15, 0, 0, 172, value15.X * 2f, value15.Y * 2f, 100, default, Projectile.scale); - Main.dust[num628].noGravity = true; - Main.dust[num628].noLight = true; - Main.dust[num628].velocity /= 4f; - Main.dust[num628].velocity -= Projectile.velocity; + float angle = i / (float)dustCount * MathHelper.TwoPi + offset; + Vector2 dustPos = Projectile.Center + angle.ToRotationVector2() * 46f; + Dust dust = Dust.NewDustPerfect(dustPos, 176, (angle - MathHelper.PiOver2 * Math.Sign(Projectile.velocity.X)).ToRotationVector2() * 8f + Projectile.velocity, Scale: Main.rand.NextFloat(1.6f, 3f)); + dust.noGravity = true; } - if (Projectile.scale <= 1f) - { - Projectile.scale *= 1.015f; - } - if (Projectile.scale >= 1f) - { - Projectile.Kill(); - } - Projectile.frameCounter++; - if (Projectile.frameCounter > 3) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame >= 3) - { - Projectile.frame = 0; - } - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; } public override bool PreDraw(ref Color lightColor) { - Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = ModContent.Request(Texture).Value.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + Texture2D texture = ModContent.Request(Texture).Value; + + SpriteEffects flip = Math.Sign(Projectile.velocity.X) < 0? SpriteEffects.None : SpriteEffects.FlipHorizontally; + + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, lightColor * 0.3f, Projectile.rotation * 1.2f, texture.Size() / 2f, 1.5f, flip, 0); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, lightColor * 0.4f, Projectile.rotation, texture.Size() / 2f, 2f, flip, 0); + return false; } public override void Kill(int timeLeft) { SoundEngine.PlaySound(SoundID.NPCDeath19, Projectile.position); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + + int dustCount = 36; + for (int i = 0; i < dustCount; i++) { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 172, vector7.X * 2f, vector7.Y * 2f, 100, default, 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 offset = Vector2.Normalize(Projectile.velocity) * new Vector2(Projectile.width / 2f, Projectile.height) * 0.75f; + offset = offset.RotatedBy(((i - (dustCount / 2 - 1)) * MathHelper.TwoPi / (float)dustCount), default) + Projectile.Center; + Vector2 dustDirection = offset - Projectile.Center; + Dust dust = Dust.NewDustPerfect(offset + dustDirection, 172, Vector2.Zero, 100, default, 1.4f); + dust.noGravity = true; + dust.noLight = true; + dust.velocity = dustDirection; } } } diff --git a/Projectiles/Melee/RedtideWhirlpool.png b/Projectiles/Melee/RedtideWhirlpool.png new file mode 100644 index 0000000000..0736e9ebff Binary files /dev/null and b/Projectiles/Melee/RedtideWhirlpool.png differ diff --git a/Projectiles/Melee/Spears/RedtideSpearProjectile.cs b/Projectiles/Melee/Spears/RedtideSpearProjectile.cs new file mode 100644 index 0000000000..5ede7b2556 --- /dev/null +++ b/Projectiles/Melee/Spears/RedtideSpearProjectile.cs @@ -0,0 +1,340 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Projectiles.Melee.Spears +{ + public class RedtideSpearProjectile : ModProjectile + { + public Player Owner => Main.player[Projectile.owner]; + public static int Lifetime = 28; + public int Timer => Lifetime - Projectile.timeLeft; + + private SlotId ChargeWindSoundSlot; + public ActiveSound ChargeWindSound + { + get + { + ActiveSound sound; + if (SoundEngine.TryGetActiveSound(ChargeWindSoundSlot, out sound)) + return sound; + return null; + } + } + + + public int ChargeDirection => Math.Sign(Projectile.velocity.X); + + #region Thrust + //Basic animation variables. + public float ThrustProgress => Timer / (float)Lifetime; + public float BaseRotation => Projectile.velocity.ToRotation(); + public float ThrustRotation => BaseRotation + Owner.direction * RotationShift; + + //Thrust animation keys + public CurveSegment thrust = new CurveSegment(EasingType.PolyIn, 0f, 0.15f, 0.85f, 3); + public CurveSegment hold = new CurveSegment(EasingType.SineBump, 0.3f, 1f, 0.2f); + public CurveSegment retract = new CurveSegment(EasingType.PolyOut, 0.7f, 1f, -1f, 2); + public CurveSegment correct = new CurveSegment(EasingType.PolyIn, 0.85f, 0f, 0.17f); + internal float Displacement => PiecewiseAnimation(ThrustProgress, new CurveSegment[] { thrust, hold, retract, correct }); + + internal const float startRotation = MathHelper.PiOver4 * 0.1f; + internal const float downwardsRotation = MathHelper.PiOver4 * 0.15f; + internal const float upwardsRotation = MathHelper.PiOver4 * -0.44f; + internal const float loweredTime = 0.25f; + + public CurveSegment downwards = new CurveSegment(EasingType.SineOut, 0f, startRotation, downwardsRotation, 2); + public CurveSegment raiseback = new CurveSegment(EasingType.SineIn, loweredTime, startRotation + downwardsRotation, upwardsRotation); + public CurveSegment stayUp = new CurveSegment(EasingType.Linear, 0.8f, startRotation + downwardsRotation + upwardsRotation, 0f); + internal float RotationShift => PiecewiseAnimation(ThrustProgress, new CurveSegment[] { downwards, raiseback, stayUp }); + public int InitializationTime => (int)(loweredTime * Lifetime); + #endregion + + #region Drag along the ground + + + public static int MaxRunTime = 300; + //Player can only do the run attack while moving fast horizontally in the direction of the thrust, but remaining on the ground + public bool CanRunAttack => Math.Abs(Owner.velocity.Y) <= 0.8f && Math.Abs(Owner.velocity.X) >= Owner.maxRunSpeed * 0.7f && Math.Sign(Owner.velocity.X) == ChargeDirection && Owner.channel && !RunBroken; + //You can only start a run attack if you meet the other conditions, but ALSO you can't do it if you are aiming too much upwards or downwards + public bool CanStartRunAttack => CanRunAttack && Math.Abs(Owner.Calamity().mouseWorld.Y - Owner.MountedCenter.Y) <= 300; + public ref float RunTimer => ref Projectile.ai[0]; + //The window of time during which the run hasn't fully started, and is indentical to the regular thrust's start. This tells us when we can no longer do this switch. + public bool FullyRunning => RunTimer > InitializationTime; + + //Basically tracks if the run has been broken, either because the player did not try to run at all, stopped running, or ran for too long. + public bool RunBroken + { + get => Projectile.ai[1] > 0f; + set { Projectile.ai[1] = value ? 1f : 0f; } + } + + public static int UpThrustLifetime = 20; + public int UpThrustTimer => UpThrustLifetime - Projectile.timeLeft; + public float UpThrustProgress => UpThrustTimer / (float)UpThrustLifetime; + + //Gets the ideal rotation for the spear while running. Basically, slightly angled downwards towards the ground, to the left or right of the player depending on the direction + public float IdealSpearRotationForRun + { + get + { + float rotation = MathHelper.PiOver4 * 0.12f; + + if (ChargeDirection > 0) + return rotation; + + //Mirror the angle if facing left. + return MathHelper.Pi - rotation - MathHelper.TwoPi; + } + } + + //Properly wrap the angle. Indeed, the angles on the left suddenly go from Pi to -Pi + public float ProjectileRotationButWrappedForTransition + { + get + { + if (ChargeDirection < 0 && Projectile.rotation > 0) + return Projectile.rotation - MathHelper.TwoPi; + + return Projectile.rotation; + } + } + + public CurveSegment transitionSegment => new CurveSegment(EasingType.PolyInOut, 0f, ProjectileRotationButWrappedForTransition, IdealSpearRotationForRun - ProjectileRotationButWrappedForTransition, 2); + internal float RunAttackRotation => PiecewiseAnimation(Math.Clamp(RunTimer / 30f, 0f, 1f), new CurveSegment[] { transitionSegment }); + + + public CurveSegment anticipationDown => new CurveSegment(EasingType.SineIn, 0f, IdealSpearRotationForRun, ChargeDirection * MathHelper.PiOver4 * 0.1f, 2); + public CurveSegment upthrust => new CurveSegment(EasingType.SineOut, 0.4f, IdealSpearRotationForRun + ChargeDirection * MathHelper.PiOver4 * 0.1f, ChargeDirection * MathHelper.PiOver2 * -0.75f); + public CurveSegment holdup => new CurveSegment(EasingType.Linear, 0.8f, IdealSpearRotationForRun + ChargeDirection * MathHelper.PiOver2 * -0.7f, -0.14f); + internal float UpThrustRotation => PiecewiseAnimation(UpThrustProgress, new CurveSegment[] { anticipationDown, upthrust, holdup }); + + + public CurveSegment goback = new CurveSegment(EasingType.SineOut, 0f, 0.68f, -0.2f); + public CurveSegment goforwardfast = new CurveSegment(EasingType.PolyIn, 0.33f, 0.58f, 0.7f, 3); + public CurveSegment gobounce = new CurveSegment(EasingType.Linear, 0.6f, 1.28f, 0f); + public CurveSegment gobackagain = new CurveSegment(EasingType.SineOut, 0.86f, 1.28f, -0.2f); + internal float UpThrustDisplacement => PiecewiseAnimation(UpThrustProgress, new CurveSegment[] { goback, goforwardfast, gobounce, gobackagain }); + + #endregion + + #region General calculations + public enum AttackState { ForwardThrust, RunAttack, UpwardsThrust }; + public AttackState CurrentAttackState => (RunBroken && !FullyRunning) ? AttackState.ForwardThrust : (RunBroken || RunTimer > MaxRunTime) ? AttackState.UpwardsThrust : AttackState.RunAttack; + + //Gets the proper rotation based on the current state of the spear + public float AppropriateRotation + { + get + { + //If the player isn't fully running yet, we just don't care about the actual attack, and have them have the default thrust rotation + if (!FullyRunning) + return ThrustRotation; + + if (CurrentAttackState == AttackState.RunAttack) + return RunAttackRotation; + + if (CurrentAttackState == AttackState.UpwardsThrust) + return UpThrustRotation; + + return ThrustRotation; + } + } + + //Gets the proper displacement based on the state of the spear + public float AppropriateDisplacement + { + get + { + //If the player isn't fully running yet, we just don't care about the actual attack, and have them have the default thrust rotation + if (!FullyRunning) + return Displacement; + + //If the player is running, make them keep the lance a bit behind as they run + if (CurrentAttackState == AttackState.RunAttack) + return MathHelper.Lerp(0.93f, 0.68f, Math.Clamp(RunTimer / 30f, 0f, 1f)); + + if (CurrentAttackState == AttackState.UpwardsThrust) + return UpThrustDisplacement; + + return Displacement; + } + } + #endregion + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Redtide Spear"); + } + + public override void SetDefaults() + { + Projectile.width = 56; + Projectile.DamageType = DamageClass.Melee; //Dictates whether this is a melee-class weapon. + Projectile.timeLeft = Lifetime; + Projectile.height = 56; + Projectile.friendly = true; + Projectile.hostile = false; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.ownerHitCheck = true; + } + + public override bool ShouldUpdatePosition() + { + return false; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + float collisionPoint = 0f; + float bladeLenght = 85 * Projectile.scale; + float bladeWidth = 20 * Projectile.scale; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center + AppropriateRotation.ToRotationVector2() * bladeLenght * -0.5f, Projectile.Center + ThrustRotation.ToRotationVector2() * bladeLenght * 0.5f, bladeWidth, ref collisionPoint); + } + + public override void AI() + { + UpThrustLifetime = 20; + + + //If the player starts the attack without being able to do a run attack, mark the run as "broken" from the start. + if (Projectile.timeLeft == Lifetime && RunTimer == 0 && !CanStartRunAttack) + { + RunBroken = true; + } + + if (CurrentAttackState == AttackState.RunAttack) + { + //Keep the projectile alive during the run attack. + //The fullyRunning check is important, because the animation timer relies on the projectiles time left for the startup animation. + if (FullyRunning) + Projectile.timeLeft++; + + else + //We never actually use Projectile.rotation to draw or do any collision calculations. + //Instead, we use it to keep track of the final rotation of the spear BEFORE it was fully running + //We proceed to use this value to smooth the transition between the start of the thrust animation with the run animation. + Projectile.rotation = AppropriateRotation; + + //If at any point of the run attack, something happens to interrupt it, break the run and transition back into a forward or upwards thrust, depending on how long the player ran. + if (!CanRunAttack) + { + RunBroken = true; + //If the player was running for long enough, allow them to do a thrust attack. For this, we change the animation timer. + if (FullyRunning) + { + Projectile.timeLeft = UpThrustLifetime; + } + } + + ActiveSound soundOut; + if (!SoundEngine.TryGetActiveSound(ChargeWindSoundSlot, out soundOut) || !soundOut.IsPlaying) + ChargeWindSoundSlot = SoundEngine.PlaySound(SoundID.DD2_BookStaffTwisterLoop with { IsLooped = true, Volume = SoundID.DD2_BookStaffTwisterLoop.Volume * 0.7f }, Projectile.Center); + + else + { + soundOut.Volume = MathHelper.Lerp(0f, SoundID.DD2_BookStaffTwisterLoop.Volume * 0.7f, Math.Clamp(RunTimer / 120f, 0f, 1f)); + soundOut.Position = Projectile.Center; + } + + RunTimer++; + + if (Main.rand.NextBool()) + { + int dustOpacity = Main.rand.Next(80); + float dustScale = Main.rand.NextFloat(1f, 1.4f); + Vector2 dustVelocity = (AppropriateRotation + MathHelper.Pi).ToRotationVector2().RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(0.5f, 5f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + AppropriateRotation.ToRotationVector2() * 40f, 16, dustVelocity, Alpha: dustOpacity, Scale: dustScale); + } + } + + //Basic spear attack + else if (CurrentAttackState == AttackState.ForwardThrust) + { + if (ThrustProgress == 0.5f) + SoundEngine.PlaySound(SoundID.DD2_JavelinThrowersAttack, Projectile.Center); + } + + else if (CurrentAttackState == AttackState.UpwardsThrust) + { + ActiveSound soundOut; + + + if (SoundEngine.TryGetActiveSound(ChargeWindSoundSlot, out soundOut)) + { + soundOut.Volume *= 0.7f; + soundOut.Position = Projectile.Center; + if (soundOut.Volume < 0.2f) + soundOut.Stop(); + } + + if (ThrustProgress == 0.5f) + SoundEngine.PlaySound(SoundID.DD2_MonkStaffSwing, Projectile.Center); + } + + UpdateOwnerVars(); + Vector2 thrust = AppropriateRotation.ToRotationVector2() * (AppropriateDisplacement * 40f + 5f); + + //During the run anim, make the spear bob up and down. + if (CurrentAttackState == AttackState.RunAttack) + thrust -= Vector2.UnitY * 2f * MathHelper.Clamp(0.5f + 0.8f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 20f), 0f, 1f); + + Projectile.Center = Owner.MountedCenter + thrust; + } + + public void UpdateOwnerVars() + { + Owner.direction = Math.Sign(BaseRotation.ToRotationVector2().X); + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, AppropriateRotation - MathHelper.PiOver2); + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + + //Add more latency after an upwards thrust, for impact purposes + if (CurrentAttackState == AttackState.UpwardsThrust) + { + Owner.itemTime = 20; + Owner.itemAnimation = 20; + } + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + //Send the enemy flying up if hit by the upwards thrust. + if (CurrentAttackState == AttackState.UpwardsThrust) + { + target.velocity.Y -= 12 * (float)Math.Sqrt(target.knockBackResist); + target.FallingNPC().ApplyFallDamage(target, 50, 5f); + } + + target.AddBuff(BuffID.Poisoned, 180); + + //Give a sliver of iframes to the player so its safer to ram into hordes (which is fun and should be encouraged) + if (CurrentAttackState == AttackState.RunAttack) + Owner.GiveIFrames(5); + } + + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + //Boost the knockback during the run attack + if (CurrentAttackState == AttackState.RunAttack) + knockback *= 1.35f; + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, lightColor, AppropriateRotation + MathHelper.PiOver2 * 1.5f - MathHelper.ToRadians(12), texture.Size() / 2f, Projectile.scale, 0, 0); + return false; + } + } +} diff --git a/Projectiles/Melee/Spears/RedtideSpearProjectile.png b/Projectiles/Melee/Spears/RedtideSpearProjectile.png new file mode 100644 index 0000000000..b72059c817 Binary files /dev/null and b/Projectiles/Melee/Spears/RedtideSpearProjectile.png differ diff --git a/Projectiles/Melee/Spears/UrchinSpearProjectile.cs b/Projectiles/Melee/Spears/UrchinSpearProjectile.cs deleted file mode 100644 index 23dce17159..0000000000 --- a/Projectiles/Melee/Spears/UrchinSpearProjectile.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using CalamityMod.Projectiles.BaseProjectiles; -namespace CalamityMod.Projectiles.Melee.Spears -{ - public class UrchinSpearProjectile : BaseSpearProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Spear"); - } - - public override void SetDefaults() - { - Projectile.width = 56; //The width of the .png file in pixels divided by 2. - Projectile.aiStyle = 19; - Projectile.DamageType = DamageClass.Melee; //Dictates whether this is a melee-class weapon. - Projectile.timeLeft = 90; - Projectile.height = 56; //The height of the .png file in pixels divided by 2. - Projectile.friendly = true; - Projectile.hostile = false; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.penetrate = -1; - Projectile.ownerHitCheck = true; - } - - public override float InitialSpeed => 3f; - public override float ReelbackSpeed => 2.4f; - public override float ForwardSpeed => 0.95f; - public override Action EffectBeforeReelback => (proj) => - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X + Projectile.velocity.X, Projectile.Center.Y + Projectile.velocity.Y, - Projectile.velocity.X * 1.6f, Projectile.velocity.Y * 1.6f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * 0.5f, Projectile.owner, 0f, 0f); - }; - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.Poisoned, 180); - } - } -} diff --git a/Projectiles/Melee/Spears/UrchinSpearProjectile.png b/Projectiles/Melee/Spears/UrchinSpearProjectile.png deleted file mode 100644 index 2436b8e48d..0000000000 Binary files a/Projectiles/Melee/Spears/UrchinSpearProjectile.png and /dev/null differ diff --git a/Projectiles/Melee/UrchinMaceProjectile.cs b/Projectiles/Melee/UrchinMaceProjectile.cs new file mode 100644 index 0000000000..9310242891 --- /dev/null +++ b/Projectiles/Melee/UrchinMaceProjectile.cs @@ -0,0 +1,172 @@ +using System; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class UrchinMaceProjectile : ModProjectile + { + public Player Owner => Main.player[Projectile.owner]; + public override string Texture => "CalamityMod/Items/Weapons/Melee/UrchinMace"; + + public static float MaxWindup = 110; + public ref float Windup => ref Projectile.ai[0]; + public float WindupProgress => MathHelper.Clamp(Windup, 0, MaxWindup) / MaxWindup; + public static float whirlpoolDamageMultiplier = 1.6f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Urchin Mace"); + } + + public override void SetDefaults() + { + Projectile.width = 60; + Projectile.height = 60; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Melee; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + //Prevent spam click abuse + if (Windup < Projectile.localNPCHitCooldown) + return false; + + float collisionPoint = 0f; + float bladeLenght = 70 * Projectile.scale; + float bladeWidth = 30 * Projectile.scale; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + (Projectile.rotation.ToRotationVector2() * bladeLenght), bladeWidth, ref collisionPoint); + } + + public override void AI() + { + Owner.direction = Math.Sign(Owner.Calamity().mouseWorld.X - Owner.position.X); + + Projectile.velocity = Vector2.Zero; + + Projectile.rotation += (WindupProgress * MathHelper.PiOver4 / 1.5f) * Owner.direction; + + if (Owner.channel) + { + Projectile.timeLeft = 2; + UpdateOwnerVars(); + } + + if (WindupProgress > 0.5f) + { + int dustCount = Main.rand.Next(4); + float offset = Main.rand.NextFloat(MathHelper.TwoPi); + for (int i = 0; i < dustCount; i++) + { + float angle = i / (float)dustCount * MathHelper.TwoPi + offset; + Vector2 dustPos = Owner.MountedCenter + angle.ToRotationVector2() * 40f * WindupProgress; + Dust dust = Dust.NewDustPerfect(dustPos, 176, (angle - MathHelper.PiOver2 * Owner.direction).ToRotationVector2() * 5f + Owner.velocity, Scale: Main.rand.NextFloat(1f, 2f)); + dust.noGravity = true; + } + } + + Projectile.Center = Owner.MountedCenter + Projectile.rotation.ToRotationVector2() * 10f - Vector2.UnitX * 4 * Owner.direction; + + if (Projectile.soundDelay <= 0) + { + SoundEngine.PlaySound(SoundID.DD2_GhastlyGlaivePierce, Owner.MountedCenter); + Projectile.soundDelay = 28; + } + + if (Windup == MaxWindup && Owner.whoAmI == Main.myPlayer) + { + SoundEngine.PlaySound(SoundID.Item43, Owner.MountedCenter); + } + + Windup++; + } + + public void UpdateOwnerVars() + { + float armPointingDirection = ((Owner.Calamity().mouseWorld - Owner.MountedCenter).ToRotation()); + + //"crop" the rotation so the player only points their arm in a smaller range. (The back arm points in the throw direction) + if (armPointingDirection < MathHelper.PiOver2 && armPointingDirection >= -MathHelper.PiOver2) + armPointingDirection = -MathHelper.PiOver2 + MathHelper.PiOver4 / 2f + MathHelper.PiOver2 * 1.5f * Utils.GetLerpValue(0f, MathHelper.Pi, armPointingDirection + MathHelper.PiOver2, true); + else + { + if (armPointingDirection > 0) + armPointingDirection = MathHelper.PiOver2 + MathHelper.PiOver4 / 2f + MathHelper.PiOver4 * 1.5f * Utils.GetLerpValue(0f, MathHelper.PiOver2, armPointingDirection - MathHelper.PiOver2, true); + else + armPointingDirection = -MathHelper.Pi + MathHelper.PiOver4 * 1.5f * Utils.GetLerpValue(-MathHelper.Pi, -MathHelper.PiOver4, armPointingDirection, true); + } + + + Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, armPointingDirection - MathHelper.PiOver2); + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, Projectile.rotation - MathHelper.PiOver2); + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + for (int i = 0; i < 3; i++) + { + float angle = Main.rand.NextFloat(MathHelper.TwoPi); + + Particle spike = new UrchinSpikeParticle(target.Center + angle.ToRotationVector2() * 15f, angle.ToRotationVector2() * 6f, angle + MathHelper.PiOver2, Main.rand.NextFloat(1f, 1.3f), lifetime: Main.rand.Next(10) + 25); + GeneralParticleHandler.SpawnParticle(spike); + } + } + + //If we don't do that, the hit enemies get knocked back towards you if you hit them from the right?? + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + // This would knock enemies away consistently, but i'm choosing to go with the other option + //hitDirection = Math.Sign(target.Center.X - Owner.Center.X); + + //Doing it this way lets the player choose if they want to knockback enemies towards them by pointing away from them + hitDirection = Owner.direction; + } + + public override bool PreDraw(ref Color lightColor) + { + Owner.direction = Math.Sign(Owner.Calamity().mouseWorld.X - Owner.position.X); + + Texture2D maceTexture = ModContent.Request(Texture).Value; + Texture2D whirlpoolTexture = ModContent.Request("CalamityMod/Projectiles/Melee/RedtideWhirlpool").Value; + + float whirlpoolScale = MathHelper.Clamp(WindupProgress * 3f - 0.4f, 0f, 1f) * 2f; + float whirlpoolOpacity = WindupProgress * 0.2f + (float)Math.Sin(Main.GlobalTimeWrappedHourly * 3f) * 0.1f; + float whirlpoolRotation = Windup * 0.34f * Owner.direction; + SpriteEffects flip = Owner.direction < 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + + Main.EntitySpriteDraw(whirlpoolTexture, Owner.MountedCenter - Main.screenPosition, null, Lighting.GetColor((int)Owner.MountedCenter.X / 16, (int)Owner.MountedCenter.Y / 16) * whirlpoolOpacity * 0.3f, whirlpoolRotation * 1.2f, whirlpoolTexture.Size() / 2f, whirlpoolScale, flip, 0); + Main.EntitySpriteDraw(whirlpoolTexture, Owner.MountedCenter - Main.screenPosition, null, Lighting.GetColor((int)Owner.MountedCenter.X / 16, (int)Owner.MountedCenter.Y / 16) * whirlpoolOpacity, whirlpoolRotation, whirlpoolTexture.Size() / 2f, whirlpoolScale, flip, 0); + + Vector2 handleOrigin = new Vector2(0, maceTexture.Height); + float maceRotation = Projectile.rotation + MathHelper.PiOver4; + Main.EntitySpriteDraw(maceTexture, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), maceRotation, handleOrigin, Projectile.scale, SpriteEffects.None, 0); + + return false; + } + + public override void Kill(int timeLeft) + { + //Spawn a whirlpool typhoon after sending it out + if (WindupProgress >= 1f && Projectile.owner == Main.myPlayer) + { + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, (Main.MouseWorld - Owner.position).SafeNormalize(Vector2.One) * 25f, ModContent.ProjectileType(), (int)(Projectile.damage * whirlpoolDamageMultiplier), Projectile.knockBack, Projectile.owner, 0, 0f); + } + + SoundEngine.PlaySound(SoundID.Item7, Projectile.position); + } + } +} diff --git a/Projectiles/Melee/Yoyos/CnidarianYoyo.cs b/Projectiles/Melee/Yoyos/CnidarianYoyo.cs deleted file mode 100644 index 9c384e78da..0000000000 --- a/Projectiles/Melee/Yoyos/CnidarianYoyo.cs +++ /dev/null @@ -1,48 +0,0 @@ -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee.Yoyos -{ - public class CnidarianYoyo : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cnidarian"); - ProjectileID.Sets.YoyosLifeTimeMultiplier[Projectile.type] = 7f; - ProjectileID.Sets.YoyosMaximumRange[Projectile.type] = 240f; - ProjectileID.Sets.YoyosTopSpeed[Projectile.type] = 11f; - } - - public override void SetDefaults() - { - Projectile.aiStyle = 99; - Projectile.width = 16; - Projectile.height = 16; - Projectile.scale = 1.15f; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.penetrate = -1; - Projectile.MaxUpdates = 2; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 20; - } - - public override void AI() - { - CalamityGlobalProjectile.MagnetSphereHitscan(Projectile, 300f, 6f, 180f, 5, ModContent.ProjectileType(), 0.75); - if ((Projectile.position - Main.player[Projectile.owner].position).Length() > 3200f) //200 blocks - Projectile.Kill(); - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D tex = ModContent.Request(Texture).Value; - Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); - return false; - } - } -} diff --git a/Projectiles/Melee/Yoyos/CnidarianYoyo.png b/Projectiles/Melee/Yoyos/CnidarianYoyo.png deleted file mode 100644 index 1eb7ff5b6e..0000000000 Binary files a/Projectiles/Melee/Yoyos/CnidarianYoyo.png and /dev/null differ diff --git a/Projectiles/Ranged/PressurizedBubbleStream.cs b/Projectiles/Ranged/PressurizedBubbleStream.cs new file mode 100644 index 0000000000..efa7b8dea8 --- /dev/null +++ b/Projectiles/Ranged/PressurizedBubbleStream.cs @@ -0,0 +1,151 @@ +using System; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class PressurizedBubbleStream : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public static int FireTime = 60; + public static int ChargeupTime = 12; + public float Progress => 1 - Projectile.timeLeft / (float)FireTime; + public bool ChargingUp => Projectile.timeLeft > FireTime; + public float ChargeupProgress => (ChargeupTime - (Projectile.timeLeft - FireTime)) / (float)ChargeupTime; + + public Particle chargeBubble; + public Player Owner => Main.player[Projectile.owner]; + public ref float PulseTimer => ref Projectile.localAI[0]; + public ref float PrevPulseTimer => ref Projectile.localAI[1]; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pressurized Bubble Stream"); + } + + public override void SetDefaults() + { + Projectile.width = 12; + Projectile.height = 12; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = 1; + Projectile.extraUpdates = 4; + Projectile.timeLeft = FireTime + ChargeupTime; + } + + public override bool ShouldUpdatePosition() + { + return !ChargingUp; + } + + public override void AI() + { + ChargeupTime = 60; + + if (ChargingUp) + { + float bubbleRotation = Owner.itemRotation - (MathHelper.PiOver4 / 3f * Owner.direction); + if (Owner.direction < 0) + bubbleRotation += MathHelper.Pi; + + Vector2 bubblePosition = Owner.MountedCenter - Vector2.UnitY * 4f + bubbleRotation.ToRotationVector2() * 55f; + + Projectile.Center = bubblePosition; + Projectile.velocity = Vector2.UnitX.RotatedBy(bubbleRotation) * Projectile.velocity.Length(); + + if (chargeBubble == null) + { + chargeBubble = new GenericBubbleParticle(bubblePosition, Vector2.Zero, 0.4f, Owner.itemRotation, ChargeupTime / Projectile.extraUpdates); + GeneralParticleHandler.SpawnParticle(chargeBubble); + } + else + { + chargeBubble.Position = bubblePosition; + chargeBubble.Rotation = Owner.itemRotation; + chargeBubble.Scale = MathHelper.Lerp(0.4f, 1.4f, (float)Math.Sqrt(ChargeupProgress)); + } + return; + } + + if (Projectile.timeLeft == FireTime) + { + float bubbleRotation = Owner.itemRotation - (MathHelper.PiOver4 / 3f * Owner.direction); + if (Owner.direction < 0) + bubbleRotation += MathHelper.Pi; + + Vector2 bubblePosition = Owner.MountedCenter - Vector2.UnitY * 4f + bubbleRotation.ToRotationVector2() * 55f; + + SoundEngine.PlaySound(ReedBlowgun.BubbleBurstSound, bubblePosition); + } + + Projectile.velocity *= 0.985f; + PulseTimer--; + Lighting.AddLight(Projectile.Center, 0f, 0f, 0.5f); + + //Pulse + if (PulseTimer <= 0 && Progress < 0.7f) + { + if (PrevPulseTimer == 0) + PrevPulseTimer = 2; + else + PrevPulseTimer *= 2; + + PulseTimer = PrevPulseTimer * 2f; + + Color pulseColor = Main.rand.NextBool() ? (Main.rand.NextBool() ? Color.SkyBlue : Color.LightSkyBlue) : (Main.rand.NextBool() ? Color.LightBlue : Color.DeepSkyBlue); + Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, pulseColor, new Vector2(0.5f, 1f), Projectile.velocity.ToRotation(), 0.05f, 0.2f + 0.3f * (1 - Progress), 30); + GeneralParticleHandler.SpawnParticle(pulse); + + int numDust = 18; + + for (int i = 0; i < numDust; i++) + { + Vector2 ringSpeed = new Vector2((float)Math.Cos(i / (float)numDust * MathHelper.TwoPi), (float)Math.Sin(i / (float)numDust * MathHelper.TwoPi) * 0.5f).RotatedBy(Projectile.velocity.ToRotation() + MathHelper.PiOver2) * (3.5f * (1 - Progress) + 3f) ; + Dust ringDust = Dust.NewDustPerfect(Projectile.position, 211, ringSpeed, 100, default, 1.25f); + ringDust.noGravity = true; + + } + } + + //Bubbles + if (!Main.rand.NextBool(3)) + { + Gore bubble = Gore.NewGorePerfect(Projectile.GetSource_FromAI(), Projectile.position, Projectile.velocity * 0.2f + Main.rand.NextVector2Circular(1f, 1f) * Progress, 411); + bubble.timeLeft = 8 + Main.rand.Next(6); + bubble.scale = Main.rand.NextFloat(0.6f, 1f) * (1 + Progress * 0.4f); + bubble.type = Main.rand.NextBool(3) ? 412 : 411; + } + + //Water trail + for (int i = 0; i < 6; i++) + { + Dust waterDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 0.9f); + waterDust.noGravity = true; + waterDust.velocity *= 0.5f; + waterDust.velocity -= Projectile.velocity * 0.1f; + } + } + + public override void Kill(int timeLeft) + { + SoundEngine.PlaySound(SoundID.Item21, Projectile.position); + int bubbleCount = 25 + Main.rand.Next(15); + + for (int i = 0; i <= bubbleCount; i++) + { + Gore bubble = Gore.NewGorePerfect(Projectile.GetSource_Death(), Projectile.position, Projectile.velocity * 0.3f + Main.rand.NextVector2Circular(4f, 4f), 411); + bubble.timeLeft = 8 + Main.rand.Next(6); + bubble.scale = Main.rand.NextFloat(0.6f, 1f) * (1 + Progress * 0.4f); + bubble.type = Main.rand.NextBool(3) ? 412 : 411; + } + } + } +} diff --git a/Projectiles/Ranged/SandWater.cs b/Projectiles/Ranged/SandWater.cs deleted file mode 100644 index 303af7e9a1..0000000000 --- a/Projectiles/Ranged/SandWater.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Microsoft.Xna.Framework; -using System; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.Audio; -namespace CalamityMod.Projectiles.Ranged -{ - public class SandWater : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Water"); - } - - public override void SetDefaults() - { - Projectile.width = 12; - Projectile.height = 12; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 1; - Projectile.timeLeft = 60; - } - - public override void AI() - { - Lighting.AddLight(Projectile.Center, 0f, 0f, 0.5f); - for (int num457 = 0; num457 < 10; num457++) - { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 0.9f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; - } - } - - public override void Kill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item21, Projectile.position); - for (int dust = 0; dust <= 40; dust++) - { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 0.6f); - Dust dust2 = Main.dust[num467]; - dust2.noGravity = true; - dust2.position.X = Projectile.Center.X; - dust2.position.Y = Projectile.Center.Y; - dust2.position.X += (float)Main.rand.Next(-10, 11); - dust2.position.Y += (float)Main.rand.Next(-10, 11); - dust2.velocity.X = num463; - dust2.velocity.Y = num464; - } - } - } -} diff --git a/Projectiles/Rogue/FishboneBoomerangProjectile.cs b/Projectiles/Rogue/FishboneBoomerangProjectile.cs new file mode 100644 index 0000000000..c1339a3a1d --- /dev/null +++ b/Projectiles/Rogue/FishboneBoomerangProjectile.cs @@ -0,0 +1,228 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Projectiles.Rogue +{ + public class FishboneBoomerangProjectile : ModProjectile + { + internal PrimitiveTrail TrailRenderer; + public override string Texture => "CalamityMod/Items/Weapons/Rogue/FishboneBoomerang"; + + public static int ChargeupTime = 20; + public static int Lifetime = 240; + public float OverallProgress => 1 - Projectile.timeLeft / (float)Lifetime; + public float ThrowProgress => 1 - Projectile.timeLeft / (float)(Lifetime); + public float ChargeProgress => 1 - (Projectile.timeLeft - Lifetime) / (float)(ChargeupTime); + + public Player Owner => Main.player[Projectile.owner]; + public ref float Returning => ref Projectile.ai[0]; + public ref float Bouncing => ref Projectile.ai[1]; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Fishbone Boomerang"); + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 38; + Projectile.height = 32; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = Lifetime + ChargeupTime; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.ignoreWater = true; + } + + public override bool ShouldUpdatePosition() + { + return ChargeProgress >= 1; + } + + public override bool? CanDamage() + { + //We don't want the anticipation to deal damage. + if (ChargeProgress < 1) + return false; + + return base.CanDamage(); + } + + //Swing animation keys + public CurveSegment pullback = new CurveSegment(EasingType.PolyOut, 0f, 0f, MathHelper.PiOver4 * -1.2f, 2); + public CurveSegment throwout = new CurveSegment(EasingType.PolyOut, 0.7f, MathHelper.PiOver4 * -1.2f, MathHelper.PiOver4 * 1.2f + MathHelper.PiOver2, 3); + internal float ArmAnticipationMovement() => PiecewiseAnimation(ChargeProgress, new CurveSegment[] { pullback, throwout }); + + public override void AI() + { + //Anticipation animation. Make the player look like theyre holding the fish skeleton + if (ChargeProgress < 1) + { + float armRotation = ArmAnticipationMovement() * Owner.direction; + + Owner.heldProj = Projectile.whoAmI; + + Projectile.Center = Owner.MountedCenter + Vector2.UnitY.RotatedBy(armRotation) * -40f; + Projectile.rotation = -MathHelper.PiOver2 + armRotation; + + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, MathHelper.Pi + armRotation); + + return; + } + + //Play the throw sound when the throw ACTUALLY BEGINS. + //Additionally, make the projectile collide and set its speed and velocity + if (Projectile.timeLeft == Lifetime) + { + SoundEngine.PlaySound(SoundID.Item1, Projectile.Center); + Projectile.Center = Owner.MountedCenter + Projectile.velocity * 12f; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.Zero) * 17.5f; + Projectile.tileCollide = true; + } + + //Boomerang spinny sounds + if (Projectile.soundDelay <= 0) + { + SoundEngine.PlaySound(SoundID.Item7, Projectile.Center); + Projectile.soundDelay = 8; + } + + Projectile.rotation += (MathHelper.PiOver4 / 4f + MathHelper.PiOver4 / 2f * Math.Clamp(ThrowProgress * 2f, 0, 1)) * Math.Sign(Projectile.velocity.X); + + if (Projectile.velocity.Length() < 2f && Bouncing == 0f) + { + Returning = 1f; + } + + if (Returning == 0f && Bouncing == 0f && Projectile.velocity.Length() > 2f) + { + Projectile.velocity *= 0.97f; + } + + if (Returning == 1f && Projectile.velocity.Length() < 17f) + { + Projectile.velocity *= 1.1f; + } + + for (int i = 0; i < 2; i++) + { + Vector2 dustPos = Projectile.Center + (i * MathHelper.Pi + Projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * 14f; + Dust dust = Dust.NewDustPerfect(dustPos, 176, (i * MathHelper.Pi + Projectile.rotation * Math.Sign(Projectile.velocity.X)).ToRotationVector2() * 3f); + dust.noGravity = true; + } + + + if (Returning == 1f) + { + Projectile.tileCollide = false; + //Aim back at the player + Projectile.velocity = Projectile.velocity.Length() * (Owner.MountedCenter - Projectile.Center).SafeNormalize(Vector2.One); + + if ((Projectile.Center - Owner.MountedCenter).Length() < 24f) + { + Projectile.Kill(); + } + } + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + ImpactEffects(); + + float streakRotation; + for (int i = 0; i < 5; i++) + { + streakRotation = Main.rand.NextFloat(MathHelper.TwoPi); + + for (int j = 0; j < 4; j++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + streakRotation.ToRotationVector2() * (2f + 0.4f * j), 176, streakRotation.ToRotationVector2() * (0.6f * j + 3f), Scale: 1.4f); + dust.noGravity = true; + } + } + + if (((Projectile.Calamity().stealthStrike && Projectile.numHits > 2) || !Projectile.Calamity().stealthStrike) && Returning != 1f) + { + Projectile.velocity *= 0.3f; + Returning = 1f; + } + + else + { + //Retarget + NPC newTarget = null; + float closestNPCDistance = 10000f; + float targettingDistance = 400f; + + for (int i = 0; i < Main.maxNPCs; i++) + { + if (i == target.whoAmI) + continue; + + if (Main.npc[i].CanBeChasedBy(Projectile)) + { + float potentialNewDistance = (Projectile.Center - Main.npc[i].Center).Length(); + if (potentialNewDistance < targettingDistance && potentialNewDistance < closestNPCDistance) + { + closestNPCDistance = potentialNewDistance; + newTarget = Main.npc[i]; + } + } + } + + if (newTarget == null) + { + Projectile.velocity *= 0.3f; + Returning = 1f; + return; + } + + Bouncing = 1f; + Projectile.velocity = 15f * (newTarget.Center - Projectile.Center).SafeNormalize(Vector2.One); + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + ImpactEffects(); + Projectile.velocity = Projectile.oldVelocity.Length() * 0.3f * (Owner.MountedCenter - Projectile.Center).SafeNormalize(Vector2.One); + Returning = 1f; + return false; + } + + public void ImpactEffects() + { + //If the boomerang somehow hits 10 enemies, make it start doing drum sounds + SoundStyle bonkSound = Projectile.numHits < 10 ? SoundID.DD2_SkeletonHurt with { Volume = SoundID.DD2_SkeletonHurt.Volume * 0.8f, Pitch = SoundID.DD2_SkeletonHurt.Pitch + 0.1f * Projectile.numHits } : + Utils.SelectRandom(Main.rand, new SoundStyle[] + { + SoundID.DrumClosedHiHat, + SoundID.DrumCymbal1, + SoundID.DrumCymbal2, + SoundID.DrumKick, + SoundID.DrumTamaSnare, + SoundID.DrumTomHigh, + SoundID.DrumHiHat + }); + + SoundEngine.PlaySound(bonkSound, Projectile.Center); + int goreNumber = Main.rand.Next(4); + + for (int i = 0; i < goreNumber; i++) + { + int goreID = Main.rand.NextBool() ? 266 : Main.rand.NextBool() ? 971 : 972; + Gore bone = Gore.NewGorePerfect(Projectile.GetSource_FromAI(), Projectile.position, Projectile.velocity * 0.2f + Main.rand.NextVector2Circular(5f, 5f), goreID); + bone.scale = Main.rand.NextFloat(0.6f, 1f) * (goreID == 972 ? 0.7f : 1f); //Shrink the larger bones + bone.type = goreID; //Gotta do that or else itll spawn gores from the general pool :( + } + } + } +} diff --git a/Projectiles/Rogue/SeashellBoomerangProjectile.cs b/Projectiles/Rogue/SeashellBoomerangProjectile.cs deleted file mode 100644 index b8b9cd0ef9..0000000000 --- a/Projectiles/Rogue/SeashellBoomerangProjectile.cs +++ /dev/null @@ -1,34 +0,0 @@ -using CalamityMod.Projectiles.Typeless; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class SeashellBoomerangProjectile : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/SeashellBoomerang"; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Seashell Boomerang"); - } - - public override void SetDefaults() - { - Projectile.width = 14; - Projectile.height = 14; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.aiStyle = 3; - Projectile.timeLeft = 240; - AIType = ProjectileID.WoodenBoomerang; - Projectile.DamageType = RogueDamageClass.Instance; - } - - public override void AI() - { - if (Projectile.Calamity().stealthStrike) - CalamityGlobalProjectile.MagnetSphereHitscan(Projectile, 300f, 10f, 20f, 5, ModContent.ProjectileType()); - } - } -} diff --git a/Projectiles/Summon/Urchin.cs b/Projectiles/Summon/Urchin.cs deleted file mode 100644 index ab829cf32f..0000000000 --- a/Projectiles/Summon/Urchin.cs +++ /dev/null @@ -1,123 +0,0 @@ -using CalamityMod.CalPlayer; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.Audio; - -namespace CalamityMod.Projectiles.Summon -{ - public class Urchin : ModProjectile - { - public int dust = 3; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Urchin"); - ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; - } - - public override void SetDefaults() - { - Projectile.width = 30; - Projectile.height = 30; - Projectile.netImportant = true; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.minion = true; - Projectile.minionSlots = 0f; - Projectile.timeLeft = 18000; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.timeLeft *= 5; - } - - public override void AI() - { - Player player = Main.player[Projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - if (!modPlayer.urchin) - { - Projectile.active = false; - return; - } - bool correctMinion = Projectile.type == ModContent.ProjectileType(); - if (correctMinion) - { - if (player.dead) - { - modPlayer.vUrchin = false; - } - if (modPlayer.vUrchin) - { - Projectile.timeLeft = 2; - } - } - dust--; - if (dust >= 0) - { - int dustAmt = 50; - for (int d = 0; d < dustAmt; d++) - { - int index = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, 179, 0f, 0f, 0, default, 1f); - Main.dust[index].velocity *= 2f; - Main.dust[index].scale *= 1.15f; - } - } - float scalar = (float)Main.mouseTextColor / 200f - 0.35f; - scalar *= 0.2f; - Projectile.scale = scalar + 0.95f; - Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); - if (player.gravDir == -1f) - { - Projectile.position.Y += 120f; - Projectile.rotation = MathHelper.Pi; - } - else - { - Projectile.rotation = 0f; - } - Projectile.position.X = (int)Projectile.position.X; - Projectile.position.Y = (int)Projectile.position.Y; - if (Projectile.owner == Main.myPlayer) - { - if (Projectile.ai[0] != 0f) - { - Projectile.ai[0] -= 1f; - return; - } - bool foundTarget = false; - float maxDist = 300f; - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy(Projectile, false)) - { - if (Vector2.Distance(Projectile.Center, npc.Center) < maxDist && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) - { - foundTarget = true; - break; - } - } - } - if (foundTarget) - { - int projAmt = Main.rand.Next(3, 7); - for (int u = 0; u < projAmt; u++) - { - Vector2 source = new Vector2(Projectile.Center.X - 4f, Projectile.Center.Y); - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int spore = Projectile.NewProjectile(Projectile.GetSource_FromThis(), source, velocity, ModContent.ProjectileType(), Projectile.damage, 1f, Projectile.owner, 0f, 0f); - Main.projectile[spore].minion = true; - Main.projectile[spore].minionSlots = 0f; - Main.projectile[spore].originalDamage = Projectile.originalDamage; - } - SoundEngine.PlaySound(SoundID.Item42, Projectile.position); - Projectile.ai[0] = 60f; - } - } - } - - public override bool? CanDamage() => false; - } -} diff --git a/Projectiles/Summon/UrchinSpike.cs b/Projectiles/Summon/UrchinSpike.cs index d8cc51e33b..fa8b090ce4 100644 --- a/Projectiles/Summon/UrchinSpike.cs +++ b/Projectiles/Summon/UrchinSpike.cs @@ -23,6 +23,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.penetrate = 1; Projectile.timeLeft = 600; Projectile.aiStyle = 1; + Projectile.DamageType = DamageClass.Summon; } public override void AI() diff --git a/Projectiles/Summon/VictideSeaSnail.cs b/Projectiles/Summon/VictideSeaSnail.cs new file mode 100644 index 0000000000..98acaec37e --- /dev/null +++ b/Projectiles/Summon/VictideSeaSnail.cs @@ -0,0 +1,237 @@ +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Audio; +using System; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Projectiles.Summon +{ + public class VictideSeaSnail : ModProjectile + { + public ref float DustTimer => ref Projectile.localAI[0]; + public ref float FireCooldown => ref Projectile.localAI[1]; + public ref float PeekingOut => ref Projectile.ai[0]; + public ref float PlayerStandStillTimer => ref Projectile.ai[1]; + + public const int frameTime = 6; + public const int timeToStandStillBeforePeekOut = 200; + + public bool CanComePeekOut => !Main.player[Projectile.owner].mount.Active && PlayerStandStillTimer >= timeToStandStillBeforePeekOut || Projectile.frame > 0; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sea Snail"); + ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; + Main.projFrames[Projectile.type] = 7; + } + + public override void SetDefaults() + { + Projectile.width = 30; + Projectile.height = 30; + Projectile.netImportant = true; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.minion = true; + Projectile.minionSlots = 0f; + Projectile.timeLeft = 18000; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.timeLeft *= 5; + } + + public override void AI() + { + Player player = Main.player[Projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + + if (!modPlayer.victideSummoner) + { + for (int d = 0; d < 45; d++) + { + Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, 179, 0f, 0f, 0, default, 1f); + dust.velocity *= 2f; + dust.scale *= 1.15f; + } + Projectile.active = false; + return; + } + + if (player.dead) + modPlayer.victideSnail = false; + + if (modPlayer.victideSnail) + Projectile.timeLeft = 2; + + //Create a burst of dust as it gets created + DustTimer++; + if (DustTimer <= 3) + { + int dustAmount = Main.rand.Next(40, 50); + for (int d = 0; d < dustAmount; d++) + { + Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, 179, 0f, 0f, 0, default, 1f); + dust.velocity *= 2f; + dust.scale *= 1.15f; + } + } + + if (player.velocity.Length() == 0) + { + PlayerStandStillTimer++; + //pop out the shell + if (PlayerStandStillTimer == timeToStandStillBeforePeekOut ) + { + DustTimer = 0; + float direction = Main.rand.NextBool() ? 1f : -1f; + Projectile.velocity = new Vector2(Main.rand.NextFloat(4f, 10f) * direction, Main.rand.NextFloat(-6f, 0f)); + } + + Projectile.velocity *= 0.98f; + Projectile.velocity.X *= 0.95f; + Projectile.velocity.Y = Math.Min(Projectile.velocity.Y + 0.1f, 14f); + Projectile.tileCollide = true; + + if (CanComePeekOut) + Projectile.rotation = Projectile.rotation.AngleTowards(0, MathHelper.PiOver4 * 0.14f); + + if (PeekingOut > 0) + { + Projectile.frameCounter++; + if (Projectile.frameCounter > frameTime) + { + Projectile.frameCounter = 0; + Projectile.frame = Math.Min(6, Projectile.frame + 1); + } + } + } + + //Go back, in the shell + if (player.velocity.Length() > 0 && CanComePeekOut) + { + + Projectile.frameCounter++; + if (Projectile.frameCounter > frameTime) + { + Projectile.frameCounter = 0; + Projectile.frame--; + } + + if (Projectile.frame == 0) + { + PlayerStandStillTimer = 0f; + } + + } + + if (!CanComePeekOut) + { + PeekingOut = 0f; + + if (player.velocity.Length() > 0) + PlayerStandStillTimer = 0f; + + Projectile.velocity = Vector2.Zero; + Projectile.tileCollide = false; + Vector2 desiredPosition = player.Center + Vector2.UnitY * (player.gfxOffY - 60f) * player.gravDir; + //Round the result so it doesn't jitter. + desiredPosition = new Vector2((int)desiredPosition.X, (int)desiredPosition.Y); + + Projectile.rotation += MathHelper.PiOver4 * 0.2f; + + Projectile.Center = Projectile.Center.MoveTowards(desiredPosition, 7f + player.velocity.Length()); + } + + //Fire a projectile + if (Projectile.owner == Main.myPlayer) + { + if (FireCooldown > 0f) + { + FireCooldown --; + return; + } + + bool foundTarget = false; + float maxDist = 300f; + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(Projectile, false)) + { + if (Vector2.Distance(Projectile.Center, npc.Center) < maxDist && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) + { + foundTarget = true; + break; + } + } + } + + if (foundTarget) + { + int projAmt = Main.rand.Next(3, 7); + for (int u = 0; u < projAmt; u++) + { + Vector2 source = new Vector2(Projectile.Center.X - 4f, Projectile.Center.Y); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int spore = Projectile.NewProjectile(Projectile.GetSource_FromThis(), source, velocity, ModContent.ProjectileType(), Projectile.damage, 1f, Projectile.owner, 0f, 0f); + Main.projectile[spore].minion = true; + Main.projectile[spore].minionSlots = 0f; + Main.projectile[spore].originalDamage = Projectile.originalDamage; + } + + SoundEngine.PlaySound(SoundID.Item42, Projectile.position); + FireCooldown = 60f; + } + } + + if ((Projectile.Center - player.Center).Length() > 400) + { + DustTimer = 0; + Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f) * player.gravDir; + PlayerStandStillTimer = 0f; + Projectile.frame = 0; + } + } + + public override bool? CanDamage() => false; + + public override void Kill(int timeLeft) + { + for (int d = 0; d < 45; d++) + { + Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, 179, 0f, 0f, 0, default, 1f); + dust.velocity *= 2f; + dust.scale *= 1.15f; + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + //Touches the ground + if (oldVelocity.Y >= 0) + { + PeekingOut = 1f; + } + return false; + } + + public override bool PreDraw(ref Color lightColor) + { + Player owner = Main.player[Projectile.owner]; + + Texture2D tex = ModContent.Request(Texture).Value; + Rectangle frame = new Rectangle(0, 36 * Projectile.frame, 38, 34); + Vector2 origin = !CanComePeekOut ? new Vector2(15, 23) : frame.Size() / 2f; + + //Look at the player + SpriteEffects flipperoni = Math.Sign(Projectile.position.X - owner.position.X) > 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, frame, lightColor, Projectile.rotation, origin, Projectile.scale, flipperoni, 0); + + return false; + } + } +} diff --git a/Projectiles/Summon/VictideSeaSnail.png b/Projectiles/Summon/VictideSeaSnail.png new file mode 100644 index 0000000000..45a502f21d Binary files /dev/null and b/Projectiles/Summon/VictideSeaSnail.png differ diff --git a/Sounds/Custom/PistolShrimpBubbleBurst.ogg b/Sounds/Custom/PistolShrimpBubbleBurst.ogg new file mode 100644 index 0000000000..412ca23d4c Binary files /dev/null and b/Sounds/Custom/PistolShrimpBubbleBurst.ogg differ diff --git a/Sounds/Custom/WetSlap1.ogg b/Sounds/Custom/WetSlap1.ogg new file mode 100644 index 0000000000..576d115cdb Binary files /dev/null and b/Sounds/Custom/WetSlap1.ogg differ diff --git a/Sounds/Custom/WetSlap2.ogg b/Sounds/Custom/WetSlap2.ogg new file mode 100644 index 0000000000..303585e107 Binary files /dev/null and b/Sounds/Custom/WetSlap2.ogg differ diff --git a/Sounds/Custom/WetSlap3.ogg b/Sounds/Custom/WetSlap3.ogg new file mode 100644 index 0000000000..04cf9a1e98 Binary files /dev/null and b/Sounds/Custom/WetSlap3.ogg differ diff --git a/Sounds/Custom/WetSlap4.ogg b/Sounds/Custom/WetSlap4.ogg new file mode 100644 index 0000000000..3f0ae5ee64 Binary files /dev/null and b/Sounds/Custom/WetSlap4.ogg differ diff --git a/Utilities/GeneralExtensionUtils.cs b/Utilities/GeneralExtensionUtils.cs index a4b8db2b25..895b51c85f 100644 --- a/Utilities/GeneralExtensionUtils.cs +++ b/Utilities/GeneralExtensionUtils.cs @@ -1,4 +1,4 @@ -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using CalamityMod.Items; using CalamityMod.NPCs; using CalamityMod.Projectiles; @@ -10,6 +10,7 @@ namespace CalamityMod { public static CalamityPlayer Calamity(this Player player) => player.GetModPlayer(); public static CalamityGlobalNPC Calamity(this NPC npc) => npc.GetGlobalNPC(); + public static CalamityFallDamageNPC FallingNPC(this NPC npc) => npc.GetGlobalNPC(); public static CalamityGlobalItem Calamity(this Item item) => item.GetGlobalItem(); public static CalamityGlobalProjectile Calamity(this Projectile proj) => proj.GetGlobalProjectile(); public static Item ActiveItem(this Player player) => Main.mouseItem.IsAir ? player.HeldItem : Main.mouseItem; diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index 11c59f459b..a395779442 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -8,6 +8,8 @@ using System.Linq; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using static Terraria.ModLoader.ModContent; namespace CalamityMod @@ -482,6 +484,63 @@ namespace CalamityMod } #endregion + #region Arms Control + /// + /// Properly sets the player's held item rotation and position by doing the annoying math for you, since vanilla decided to be wholly inconsistent about it! + /// This all assumes the player is facing right. All the flip stuff is automatically handled in here + /// + /// The player for which we set the hold style + /// The desired rotation of the item + /// The desired position of the item + /// The size of the item sprite (used in calculations) + /// The offset from the center of the sprite of the rotation origin + /// Should the angle get flipped with the player, or should it be rotated by 180 degrees + /// Should the item get displaced with the player's height during the walk anim? + public static void CleanHoldStyle(Player player, float desiredRotation, Vector2 desiredPosition, Vector2 spriteSize, Vector2? rotationOriginFromCenter = null, bool flipAngle = false, bool stepDisplace = true) + { + //Since Vector2.Zero isn't a compile-time constant, we can't use it directly as the default parameter + if (rotationOriginFromCenter == null) + rotationOriginFromCenter = Vector2.Zero; + + Vector2 origin = rotationOriginFromCenter.Value; + //Flip the origin's X position, since the sprite will be flipped if the player faces left. + origin.X *= player.direction; + + player.itemRotation = desiredRotation; + + if (flipAngle) + player.itemRotation *= player.direction; + else if (player.direction < 0) + player.itemRotation += MathHelper.Pi; + + //This can anchors the item to rotate around the middle left of its sprite + //Vector2 consistentLeftAnchor = (player.itemRotation).ToRotationVector2() * -10f * player.direction; + + //This anchors the item to rotate around the center of its sprite. + Vector2 consistentCenterAnchor = player.itemRotation.ToRotationVector2() * (spriteSize.X / -2f - 10f) * player.direction; + + //This shifts the item so it rotates around the set origin instead + Vector2 consistentAnchor = consistentCenterAnchor - origin.RotatedBy(player.itemRotation); + + //The item is just offset by 20 and 18 pixels for no fucking reason. Doesn't even get flipped with the player sprite + Vector2 stupidOffset = new Vector2(-20, -18); + + Vector2 finalPosition = desiredPosition + stupidOffset + consistentAnchor; + + //Account for the players extra height when stepping + if (stepDisplace) + { + int frame = player.bodyFrame.Y / player.bodyFrame.Height; + if ((frame > 6 && frame < 10) || (frame > 13 && frame < 17)) + { + finalPosition -= Vector2.UnitY * 2f; + } + } + + player.itemLocation = finalPosition; + } + #endregion + /// /// 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.