diff --git a/Buffs/Summon/ExoskeletonCannons.cs b/Buffs/Summon/ExoskeletonCannons.cs new file mode 100644 index 0000000000..5c0da06187 --- /dev/null +++ b/Buffs/Summon/ExoskeletonCannons.cs @@ -0,0 +1,33 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Weapons.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class ExoskeletonCannons : ModBuff + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Ares' Cannons"); + Description.SetDefault("Pulse cannon not included"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (AresExoskeleton.ArmExists(player)) + modPlayer.AresCannons = true; + + if (modPlayer.AresCannons) + player.buffTime[buffIndex] = 18000; + else + { + player.DelBuff(buffIndex); + buffIndex--; + } + } + } +} diff --git a/Buffs/Summon/ExoskeletonCannons.png b/Buffs/Summon/ExoskeletonCannons.png new file mode 100644 index 0000000000..2659608f58 Binary files /dev/null and b/Buffs/Summon/ExoskeletonCannons.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index d85edc3c44..cc26d6e216 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -36,6 +36,7 @@ using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs; using CalamityMod.NPCs.Abyss; using CalamityMod.NPCs.ExoMechs.Apollo; @@ -606,6 +607,7 @@ namespace CalamityMod.CalPlayer public bool BloomStoneRegen = false; public bool ChaosStone = false; public bool CryoStone = false; + public bool voidField = false; #endregion #region Armor Set @@ -987,6 +989,7 @@ namespace CalamityMod.CalPlayer public bool eyeOfNight = false; public bool soulSeeker = false; public bool perditionBeacon = false; + public bool AresCannons = false; public List PendingProjectilesToRespawn = new List(); @@ -1707,6 +1710,7 @@ namespace CalamityMod.CalPlayer BloomStoneRegen = false; ChaosStone = false; CryoStone = false; + voidField = false; daedalusReflect = false; daedalusSplit = false; @@ -2057,6 +2061,7 @@ namespace CalamityMod.CalPlayer eyeOfNight = false; soulSeeker = false; perditionBeacon = false; + AresCannons = false; disableVoodooSpawns = false; disablePerfCystSpawns = false; @@ -5601,6 +5606,9 @@ namespace CalamityMod.CalPlayer Player.head = EquipLoader.GetEquipSlot(Mod, snowmanNoseless ? "PopoNoseless" : "Popo", EquipType.Head); Player.face = -1; } + else if (AresExoskeleton.ArmExists(Player)) + Player.body = EquipLoader.GetEquipSlot(Mod, "AresExoskeleton", EquipType.Body); + else if ((abyssalDivingSuitPower || abyssalDivingSuitForce) && !abyssalDivingSuitHide) { Player.legs = EquipLoader.GetEquipSlot(Mod, "AbyssalDivingSuit", EquipType.Legs); @@ -6419,7 +6427,7 @@ namespace CalamityMod.CalPlayer var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); if (Player.whoAmI == Main.myPlayer && !Player.HasCooldown(Cooldowns.InkBomb.ID)) { - Player.AddCooldown(Cooldowns.InkBomb.ID, CalamityUtils.SecondsToFrames(20)); + Player.AddCooldown(Cooldowns.InkBomb.ID, CalamityUtils.SecondsToFrames(25)); rogueStealth += 0.5f; for (int i = 0; i < 3; i++) { diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index a4ddb1a895..1bc56fc99d 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -1388,7 +1388,7 @@ namespace CalamityMod.CalPlayer } if (corrosiveSpine) { - target.AddBuff(BuffID.Venom, 240); + target.AddBuff(BuffID.Poisoned, 240); } if (aWeapon) { diff --git a/DataStructures/IAdditiveDrawer.cs b/DataStructures/IAdditiveDrawer.cs new file mode 100644 index 0000000000..1081cf511b --- /dev/null +++ b/DataStructures/IAdditiveDrawer.cs @@ -0,0 +1,17 @@ +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.DataStructures +{ + + // Restarting the sprite batch for each different projectile is analogously equivalent to creating an entire new factory just to build a single car. + // It is inefficient and leads to performance problems as many projectiles do it. + // To mitigate this problem, a special interface exists for the purpose of deferring drawing of certain entities to a time in which they all may be + // subject to the same additive draw state before all of the spritebatch's contents are flushed. + // Manual drawing hooks should not be utilized when using this interface, such as ModNPC.PreDraw. + + // The implementation of this is almost identical to that of SLR but they're both so simple that it really shouldn't matter. + public interface IAdditiveDrawer + { + void AdditiveDraw(SpriteBatch spriteBatch); + } +} diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index e346d98659..cce8a156eb 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -49,6 +49,7 @@ namespace CalamityMod.ILEditing IL.Terraria.Player.QuickHeal += ConditionallyReplaceManaSickness; IL.Terraria.Player.QuickMana += ConditionallyReplaceManaSickness; IL.Terraria.Player.ItemCheck_Inner += ConditionallyReplaceManaSickness; + IL.Terraria.Main.DoDraw += AdditiveDrawing; On.Terraria.Main.SortDrawCacheWorms += DrawFusableParticles; On.Terraria.Main.DrawInfernoRings += DrawForegroundParticles; On.Terraria.Main.SetDisplayMode += ResetRenderTargetSizes; @@ -161,6 +162,7 @@ namespace CalamityMod.ILEditing IL.Terraria.Player.QuickHeal -= ConditionallyReplaceManaSickness; IL.Terraria.Player.QuickMana -= ConditionallyReplaceManaSickness; IL.Terraria.Player.ItemCheck_Inner -= ConditionallyReplaceManaSickness; + IL.Terraria.Main.DoDraw -= AdditiveDrawing; On.Terraria.Main.SortDrawCacheWorms -= DrawFusableParticles; On.Terraria.Main.DrawInfernoRings -= DrawForegroundParticles; On.Terraria.Main.SetDisplayMode -= ResetRenderTargetSizes; diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index 2fb8141223..fd979556d8 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -38,6 +38,8 @@ using Terraria.ModLoader; using Terraria.UI.Gamepad; using Terraria.Utilities; using Terraria.Graphics.Light; +using Terraria.GameContent.Events; +using CalamityMod.DataStructures; using CalamityMod.Particles.Metaballs; namespace CalamityMod.ILEditing @@ -637,10 +639,45 @@ namespace CalamityMod.ILEditing } #endregion Fire Cursor Effect for the Calamity Accessory + #region Custom Draw Layers + private static void AdditiveDrawing(ILContext il) + { + ILCursor cursor = new(il); + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCall("DrawWhite"))) + return; + + cursor.EmitDelegate(() => + { + Main.spriteBatch.SetBlendState(BlendState.Additive); + + // Draw Projectiles. + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (!Main.projectile[i].active) + continue; + + if (Main.projectile[i].ModProjectile is IAdditiveDrawer d) + d.AdditiveDraw(Main.spriteBatch); + } + + // Draw NPCs. + for (int i = 0; i < Main.maxNPCs; i++) + { + if (!Main.npc[i].active) + continue; + + if (Main.npc[i].ModNPC is IAdditiveDrawer d) + d.AdditiveDraw(Main.spriteBatch); + } + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + }); + } + #endregion Custom Draw Layers + #region General Particle Rendering private static void DrawFusableParticles(On.Terraria.Main.orig_SortDrawCacheWorms orig, Main self) { - DeathAshParticle.DrawAll(); FusableParticleManager.RenderAllFusableParticles(); diff --git a/ILEditing/VanillaBugfixingILChanges.cs b/ILEditing/VanillaBugfixingILChanges.cs index 0cd1d964cd..e7ed8c81fd 100644 --- a/ILEditing/VanillaBugfixingILChanges.cs +++ b/ILEditing/VanillaBugfixingILChanges.cs @@ -174,7 +174,7 @@ namespace CalamityMod.ILEditing { cache.Add(new OrderedProjectileEntry() { - Proj = Main.projectile[i] ?? new Projectile(), + Proj = Main.projectile[i] ?? new(), OriginalIndex = i }); } @@ -182,12 +182,18 @@ namespace CalamityMod.ILEditing }); cursor.Emit(OpCodes.Stsfld, typeof(ILChanges).GetField("OrderedProjectiles", BindingFlags.Static | BindingFlags.Public)); + // Find the update loop update local index. + int updateLoopLocalIndex = -1; + cursor.GotoNext(i => i.MatchStloc(out updateLoopLocalIndex)); + // Go before the declaration of the projectile loop index and declare the ordered projectile. - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchStsfld
("ProjectileUpdateLoopIndex"))) + cursor.Goto(0); + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStsfld
("ProjectileUpdateLoopIndex"))) { LogFailure("Projectile Update Priority fix", "Could not locate the ProjectileUpdateLoopIndex field."); return; } + int updateIndexPosition = cursor.Index; // Replace the projectile reference on the Projectile.Update call. if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdelemRef())) @@ -199,14 +205,21 @@ namespace CalamityMod.ILEditing // Pop the Main.projectile[i] reference and replace it with OrderedProjectiles[i].Proj. cursor.Emit(OpCodes.Pop); cursor.Emit(OpCodes.Ldsfld, typeof(ILChanges).GetField("OrderedProjectiles", BindingFlags.Static | BindingFlags.Public)); - cursor.Emit(OpCodes.Ldloc, 29); + cursor.Emit(OpCodes.Ldloc, updateLoopLocalIndex); cursor.Emit(OpCodes.Callvirt, typeof(List).GetMethod("get_Item")); cursor.Emit(OpCodes.Ldfld, typeof(OrderedProjectileEntry).GetField("Proj")); - // Remove the direct i reference in the Update call and replace it with the original index in the cache, to prevent update ID + // Pop the direct i reference in the Update call and replace it with the original index in the cache, to prevent update ID // mismatches. - cursor.Remove(); - cursor.Emit(OpCodes.Ldloc, 29); + cursor.Goto(updateIndexPosition); + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchCall("Call"))) + { + LogFailure("Projectile Update Priority fix", "Could not locate the projectile Update call."); + return; + } + cursor.Emit(OpCodes.Pop); + cursor.Emit(OpCodes.Ldloc, updateLoopLocalIndex); cursor.EmitDelegate>(i => OrderedProjectiles[i].OriginalIndex); } #endregion Fix Projectile Update Priority Problems diff --git a/InverseKinematics/CyclicCoordinateDescentUpdateRule.cs b/InverseKinematics/CyclicCoordinateDescentUpdateRule.cs new file mode 100644 index 0000000000..4ba0b13b44 --- /dev/null +++ b/InverseKinematics/CyclicCoordinateDescentUpdateRule.cs @@ -0,0 +1,55 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; + +namespace CalamityMod.InverseKinematics +{ + public class CyclicCoordinateDescentUpdateRule : IInverseKinematicsUpdateRule + { + public float AngularOffsetAcceleration; + public float AngularDeviationLenience; + public CyclicCoordinateDescentUpdateRule(float angularOffsetAcceleration, float angularDeviationLenience) + { + AngularOffsetAcceleration = angularOffsetAcceleration; + AngularDeviationLenience = angularDeviationLenience; + } + + public void Update(LimbCollection limbs, Vector2 destination) + { + float distanceFromStart = Vector2.Distance(destination, limbs.ConnectPoint); + float distanceFromEnd = Vector2.Distance(destination, limbs.EndPoint); + float slowdownInterpolant = Utils.GetLerpValue(8f, 40f, distanceFromEnd, true); + slowdownInterpolant *= Utils.GetLerpValue(8f, 40f, distanceFromStart, true); + + Vector2 originalEndPoint = limbs.EndPoint; + for (int i = limbs.Limbs.Length - 1; i >= 0; i--) + { + // Move based on angular offsets. Movement is dampened the closer a limb is to being the first limb. + Vector2 currentToEndOffset = originalEndPoint - limbs.Limbs[i].ConnectPoint; + Vector2 currentToDestinationOffset = destination - limbs.Limbs[i].ConnectPoint; + Vector2 perpendicularDirection = currentToDestinationOffset.RotatedBy(MathHelper.PiOver2); + float angularOffset = currentToEndOffset.AngleBetween(currentToDestinationOffset) * (float)Math.Sqrt((i + 1f) / limbs.Limbs.Length); + + // Determine direction by choosing the angle which approaches the destination faster. + float leftAngularOffset = currentToEndOffset.AngleBetween(currentToDestinationOffset - perpendicularDirection); + float rightAngularOffset = currentToEndOffset.AngleBetween(currentToDestinationOffset + perpendicularDirection); + if (leftAngularOffset > rightAngularOffset) + angularOffset *= -1f; + + // Perform safety checks on the result of the underlying arccosines. + if (float.IsNaN(angularOffset)) + break; + + // Update rotation. + limbs.Limbs[i].Rotation += angularOffset * slowdownInterpolant * AngularOffsetAcceleration; + + // And limit it so that it doesn't look weird. + if (i > 0) + { + float behindRotation = (float)limbs.Limbs[i - 1].Rotation; + limbs.Limbs[i].Rotation = MathHelper.Clamp((float)limbs.Limbs[i].Rotation, behindRotation - AngularDeviationLenience, behindRotation + AngularDeviationLenience); + } + } + } + } +} diff --git a/InverseKinematics/IInverseKinematicsUpdateRule.cs b/InverseKinematics/IInverseKinematicsUpdateRule.cs new file mode 100644 index 0000000000..1e90ddefc1 --- /dev/null +++ b/InverseKinematics/IInverseKinematicsUpdateRule.cs @@ -0,0 +1,9 @@ +using Microsoft.Xna.Framework; + +namespace CalamityMod.InverseKinematics +{ + public interface IInverseKinematicsUpdateRule + { + void Update(LimbCollection limbs, Vector2 destination); + } +} diff --git a/InverseKinematics/Limb.cs b/InverseKinematics/Limb.cs new file mode 100644 index 0000000000..be5e1c43d2 --- /dev/null +++ b/InverseKinematics/Limb.cs @@ -0,0 +1,21 @@ +using Microsoft.Xna.Framework; +using Terraria; + +namespace CalamityMod.InverseKinematics +{ + public class Limb + { + // Doubles are used instead of floats as a means of providing sufficient precision to not cause erroneous results when + // doing approximations of derivative limits with small divisors. + public double Rotation; + public double Length; + public Vector2 ConnectPoint; + public Vector2 EndPoint => ConnectPoint + ((float)Rotation).ToRotationVector2() * (float)Length; + + public Limb(float rotation, float length) + { + Rotation = rotation; + Length = length; + } + } +} diff --git a/InverseKinematics/LimbCollection.cs b/InverseKinematics/LimbCollection.cs new file mode 100644 index 0000000000..071baa3122 --- /dev/null +++ b/InverseKinematics/LimbCollection.cs @@ -0,0 +1,55 @@ +using Microsoft.Xna.Framework; +using System.Linq; + +namespace CalamityMod.InverseKinematics +{ + public class LimbCollection + { + public Limb[] Limbs; + public IInverseKinematicsUpdateRule UpdateRule; + public Vector2 ConnectPoint => Limbs.First().ConnectPoint; + public Vector2 EndPoint => Limbs.Last().EndPoint; + public double TotalLength => Limbs.Sum(l => l.Length); + + public LimbCollection(IInverseKinematicsUpdateRule updateRule, int limbCount, float limbLength) + { + UpdateRule = updateRule; + + Limbs = new Limb[limbCount]; + for (int i = 0; i < limbCount; i++) + Limbs[i] = new Limb(0f, limbLength); + } + + public LimbCollection(IInverseKinematicsUpdateRule updateRule, params float[] limbLengths) + { + UpdateRule = updateRule; + + int limbCount = limbLengths.Length; + Limbs = new Limb[limbCount]; + for (int i = 0; i < limbCount; i++) + Limbs[i] = new Limb(0f, limbLengths[i]); + } + + public void UpdateConnectPoints(Vector2? connectPoint = null) + { + if (connectPoint.HasValue) + Limbs[0].ConnectPoint = connectPoint.Value; + + for (int i = 1; i < Limbs.Length; i++) + Limbs[i].ConnectPoint = Limbs[i - 1].EndPoint; + } + + public Limb this[int index] + { + get => Limbs[index]; + set => Limbs[index] = value; + } + + public void Update(Vector2 connectPoint, Vector2 destination) + { + UpdateRule.Update(this, destination); + Limbs[0].ConnectPoint = connectPoint; + UpdateConnectPoints(connectPoint); + } + } +} diff --git a/Items/Accessories/QuiverofNihility.cs b/Items/Accessories/QuiverofNihility.cs new file mode 100644 index 0000000000..d6616b1c14 --- /dev/null +++ b/Items/Accessories/QuiverofNihility.cs @@ -0,0 +1,65 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; + +namespace CalamityMod.Items.Accessories +{ + [AutoloadEquip(EquipType.Back)] + public class QuiverofNihility : ModItem + { + public override void SetStaticDefaults() + { + SacrificeTotal = 1; + DisplayName.SetDefault("Quiver of Nihility"); + Tooltip.SetDefault("'Filled with a substance darker than the night sky'\n"+"Summons a ring of four void fields to orbit you\n" + "Arrows that pass through these fields gain a 20% damage boost and double the speed"); + } + + public override void SetDefaults() + { + Item.width = 42; + Item.height = 36; + Item.value = CalamityGlobalItem.Rarity12BuyPrice; + Item.Calamity().customRarity = CalamityRarity.Turquoise; + Item.Calamity().donorItem = true; + Item.accessory = true; + } + + public override bool CanEquipAccessory(Player player, int slot, bool modded) + { + if (player.Calamity().voidField) + return false; + + return true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.voidField = true; + if (player.whoAmI == Main.myPlayer) + { + var source = player.GetSource_Accessory(Item); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 4) + { + for (int v = 0; v < 4; v++) + { + Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, v); + } + } + } + } + public override void AddRecipes() + { + CreateRecipe(). + AddRecipeGroup("QuiversGroup"). + AddIngredient(3). + AddIngredient(5). + AddTile(TileID.LunarCraftingStation). + Register(); + } + } +} diff --git a/Items/Accessories/QuiverofNihility.png b/Items/Accessories/QuiverofNihility.png new file mode 100644 index 0000000000..57136e2c62 Binary files /dev/null and b/Items/Accessories/QuiverofNihility.png differ diff --git a/Items/Accessories/QuiverofNihility_Back.png b/Items/Accessories/QuiverofNihility_Back.png new file mode 100644 index 0000000000..67710577a0 Binary files /dev/null and b/Items/Accessories/QuiverofNihility_Back.png differ diff --git a/Items/Armor/DesertProwler/DesertProwlerSet.cs b/Items/Armor/DesertProwler/DesertProwlerSet.cs index 9f32cf59ec..ba91c442b2 100644 --- a/Items/Armor/DesertProwler/DesertProwlerSet.cs +++ b/Items/Armor/DesertProwler/DesertProwlerSet.cs @@ -406,7 +406,7 @@ namespace CalamityMod.Items.Armor.DesertProwler public override void OnSpawn(Projectile projectile, IEntitySource source) { - if (projectile.damage > 0) + if (projectile.damage > 0 && !Main.gameMenu) { if (projectile.owner >= 0 && DesertProwlerHat.ShroudedInSmoke(Main.player[projectile.owner], out var cd) && projectile.DamageType.CountsAsClass(DamageClass.Ranged)) { diff --git a/Items/Armor/Wulfrum/WulfrumSet.cs b/Items/Armor/Wulfrum/WulfrumSet.cs index 902d7fe782..c46d387994 100644 --- a/Items/Armor/Wulfrum/WulfrumSet.cs +++ b/Items/Armor/Wulfrum/WulfrumSet.cs @@ -1,15 +1,15 @@ -using System; -using System.Collections.Generic; -using CalamityMod.Cooldowns; -using CalamityMod.Items.Accessories.Vanity; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Particles; -using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Terraria.DataStructures; +using CalamityMod.Items.Accessories.Vanity; +using CalamityMod.Cooldowns; +using Terraria.Audio; +using System; +using System.Collections.Generic; using static Microsoft.Xna.Framework.Input.Keys; using static Terraria.ModLoader.ModContent; diff --git a/Items/TreasureBags/DraedonBag.cs b/Items/TreasureBags/DraedonBag.cs index a643ce9d1a..a308531046 100644 --- a/Items/TreasureBags/DraedonBag.cs +++ b/Items/TreasureBags/DraedonBag.cs @@ -5,6 +5,7 @@ using CalamityMod.Items.Mounts; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.ExoMechs.Ares; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -60,6 +61,7 @@ namespace CalamityMod.Items.TreasureBags { DropHelper.DropItem(s, player, ModContent.ItemType()); DropHelper.DropItem(s, player, ModContent.ItemType()); + DropHelper.DropItem(s, player, ModContent.ItemType()); } if (DownedBossSystem.downedThanatos) { diff --git a/Items/Weapons/Melee/AquaticDischarge.cs b/Items/Weapons/Melee/AquaticDischarge.cs index d32af11b10..86a11e3c36 100644 --- a/Items/Weapons/Melee/AquaticDischarge.cs +++ b/Items/Weapons/Melee/AquaticDischarge.cs @@ -3,6 +3,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Projectiles.Melee.Shortswords; namespace CalamityMod.Items.Weapons.Melee { @@ -17,40 +18,28 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { - Item.useStyle = ItemUseStyleID.Thrust; + Item.useStyle = ItemUseStyleID.Rapier; Item.useTurn = false; - Item.useAnimation = 12; - Item.useTime = 12; + Item.useAnimation = 18; + Item.useTime = 18; Item.width = 32; Item.height = 32; Item.damage = 23; - Item.DamageType = DamageClass.Melee; Item.knockBack = 5.5f; Item.UseSound = SoundID.Item1; - Item.useTurn = true; Item.autoReuse = true; + Item.noUseGraphic = true; + Item.noMelee = true; + + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 2f; Item.value = Item.buyPrice(0, 2, 0, 0); Item.rare = ItemRarityID.Green; } public override void MeleeEffects(Player player, Rectangle hitbox) { - if (Main.rand.NextBool(5)) - Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 226); - } - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - var source = player.GetSource_ItemUse(Item); - int sparkDamage = player.CalcIntDamage(0.5f * Item.damage); - Projectile.NewProjectile(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), sparkDamage, knockback, Main.myPlayer); - } - - public override void OnHitPvp(Player player, Player target, int damage, bool crit) - { - var source = player.GetSource_ItemUse(Item); - int sparkDamage = player.CalcIntDamage(0.5f * Item.damage); - Projectile.NewProjectile(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), sparkDamage, Item.knockBack, Main.myPlayer); } } } diff --git a/Items/Weapons/Melee/CosmicShiv.cs b/Items/Weapons/Melee/CosmicShiv.cs index 0d44135e1e..93a740c099 100644 --- a/Items/Weapons/Melee/CosmicShiv.cs +++ b/Items/Weapons/Melee/CosmicShiv.cs @@ -1,13 +1,11 @@ -using Terraria.DataStructures; -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Melee.Shortswords; using CalamityMod.Tiles.Furniture.CraftingStations; + namespace CalamityMod.Items.Weapons.Melee { public class CosmicShiv : ModItem @@ -15,75 +13,30 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Cosmic Shiv"); - Tooltip.SetDefault("Definitely don't underestimate the power of shivs\n" + - "Fires a cosmic beam that homes in on enemies\n" + + Tooltip.SetDefault("Fires a cosmic beam that homes in on enemies\n" + "Upon hitting an enemy, a barrage of offscreen objects home in on the enemy as well as raining stars"); SacrificeTotal = 1; } public override void SetDefaults() { - Item.useStyle = ItemUseStyleID.Thrust; - Item.useTurn = false; + Item.useStyle = ItemUseStyleID.Rapier; Item.useAnimation = 18; Item.useTime = 18; Item.width = 44; Item.height = 44; - Item.damage = 218; - - Item.DamageType = DamageClass.Melee; Item.knockBack = 9f; Item.UseSound = SoundID.Item1; - Item.useTurn = true; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 14f; + Item.noUseGraphic = true; + Item.noMelee = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 2.4f; Item.value = CalamityGlobalItem.Rarity14BuyPrice; Item.Calamity().customRarity = CalamityRarity.DarkBlue; - Item.Calamity().donorItem = true; - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - Projectile.NewProjectile(source, position.X, position.Y, Item.shootSpeed * player.direction, 0f, type, damage, knockback, player.whoAmI); - return false; - } - - public override void MeleeEffects(Player player, Rectangle hitbox) - { - Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 173); - } - - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - for (int k = 0; k < 36; k++) - { - int dustID = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 16f), player.width, player.height - 16, 173, 0f, 0f, 0, default, 1f); - Main.dust[dustID].velocity *= 3f; - Main.dust[dustID].scale *= 2f; - } - - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - } - - public override void OnHitPvp(Player player, Player target, int damage, bool crit) - { - for (int k = 0; k < 36; k++) - { - int dustID = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 16f), player.width, player.height - 16, 173, 0f, 0f, 0, default, 1f); - Main.dust[dustID].velocity *= 3f; - Main.dust[dustID].scale *= 2f; - } - - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + Item.Calamity().donorItem = true; //Yatagarasu#0001 } public override void AddRecipes() diff --git a/Items/Weapons/Melee/ElementalShiv.cs b/Items/Weapons/Melee/ElementalShiv.cs index b683790c62..aeac43d76f 100644 --- a/Items/Weapons/Melee/ElementalShiv.cs +++ b/Items/Weapons/Melee/ElementalShiv.cs @@ -1,7 +1,7 @@ using Terraria.DataStructures; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Melee.Shortswords; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -15,61 +15,29 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Elemental Shiv"); - Tooltip.SetDefault("Don't underestimate the power of shivs\n" + - "Shoots a rainbow shiv that spawns additional shivs on hit"); + Tooltip.SetDefault("Shoots a rainbow shiv that spawns additional shivs on hit"); SacrificeTotal = 1; } public override void SetDefaults() { - Item.useStyle = ItemUseStyleID.Thrust; - Item.useTurn = false; + Item.useStyle = ItemUseStyleID.Rapier; Item.useAnimation = 10; Item.useTime = 10; Item.width = 44; Item.height = 44; - Item.damage = 168; - Item.DamageType = DamageClass.Melee; + Item.damage = 190; Item.knockBack = 8.5f; Item.UseSound = SoundID.Item1; - Item.useTurn = true; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 14f; + Item.noUseGraphic = true; + Item.noMelee = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 2.4f; Item.value = CalamityGlobalItem.Rarity11BuyPrice; Item.rare = ItemRarityID.Purple; } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - Projectile.NewProjectile(source, position.X, position.Y, Item.shootSpeed * player.direction, 0f, type, (int)(damage * 0.5), knockback, player.whoAmI, 0f, 0f); - return false; - } - - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.NextBool(5)) - { - int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 66, (float)(player.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); - Main.dust[num250].velocity *= 0.2f; - Main.dust[num250].noGravity = true; - } - } - - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(ModContent.BuffType(), 120); - } - - public override void OnHitPvp(Player player, Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(ModContent.BuffType(), 120); - } - public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Melee/GalileoGladius.cs b/Items/Weapons/Melee/GalileoGladius.cs index 425554b466..6ef7634ec2 100644 --- a/Items/Weapons/Melee/GalileoGladius.cs +++ b/Items/Weapons/Melee/GalileoGladius.cs @@ -1,9 +1,6 @@ -using Terraria.DataStructures; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; -using CalamityMod.Projectiles.Melee; -using Microsoft.Xna.Framework; +using CalamityMod.Projectiles.Melee.Shortswords; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -23,72 +20,28 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { - Item.useStyle = ItemUseStyleID.Thrust; - Item.useTurn = false; + Item.useStyle = ItemUseStyleID.Rapier; Item.useAnimation = 10; Item.useTime = 10; Item.width = 44; Item.height = 44; Item.damage = 110; - Item.DamageType = DamageClass.Melee; Item.knockBack = 10f; Item.UseSound = SoundID.Item1; - Item.useTurn = true; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 14f; + Item.noUseGraphic = true; + Item.noMelee = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 2.4f; Item.value = CalamityGlobalItem.Rarity13BuyPrice; Item.Calamity().customRarity = CalamityRarity.PureGreen; } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - int moonDamage = (int)(damage * 0.3333f); - Projectile.NewProjectile(source, position.X, position.Y, Item.shootSpeed * player.direction, 0f, type, moonDamage, knockback, player.whoAmI, 0f, 0f); - return false; - } - - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.NextBool(5)) - { - int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, (Main.rand.NextBool(2) ? 20 : 176), (float)(player.direction * 2), 0f, 150, default, 1.3f); - Main.dust[num250].velocity *= 0.2f; - Main.dust[num250].noGravity = true; - } - } - - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - SpawnMeteor(player); - } - - public override void OnHitPvp(Player player, Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - SpawnMeteor(player); - } - - private void SpawnMeteor(Player player) - { - if (player.whoAmI == Main.myPlayer) - { - var source = player.GetSource_ItemUse(Item); - if (player.Calamity().galileoCooldown <= 0) - { - int damage = player.GetWeaponDamage(player.ActiveItem()) * 2; - CalamityUtils.ProjectileRain(source, player.Center, 400f, 100f, 500f, 800f, 25f, ModContent.ProjectileType(), damage, 15f, player.whoAmI); - player.Calamity().galileoCooldown = 15; - } - } - } - public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.Gladius). //This may be too rare for this recipe, we'll see I guess. - Merkalto + AddIngredient(ItemID.Gladius). AddIngredient(8). AddIngredient(5). AddIngredient(15). diff --git a/Items/Weapons/Melee/Lucrecia.cs b/Items/Weapons/Melee/Lucrecia.cs index 0d1aca5476..c88ef7ad21 100644 --- a/Items/Weapons/Melee/Lucrecia.cs +++ b/Items/Weapons/Melee/Lucrecia.cs @@ -5,13 +5,12 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Projectiles.Melee.Shortswords; namespace CalamityMod.Items.Weapons.Melee { public class Lucrecia : ModItem { - public const int OnHitIFrames = 5; - public override void SetStaticDefaults() { DisplayName.SetDefault("Lucrecia"); @@ -23,58 +22,24 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { - Item.useStyle = ItemUseStyleID.Thrust; + Item.useStyle = ItemUseStyleID.Rapier; Item.useTurn = false; Item.useAnimation = 25; Item.useTime = 25; Item.width = 58; Item.height = 58; Item.damage = 90; - Item.DamageType = DamageClass.Melee; Item.knockBack = 8.25f; Item.UseSound = SoundID.Item1; - Item.useTurn = true; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 32f; + Item.noUseGraphic = true; + Item.noMelee = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 2f; Item.value = Item.buyPrice(0, 80, 0, 0); Item.rare = ItemRarityID.Yellow; } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - Projectile.NewProjectile(source, position.X, position.Y, Item.shootSpeed * player.direction, 0f, type, damage, knockback, player.whoAmI, 0f, 0f); - return false; - } - - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.NextBool(5)) - { - Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 234); - } - } - - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - player.GiveIFrames(OnHitIFrames, false); - } - - public override void OnHitPvp(Player player, Player target, int damage, bool crit) - { - bool isImmune = false; - for (int j = 0; j < player.hurtCooldowns.Length; j++) - { - if (player.hurtCooldowns[j] > 0) - isImmune = true; - } - if (!isImmune) - { - player.immune = true; - player.immuneTime = Item.useTime / 5; - } - } - public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Melee/SubmarineShocker.cs b/Items/Weapons/Melee/SubmarineShocker.cs index 9607a814bb..f3604ab152 100644 --- a/Items/Weapons/Melee/SubmarineShocker.cs +++ b/Items/Weapons/Melee/SubmarineShocker.cs @@ -3,6 +3,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Projectiles.Melee.Shortswords; namespace CalamityMod.Items.Weapons.Melee { @@ -17,46 +18,23 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { - Item.useStyle = ItemUseStyleID.Thrust; + Item.useStyle = ItemUseStyleID.Rapier; Item.useTurn = false; Item.useAnimation = 10; Item.useTime = 10; Item.width = 32; Item.height = 32; Item.damage = 60; - Item.DamageType = DamageClass.Melee; Item.knockBack = 7f; Item.UseSound = SoundID.Item1; - Item.useTurn = true; Item.autoReuse = true; + Item.noUseGraphic = true; + Item.noMelee = true; + + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 2f; Item.value = Item.buyPrice(0, 36, 0, 0); Item.rare = ItemRarityID.Pink; } - - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.NextBool(5)) - { - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 226); - } - } - - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - var source = player.GetSource_ItemUse(Item); - if (crit) - damage /= 2; - - Projectile.NewProjectile(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(damage * 0.7f), knockback, Main.myPlayer); - } - - public override void OnHitPvp(Player player, Player target, int damage, bool crit) - { - var source = player.GetSource_ItemUse(Item); - if (crit) - damage /= 2; - - Projectile.NewProjectile(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(damage * 0.7f), Item.knockBack, Main.myPlayer); - } } } diff --git a/Items/Weapons/Ranged/TheSevensStriker.cs b/Items/Weapons/Ranged/TheSevensStriker.cs new file mode 100644 index 0000000000..4bb81d5508 --- /dev/null +++ b/Items/Weapons/Ranged/TheSevensStriker.cs @@ -0,0 +1,170 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Audio; +using System.Linq; + +namespace CalamityMod.Items.Weapons.Ranged +{ + public class TheSevensStriker : ModItem + { + public static readonly SoundStyle RouletteSound = new("CalamityMod/Sounds/Item/SevensStrikerRoulette") { Volume = 0.6f, SoundLimitBehavior = SoundLimitBehavior.ReplaceOldest}; + public static readonly SoundStyle RouletteTickSound = new("CalamityMod/Sounds/Item/SevensStrikerRouletteTick") { Volume = 0.5f}; + + public static readonly SoundStyle BustSound = new("CalamityMod/Sounds/Item/SevensStrikerBust"); + public static readonly SoundStyle DoublesSound = new("CalamityMod/Sounds/Item/SevensStrikerDoubles"); + public static readonly SoundStyle TriplesSound = new("CalamityMod/Sounds/Item/SevensStrikerTriples"); + public static readonly SoundStyle JackpotSound = new("CalamityMod/Sounds/Item/SevensStrikerJackpot"); + public static readonly SoundStyle CoinSound = new("CalamityMod/Sounds/Item/SevensStrikerCoinShot") { MaxInstances = 0, PitchVariance = 0.5f }; + + public static int ShotCoin = 0; + + public override void SetStaticDefaults() + { + SacrificeTotal = 1; + DisplayName.SetDefault("The Sevens Striker"); + Tooltip.SetDefault("'A gun given to a great gunslinger\n"+ + "Forged by the arms of a man given no name'\n"+ + "Consumes coins to power a slot machine with several different outcomes\n"+ + "Quality of the outcome depends on the coin inputted\n"+ + "Right click to rapidly fire a spread of coins\n"+ + "The gun refuses to fire platinum coins for its right click"); + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; + } + + public override void SetDefaults() + { + Item.damage = 400; + Item.knockBack = 9f; + Item.useTime = 30; + Item.useAnimation = 30; + Item.DamageType = DamageClass.Ranged; + Item.noMelee = true; + Item.channel = true; + Item.useTurn = true; + Item.autoReuse = true; + Item.width = 170; + Item.height = 56; + Item.useStyle = ItemUseStyleID.Shoot; + Item.useAmmo = AmmoID.Coin; + Item.shootSpeed = 24f; + Item.reuseDelay = 0; + Item.shoot = ProjectileID.PurificationPowder; + Item.value = CalamityGlobalItem.Rarity12BuyPrice; + Item.Calamity().customRarity = CalamityRarity.Turquoise; + Item.Calamity().donorItem = true; + } + + public override bool AltFunctionUse(Player player) => true; + + public override bool? UseItem(Player player) + { + if (player.altFunctionUse == 2) + { + long coinCount = Utils.CoinsCount(out bool overflow, player.inventory); + + if (overflow || coinCount > 10000) + { + player.BuyItem(10000); + ShotCoin = ProjectileID.GoldCoin; + } + else if (coinCount > 100) + { + player.BuyItem(100); + ShotCoin = ProjectileID.SilverCoin; + } + else + { + player.BuyItem(1); + ShotCoin = ProjectileID.CopperCoin; + } + } + else + { + Item.shoot = ModContent.ProjectileType(); + } + return base.UseItem(player); + } + public override bool CanConsumeAmmo(Item ammo, Player player) => player.altFunctionUse == 2 ? false : true; + + public override Vector2? HoldoutOffset() => new Vector2(-30, -11); + + + public override void UseAnimation(Player player) + { + if (player.altFunctionUse == 2f) + { + Item.UseSound = CoinSound; + Item.noUseGraphic = false; + } + else + { + Item.UseSound = null; + Item.noUseGraphic = true; + } + } + + public override float UseTimeMultiplier(Player player) + { + if (player.altFunctionUse == 2f) + return 0.1f; + + return 1f; + } + + public override bool CanUseItem(Player player) + { + if (player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) + { + return true; + } + if (player.altFunctionUse == 2) + { + Utils.CoinsCount(out bool overflow, player.inventory); + return overflow; + } + return true; + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.altFunctionUse == 2f) + { + Vector2 shootVelocity = velocity; + Vector2 shootDirection = shootVelocity.SafeNormalize(Vector2.UnitX * player.direction); + Vector2 gunTip = position + shootDirection * Item.scale * 90f; + gunTip.Y -= 20f; + + for (int i = 0; i < 2; i++) + { + float SpeedX = velocity.X + Main.rand.Next(-15, 16) * 0.05f; + float SpeedY = velocity.Y + Main.rand.Next(-15, 16) * 0.05f; + + Projectile.NewProjectile(source, gunTip.X, gunTip.Y, SpeedX, SpeedY, ShotCoin, (int)(damage * 0.07f), knockback, player.whoAmI); + } + } + else + { + Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage * 7, knockback, player.whoAmI, type, 0f); + } + return false; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.CoinGun). + AddIngredient(1). + AddIngredient(ItemID.PlatinumCoin, 7). + AddIngredient(ItemID.GoldCoin, 77). + AddIngredient(2). + AddIngredient(ItemID.LunarBar, 12). + AddTile(TileID.LunarCraftingStation). + Register(); + } + } +} diff --git a/Items/Weapons/Ranged/TheSevensStriker.png b/Items/Weapons/Ranged/TheSevensStriker.png new file mode 100644 index 0000000000..fd7fa9bcd4 Binary files /dev/null and b/Items/Weapons/Ranged/TheSevensStriker.png differ diff --git a/Items/Weapons/Rogue/GraveGrimreaver.cs b/Items/Weapons/Rogue/GraveGrimreaver.cs index 2f586cea65..414281d006 100644 --- a/Items/Weapons/Rogue/GraveGrimreaver.cs +++ b/Items/Weapons/Rogue/GraveGrimreaver.cs @@ -23,11 +23,11 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SetDefaults() { Item.width = 80; - Item.damage = 62; + Item.damage = 25; Item.noMelee = true; Item.noUseGraphic = true; - Item.useAnimation = 40; - Item.useTime = 40; + Item.useAnimation = 50; + Item.useTime = 50; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 4f; Item.UseSound = SoundID.Item1; @@ -45,8 +45,8 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - damage = (int)(damage * 0.8); - int proj = Projectile.NewProjectile(source, position, velocity, type, damage / 2, knockback, player.whoAmI); + damage = (int)(damage * 1.1); + int proj = Projectile.NewProjectile(source, position, velocity * 1.1f, type, damage / 2, knockback, player.whoAmI); if (proj.WithinBounds(Main.maxProjectiles)) { Main.projectile[proj].Calamity().stealthStrike = true; diff --git a/Items/Weapons/Summon/AresExoskeleton.cs b/Items/Weapons/Summon/AresExoskeleton.cs new file mode 100644 index 0000000000..b9175bf0f9 --- /dev/null +++ b/Items/Weapons/Summon/AresExoskeleton.cs @@ -0,0 +1,146 @@ +using Terraria.DataStructures; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using CalamityMod.Projectiles.Summon.SmallAresArms; +using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Particles; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class AresExoskeleton : ModItem + { + public int FrameCounter = 0; + + public int Frame = 0; + + public const int BoxParticleLifetime = 95; + + public const int PlasmaCannonShootRate = 30; + + public const int TeslaCannonShootRate = 48; + + public const int LaserCannonNormalShootRate = 30; + + public const int GaussNukeShootRate = 210; + + public const float TargetingDistance = 1020f; + + public const float MinionSlotsPerCannon = 2f; + + // Multiple orbs can arc together when there are 2+ tesla cannons, resulting in a LOT of hits. + // The local i-frames are also quite high to combat this problem. + public const float TeslaOrbDamageFactor = 0.625f; + + public const float NukeDamageFactor = 1.5f; + + public const float MaxNukeExplosionRadius = 720f; + + public const float TeslaOrbDetatchDistance = 1500f; + + public static bool ArmExists(Player player) + { + if (player.ownedProjectileCounts[ModContent.ProjectileType()] >= 1) + return true; + if (player.ownedProjectileCounts[ModContent.ProjectileType()] >= 1) + return true; + if (player.ownedProjectileCounts[ModContent.ProjectileType()] >= 1) + return true; + if (player.ownedProjectileCounts[ModContent.ProjectileType()] >= 1) + return true; + + return false; + } + + public override void Load() + { + // Add the body equip texture. + if (Main.netMode != NetmodeID.Server) + EquipLoader.AddEquipTexture(Mod, $"{Texture}_{EquipType.Body}", EquipType.Body, this); + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Ares' Exoskeleton"); + Tooltip.SetDefault("Creates a panel with four slots and four choices above it: Plasma, Tesla, Laser, and Gauss\n" + + "Clicking one of the choices and then clicking one of the slots allows you to summon a cannon that stays close to you and attacks nearby enemies\n" + + "Clicking on a slot that's already occupied destroys its associated cannon and clears the slot\n" + + $"Cannons take {MinionSlotsPerCannon} minion slots each"); + SacrificeTotal = 1; + } + + public override void SetDefaults() + { + Item.mana = 80; + Item.damage = 672; + Item.useStyle = ItemUseStyleID.HoldUp; + Item.noUseGraphic = true; + Item.width = Item.height = 36; + Item.useTime = Item.useAnimation = 9; + Item.noMelee = true; + Item.knockBack = 1f; + + Item.value = CalamityGlobalItem.RarityVioletBuyPrice; + Item.Calamity().customRarity = CalamityRarity.Violet; + + Item.UseSound = SoundID.Item117; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 10f; + Item.DamageType = DamageClass.Summon; + } + + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Summon/AresExoskeleton").Value; + if (ArmExists(Main.LocalPlayer)) + { + texture = ModContent.Request("CalamityMod/Items/Weapons/Summon/AresExoskeletonRemote").Value; + position.X += scale * 6f; + } + + spriteBatch.Draw(texture, position, new(0, 0, texture.Width, texture.Height), Color.White, 0f, origin, scale, 0, 0); + return false; + } + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Summon/AresExoskeleton").Value; + spriteBatch.Draw(texture, Item.position - Main.screenPosition, Item.GetCurrentFrame(ref Frame, ref FrameCounter, 1, 1), lightColor, 0f, Vector2.Zero, 1f, 0, 0); + return false; + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + int panelID = ModContent.ProjectileType(); + + // If the player owns a panel, make it fade away. + if (player.ownedProjectileCounts[panelID] >= 1) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type != panelID || Main.projectile[i].owner != player.whoAmI || !Main.projectile[i].active) + continue; + + Main.projectile[i].ai[0] = 1f; + Main.projectile[i].netUpdate = true; + } + } + + // Otherwise, create one. While it doesn't do damage on its own, it does store it for reference by the cannons that might be spawned. + else + { + int panel = Projectile.NewProjectile(source, position, Vector2.Zero, panelID, damage, 0f, player.whoAmI); + if (Main.projectile.IndexInRange(panel)) + Main.projectile[panel].originalDamage = Item.damage; + + // Also throw a cool mechanical box particle out. + Vector2 boxVelocity = -Vector2.UnitY.RotatedByRandom(0.7f) * 6f + Vector2.UnitX * player.direction * 4f; + Particle box = new AresSummonCrateParticle(player, boxVelocity, BoxParticleLifetime); + GeneralParticleHandler.SpawnParticle(box); + } + + return false; + } + } +} diff --git a/Items/Weapons/Summon/AresExoskeleton.png b/Items/Weapons/Summon/AresExoskeleton.png new file mode 100644 index 0000000000..fa76b67f33 Binary files /dev/null and b/Items/Weapons/Summon/AresExoskeleton.png differ diff --git a/Items/Weapons/Summon/AresExoskeletonRemote.png b/Items/Weapons/Summon/AresExoskeletonRemote.png new file mode 100644 index 0000000000..afa7801772 Binary files /dev/null and b/Items/Weapons/Summon/AresExoskeletonRemote.png differ diff --git a/Items/Weapons/Summon/AresExoskeleton_Body.png b/Items/Weapons/Summon/AresExoskeleton_Body.png new file mode 100644 index 0000000000..5cd9d002d9 Binary files /dev/null and b/Items/Weapons/Summon/AresExoskeleton_Body.png differ diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 83215e88e7..6d55b386d3 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -1367,7 +1367,7 @@ namespace CalamityMod.NPCs break; case NPCID.TheDestroyer: - SetNewShopVariable(new int[] { NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle, ModContent.NPCType() }, NPC.downedMechBossAny); + SetNewShopVariable(new int[] { NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle }, NPC.downedMechBossAny); SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3); SetNewBossJustDowned(npc); @@ -1379,7 +1379,7 @@ namespace CalamityMod.NPCs case NPCID.Retinazer: if (lastTwinStanding) { - SetNewShopVariable(new int[] { NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle, ModContent.NPCType() }, NPC.downedMechBossAny); + SetNewShopVariable(new int[] { NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle }, NPC.downedMechBossAny); SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, !NPC.downedMechBoss1 || NPC.downedMechBoss2 || !NPC.downedMechBoss3); SetNewBossJustDowned(npc); @@ -1389,7 +1389,7 @@ namespace CalamityMod.NPCs break; case NPCID.SkeletronPrime: - SetNewShopVariable(new int[] { NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle, ModContent.NPCType() }, NPC.downedMechBossAny); + SetNewShopVariable(new int[] { NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle }, NPC.downedMechBossAny); SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, !NPC.downedMechBoss1 || !NPC.downedMechBoss2 || NPC.downedMechBoss3); SetNewBossJustDowned(npc); diff --git a/NPCs/ExoMechs/Ares/AresBody.cs b/NPCs/ExoMechs/Ares/AresBody.cs index ae868570c5..8825a3ddc7 100644 --- a/NPCs/ExoMechs/Ares/AresBody.cs +++ b/NPCs/ExoMechs/Ares/AresBody.cs @@ -30,6 +30,7 @@ using Terraria.ModLoader; using Terraria.Audio; using Terraria.GameContent.ItemDropRules; using CalamityMod.Sounds; +using CalamityMod.Items.Weapons.Summon; namespace CalamityMod.NPCs.ExoMechs.Ares { @@ -185,8 +186,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares //We'll probably want a custom background for Exos like ML has. //BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Exo, - // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("While it is the most flamboyant of Draedon’s machines, it appears to be lacking some finish, though this trait does not compromise its killing potential whatsoever.") + // Will move to localization whenever that is cleaned up. + new FlavorTextBestiaryInfoElement("While it is the most flamboyant of Draedon’s machines, it appears to be lacking some finish, though this trait does not compromise its killing potential whatsoever.") }); } @@ -1370,6 +1371,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Ares weapons normalOnly.Add(ItemDropRule.ByCondition(DropHelper.If(AresLoot), ModContent.ItemType())); normalOnly.Add(ItemDropRule.ByCondition(DropHelper.If(AresLoot), ModContent.ItemType())); + normalOnly.Add(ItemDropRule.ByCondition(DropHelper.If(AresLoot), ModContent.ItemType())); // Twins weapons normalOnly.Add(ItemDropRule.ByCondition(DropHelper.If(ApolloLoot), ModContent.ItemType())); diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 711e69ba3f..19dd12a82d 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -1514,8 +1514,6 @@ namespace CalamityMod.NPCs.Providence { CalamityGlobalNPC.SetNewBossJustDowned(NPC); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedProvidence); - if (Main.netMode != NetmodeID.MultiplayerClient && NPC.Top.Y >= (Main.maxTilesY - 240f) * 16f) SpawnLootBox(); diff --git a/Particles/AresSummonCrate.png b/Particles/AresSummonCrate.png new file mode 100644 index 0000000000..18e45a6672 Binary files /dev/null and b/Particles/AresSummonCrate.png differ diff --git a/Particles/AresSummonCrateParticle.cs b/Particles/AresSummonCrateParticle.cs new file mode 100644 index 0000000000..d79e48fd8f --- /dev/null +++ b/Particles/AresSummonCrateParticle.cs @@ -0,0 +1,52 @@ +using Microsoft.Xna.Framework; +using Terraria; +using System; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Particles +{ + public class AresSummonCrateParticle : Particle + { + public override bool SetLifetime => true; + public override string Texture => "CalamityMod/Particles/AresSummonCrate"; + public override bool UseCustomDraw => true; + + public AresSummonCrateParticle(Player owner, Vector2 velocity, int lifetime) + { + Position = owner.Center - Vector2.UnitY * 4f; + Scale = 1f; + Color = Color.White; + Velocity = velocity; + Rotation = 0f; + Lifetime = lifetime; + } + + public override void Update() + { + Rotation += Math.Sign(Velocity.X) * 0.05f; + Velocity.X *= 0.95f; + Velocity.Y += 0.24f; + if (Collision.SolidCollision(Position - Vector2.One * Scale * 19f, (int)(Scale * 38f), (int)(Scale * 38f), true)) + { + Velocity.X *= 0.8f; + Rotation = 0f; + Velocity.Y = 0f; + } + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D texture = GeneralParticleHandler.GetTexture(Type); + Color lightColor = Lighting.GetColor(Position.ToTileCoordinates()); + + int frameY = (int)Math.Round(MathHelper.Lerp(0f, 2f, (float)Math.Pow(LifetimeCompletion, 0.16f))); + Rectangle frame = texture.Frame(1, 3, 0, frameY); + float opacity = MathHelper.Clamp(1f - (float)Math.Pow(LifetimeCompletion, 7f), 0f, 1f); + spriteBatch.Draw(texture, Position - Main.screenPosition, frame, lightColor * opacity, Rotation, frame.Size() * 0.5f, Scale, 0, 0); + } + } +} + + + + diff --git a/Particles/Metaballs/VoidGeneratorParticleSet.cs b/Particles/Metaballs/VoidGeneratorParticleSet.cs new file mode 100644 index 0000000000..fef4abab19 --- /dev/null +++ b/Particles/Metaballs/VoidGeneratorParticleSet.cs @@ -0,0 +1,62 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ModLoader; + +namespace CalamityMod.Particles.Metaballs +{ + //This is basically just the Stream Gouge set but purple + public class VoidGeneratorParticleSet : BaseFusableParticleSet + { + public override float BorderSize => 3f; + public override bool BorderShouldBeSolid => false; + public override Color BorderColor => Color.Lerp(Color.Purple, Color.Black, 0.75f) * 0.85f; + + public override List BackgroundShaders => new List() + { + GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, + }; + public override List BackgroundTextures => new List() + { + ModContent.Request("CalamityMod/ExtraTextures/ParticleBackgrounds/StreamGougeLayer").Value, + }; + public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) + { + Particles.Add(new FusableParticle(center, sizeStrength)); + return Particles.Last(); + } + + public override void UpdateBehavior(FusableParticle particle) + { + particle.Size = MathHelper.Clamp(particle.Size - 1f, 0f, 200f) * 0.98f; + } + + public override void PrepareOptionalShaderData(Effect effect, int index) + { + switch (index) + { + // Background. + case 0: + Vector2 offset = Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.045f; + effect.Parameters["generalBackgroundOffset"].SetValue(offset); + effect.Parameters["upscaleFactor"].SetValue(Vector2.One * -0.3f); + break; + } + } + + public override void DrawParticles() + { + Texture2D fusableParticleBase = ModContent.Request("CalamityMod/ExtraTextures/FusableParticleBase").Value; + foreach (FusableParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = fusableParticleBase.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); + Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Particles/WulfrumHatParticle.cs b/Particles/WulfrumHatParticle.cs index 8c18326e97..e41b619957 100644 --- a/Particles/WulfrumHatParticle.cs +++ b/Particles/WulfrumHatParticle.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.ModLoader; using System; using Microsoft.Xna.Framework.Graphics; @@ -12,11 +11,11 @@ namespace CalamityMod.Particles public override string Texture => "CalamityMod/Particles/WulfrumHat"; public override bool UseCustomDraw => true; - public int Direction ; + public int Direction; public WulfrumHatParticle(Player owner, Vector2 velocity, int lifetime) { - Position = owner.Center - Vector2.UnitY * 20f;; + Position = owner.Center - Vector2.UnitY * 20f; Direction = owner.direction; Scale = 1f; Color = Color.White; diff --git a/Projectiles/BaseProjectiles/BaseShortswordProjectile.cs b/Projectiles/BaseProjectiles/BaseShortswordProjectile.cs new file mode 100644 index 0000000000..7f0e3de2ce --- /dev/null +++ b/Projectiles/BaseProjectiles/BaseShortswordProjectile.cs @@ -0,0 +1,129 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.Enums; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Projectiles.BaseProjectiles +{ + public abstract class BaseShortswordProjectile : ModProjectile + { + public enum ShortswordType + { + TypicalShortsword + } + + + #region Virtual Values + // Typical shortsword virtual values + public virtual float FadeInDuration => 7f; + public virtual float FadeOutDuration => 4f; + public virtual float TotalDuration => 16f; + public virtual Action EffectBeforePullback => null; + public virtual ShortswordType ShortswordAIType => ShortswordType.TypicalShortsword; + #endregion + + public float CollisionWidth => 4f * Projectile.scale; + public float FullUse => Timer / 14f; + public Player Owner => Main.player[Projectile.owner]; + + + public int Timer + { + get => (int)Projectile.ai[0]; + set => Projectile.ai[0] = value; + } + public virtual void Behavior() + { + Player player = Main.player[Projectile.owner]; + + if (ShortswordAIType == ShortswordType.TypicalShortsword && !player.frozen) + { + player.direction = Projectile.direction; + player.heldProj = Projectile.whoAmI; + player.itemTime = player.itemAnimation; + + + Timer += 1; + if (Timer >= TotalDuration) + { + Projectile.Kill(); + return; + } + else + { + player.heldProj = Projectile.whoAmI; + } + + // Fade in and out + Projectile.Opacity = Utils.GetLerpValue(0f, FadeInDuration, Timer, clamped: true) * Utils.GetLerpValue(TotalDuration, TotalDuration - FadeOutDuration, Timer, clamped: true); + + // If we haven't done the special effect yet (assuming there is one), do it. + // Note : Null Coalescing does not work in this case because we are invoking a method, not setting a value. + if (Projectile.localAI[0] == 0f && EffectBeforePullback != null && Main.myPlayer == Projectile.owner) + { + Projectile.localAI[0] = 1f; + EffectBeforePullback.Invoke(Projectile); + } + + // Keep locked onto the player, but extend further based on the given velocity (Requires ShouldUpdatePosition returning false to work) + Vector2 playerCenter = player.RotatedRelativePoint(player.MountedCenter, reverseRotation: false, addGfxOffY: false); + Projectile.Center = playerCenter + Projectile.velocity * (Timer - 1f); + + // Rotate the sprite + Projectile.Center = Owner.MountedCenter + OffsetFromPlayer; + Projectile.scale = 1f + (float)Math.Sin(FullUse * MathHelper.Pi) * 0.2f; + + // Set spriteDirection based on moving left or right. Left -1, right 1 + Projectile.spriteDirection = (Vector2.Dot(Projectile.velocity, Vector2.UnitX) >= 0f).ToDirectionInt(); + + // Point towards where it is moving, applied offset for top right of the sprite respecting spriteDirection + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2 - MathHelper.PiOver4 * Projectile.spriteDirection; + + // The code in this method is important to align the sprite with the hitbox how we want it to + SetVisualOffsets(); + } + } + + public virtual void SetVisualOffsets() // Intentionally blank + { + + } + + public virtual void ExtraBehavior() // Intentionally blank + { + + } + + public override void AI() + { + Behavior(); + ExtraBehavior(); + } + + public override bool ShouldUpdatePosition() => false; + public CurveSegment ThrustSegment = new CurveSegment(LinearEasing, 0f, 0f, 1f, 3); + public CurveSegment HoldSegment = new CurveSegment(SineBumpEasing, 0.2f, 1f, 0.2f); + public CurveSegment RetractSegment = new CurveSegment(PolyOutEasing, 0.76f, 1f, -0.8f, 3); + public CurveSegment BumpSegment = new CurveSegment(SineBumpEasing, 0.9f, 0.2f, 0.15f); + internal float DistanceFromPlayer => PiecewiseAnimation(FullUse, new CurveSegment[] { ThrustSegment, HoldSegment, RetractSegment, BumpSegment }); + public Vector2 OffsetFromPlayer => Projectile.velocity * DistanceFromPlayer * 12f; + + public override void CutTiles() + { + // "cutting tiles" refers to breaking pots, grass, queen bee larva, etc. + DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; + Vector2 start = Projectile.Center; + Vector2 end = start + Projectile.velocity.SafeNormalize(-Vector2.UnitY) * 10f; + Utils.PlotTileLine(start, end, CollisionWidth, DelegateMethods.CutTiles); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + float collisionPoint = 0f; + float bladeLenght = 12f * Projectile.scale; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Owner.MountedCenter + OffsetFromPlayer, Owner.MountedCenter + OffsetFromPlayer + (Projectile.velocity * bladeLenght), 24, ref collisionPoint); + } + } +} diff --git a/Projectiles/Boss/AresGaussNukeProjectileSpark.png b/Projectiles/Boss/AresGaussNukeProjectileSpark.png index 7424a71ed9..593e2629cb 100644 Binary files a/Projectiles/Boss/AresGaussNukeProjectileSpark.png and b/Projectiles/Boss/AresGaussNukeProjectileSpark.png differ diff --git a/Projectiles/Boss/AresPlasmaFireball.cs b/Projectiles/Boss/AresPlasmaFireball.cs index c721d21a57..5c12567ab1 100644 --- a/Projectiles/Boss/AresPlasmaFireball.cs +++ b/Projectiles/Boss/AresPlasmaFireball.cs @@ -94,7 +94,6 @@ namespace CalamityMod.Projectiles.Boss Dust dust = Main.dust[num54]; dust.velocity *= 3f; - dust = Main.dust[num54]; num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); Main.dust[num54].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; @@ -105,8 +104,6 @@ namespace CalamityMod.Projectiles.Boss Main.dust[num54].noGravity = true; Main.dust[num54].fadeIn = 1f; Main.dust[num54].color = Color.Green * 0.5f; - - dust = Main.dust[num54]; } for (int num55 = 0; num55 < 20; num55++) { @@ -122,7 +119,6 @@ namespace CalamityMod.Projectiles.Boss Dust dust = Main.dust[num56]; dust.velocity *= 0.5f; - dust = Main.dust[num56]; } } } diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 151e5aa410..d4948017fe 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -81,6 +81,9 @@ namespace CalamityMod.Projectiles /// public bool DealsDefenseDamage = false; + // Nihility Quiver + public bool nihilicArrow = false; + // Rogue Stuff public bool stealthStrike = false; public int stealthStrikeHitCount = 0; @@ -2475,6 +2478,11 @@ namespace CalamityMod.Projectiles return new Color(255, 255, 255, projectile.alpha); } + if (projectile.Calamity().nihilicArrow) + { + return Color.Black; + } + return null; } diff --git a/Projectiles/Melee/DNA.cs b/Projectiles/Melee/DNA.cs index 3e2e610fd3..c407b95e76 100644 --- a/Projectiles/Melee/DNA.cs +++ b/Projectiles/Melee/DNA.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Melee.Shortswords; using System; using Terraria; using Terraria.ID; @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Melee { if (Projectile.alpha < 170 && Projectile.alpha + 5 >= 170) { - for (int num55 = 0; num55 < 8; num55++) + for (int num55 = 0; num55 < 3; num55++) { int num56 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 234, Projectile.velocity.X * 0.005f, Projectile.velocity.Y * 0.005f, 200, default, 1f); Main.dust[num56].noGravity = true; @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.Kill(); } } - if (Main.rand.NextBool(4)) + if (Main.rand.NextBool(10)) { Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 234, Projectile.velocity.X * 0.005f, Projectile.velocity.Y * 0.005f); } @@ -81,7 +81,7 @@ namespace CalamityMod.Projectiles.Melee public override void Kill(int timeLeft) { - for (int k = 0; k < 3; k++) + for (int k = 0; k < 1; k++) { Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 234, Projectile.oldVelocity.X * 0.005f, Projectile.oldVelocity.Y * 0.005f); } @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - Main.player[Projectile.owner].GiveIFrames(Lucrecia.OnHitIFrames); + Main.player[Projectile.owner].GiveIFrames(LucreciaProj.OnHitIFrames); target.immune[Projectile.owner] = 5; } } diff --git a/Projectiles/Melee/DNA2.cs b/Projectiles/Melee/DNA2.cs index 1f62ff2b5e..3f298d0f9a 100644 --- a/Projectiles/Melee/DNA2.cs +++ b/Projectiles/Melee/DNA2.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Melee.Shortswords; using System; using Terraria; using Terraria.ID; @@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Melee { if (Projectile.alpha < 170 && Projectile.alpha + 5 >= 170) { - for (int num55 = 0; num55 < 8; num55++) + for (int num55 = 0; num55 < 3; num55++) { int num56 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 234, Projectile.velocity.X * 0.005f, Projectile.velocity.Y * 0.005f, 200, default, 1f); Main.dust[num56].noGravity = true; @@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.Kill(); } } - if (Main.rand.NextBool(4)) + if (Main.rand.NextBool(10)) { Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 234, Projectile.velocity.X * 0.005f, Projectile.velocity.Y * 0.005f); } @@ -71,7 +71,7 @@ namespace CalamityMod.Projectiles.Melee public override void Kill(int timeLeft) { - for (int k = 0; k < 3; k++) + for (int k = 0; k < 1; k++) { Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 234, Projectile.oldVelocity.X * 0.005f, Projectile.oldVelocity.Y * 0.005f); } @@ -79,7 +79,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - Main.player[Projectile.owner].GiveIFrames(Lucrecia.OnHitIFrames); + Main.player[Projectile.owner].GiveIFrames(LucreciaProj.OnHitIFrames); target.immune[Projectile.owner] = 5; } } diff --git a/Projectiles/Melee/ElementBallShiv.cs b/Projectiles/Melee/ElementBallShiv.cs index 468019df6a..8177a910e4 100644 --- a/Projectiles/Melee/ElementBallShiv.cs +++ b/Projectiles/Melee/ElementBallShiv.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.DamageType = DamageClass.Melee; Projectile.penetrate = 1; Projectile.tileCollide = false; - Projectile.timeLeft = 120; + Projectile.timeLeft = 60; Projectile.aiStyle = 27; } @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - if (Projectile.timeLeft > 115) + if (Projectile.timeLeft > 50) return false; return true; @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Melee public override void Kill(int timeLeft) { - for (int k = 0; k < 4; k++) + for (int k = 0; k < 2; k++) { int rainbow = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 66, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); Main.dust[rainbow].noGravity = true; diff --git a/Projectiles/Melee/SHIV.cs b/Projectiles/Melee/SHIV.cs index f6c3af8b40..73d4430291 100644 --- a/Projectiles/Melee/SHIV.cs +++ b/Projectiles/Melee/SHIV.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.DamageType = DamageClass.Melee; Projectile.penetrate = 1; Projectile.tileCollide = false; - Projectile.timeLeft = 600; + Projectile.timeLeft = 90; Projectile.aiStyle = 27; Projectile.extraUpdates = 1; } @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { if (Projectile.velocity.Length() < 25f && Projectile.timeLeft % 2 == 0) - Projectile.velocity *= 1.04f; + Projectile.velocity *= 2.08f; int rainbow = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); Main.dust[rainbow].noGravity = true; @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - if (Projectile.timeLeft > 595) + if (Projectile.timeLeft > 85) return false; CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); diff --git a/Projectiles/Melee/Shortswords/AquaticDischargeProj.cs b/Projectiles/Melee/Shortswords/AquaticDischargeProj.cs new file mode 100644 index 0000000000..0373fc8956 --- /dev/null +++ b/Projectiles/Melee/Shortswords/AquaticDischargeProj.cs @@ -0,0 +1,69 @@ +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using CalamityMod.Projectiles.BaseProjectiles; + +namespace CalamityMod.Projectiles.Melee.Shortswords +{ + public class AquaticDischargeProj: BaseShortswordProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Melee/AquaticDischarge"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Aquatic Discharge"); + } + + public override void SetDefaults() + { + Projectile.Size = new Vector2(16); + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.scale = 1f; + Projectile.DamageType = TrueMeleeDamageClass.Instance; + Projectile.ownerHitCheck = true; + Projectile.timeLeft = 360; + Projectile.hide = true; + Projectile.ownerHitCheck = true; + } + + public override void SetVisualOffsets() + { + const int HalfSpriteWidth = 32 / 2; + const int HalfSpriteHeight = 32 / 2; + + int HalfProjWidth = Projectile.width / 2; + int HalfProjHeight = Projectile.height / 2; + + DrawOriginOffsetX = 0; + DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth); + DrawOriginOffsetY = -(HalfSpriteHeight - HalfProjHeight); + } + + public override void ExtraBehavior() + { + if (Main.rand.NextBool(5)) + Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Electric); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + Player player = Main.player[Projectile.owner]; + var source = Projectile.GetSource_FromThis(); + int sparkDamage = player.CalcIntDamage(0.5f * Projectile.damage); + Projectile.NewProjectile(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), sparkDamage, knockback, Main.myPlayer); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + Player player = Main.player[Projectile.owner]; + var source = Projectile.GetSource_FromThis(); + int sparkDamage = player.CalcIntDamage(0.5f * Projectile.damage); + Projectile.NewProjectile(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), sparkDamage, Projectile.knockBack, Main.myPlayer); + } + } +} diff --git a/Projectiles/Melee/Shortswords/CosmicShivProj.cs b/Projectiles/Melee/Shortswords/CosmicShivProj.cs new file mode 100644 index 0000000000..4c8068b43b --- /dev/null +++ b/Projectiles/Melee/Shortswords/CosmicShivProj.cs @@ -0,0 +1,89 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using CalamityMod.Buffs.DamageOverTime; +using System; + +using CalamityMod.Projectiles.BaseProjectiles; + +namespace CalamityMod.Projectiles.Melee.Shortswords +{ + public class CosmicShivProj : BaseShortswordProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Melee/CosmicShiv"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cosmic Shiv"); + } + + public override void SetDefaults() + { + Projectile.Size = new Vector2(24); + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.scale = 1f; + Projectile.DamageType = TrueMeleeDamageClass.Instance; + Projectile.ownerHitCheck = true; + Projectile.timeLeft = 360; + Projectile.extraUpdates = 1; + Projectile.hide = true; + Projectile.ownerHitCheck = true; + } + + public override Action EffectBeforePullback => (proj) => + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 14f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), Projectile.knockBack, Projectile.owner, 0f, 0f); + }; + + public override void SetVisualOffsets() + { + const int HalfSpriteWidth = 48 / 2; + const int HalfSpriteHeight = 48 / 2; + + int HalfProjWidth = Projectile.width / 2; + int HalfProjHeight = Projectile.height / 2; + + DrawOriginOffsetX = 0; + DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth); + DrawOriginOffsetY = -(HalfSpriteHeight - HalfProjHeight); + } + + public override void ExtraBehavior() + { + Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 173); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + for (int k = 0; k < 36; k++) + { + int dustID = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height -16, 173, 0f, 0f, 0, default, 1f); + Main.dust[dustID].velocity *= 3f; + Main.dust[dustID].scale *= 2f; + } + + target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); + target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 120); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + for (int k = 0; k < 36; k++) + { + int dustID = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height - 16, 173, 0f, 0f, 0, default, 1f); + Main.dust[dustID].velocity *= 3f; + Main.dust[dustID].scale *= 2f; + } + + target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); + target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 120); + } +} +} diff --git a/Projectiles/Melee/Shortswords/ElementalShivProj.cs b/Projectiles/Melee/Shortswords/ElementalShivProj.cs new file mode 100644 index 0000000000..a073e02efb --- /dev/null +++ b/Projectiles/Melee/Shortswords/ElementalShivProj.cs @@ -0,0 +1,78 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using CalamityMod.Buffs.DamageOverTime; +using System; + +using CalamityMod.Projectiles.BaseProjectiles; + +namespace CalamityMod.Projectiles.Melee.Shortswords +{ + public class ElementalShivProj: BaseShortswordProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Melee/ElementalShiv"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Elemental Shiv"); // TODO: Make this one function like PiercingStarlight + } + + public override void SetDefaults() + { + Projectile.Size = new Vector2(22); + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.scale = 1f; + Projectile.DamageType = TrueMeleeDamageClass.Instance; + Projectile.ownerHitCheck = true; + Projectile.timeLeft = 360; + Projectile.extraUpdates = 1; + Projectile.hide = true; + Projectile.ownerHitCheck = true; + } + + public override Action EffectBeforePullback => (proj) => + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 14f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), Projectile.knockBack, Projectile.owner, 0f, 0f); + }; + + public override void SetVisualOffsets() + { + const int HalfSpriteWidth = 44 / 2; + const int HalfSpriteHeight = 44 / 2; + + int HalfProjWidth = Projectile.width / 2; + int HalfProjHeight = Projectile.height / 2; + + DrawOriginOffsetX = 0; + DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth); + DrawOriginOffsetY = -(HalfSpriteHeight - HalfProjHeight); + } + + public override void ExtraBehavior() + { + if (Main.rand.NextBool(5)) + { + int num250 = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 66, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); + Main.dust[num250].velocity *= 0.2f; + Main.dust[num250].noGravity = true; + } + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); + target.AddBuff(ModContent.BuffType(), 120); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); + target.AddBuff(ModContent.BuffType(), 120); + } + } +} diff --git a/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs b/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs new file mode 100644 index 0000000000..0e72981f08 --- /dev/null +++ b/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs @@ -0,0 +1,91 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using CalamityMod.Buffs.DamageOverTime; +using System; + +using CalamityMod.Projectiles.BaseProjectiles; + +namespace CalamityMod.Projectiles.Melee.Shortswords +{ + public class GalileoGladiusProj : BaseShortswordProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Melee/GalileoGladius"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Galileo Gladius"); // TODO: Make it function like Gladius, not like PiercingStarlight. + } + + public override void SetDefaults() + { + Projectile.Size = new Vector2(24); + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.scale = 1f; + Projectile.DamageType = TrueMeleeDamageClass.Instance; + Projectile.ownerHitCheck = true; + Projectile.timeLeft = 360; + Projectile.extraUpdates = 1; + Projectile.hide = true; + Projectile.ownerHitCheck = true; + } + + public override Action EffectBeforePullback => (proj) => + { + int moonDamage = (int)(Projectile.damage * 0.3333f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 10f, ModContent.ProjectileType(), moonDamage, Projectile.knockBack, Projectile.owner, 0f, 0f); + }; + + public override void SetVisualOffsets() + { + const int HalfSpriteWidth = 42 / 2; + const int HalfSpriteHeight = 46 / 2; + + int HalfProjWidth = Projectile.width / 2; + int HalfProjHeight = Projectile.height / 2; + + DrawOriginOffsetX = 0; + DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth); + DrawOriginOffsetY = -(HalfSpriteHeight - HalfProjHeight); + } + + public override void ExtraBehavior() + { + if (Main.rand.NextBool(5)) + { + int num250 = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, (Main.rand.NextBool(2) ? 20 : 176), (float)(Main.player[Projectile.owner].direction * 2), 0f, 150, default, 1.3f); + Main.dust[num250].velocity *= 0.2f; + Main.dust[num250].noGravity = true; + } + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + SpawnMeteor(Main.player[Projectile.owner]); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + SpawnMeteor(Main.player[Projectile.owner]); + } + + private void SpawnMeteor(Player player) + { + if (player.whoAmI == Main.myPlayer) + { + var source = player.GetSource_FromThis(); + if (player.Calamity().galileoCooldown <= 0) + { + int damage = player.GetWeaponDamage(player.ActiveItem()) * 2; + CalamityUtils.ProjectileRain(source, player.Center, 400f, 100f, 500f, 800f, 25f, ModContent.ProjectileType(), damage, 15f, player.whoAmI); + player.Calamity().galileoCooldown = 15; + } + } + } + } +} diff --git a/Projectiles/Melee/Shortswords/LucreciaProj.cs b/Projectiles/Melee/Shortswords/LucreciaProj.cs new file mode 100644 index 0000000000..cf3e2c54db --- /dev/null +++ b/Projectiles/Melee/Shortswords/LucreciaProj.cs @@ -0,0 +1,79 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using System; +using CalamityMod.Projectiles.BaseProjectiles; + +namespace CalamityMod.Projectiles.Melee.Shortswords +{ + public class LucreciaProj: BaseShortswordProjectile + { + public const int OnHitIFrames = 5; + public override string Texture => "CalamityMod/Items/Weapons/Melee/Lucrecia"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Lucrecia"); + } + + public override void SetDefaults() + { + Projectile.Size = new Vector2(31); + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.scale = 1f; + Projectile.DamageType = TrueMeleeDamageClass.Instance; + Projectile.ownerHitCheck = true; + Projectile.timeLeft = 360; + Projectile.hide = true; + Projectile.ownerHitCheck = true; + } + + public override Action EffectBeforePullback => (proj) => + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 12f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); + }; + + + public override void SetVisualOffsets() + { + const int HalfSpriteWidth = 62 / 2; + const int HalfSpriteHeight = 62 / 2; + + int HalfProjWidth = Projectile.width / 2; + int HalfProjHeight = Projectile.height / 2; + + DrawOriginOffsetX = 0; + DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth); + DrawOriginOffsetY = -(HalfSpriteHeight - HalfProjHeight); + } + + public override void ExtraBehavior() + { + if (Main.rand.NextBool(5)) + Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.BoneTorch); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + Main.player[Projectile.owner].GiveIFrames(OnHitIFrames, false); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + Player player = Main.player[Projectile.owner]; + bool isImmune = false; + for (int j = 0; j < player.hurtCooldowns.Length; j++) + { + if (player.hurtCooldowns[j] > 0) + isImmune = true; + } + if (!isImmune) + { + Owner.GiveIFrames(OnHitIFrames, true); + } + } + } +} diff --git a/Projectiles/Melee/Shortswords/SubmarineShockerProj.cs b/Projectiles/Melee/Shortswords/SubmarineShockerProj.cs new file mode 100644 index 0000000000..e0d11c35c1 --- /dev/null +++ b/Projectiles/Melee/Shortswords/SubmarineShockerProj.cs @@ -0,0 +1,68 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +using CalamityMod.Projectiles.BaseProjectiles; + +namespace CalamityMod.Projectiles.Melee.Shortswords +{ + public class SubmarineShockerProj: BaseShortswordProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Melee/SubmarineShocker"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Submarine Shocker"); + } + + public override void SetDefaults() + { + Projectile.Size = new Vector2(16); + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.scale = 1f; + Projectile.DamageType = TrueMeleeDamageClass.Instance; + Projectile.ownerHitCheck = true; + Projectile.timeLeft = 360; + Projectile.hide = true; + Projectile.ownerHitCheck = true; + } + + public override void SetVisualOffsets() + { + const int HalfSpriteWidth = 32 / 2; + const int HalfSpriteHeight = 32 / 2; + + int HalfProjWidth = Projectile.width / 2; + int HalfProjHeight = Projectile.height / 2; + + DrawOriginOffsetX = 0; + DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth); + DrawOriginOffsetY = -(HalfSpriteHeight - HalfProjHeight); + } + + public override void ExtraBehavior() + { + if (Main.rand.NextBool(5)) + Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Electric); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + var source = Projectile.GetSource_FromThis(); + if (crit) + damage /= 2; + Projectile.NewProjectile(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(damage * 0.7f), knockback, Main.myPlayer); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + var source = Projectile.GetSource_FromThis(); + if (crit) + damage /= 2; + Projectile.NewProjectile(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(damage * 0.7f), Projectile.knockBack, Main.myPlayer); + } + } +} diff --git a/Projectiles/Ranged/SevensStrikerBrick.cs b/Projectiles/Ranged/SevensStrikerBrick.cs new file mode 100644 index 0000000000..f8860da28c --- /dev/null +++ b/Projectiles/Ranged/SevensStrikerBrick.cs @@ -0,0 +1,53 @@ +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; +using Terraria.Audio; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SevensStrikerBrick : ModProjectile + { + public override string Texture => "CalamityMod/Items/Weapons/Rogue/ThrowingBrick"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Brick"); + } + + public override void SetDefaults() + { + Projectile.width = 19; + Projectile.height = 19; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + } + + public override void AI() + { + //Constant rotation and gravity + Projectile.rotation += 0.4f * Projectile.direction; + Projectile.velocity.Y = Projectile.velocity.Y + 0.3f; + if (Projectile.velocity.Y > 16f) + { + Projectile.velocity.Y = 16f; + } + //Dust trail + if (Main.rand.NextBool(13)) + { + Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 22, Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f, 150, default, 0.9f); + } + } + + public override void Kill(int timeLeft) + { + SoundEngine.PlaySound(SoundID.Item50, Projectile.position); + //Dust on impact + int dust_splash = 0; + while (dust_splash < 9) + { + Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 9, -Projectile.velocity.X * 0.15f, -Projectile.velocity.Y * 0.15f, 120, default, 1.5f); + dust_splash += 1; + } + } + } +} diff --git a/Projectiles/Ranged/SevensStrikerCherry.cs b/Projectiles/Ranged/SevensStrikerCherry.cs new file mode 100644 index 0000000000..f8d5d356e1 --- /dev/null +++ b/Projectiles/Ranged/SevensStrikerCherry.cs @@ -0,0 +1,43 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Audio; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SevensStrikerCherry : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cherry"); + } + + public override void SetDefaults() + { + Projectile.width = 20; + Projectile.height = 20; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.timeLeft = 480; + } + + public override void AI() + { + Projectile.rotation += 0.1f * Projectile.direction; + } + + public override void Kill(int timeLeft) + { + if (Projectile.owner == Main.myPlayer) + { + for (int f = 0; f < 3; f++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4), 0f, Projectile.owner); + } + } + SoundEngine.PlaySound(SoundID.NPCDeath1, Projectile.position); + } + } +} diff --git a/Projectiles/Ranged/SevensStrikerCherry.png b/Projectiles/Ranged/SevensStrikerCherry.png new file mode 100644 index 0000000000..2cb1f0cd0b Binary files /dev/null and b/Projectiles/Ranged/SevensStrikerCherry.png differ diff --git a/Projectiles/Ranged/SevensStrikerCherrySplit.cs b/Projectiles/Ranged/SevensStrikerCherrySplit.cs new file mode 100644 index 0000000000..13917b1848 --- /dev/null +++ b/Projectiles/Ranged/SevensStrikerCherrySplit.cs @@ -0,0 +1,32 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SevensStrikerCherrySplit : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cherry"); + } + + public override void SetDefaults() + { + Projectile.width = 20; + Projectile.height = 20; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.timeLeft = 240; + } + + public override void AI() + { + Projectile.rotation += 0.4f * Projectile.direction; + Projectile.velocity.Y += 0.2f; + if (Projectile.velocity.Y > 16f) + { + Projectile.velocity.Y = 16f; + } + } + } +} diff --git a/Projectiles/Ranged/SevensStrikerCherrySplit.png b/Projectiles/Ranged/SevensStrikerCherrySplit.png new file mode 100644 index 0000000000..5b812f08ad Binary files /dev/null and b/Projectiles/Ranged/SevensStrikerCherrySplit.png differ diff --git a/Projectiles/Ranged/SevensStrikerGrape.cs b/Projectiles/Ranged/SevensStrikerGrape.cs new file mode 100644 index 0000000000..4ef1f08dcd --- /dev/null +++ b/Projectiles/Ranged/SevensStrikerGrape.cs @@ -0,0 +1,28 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SevensStrikerGrape : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Grapes"); + } + + public override void SetDefaults() + { + Projectile.width = 20; + Projectile.height = 20; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = -1; + Projectile.timeLeft = 480; + } + + public override void AI() + { + Projectile.rotation += 0.1f * Projectile.direction; + } + } +} diff --git a/Projectiles/Ranged/SevensStrikerGrape.png b/Projectiles/Ranged/SevensStrikerGrape.png new file mode 100644 index 0000000000..5d0c1ce0fe Binary files /dev/null and b/Projectiles/Ranged/SevensStrikerGrape.png differ diff --git a/Projectiles/Ranged/SevensStrikerHoldout.cs b/Projectiles/Ranged/SevensStrikerHoldout.cs new file mode 100644 index 0000000000..3b7af8f8b6 --- /dev/null +++ b/Projectiles/Ranged/SevensStrikerHoldout.cs @@ -0,0 +1,342 @@ +using CalamityMod.Sounds; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using CalamityMod.Items.Weapons.Ranged; +using ReLogic.Utilities; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SevensStrikerHoldout : ModProjectile + { + public bool rolling = true; // If the slot machine is currently rolling + public bool shotonce = false; // So that the first shot doesn't consume two ammo + public int shottimer = 0; // Solely exists so that the Platinum shots aren't instantaneous + public int rolltimer = 60; // Cooldown for the slot machine so that it doesn't instantly role + public int soundtimer = 0; // Counts how long the slot machine has been spinning + the cooldown + + public SlotId RouletteSoundSlot; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sevens Striker"); + Main.projFrames[Projectile.type] = 19; + } + + public override void SetDefaults() + { + Projectile.width = 160; + Projectile.height = 62; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + Projectile.alpha = 255; + } + + public override void AI() + { + Player player = Main.player[Projectile.owner]; + Vector2 playerpos = player.RotatedRelativePoint(player.MountedCenter, true); + bool shouldBeHeld = player.channel && !player.noItems && !player.CCed; + + int shot = ProjectileID.CopperCoin; + float scaleFactor = 14f; + int weaponDamage = player.GetWeaponDamage(player.ActiveItem()); + float weaponKnockback = player.ActiveItem().knockBack; + + // Consumes a coin, stores it, then calculates what effect will be executed + if (Projectile.ai[1] == 0) + { + // These checks are here so that the weapon doesn't consume two coins when first used + if (shotonce) + { + if (player.PickAmmo(player.ActiveItem(), out shot, out scaleFactor, out weaponDamage, out weaponKnockback, out _)) + { + Projectile.ai[0] = shot; + Projectile.ai[1] = CalculateOutcome(); + } + else + { + Projectile.Kill(); + } + } + else + { + Projectile.ai[1] = CalculateOutcome(); + shotonce = true; + } + } + + rolltimer--; + soundtimer++; + + // While the slot machine is rolling, play the animation + if (rolling) + { + Projectile.frameCounter++; + } + // Make sure that it defaults at frame 1 + else + { + Projectile.frame = 0; + } + if (Projectile.frameCounter > 6) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + // Once the animation is finished, stop rolling, set the extra timer to 16 frames, and reset the sprite to frame 0 + if (Projectile.frame >= Main.projFrames[Projectile.type]) + { + rolling = false; + rolltimer = 16; + Projectile.frame = 0; + } + + if (Main.myPlayer == Projectile.owner) + { + if (shouldBeHeld && Projectile.ai[1] != 0) + { + // Holdout stuff + float holdscale = player.ActiveItem().shootSpeed * Projectile.scale; + Vector2 playerpos2 = playerpos; + Vector2 going = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - playerpos2; + if (player.gravDir == -1f) + { + going.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - playerpos2.Y; + } + Vector2 normalizedgoing = Vector2.Normalize(going); + if (float.IsNaN(normalizedgoing.X) || float.IsNaN(normalizedgoing.Y)) + { + normalizedgoing = -Vector2.UnitY; + } + normalizedgoing *= holdscale; + if (normalizedgoing.X != Projectile.velocity.X || normalizedgoing.Y != Projectile.velocity.Y) + { + Projectile.netUpdate = true; + } + Projectile.velocity = normalizedgoing * 0.55f; + + // If the animation isn't playing and the cooldown timer is at or below 0 + if (!rolling && rolltimer <= 0) + { + //Jackpot gets special benefits since it shoots multiple rounds + if (Projectile.ai[1] == 4) + { + shottimer++; + // Play a sound and display the jackpot text + if (shottimer == 1) + { + SoundEngine.PlaySound(TheSevensStriker.JackpotSound, Projectile.Center); + CombatText.NewText(player.getRect(), Color.Gold, "Jackpot!!!", true); + } + // Every 5 frames, shoot 7 coins. The first 5 frames are excluded for timing purposes + if (shottimer % 5 == 0 && shottimer > 5) + { + Shoot(7, ModContent.ProjectileType(), weaponDamage, weaponKnockback, (int)scaleFactor * 2f, 0.3f); + SoundEngine.PlaySound(TheSevensStriker.CoinSound, Projectile.Center); + } + // After 7 waves have been shot, reset the gun and roll again + if (shottimer > 40) + { + soundtimer = 0; + rolling = true; + Projectile.ai[1] = 0; + shottimer = 0; + } + } + else + { + shottimer++; + + if (shottimer == 1) + { + // The other three outcomes + switch (Projectile.ai[1]) + { + // A single brick that deals 10% damage + case 1: + Shoot(1, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1f), 0, 2f, 0); + CombatText.NewText(player.getRect(), Color.Gray, "Bust!", true); + SoundEngine.PlaySound(TheSevensStriker.BustSound, Projectile.Center); + break; + // 7 exploding oranges + case 2: + Shoot(7, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, 2f, 0.2f); + CombatText.NewText(player.getRect(), Color.Orange, "Doubles!", true); + SoundEngine.PlaySound(TheSevensStriker.DoublesSound, Projectile.Center); + break; + // 7 piercing grapes with 7 tighter splitting cherries + case 3: + Shoot(7, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, 1.5f, 0.1f); + Shoot(7, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, 2f, 0.2f); + CombatText.NewText(player.getRect(), Color.Red, "Triples!", true); + SoundEngine.PlaySound(TheSevensStriker.TriplesSound, Projectile.Center); + break; + } + } + + // Reset the gun and roll again + if (shottimer > 16) + { + soundtimer = 0; + rolling = true; + Projectile.ai[1] = 0; + shottimer = 0; + } + } + } + } + // If the player can't use the gun, KILL it + else + { + Projectile.Kill(); + } + } + + // Sounds + // Crank & new casino + if (Projectile.frameCounter == 0 && Projectile.frame == 2 * (Main.projFrames[Projectile.type] / 19)) + { + SoundEngine.PlaySound(SoundID.Item108 with { Volume = SoundID.Item108.Volume * 0.9f }, Projectile.Center); + RouletteSoundSlot = SoundEngine.PlaySound(TheSevensStriker.RouletteSound, Projectile.Center); + } + // Clicks for when each slot is finished + if (soundtimer == 96 || soundtimer == 108 || soundtimer == 120) + { + SoundEngine.PlaySound(TheSevensStriker.RouletteTickSound, Projectile.Center); + } + + // Holdout stuff + Projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - Projectile.Size / 2f; + Projectile.rotation = Projectile.velocity.ToRotation(); + Projectile.spriteDirection = Projectile.direction; + Projectile.timeLeft = 2; + player.ChangeDir(Projectile.direction); + player.heldProj = Projectile.whoAmI; + player.itemTime = 2; + player.itemAnimation = 2; + player.itemRotation = (float)Math.Atan2((double)(Projectile.velocity.Y * (float)Projectile.direction), (double)(Projectile.velocity.X * (float)Projectile.direction)); + } + + // Calculates which attack will occur based on coin. + public int CalculateOutcome() + { + switch (Projectile.ai[0]) + { + // Copper Coins have: + // 50% chance for a brick + // 30% chance for oranges + // 15% chance for grapes and cherries + // 5% chance for a jackpot + case ProjectileID.CopperCoin: + { + int roll = Main.rand.Next(100); + if (roll <= 50) + return 1; + else if (roll > 50 && roll <= 80) + return 2; + else if (roll > 80 && roll <= 95) + return 3; + else + return 4; + } + // Silver Coins have: + // 20% chance for a brick + // 50% chance for oranges + // 20% chance for grapes and cherries + // 10% chance for a jackpot + case ProjectileID.SilverCoin: + { + int roll = Main.rand.Next(100); + if (roll <= 20) + return 1; + else if (roll > 20 && roll <= 70) + return 2; + else if (roll > 70 && roll <= 90) + return 3; + else + return 4; + } + // Gold Coins have: + // 5% chance for a brick + // 30% chance for oranges + // 50% chance for grapes and cherries + // 15% chance for a jackpot + case ProjectileID.GoldCoin: + { + int roll = Main.rand.Next(100); + if (roll <= 5) + return 1; + else if (roll > 5 && roll <= 35) + return 2; + else if (roll > 35 && roll <= 85) + return 3; + else + return 4; + } + // Platinum Coins are a guaranteed jackpot + case ProjectileID.PlatinumCoin: + return 4; + } + // This should never be returned + return 1; + } + + // Where the shooting takes place (wow!) + public void Shoot(int projcount, int type, int damage, float kb, float scaleFactor, float spreadfactor) + { + Player player = Main.player[Projectile.owner]; + Vector2 armPosition = player.RotatedRelativePoint(player.MountedCenter, true); + armPosition += Projectile.velocity.SafeNormalize(player.direction * Vector2.UnitX) * 32f; + armPosition.Y -= 20f; + Vector2 shootDirection = (Main.MouseWorld - Projectile.Center).SafeNormalize(-Vector2.UnitY); + Vector2 gunTip = armPosition + shootDirection * player.ActiveItem().scale * 90f; + for (int i = 0; i < projcount; ++i) + { + Vector2 perturbedSpeed = Projectile.velocity.RotatedBy(MathHelper.Lerp(-spreadfactor, spreadfactor, i / 7f)) * scaleFactor; + int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), gunTip, perturbedSpeed, type, damage, kb, Main.player[Projectile.owner].whoAmI); + if (Main.projectile.IndexInRange(p)) + Main.projectile[p].originalDamage = damage; + + } + } + public override bool PreDraw(ref Color lightColor) + { + Player Owner = Main.player[Projectile.owner]; + Texture2D gun = ModContent.Request("CalamityMod/Projectiles/Ranged/SevensStrikerHoldout").Value; + + SpriteEffects flip = Projectile.direction < 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + float drawAngle = Projectile.rotation + (Owner.direction < 0 ? MathHelper.Pi : 0); + Vector2 drawOrigin = new Vector2(Owner.direction < 0 ? gun.Width - 33f : 33f, 33f); + Vector2 drawOffset = Owner.MountedCenter + Projectile.rotation.ToRotationVector2() - Main.screenPosition; + drawOffset.Y -= 10; + int indframeheight = gun.Height / Main.projFrames[Projectile.type]; + int currentframe = indframeheight * Projectile.frame; + Rectangle frame = new Rectangle(0, currentframe, gun.Width, indframeheight); + + Main.EntitySpriteDraw(gun, drawOffset, frame, lightColor, drawAngle, drawOrigin, Projectile.scale, flip, 0); + + return false; + } + + public override void Kill(int timeLeft) + { + if (SoundEngine.TryGetActiveSound(RouletteSoundSlot, out var dringdring)) + { + dringdring.Stop(); + } + + Main.player[Projectile.owner].SetDummyItemTime(12); + } + + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Ranged/SevensStrikerHoldout.png b/Projectiles/Ranged/SevensStrikerHoldout.png new file mode 100644 index 0000000000..91ac944a85 Binary files /dev/null and b/Projectiles/Ranged/SevensStrikerHoldout.png differ diff --git a/Projectiles/Ranged/SevensStrikerOrange.cs b/Projectiles/Ranged/SevensStrikerOrange.cs new file mode 100644 index 0000000000..7b8b36592f --- /dev/null +++ b/Projectiles/Ranged/SevensStrikerOrange.cs @@ -0,0 +1,54 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SevensStrikerOrange : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Orange"); + } + + public override void SetDefaults() + { + Projectile.width = 20; + Projectile.height = 20; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 1; + Projectile.timeLeft = 480; + } + + public override void AI() + { + Projectile.rotation += 0.1f * Projectile.direction; + Projectile.velocity.Y += 0.2f; + if (Projectile.velocity.Y > 16f) + { + Projectile.velocity.Y = 16f; + } + } + + public override void Kill(int timeLeft) + { + Projectile.position = Projectile.Center; + Projectile.width = Projectile.height = 48; + Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); + Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); + SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); + //Explosion copied over from another ranged orange explosive gravity-affected plant projectile + for (int i = 0; i < 15; i++) + { + Particle smoke = new SmallSmokeParticle(Projectile.Center + Main.rand.NextVector2Circular(15f, 15f), Vector2.Zero, Color.Orange, new Color(40, 40, 40), Main.rand.NextFloat(0.8f, 1.6f), 145 - Main.rand.Next(30)); + smoke.Velocity = (smoke.Position - Projectile.Center) * 0.2f + Projectile.velocity; + GeneralParticleHandler.SpawnParticle(smoke); + } + } + } +} diff --git a/Projectiles/Ranged/SevensStrikerOrange.png b/Projectiles/Ranged/SevensStrikerOrange.png new file mode 100644 index 0000000000..b8661a3975 Binary files /dev/null and b/Projectiles/Ranged/SevensStrikerOrange.png differ diff --git a/Projectiles/Ranged/SevensStrikerPlatinumCoin.cs b/Projectiles/Ranged/SevensStrikerPlatinumCoin.cs new file mode 100644 index 0000000000..80c9fa35d2 --- /dev/null +++ b/Projectiles/Ranged/SevensStrikerPlatinumCoin.cs @@ -0,0 +1,30 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SevensStrikerPlatinumCoin : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Platinum Coin"); + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.PlatinumCoin); + Projectile.DamageType = DamageClass.Ranged; + Projectile.aiStyle = 1; + AIType = ProjectileID.PlatinumCoin; + Projectile.width = 10; //Cool gaming facts: the vanilla coin projectiles are literally 4 pixels in hitbox size + Projectile.height = 10; + Projectile.CritChance = 50; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.Midas, 25200); // 7 Minutes of Midas + } + } +} diff --git a/Projectiles/Ranged/SevensStrikerPlatinumCoin.png b/Projectiles/Ranged/SevensStrikerPlatinumCoin.png new file mode 100644 index 0000000000..6711fdf068 Binary files /dev/null and b/Projectiles/Ranged/SevensStrikerPlatinumCoin.png differ diff --git a/Projectiles/Rogue/GrimreaverSkull.cs b/Projectiles/Rogue/GrimreaverSkull.cs index 770833f5da..fbba3e6ee4 100644 --- a/Projectiles/Rogue/GrimreaverSkull.cs +++ b/Projectiles/Rogue/GrimreaverSkull.cs @@ -24,6 +24,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.DamageType = RogueDamageClass.Instance; Projectile.penetrate = 1; Projectile.timeLeft = 300; + Projectile.tileCollide = false; } public override void AI() @@ -42,6 +43,11 @@ namespace CalamityMod.Projectiles.Rogue Projectile.ai[1]++; + if (Projectile.ai[0] != 0) + { + Projectile.tileCollide = true; + } + // Stealth skulls instantly home in if (Projectile.ai[0] == 0) { diff --git a/Projectiles/Summon/SmallAresArms/ArmPart1.png b/Projectiles/Summon/SmallAresArms/ArmPart1.png new file mode 100644 index 0000000000..ed29779ed5 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ArmPart1.png differ diff --git a/Projectiles/Summon/SmallAresArms/ArmPart1Glowmask.png b/Projectiles/Summon/SmallAresArms/ArmPart1Glowmask.png new file mode 100644 index 0000000000..2988cc3e3b Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ArmPart1Glowmask.png differ diff --git a/Projectiles/Summon/SmallAresArms/ArmPart2.png b/Projectiles/Summon/SmallAresArms/ArmPart2.png new file mode 100644 index 0000000000..45a03af177 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ArmPart2.png differ diff --git a/Projectiles/Summon/SmallAresArms/ArmPart2Glowmask.png b/Projectiles/Summon/SmallAresArms/ArmPart2Glowmask.png new file mode 100644 index 0000000000..791078abfa Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ArmPart2Glowmask.png differ diff --git a/Projectiles/Summon/SmallAresArms/ArmTopShoulder.png b/Projectiles/Summon/SmallAresArms/ArmTopShoulder.png new file mode 100644 index 0000000000..fe6a82ee40 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ArmTopShoulder.png differ diff --git a/Projectiles/Summon/SmallAresArms/ArmTopShoulderGlowmask.png b/Projectiles/Summon/SmallAresArms/ArmTopShoulderGlowmask.png new file mode 100644 index 0000000000..a8dab820ed Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ArmTopShoulderGlowmask.png differ diff --git a/Projectiles/Summon/SmallAresArms/Arrow.png b/Projectiles/Summon/SmallAresArms/Arrow.png new file mode 100644 index 0000000000..dd54c01276 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/Arrow.png differ diff --git a/Projectiles/Summon/SmallAresArms/CannonLaserbeam.cs b/Projectiles/Summon/SmallAresArms/CannonLaserbeam.cs new file mode 100644 index 0000000000..ad4642c3cf --- /dev/null +++ b/Projectiles/Summon/SmallAresArms/CannonLaserbeam.cs @@ -0,0 +1,158 @@ +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon.SmallAresArms +{ + public class CannonLaserbeam : BaseLaserbeamProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public Player Owner => Main.player[Projectile.owner]; + + public Projectile OwnerProjectile => CalamityUtils.FindProjectileByIdentity((int)Projectile.ai[1], Projectile.owner); + + public const int LifetimeConst = 75; + public override float MaxScale => 0.5f + (float)Math.Cos(Main.GlobalTimeWrappedHourly * 10f) * 0.07f; + public override float MaxLaserLength => 1560f; + public override float Lifetime => LifetimeConst; + public override Color LaserOverlayColor => Color.White; + public override Color LightCastColor => LaserOverlayColor; + public override Texture2D LaserBeginTexture => ModContent.Request("CalamityMod/Projectiles/Boss/ThanatosBeamStart", AssetRequestMode.ImmediateLoad).Value; + public override Texture2D LaserMiddleTexture => ModContent.Request("CalamityMod/ExtraTextures/Lasers/ThanatosBeamMiddle", AssetRequestMode.ImmediateLoad).Value; + public override Texture2D LaserEndTexture => ModContent.Request("CalamityMod/ExtraTextures/Lasers/ThanatosBeamEnd", AssetRequestMode.ImmediateLoad).Value; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Exothermal Deathray"); + Main.projFrames[Projectile.type] = 5; + ProjectileID.Sets.MinionShot[Projectile.type] = true; + } + public override void SetDefaults() + { + Projectile.width = Projectile.height = 38; + Projectile.friendly = true; + Projectile.minion = true; + Projectile.minionSlots = 0f; + Projectile.penetrate = -1; + Projectile.alpha = 255; + Projectile.localNPCHitCooldown = 14; + Projectile.scale = 0.5f; + Projectile.usesLocalNPCImmunity = true; + Projectile.hide = true; + Projectile.Calamity().UpdatePriority = 1f; + } + + public override float DetermineLaserLength() + { + float[] samples = new float[4]; + Collision.LaserScan(Projectile.Center, Projectile.velocity, Projectile.width * Projectile.scale, MaxLaserLength, samples); + return samples.Average(); + } + + public override void UpdateLaserMotion() + { + if (OwnerProjectile is null) + { + Projectile.Kill(); + return; + } + Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; + } + + public override void AttachToSomething() + { + Projectile ownerProjectile = OwnerProjectile; + if (ownerProjectile is null) + { + Projectile.Kill(); + return; + } + + float attachmentOffset = ownerProjectile.width * ownerProjectile.scale * 0.75f; + Projectile.Center = ownerProjectile.Center + ownerProjectile.rotation.ToRotationVector2() * attachmentOffset - Owner.velocity; + Projectile.rotation = ownerProjectile.rotation; + Projectile.velocity = Projectile.rotation.ToRotationVector2(); + + // Update frames. + Projectile.frame = Projectile.frameCounter++ / 5 % Main.projFrames[Type]; + } + + public override bool ShouldUpdatePosition() => false; + + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + overPlayers.Add(index); + } + + public override bool PreDraw(ref Color lightColor) + { + // This should never happen, but just in case. + if (Projectile.velocity == Vector2.Zero || Projectile.localAI[0] < 2f) + return false; + + Color beamColor = LaserOverlayColor; + Rectangle startFrameArea = LaserBeginTexture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Rectangle middleFrameArea = LaserMiddleTexture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Rectangle endFrameArea = LaserEndTexture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + + // Start texture drawing. + Main.EntitySpriteDraw(LaserBeginTexture, + Projectile.Center - Main.screenPosition, + startFrameArea, + beamColor, + Projectile.rotation, + startFrameArea.Size() * new Vector2(0.5f, 1f), + Projectile.scale, + SpriteEffects.None, + 0); + + // Prepare things for body drawing. + float laserBodyLength = LaserLength + middleFrameArea.Height; + Vector2 centerOnLaser = Projectile.Center; + + // Body drawing. + if (laserBodyLength > 0f) + { + float laserOffset = middleFrameArea.Height * Projectile.scale; + float incrementalBodyLength = 0f; + while (incrementalBodyLength + 1f < laserBodyLength) + { + Main.EntitySpriteDraw(LaserMiddleTexture, + centerOnLaser - Main.screenPosition, + middleFrameArea, + beamColor, + Projectile.rotation, + middleFrameArea.Size() * 0.5f, + Projectile.scale, + SpriteEffects.None, + 0); + incrementalBodyLength += laserOffset; + centerOnLaser += Projectile.velocity * laserOffset; + middleFrameArea.Y += LaserMiddleTexture.Height / Main.projFrames[Projectile.type]; + if (middleFrameArea.Y + middleFrameArea.Height > LaserMiddleTexture.Height) + middleFrameArea.Y = 0; + } + } + + Vector2 laserEndCenter = centerOnLaser - Main.screenPosition; + Main.EntitySpriteDraw(LaserEndTexture, + laserEndCenter, + endFrameArea, + beamColor, + Projectile.rotation, + endFrameArea.Size() * 0.5f, + Projectile.scale, + SpriteEffects.None, + 0); + return false; + } + } +} diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonCannon.cs b/Projectiles/Summon/SmallAresArms/ExoskeletonCannon.cs new file mode 100644 index 0000000000..bc47b7fa53 --- /dev/null +++ b/Projectiles/Summon/SmallAresArms/ExoskeletonCannon.cs @@ -0,0 +1,218 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.InverseKinematics; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using CalamityMod.Buffs.Summon; + +namespace CalamityMod.Projectiles.Summon.SmallAresArms +{ + public abstract class ExoskeletonCannon : ModProjectile + { + public int ShootTimer; + + public int HoverOffsetIndex => (int)Projectile.ai[0]; + + public bool TargetingSomething => Projectile.ai[1] == 1f; + + public Player Owner => Main.player[Projectile.owner]; + + public LimbCollection Limbs = new(new CyclicCoordinateDescentUpdateRule(0.27f, MathHelper.PiOver2), 70f, 82f); + + public static readonly Vector2[] HoverOffsetTable = new Vector2[] + { + new(300f, 96f), + new(-300f, 96f), + new(190f, -102f), + new(-190f, -102f) + }; + + public static readonly float[] RotationalClampTable = new float[] + { + 0.23f, + MathHelper.Pi - 0.23f, + 0.2f, + MathHelper.Pi - 0.2f + }; + + public virtual bool UsesSuperpredictiveness => false; + + public virtual Vector2 DrawOffset => new((OwnerRestingOffset.X > 0f).ToDirectionInt() * 6f, -6f); + + public virtual Vector2 ConnectOffset => HoverOffsetIndex >= 2 ? new((OwnerRestingOffset.X > 0f).ToDirectionInt() * 14f, -30f) : Vector2.Zero; + + public abstract int ShootRate { get; } + + public abstract float ShootSpeed { get; } + + public abstract Vector2 OwnerRestingOffset { get; } + + public abstract void ClampFirstLimbRotation(ref double limbRotation); + + public abstract void ShootAtTarget(NPC target, Vector2 shootDirection); + + public override void SetDefaults() + { + ShootTimer = Main.rand?.Next(ShootRate) ?? 0; + Projectile.width = 94; + Projectile.height = 40; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.netImportant = true; + Projectile.minion = true; + Projectile.minionSlots = AresExoskeleton.MinionSlotsPerCannon; + Projectile.penetrate = -1; + Projectile.timeLeft = 900000; + Projectile.scale = 1f; + Projectile.DamageType = DamageClass.Summon; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(Projectile.rotation); + writer.Write(Limbs?.Limbs?.Length ?? 0); + for (int i = 0; i < Limbs.Limbs.Length; i++) + writer.Write(Limbs[i].Rotation); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + Projectile.rotation = reader.ReadSingle(); + + int limbCount = Limbs.Limbs.Length; + for (int i = 0; i < limbCount; i++) + { + Limbs[i].Rotation = reader.ReadDouble(); + if (i >= 1) + Limbs[i].ConnectPoint = Limbs[i - 1].EndPoint; + } + } + + public override void AI() + { + // Update limbs. + if (Main.myPlayer == Projectile.owner) + { + Vector2 connectPosition = Main.LocalPlayer.Center + ConnectOffset; + connectPosition.X += (OwnerRestingOffset.X > 0f).ToDirectionInt() * Projectile.scale * 20f; + Vector2 endPosition = Owner.Center + OwnerRestingOffset; + endPosition += (Main.MouseWorld - endPosition) * 0.075f; + + ClampFirstLimbRotation(ref Limbs[0].Rotation); + Limbs.Update(connectPosition, endPosition); + + Projectile.netSpam = 0; + Projectile.netUpdate = true; + } + + Projectile.ai[1] = 0f; + Projectile.velocity = Vector2.Zero; + Projectile.Center = Limbs.EndPoint; + + // Handle buffs. + Owner.AddBuff(ModContent.BuffType(), 3600); + if (Owner.dead) + Owner.Calamity().AresCannons = false; + if (Owner.Calamity().AresCannons) + Projectile.timeLeft = 2; + + // Look at the mouse if not targetting anything. + // If something is being targeted, look at them instead. + float idealRotation = Main.myPlayer != Projectile.owner ? Projectile.rotation : Projectile.AngleTo(Main.MouseWorld); + NPC potentialTarget = Projectile.Center.ClosestNPCAt(AresExoskeleton.TargetingDistance); + if (potentialTarget != null) + { + Projectile.ai[1] = 1f; + + idealRotation = Projectile.AngleTo(potentialTarget.Center); + if (UsesSuperpredictiveness) + idealRotation = CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, potentialTarget, ShootSpeed).ToRotation(); + + ShootTimer++; + if (ShootTimer >= ShootRate) + { + ShootAtTarget(potentialTarget, idealRotation.ToRotationVector2()); + ShootTimer = 0; + } + } + + Projectile.rotation = Projectile.rotation.AngleLerp(idealRotation, 0.15f); + Projectile.spriteDirection = (Math.Cos(Projectile.rotation) > 0f).ToDirectionInt(); + } + + public void DefaultDrawCannon(Texture2D glowmask) + { + Texture2D texture = ModContent.Request(Texture).Value; + Rectangle frame = texture.Frame(2, Main.projFrames[Type], TargetingSomething.ToInt(), Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + float rotation = Projectile.rotation; + if (Projectile.spriteDirection == -1) + rotation += MathHelper.Pi; + + DrawLimbs(); + + Color lightColor = Lighting.GetColor(Projectile.Center.ToTileCoordinates()); + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), rotation, origin, Projectile.scale, direction, 0); + Main.EntitySpriteDraw(glowmask, drawPosition, frame, Projectile.GetAlpha(Color.White), rotation, origin, Projectile.scale, direction, 0); + } + + public void DrawLimbs() + { + // Draw the arms. Third and onward arms use the otherwise unused old Ares arm segment texture. + int frame = (int)(Main.GlobalTimeWrappedHourly * 8.1f) % 9; + for (int i = 0; i < Limbs.Limbs.Length; i++) + { + float scale = Projectile.scale; + float rotation = (float)Limbs[i].Rotation; + Vector2 segmentOriginFactor = new(0f, 0.5f); + SpriteEffects segmentDirection = SpriteEffects.FlipHorizontally; + Texture2D segmentTexture = ModContent.Request("CalamityMod/NPCs/ExoMechs/Ares/AresArmSegment").Value; + Texture2D glowmaskTexture = null; + + Rectangle segmentFrame = segmentTexture.Frame(1, 24, 0, (int)(Main.GlobalTimeWrappedHourly * 13f + i) % 24); + if (i == 0) + { + segmentTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ArmPart1").Value; + glowmaskTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ArmPart1Glowmask").Value; + } + if (i == 1) + { + segmentTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ArmPart2").Value; + glowmaskTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ArmPart2Glowmask").Value; + } + if (i <= 1) + { + segmentFrame = segmentTexture.Frame(1, 9, 0, frame); + segmentDirection = OwnerRestingOffset.X < 0f ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + if (OwnerRestingOffset.X < 0f) + { + segmentOriginFactor.X = 1f; + rotation += MathHelper.Pi; + } + } + else + scale *= 0.67f; + + Color segmentColor = Lighting.GetColor(Limbs[i].ConnectPoint.ToTileCoordinates()); + Vector2 segmentDrawPosition = Limbs[i].ConnectPoint - Main.screenPosition; + Main.spriteBatch.DrawLineBetter(Limbs[i].ConnectPoint, Limbs[i].EndPoint, Color.Cyan, 3f); + Main.EntitySpriteDraw(segmentTexture, segmentDrawPosition, segmentFrame, Projectile.GetAlpha(segmentColor), rotation, segmentFrame.Size() * segmentOriginFactor, scale, segmentDirection, 0); + if (glowmaskTexture != null) + Main.EntitySpriteDraw(glowmaskTexture, segmentDrawPosition, segmentFrame, Projectile.GetAlpha(Color.White), rotation, segmentFrame.Size() * segmentOriginFactor, scale, segmentDirection, 0); + } + + // Draw the shoulders on top of everything else. + Vector2 shoulderPosition = Limbs.ConnectPoint + DrawOffset * Projectile.scale; + Color shoulderColor = Lighting.GetColor(Limbs.ConnectPoint.ToTileCoordinates()); + Texture2D shoulderTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ArmTopShoulder").Value; + SpriteEffects shoulderDirection = OwnerRestingOffset.X < 0f ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Rectangle shoulderFrame = shoulderTexture.Frame(1, 9, 0, frame); + Main.EntitySpriteDraw(shoulderTexture, shoulderPosition - Main.screenPosition, shoulderFrame, Projectile.GetAlpha(shoulderColor), 0f, shoulderFrame.Size() * 0.5f, Projectile.scale, shoulderDirection, 0); + } + } +} diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCannon.cs b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCannon.cs new file mode 100644 index 0000000000..466e99c646 --- /dev/null +++ b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCannon.cs @@ -0,0 +1,142 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.Audio; +using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Sounds; +using CalamityMod.Items.Weapons.Summon; +using System; + +namespace CalamityMod.Projectiles.Summon.SmallAresArms +{ + public class ExoskeletonGaussNukeCannon : ExoskeletonCannon + { + public int NukeRebuildTime => ShootRate - 45; + + public ref float RebuildTimer => ref Projectile.localAI[0]; + + public override int ShootRate => AresExoskeleton.GaussNukeShootRate; + + public override float ShootSpeed => 16f; + + public override Vector2 OwnerRestingOffset => HoverOffsetTable[HoverOffsetIndex]; + + public override void ClampFirstLimbRotation(ref double limbRotation) => limbRotation = RotationalClampTable[HoverOffsetIndex]; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gauss Nuke"); + Main.projFrames[Type] = 12; + } + + public override void ShootAtTarget(NPC target, Vector2 shootDirection) + { + // Play the large gun fire sound. + SoundEngine.PlaySound(CommonCalamitySounds.LargeWeaponFireSound with { Volume = 0.4f }, Projectile.Center); + + // Start the rebuild timer. + RebuildTimer = 1f; + + // Shoot the fireball. This only happens for the owner client. + if (Main.myPlayer != Projectile.owner) + return; + + int nukeID = ModContent.ProjectileType(); + Vector2 laserVelocity = shootDirection * ShootSpeed; + int laser = Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center, laserVelocity, nukeID, (int)(Projectile.damage * AresExoskeleton.NukeDamageFactor), 0f, Projectile.owner); + if (Main.projectile.IndexInRange(laser)) + Main.projectile[laser].originalDamage = (int)(Projectile.originalDamage * AresExoskeleton.NukeDamageFactor); + } + + public override void PostAI() + { + Projectile.frameCounter++; + Projectile.frame = Projectile.frameCounter / 5 % 6; + if (RebuildTimer >= 1f) + { + RebuildTimer++; + Projectile.frame += 6; + } + + if (RebuildTimer >= NukeRebuildTime) + { + RebuildTimer = 0f; + Projectile.frameCounter = 0; + Projectile.frame = 0; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Texture2D glowmask = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCannonGlowmask").Value; + + // The two stabilizers have two different shades of lighting, thus necessitating two different textures. + Texture2D stabilizer = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeStabilizer").Value; + Texture2D stabilizer2 = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeStabilizerBottom").Value; + Texture2D crystal = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCrystal").Value; + Texture2D core = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCore").Value; + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + + float stabilizerRotationInterpolant = (float)Math.Pow(Utils.GetLerpValue(NukeRebuildTime * 0.75f, NukeRebuildTime * 0.92f, RebuildTimer, true), 1.7); + Vector2 origin = frame.Size() * 0.5f; + Vector2 crystalOrigin = crystal.Size() * new Vector2(Projectile.spriteDirection == 1 ? 1f : 0f, 0.5f); + Vector2 stabilizerOrigin = stabilizer.Size() * new Vector2(0.5f, 1f); + Vector2 coreOrigin = core.Size() * new Vector2(Projectile.spriteDirection == 1 ? 0f : 1f, 0.5f); + Vector2 perpendicularStabilizerOffset = (Projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * Projectile.scale * MathHelper.Lerp(18f, 10f, stabilizerRotationInterpolant); + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + float rotation = Projectile.rotation; + if (Projectile.spriteDirection == -1) + rotation += MathHelper.Pi; + + DrawLimbs(); + + // Draw the nuke pieces when rebuilding. This is done before the cannon itself is drawn, to make it look like they're attached to it. + if (RebuildTimer >= 1f) + { + float componentDirection = rotation + MathHelper.Pi; + float stabilizerDirection = componentDirection; + if (Projectile.spriteDirection == -1) + stabilizerDirection += MathHelper.Pi; + + Vector2 aimDirection = Projectile.rotation.ToRotationVector2(); + + // Draw the crystal. + float crystalOffsetInterpolant = Utils.GetLerpValue(0f, NukeRebuildTime * 0.5f, RebuildTimer, true); + Vector2 crystalOffset = aimDirection * crystalOffsetInterpolant * Projectile.scale * (crystal.Width - 15f); + Main.EntitySpriteDraw(crystal, drawPosition + crystalOffset, null, Projectile.GetAlpha(lightColor), rotation, crystalOrigin, Projectile.scale, direction, 0); + + // Draw the stabilizers. + float stabilizerOffsetInterpolant = Utils.GetLerpValue(NukeRebuildTime * 0.5f, NukeRebuildTime * 0.75f, RebuildTimer, true); + float stabilizerOffsetMagnitude = MathHelper.Lerp(-stabilizer.Width * 0.32f, stabilizer.Width * 0.4f - 8f, stabilizerOffsetInterpolant) * Projectile.scale; + float leftStabilizerRotation = stabilizerDirection + MathHelper.Pi - (1f - stabilizerRotationInterpolant) * 0.42f; + float rightStabilizerRotation = stabilizerDirection + (1f - stabilizerRotationInterpolant) * 0.42f; + Vector2 stabilizerOffset = aimDirection * stabilizerOffsetMagnitude; + Color stabilizerColor = Projectile.GetAlpha(lightColor) * (float)Math.Pow(stabilizerOffsetInterpolant, 1.61); + Vector2 leftStabilizerPosition = drawPosition + stabilizerOffset - perpendicularStabilizerOffset * 0.9f; + Vector2 rightStabilizerPosition = drawPosition + stabilizerOffset + perpendicularStabilizerOffset; + SpriteEffects leftStabilizerDirection = direction; + SpriteEffects rightStabilizerDirection = direction ^ SpriteEffects.FlipHorizontally; + if (Projectile.spriteDirection == -1) + { + leftStabilizerDirection ^= SpriteEffects.FlipHorizontally; + rightStabilizerDirection ^= SpriteEffects.FlipHorizontally; + Utils.Swap(ref stabilizer, ref stabilizer2); + } + Main.EntitySpriteDraw(stabilizer, leftStabilizerPosition, null, stabilizerColor, leftStabilizerRotation, stabilizerOrigin, Projectile.scale, leftStabilizerDirection, 0); + Main.EntitySpriteDraw(stabilizer2, rightStabilizerPosition, null, stabilizerColor, rightStabilizerRotation, stabilizerOrigin, Projectile.scale, rightStabilizerDirection, 0); + + // Draw the core. + Vector2 coreDrawPosition = drawPosition + aimDirection * Projectile.scale * -12f; + Main.EntitySpriteDraw(core, coreDrawPosition, null, Projectile.GetAlpha(lightColor) * stabilizerRotationInterpolant, rotation, coreOrigin, Projectile.scale, direction, 0); + } + + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), rotation, origin, Projectile.scale, direction, 0); + Main.EntitySpriteDraw(glowmask, drawPosition, frame, Projectile.GetAlpha(Color.White), rotation, origin, Projectile.scale, direction, 0); + + return false; + } + } +} diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCannon.png b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCannon.png new file mode 100644 index 0000000000..281210e432 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCannon.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCannonGlowmask.png b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCannonGlowmask.png new file mode 100644 index 0000000000..e97dce2be6 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCannonGlowmask.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCore.png b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCore.png new file mode 100644 index 0000000000..07bc33e0d7 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCore.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCrystal.png b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCrystal.png new file mode 100644 index 0000000000..4b71265a0b Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeCrystal.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeStabilizer.png b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeStabilizer.png new file mode 100644 index 0000000000..29b08d3e2d Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeStabilizer.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeStabilizerBottom.png b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeStabilizerBottom.png new file mode 100644 index 0000000000..72b1fbe1c1 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonGaussNukeStabilizerBottom.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannon.cs b/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannon.cs new file mode 100644 index 0000000000..91350cdd0e --- /dev/null +++ b/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannon.cs @@ -0,0 +1,105 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.Audio; +using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Sounds; +using CalamityMod.Items.Weapons.Summon; +using System.IO; + +namespace CalamityMod.Projectiles.Summon.SmallAresArms +{ + public class ExoskeletonLaserCannon : ExoskeletonCannon + { + public ref float ShootCounter => ref Projectile.localAI[0]; + + // This is how many small, regular lasers will happen before the laser will charge up and prepare a laserbeam. + public const int NormalLasersBeforeBeam = 6; + + public override int ShootRate => ShootCounter % NormalLasersBeforeBeam == 0f ? 150 : AresExoskeleton.LaserCannonNormalShootRate; + + public override float ShootSpeed => 13.5f; + + public override Vector2 OwnerRestingOffset => HoverOffsetTable[HoverOffsetIndex]; + + public override void ClampFirstLimbRotation(ref double limbRotation) => limbRotation = RotationalClampTable[HoverOffsetIndex]; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Laser Cannon"); + Main.projFrames[Type] = 6; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(ShootCounter); + base.SendExtraAI(writer); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + ShootCounter = reader.ReadSingle(); + base.ReceiveExtraAI(reader); + } + + public override void ShootAtTarget(NPC target, Vector2 shootDirection) + { + // Play the laser cannon fire sound. + SoundEngine.PlaySound(CommonCalamitySounds.LaserCannonSound with { Volume = 0.4f }, Projectile.Center); + + // Create a burst of dust. + for (int i = 0; i < 24; i++) + { + Dust laserEnergy = Dust.NewDustPerfect(Projectile.Center + shootDirection * Projectile.width * Projectile.scale * 0.45f, 182); + laserEnergy.velocity = (MathHelper.TwoPi * i / 24f).ToRotationVector2() * 4f; + laserEnergy.scale = 1.1f; + laserEnergy.fadeIn = 0.4f; + laserEnergy.noGravity = true; + } + + // Shoot the laser. This only happens for the owner client. + if (Main.myPlayer != Projectile.owner) + return; + + int laserID = ModContent.ProjectileType(); + bool fireLaser = ShootCounter % NormalLasersBeforeBeam == NormalLasersBeforeBeam - 1f; + if (fireLaser) + laserID = ModContent.ProjectileType(); + + Vector2 laserVelocity = shootDirection * ShootSpeed; + int laser = Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center, laserVelocity, laserID, Projectile.damage, 0f, Projectile.owner); + if (Main.projectile.IndexInRange(laser)) + { + Main.projectile[laser].originalDamage = Projectile.originalDamage; + if (fireLaser) + Main.projectile[laser].ai[1] = Projectile.identity; + } + + // Increment the shoot counter. This decides if the cannon fires a simple laser or a beam. + ShootCounter++; + Projectile.netUpdate = true; + } + + // Create some charge dust before firing a laserbeam. + public override void PostAI() + { + Projectile.frameCounter++; + Projectile.frame = Projectile.frameCounter / 5 % Main.projFrames[Type]; + if (ShootCounter % NormalLasersBeforeBeam != NormalLasersBeforeBeam - 1f || !TargetingSomething) + return; + + Vector2 aimDirection = Projectile.rotation.ToRotationVector2(); + Dust laserEnergy = Dust.NewDustPerfect(Projectile.Center + aimDirection * Projectile.width * Projectile.scale * 0.51f, 182); + laserEnergy.velocity = aimDirection.RotatedByRandom(0.48f) * Main.rand.NextFloat(3f); + laserEnergy.scale = 1.1f; + laserEnergy.fadeIn = 0.4f; + laserEnergy.noGravity = true; + } + + public override bool PreDraw(ref Color lightColor) + { + DefaultDrawCannon(ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannonGlowmask").Value); + return false; + } + } +} diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannon.png b/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannon.png new file mode 100644 index 0000000000..bb40ea3449 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannon.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannonGlowmask.png b/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannonGlowmask.png new file mode 100644 index 0000000000..a3afe8e3fd Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannonGlowmask.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.cs b/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.cs new file mode 100644 index 0000000000..8d11da156b --- /dev/null +++ b/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.cs @@ -0,0 +1,369 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; +using CalamityMod.Items.Weapons.Summon; +using Terraria.GameContent; +using Terraria.Audio; +using System.Linq; +using System; +using System.Collections.Generic; + +namespace CalamityMod.Projectiles.Summon.SmallAresArms +{ + public class ExoskeletonPanel : ModProjectile + { + public enum IconType + { + Inactive, + Plasma, + Tesla, + Laser, + Gauss + } + + public class IconState + { + public int PanelFlashTimer; + + public int MousePressFrameCountdown; + + public bool BeingHoveredOver; + + public bool PlacedInPanel; + + public IconType CurrentState; + + public Texture2D IconTexture + { + get + { + Texture2D plasmaTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonPanelPlasma").Value; + Texture2D teslaTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonPanelTesla").Value; + Texture2D laserTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonPanelLaser").Value; + Texture2D gaussTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonPanelGauss").Value; + return CurrentState switch + { + IconType.Plasma => plasmaTexture, + IconType.Tesla => teslaTexture, + IconType.Laser => laserTexture, + IconType.Gauss => gaussTexture, + _ => null, + }; + } + } + + public Rectangle Frame + { + get + { + int frame = 0; + if (BeingHoveredOver) + frame = PlacedInPanel ? 3 : 1; + if (MousePressFrameCountdown >= 1) + frame = 2; + if (PanelFlashTimer >= 1) + frame = (int)Math.Round(MathHelper.Lerp(4f, 6f, PanelFlashTimer / 16f)); + + return IconTexture?.Frame(1, 7, 0, frame) ?? default; + } + } + + public IconState(bool hover, bool panel, IconType state) + { + BeingHoveredOver = hover; + PlacedInPanel = panel; + CurrentState = state; + } + + public void Update() + { + if (PanelFlashTimer >= 1) + PanelFlashTimer++; + if (PanelFlashTimer >= 16) + PanelFlashTimer = 0; + + if (MousePressFrameCountdown > 0) + MousePressFrameCountdown--; + } + } + + public IconType ClickedIcon = IconType.Inactive; + + public IconState[] SelectionIcons = new IconState[] + { + new(false, false, IconType.Plasma), + new(false, false, IconType.Tesla), + new(false, false, IconType.Laser), + new(false, false, IconType.Gauss), + }; + + public IconState[] PanelIcons = new IconState[] + { + new(false, true, IconType.Inactive), + new(false, true, IconType.Inactive), + new(false, true, IconType.Inactive), + new(false, true, IconType.Inactive), + }; + + public bool ShouldDeleteArmIndex = false; + + public int ArmIDToSpawn = -1; + + public int ArmIndex = -1; + + public bool FadeOut => Projectile.ai[0] == 1f; + + public Vector2 PlayerOffset; + + public ref float Time => ref Projectile.ai[1]; + + public static Rectangle MouseRectangle => new((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 2, 2); + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("UI"); + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 9999999; + } + + public override void SetDefaults() + { + Projectile.width = 40; + Projectile.height = 40; + Projectile.penetrate = -1; + Projectile.ignoreWater = true; + Projectile.timeLeft = 36000; + Projectile.Opacity = 0f; + Projectile.tileCollide = false; + Projectile.hide = true; + } + + public override void AI() + { + int plasmaCannonID = ModContent.ProjectileType(); + int teslaCannonID = ModContent.ProjectileType(); + int laserCannonID = ModContent.ProjectileType(); + int gaussNukeID = ModContent.ProjectileType(); + int[] arms = new int[] + { + plasmaCannonID, + teslaCannonID, + laserCannonID, + gaussNukeID, + }; + + // Initialize things. + if (PlayerOffset == Vector2.Zero) + PlayerOffset = Main.MouseWorld - Main.LocalPlayer.Center; + + // Dynamically update panel icons. + for (int i = 0; i < 4; i++) + PanelIcons[i].CurrentState = IconType.Inactive; + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (!arms.Contains(Main.projectile[i].type) || Main.projectile[i].owner != Projectile.owner || !Main.projectile[i].active) + continue; + + IconType stateFromID = IconType.Inactive; + if (Main.projectile[i].type == plasmaCannonID) + stateFromID = IconType.Plasma; + if (Main.projectile[i].type == teslaCannonID) + stateFromID = IconType.Tesla; + if (Main.projectile[i].type == laserCannonID) + stateFromID = IconType.Laser; + if (Main.projectile[i].type == gaussNukeID) + stateFromID = IconType.Gauss; + + PanelIcons[(int)Main.projectile[i].ai[0]].CurrentState = stateFromID; + } + + // Handle fade effects. + if (Time >= AresExoskeleton.BoxParticleLifetime) + Projectile.Opacity = MathHelper.Clamp(Projectile.Opacity - FadeOut.ToDirectionInt() * 0.0225f, 0f, 1f); + if (FadeOut && Projectile.Opacity <= 0f) + Projectile.Kill(); + + if (Main.player[Projectile.owner].dead || !Main.player[Projectile.owner].active) + Projectile.Kill(); + Time++; + + // Create and destroy arms as necessary. + if (Main.myPlayer != Projectile.owner) + return; + + if (ArmIDToSpawn >= 0) + { + bool armAlreadyExists = false; + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (!arms.Contains(Main.projectile[i].type) || Main.projectile[i].owner != Projectile.owner || !Main.projectile[i].active || Main.projectile[i].ai[0] != ArmIndex) + continue; + + armAlreadyExists = true; + break; + } + + if (!armAlreadyExists) + { + SoundEngine.PlaySound(SoundID.Zombie66, Projectile.Center); + int cannon = Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center, Vector2.Zero, ArmIDToSpawn, Projectile.damage, 0f, Projectile.owner, ArmIndex); + if (Main.projectile.IndexInRange(cannon)) + Main.projectile[cannon].originalDamage = Projectile.originalDamage; + } + } + if (ShouldDeleteArmIndex) + { + SoundEngine.PlaySound(SoundID.Item74, Projectile.Center); + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (!arms.Contains(Main.projectile[i].type) || Main.projectile[i].owner != Projectile.owner || !Main.projectile[i].active || Main.projectile[i].ai[0] != ArmIndex) + continue; + + Main.projectile[i].Kill(); + } + } + + ShouldDeleteArmIndex = false; + ArmIDToSpawn = -1; + ArmIndex = -1; + } + + public override bool PreDraw(ref Color lightColor) + { + // This UI only renders for the player that created it. + if (Main.myPlayer != Projectile.owner) + return false; + + Texture2D panelTexture = ModContent.Request(Texture).Value; + Texture2D plasmaTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonPanelPlasma").Value; + Texture2D arrowTexture = ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/Arrow").Value; + Vector2 area = plasmaTexture.Frame(1, 7, 0, 0).Size(); + Vector2 drawPosition = (Main.LocalPlayer.Center + PlayerOffset - Main.screenPosition).Floor(); + + Rectangle[] selectionIconAreas = new Rectangle[4] + { + Utils.CenteredRectangle(drawPosition + new Vector2(-62f, -70f) * Projectile.scale, area * Projectile.scale), + Utils.CenteredRectangle(drawPosition + new Vector2(-22f, -70f) * Projectile.scale, area * Projectile.scale), + Utils.CenteredRectangle(drawPosition + new Vector2(22f, -70f) * Projectile.scale, area * Projectile.scale), + Utils.CenteredRectangle(drawPosition + new Vector2(62f, -70f) * Projectile.scale, area * Projectile.scale) + }; + + bool hoveringOverAnySlot = false; + bool clickedAnIconOnPanel = false; + bool sufficientSlots = Main.LocalPlayer.maxMinions > AresExoskeleton.MinionSlotsPerCannon; + + // Draw icon and handle hover behaviors. + // If an arm needs to be destroyed or spawned, it will happen on the next frame in the AI update loop. + for (int i = 0; i < 4; i++) + { + Texture2D selectionIconTexture = SelectionIcons[i].IconTexture; + + // Handle selection icon click stuff. + SelectionIcons[i].BeingHoveredOver = false; + PanelIcons[i].BeingHoveredOver = false; + if (selectionIconAreas[i].Intersects(MouseRectangle)) + { + hoveringOverAnySlot = true; + SelectionIcons[i].BeingHoveredOver = true; + if (Main.mouseLeft && Main.mouseLeftRelease && Projectile.Opacity >= 1f) + { + ClickedIcon = SelectionIcons[i].CurrentState; + SelectionIcons[i].MousePressFrameCountdown = 15; + } + } + + // Handle panel icon click stuff. + Rectangle panelArea = selectionIconAreas[i]; + panelArea.Y += (int)(Projectile.scale * 78f); + if (panelArea.Intersects(MouseRectangle)) + { + hoveringOverAnySlot = true; + PanelIcons[i].BeingHoveredOver = true; + if (Main.mouseLeft && Main.mouseLeftRelease && Projectile.Opacity >= 1f && sufficientSlots) + { + clickedAnIconOnPanel = true; + PanelIcons[i].CurrentState = ClickedIcon; + PanelIcons[i].PanelFlashTimer = 1; + + switch (ClickedIcon) + { + case IconType.Plasma: + ArmIDToSpawn = ModContent.ProjectileType(); + break; + case IconType.Tesla: + ArmIDToSpawn = ModContent.ProjectileType(); + break; + case IconType.Laser: + ArmIDToSpawn = ModContent.ProjectileType(); + break; + case IconType.Gauss: + ArmIDToSpawn = ModContent.ProjectileType(); + break; + case IconType.Inactive: + ShouldDeleteArmIndex = true; + PanelIcons[i].PanelFlashTimer = 0; + break; + } + ArmIndex = i; + } + } + + Main.EntitySpriteDraw(selectionIconTexture, selectionIconAreas[i].Center.ToVector2(), SelectionIcons[i].Frame, Projectile.GetAlpha(Color.White), 0f, area * 0.5f, Projectile.scale, 0, 0); + } + + Main.EntitySpriteDraw(panelTexture, drawPosition, null, Projectile.GetAlpha(Color.White), 0f, panelTexture.Size() * 0.5f, Projectile.scale, 0, 0); + + // Draw panel icons. + for (int i = 0; i < 4; i++) + { + Rectangle panelArea = selectionIconAreas[i]; + panelArea.Y += (int)(Projectile.scale * 78f); + Texture2D panelIconTexture = PanelIcons[i].IconTexture; + if (panelIconTexture is not null) + Main.EntitySpriteDraw(panelIconTexture, panelArea.Center.ToVector2(), PanelIcons[i].Frame, Projectile.GetAlpha(Color.White), 0f, area * 0.5f, Projectile.scale, 0, 0); + + SelectionIcons[i].Update(); + PanelIcons[i].Update(); + } + + // Draw an arrow at the mouse from the selected icon if one has been selected. + if (ClickedIcon != IconType.Inactive) + { + Vector2 arrowDrawPosition = selectionIconAreas[(int)ClickedIcon - 1].Center.ToVector2(); + Vector2 arrowDirection = (Main.MouseScreen - arrowDrawPosition).SafeNormalize(Vector2.UnitY); + arrowDrawPosition += arrowDirection * Projectile.scale * 24f; + + Main.EntitySpriteDraw(arrowTexture, arrowDrawPosition, null, Projectile.GetAlpha(Color.White), arrowDirection.ToRotation(), arrowTexture.Size() * 0.5f, Projectile.scale, 0, 0); + } + + // Tell the player if they don't have enough summon slots. + if (hoveringOverAnySlot && !sufficientSlots) + Utils.DrawBorderStringFourWay(Main.spriteBatch, FontAssets.MouseText.Value, "Insufficient minion slots!", Main.MouseScreen.X + 20f, Main.MouseScreen.Y + 12f, Color.Cyan, Color.Black, new Vector2(0f, 0.5f)); + + // Reset the clicked icon if a click is made but not to a specific icon. + if (!hoveringOverAnySlot && Main.mouseLeft && Main.mouseLeftRelease) + ClickedIcon = IconType.Inactive; + + if (hoveringOverAnySlot) + { + Main.blockMouse = true; + Main.LocalPlayer.mouseInterface = true; + } + + // Reset the clicked icon and handle the arm creation/deletion if an icon was clicked on the panel. + if (clickedAnIconOnPanel) + ClickedIcon = IconType.Inactive; + + return false; + } + + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + overWiresUI.Add(index); + } + + // This is a UI. It should not do damage. + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.png b/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.png new file mode 100644 index 0000000000..d0d85a8a57 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonPanel.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPanelGauss.png b/Projectiles/Summon/SmallAresArms/ExoskeletonPanelGauss.png new file mode 100644 index 0000000000..399ca0170c Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonPanelGauss.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPanelLaser.png b/Projectiles/Summon/SmallAresArms/ExoskeletonPanelLaser.png new file mode 100644 index 0000000000..b92fa1e06c Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonPanelLaser.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPanelPlasma.png b/Projectiles/Summon/SmallAresArms/ExoskeletonPanelPlasma.png new file mode 100644 index 0000000000..88bf8c292a Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonPanelPlasma.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPanelTesla.png b/Projectiles/Summon/SmallAresArms/ExoskeletonPanelTesla.png new file mode 100644 index 0000000000..77dde33046 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonPanelTesla.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPlasmaCannon.cs b/Projectiles/Summon/SmallAresArms/ExoskeletonPlasmaCannon.cs new file mode 100644 index 0000000000..1e72bd6005 --- /dev/null +++ b/Projectiles/Summon/SmallAresArms/ExoskeletonPlasmaCannon.cs @@ -0,0 +1,93 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.Audio; +using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Items.Weapons.DraedonsArsenal; +using CalamityMod.Items.Weapons.Summon; + +namespace CalamityMod.Projectiles.Summon.SmallAresArms +{ + public class ExoskeletonPlasmaCannon : ExoskeletonCannon + { + public override int ShootRate => AresExoskeleton.PlasmaCannonShootRate; + + public override float ShootSpeed => 13.5f; + + public override Vector2 OwnerRestingOffset => HoverOffsetTable[HoverOffsetIndex]; + + public override void ClampFirstLimbRotation(ref double limbRotation) => limbRotation = RotationalClampTable[HoverOffsetIndex]; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Plasma Cannon"); + Main.projFrames[Type] = 6; + } + + public override void PostAI() + { + Projectile.frameCounter++; + Projectile.frame = Projectile.frameCounter / 5 % Main.projFrames[Type]; + } + + public override void ShootAtTarget(NPC target, Vector2 shootDirection) + { + // Play the plasma caster fire sound. + SoundEngine.PlaySound(PlasmaCaster.FireSound with { Volume = 0.4f }, Projectile.Center); + + // Create a burst of dust. + for (int i = 0; i < 40; i++) + { + float dustSpeed = Main.rand.NextFloat(1.8f, 3f); + Vector2 dustVel = shootDirection * dustSpeed; + dustVel = dustVel.RotatedBy(-0.35f); + dustVel = dustVel.RotatedByRandom(2.0f * 0.35f); + int randomDustType = Main.rand.NextBool(2) ? 107 : 110; + + Dust plasma = Dust.NewDustDirect(Projectile.TopLeft, Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); + plasma.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 4f; + plasma.position += shootDirection * 60f; + plasma.noGravity = true; + plasma.velocity *= Projectile.scale * 1.6f; + + plasma = Dust.NewDustDirect(Projectile.TopLeft, Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); + plasma.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 4f; + plasma.position += shootDirection * 60f; + plasma.velocity *= Projectile.scale * 0.9f; + + plasma.noGravity = true; + plasma.fadeIn = 1f; + plasma.color = Color.Green * 0.5f; + } + for (int i = 0; i < 20; i++) + { + float dustSpeed = Main.rand.NextFloat(1.8f, 3f); + Vector2 dustVel = shootDirection * dustSpeed; + dustVel = dustVel.RotatedBy(-0.35f); + dustVel = dustVel.RotatedByRandom(2.0f * 0.35f); + int randomDustType = Main.rand.NextBool(2) ? 107 : 110; + + Dust plasma = Dust.NewDustDirect(Projectile.TopLeft, Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); + plasma.position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(shootDirection.ToRotation()) * Projectile.width / 5f; + plasma.position += shootDirection * 60f; + plasma.noGravity = true; + plasma.velocity *= Projectile.scale * 0.27f; + } + + // Shoot the fireball. This only happens for the owner client. + if (Main.myPlayer != Projectile.owner) + return; + + Vector2 fireballVelocity = shootDirection * ShootSpeed; + int fireball = Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center, fireballVelocity, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner); + if (Main.projectile.IndexInRange(fireball)) + Main.projectile[fireball].originalDamage = Projectile.originalDamage; + } + + public override bool PreDraw(ref Color lightColor) + { + DefaultDrawCannon(ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonPlasmaCannonGlowmask").Value); + return false; + } + } +} diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPlasmaCannon.png b/Projectiles/Summon/SmallAresArms/ExoskeletonPlasmaCannon.png new file mode 100644 index 0000000000..782b1e8be3 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonPlasmaCannon.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonPlasmaCannonGlowmask.png b/Projectiles/Summon/SmallAresArms/ExoskeletonPlasmaCannonGlowmask.png new file mode 100644 index 0000000000..60e386b179 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonPlasmaCannonGlowmask.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonTeslaCannon.cs b/Projectiles/Summon/SmallAresArms/ExoskeletonTeslaCannon.cs new file mode 100644 index 0000000000..2418d08c74 --- /dev/null +++ b/Projectiles/Summon/SmallAresArms/ExoskeletonTeslaCannon.cs @@ -0,0 +1,67 @@ +using CalamityMod.Sounds; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.Audio; +using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Items.Weapons.Summon; +using System.IO; + +namespace CalamityMod.Projectiles.Summon.SmallAresArms +{ + public class ExoskeletonTeslaCannon : ExoskeletonCannon + { + public ref float TeslaOrbIndex => ref Projectile.localAI[0]; + + public override int ShootRate => AresExoskeleton.TeslaCannonShootRate; + + public override float ShootSpeed => 12f; + + public override bool UsesSuperpredictiveness => true; + + public override Vector2 OwnerRestingOffset => HoverOffsetTable[HoverOffsetIndex]; + + public override void ClampFirstLimbRotation(ref double limbRotation) => limbRotation = RotationalClampTable[HoverOffsetIndex]; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tesla Cannon"); + Main.projFrames[Type] = 6; + } + + public override void SendExtraAI(BinaryWriter writer) => writer.Write(TeslaOrbIndex); + + public override void ReceiveExtraAI(BinaryReader reader) => TeslaOrbIndex = reader.ReadSingle(); + + public override void PostAI() + { + Projectile.frameCounter++; + Projectile.frame = Projectile.frameCounter / 5 % Main.projFrames[Type]; + } + + public override void ShootAtTarget(NPC target, Vector2 shootDirection) + { + // Play the plasma bolt fire sound. + SoundEngine.PlaySound(CommonCalamitySounds.PlasmaBoltSound with { Volume = 0.4f }, Projectile.Center); + + // Shoot the tesla orb. This only happens for the owner client. + if (Main.myPlayer != Projectile.owner) + return; + + int damage = (int)(Projectile.damage * AresExoskeleton.TeslaOrbDamageFactor); + Vector2 teslaOrbVelocity = shootDirection * ShootSpeed; + int teslaOrb = Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center, teslaOrbVelocity, ModContent.ProjectileType(), damage, 0f, Projectile.owner); + if (Main.projectile.IndexInRange(teslaOrb)) + { + Main.projectile[teslaOrb].originalDamage = (int)(Projectile.originalDamage * AresExoskeleton.TeslaOrbDamageFactor); + Main.projectile[teslaOrb].ai[0] = TeslaOrbIndex++ % 6; + } + } + + public override bool PreDraw(ref Color lightColor) + { + DefaultDrawCannon(ModContent.Request("CalamityMod/Projectiles/Summon/SmallAresArms/ExoskeletonTeslaCannonGlowmask").Value); + return false; + } + } +} diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonTeslaCannon.png b/Projectiles/Summon/SmallAresArms/ExoskeletonTeslaCannon.png new file mode 100644 index 0000000000..21761e7ad1 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonTeslaCannon.png differ diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonTeslaCannonGlowmask.png b/Projectiles/Summon/SmallAresArms/ExoskeletonTeslaCannonGlowmask.png new file mode 100644 index 0000000000..bf6a231509 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/ExoskeletonTeslaCannonGlowmask.png differ diff --git a/Projectiles/Summon/SmallAresArms/MinionGaussBoom.cs b/Projectiles/Summon/SmallAresArms/MinionGaussBoom.cs new file mode 100644 index 0000000000..a5323cc3ee --- /dev/null +++ b/Projectiles/Summon/SmallAresArms/MinionGaussBoom.cs @@ -0,0 +1,34 @@ +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon.SmallAresArms +{ + public class MinionGaussBoom : BaseMassiveExplosionProjectile + { + public override int Lifetime => 60; + + // No screenshake is used for the sake of gameplay convenience. + public override bool UsesScreenshake => false; + public override float GetScreenshakePower(float pulseCompletionRatio) => 0f; + public override Color GetCurrentExplosionColor(float pulseCompletionRatio) => Color.Lerp(Color.Yellow * 1.6f, Color.White, MathHelper.Clamp(pulseCompletionRatio * 2.2f, 0f, 1f)); + public override void SetStaticDefaults() => DisplayName.SetDefault("Gauss Hyperexplosion"); + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 2; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = Lifetime; + Projectile.minion = true; + Projectile.minionSlots = 0f; + Projectile.DamageType = DamageClass.Summon; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 12; + } + + public override void PostAI() => Lighting.AddLight(Projectile.Center, 0.2f, 0.1f, 0f); + } +} diff --git a/Projectiles/Summon/SmallAresArms/MinionGaussNuke.cs b/Projectiles/Summon/SmallAresArms/MinionGaussNuke.cs new file mode 100644 index 0000000000..cc58f7a0b6 --- /dev/null +++ b/Projectiles/Summon/SmallAresArms/MinionGaussNuke.cs @@ -0,0 +1,59 @@ +using CalamityMod.Items.Weapons.DraedonsArsenal; +using CalamityMod.Items.Weapons.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon.SmallAresArms +{ + public class MinionGaussNuke : ModProjectile + { + public override void SetStaticDefaults() => DisplayName.SetDefault("Gauss Nuke"); + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 76; + Projectile.penetrate = -1; + Projectile.tileCollide = true; + Projectile.timeLeft = 180; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.minion = true; + Projectile.minionSlots = 0f; + Projectile.DamageType = DamageClass.Summon; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 12; + } + + public override void AI() + { + // Handle rotation. + Projectile.rotation = Projectile.velocity.ToRotation(); + + // Home towards targets. + NPC potentialTarget = Projectile.Center.ClosestNPCAt(960f, false); + if (potentialTarget != null) + Projectile.velocity = Projectile.SuperhomeTowardsTarget(potentialTarget, 23f, 10f); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + Projectile.Kill(); + } + + public override void Kill(int timeLeft) + { + SoundEngine.PlaySound(TeslaCannon.FireSound, Projectile.Center); + if (Main.myPlayer == Projectile.owner) + { + int boom = Projectile.NewProjectile(Projectile.GetSource_Death(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + if (Main.projectile.IndexInRange(boom)) + { + Main.projectile[boom].ai[1] = AresExoskeleton.MaxNukeExplosionRadius; + Main.projectile[boom].originalDamage = Projectile.originalDamage; + } + } + } + } +} diff --git a/Projectiles/Summon/SmallAresArms/MinionGaussNuke.png b/Projectiles/Summon/SmallAresArms/MinionGaussNuke.png new file mode 100644 index 0000000000..a4b11364a1 Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/MinionGaussNuke.png differ diff --git a/Projectiles/Summon/SmallAresArms/MinionLaserBurst.cs b/Projectiles/Summon/SmallAresArms/MinionLaserBurst.cs new file mode 100644 index 0000000000..b8ff8c863b --- /dev/null +++ b/Projectiles/Summon/SmallAresArms/MinionLaserBurst.cs @@ -0,0 +1,61 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; + +namespace CalamityMod.Projectiles.Summon.SmallAresArms +{ + public class MinionLaserBurst : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/Boss/ThanatosLaser"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Exothermal Laser"); + Main.projFrames[Type] = 4; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } + + public override void SetDefaults() + { + Projectile.width = 32; + Projectile.height = 32; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = true; + Projectile.netImportant = true; + Projectile.minion = true; + Projectile.minionSlots = 0f; + Projectile.timeLeft = 420; + Projectile.Opacity = 0f; + Projectile.DamageType = DamageClass.Summon; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 12; + } + + public override void AI() + { + // Accelerate. + if (Projectile.velocity.Length() < 27f) + Projectile.velocity *= 1.024f; + + // Fade in. + Projectile.Opacity = MathHelper.Clamp(Projectile.Opacity + 0.12f, 0f, 1f); + + // Handle frames and rotation. + Projectile.frameCounter++; + Projectile.frame = Projectile.frameCounter / 5 % Main.projFrames[Projectile.type]; + Projectile.rotation = Projectile.velocity.ToRotation(); + } + + public override bool PreDraw(ref Color lightColor) + { + lightColor.R = (byte)(255 * Projectile.Opacity); + lightColor.G = (byte)(255 * Projectile.Opacity); + lightColor.B = (byte)(255 * Projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); + return false; + } + } +} diff --git a/Projectiles/Summon/SmallAresArms/MinionPlasmaBlast.cs b/Projectiles/Summon/SmallAresArms/MinionPlasmaBlast.cs new file mode 100644 index 0000000000..e7ef090a06 --- /dev/null +++ b/Projectiles/Summon/SmallAresArms/MinionPlasmaBlast.cs @@ -0,0 +1,83 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.Audio; +using Terraria.ID; + +namespace CalamityMod.Projectiles.Summon.SmallAresArms +{ + public class MinionPlasmaBlast : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/Boss/AresPlasmaFireball"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Volatile Plasma Blast"); + Main.projFrames[Type] = 6; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } + + public override void SetDefaults() + { + Projectile.width = 36; + Projectile.height = 36; + Projectile.friendly = true; + Projectile.penetrate = 1; + Projectile.tileCollide = true; + Projectile.netImportant = true; + Projectile.minion = true; + Projectile.minionSlots = 0f; + Projectile.timeLeft = 420; + Projectile.Opacity = 0f; + Projectile.DamageType = DamageClass.Summon; + } + + public override void AI() + { + // Accelerate. + if (Projectile.velocity.Length() < 23f) + Projectile.velocity *= 1.0175f; + + // Fade in. + Projectile.Opacity = MathHelper.Clamp(Projectile.Opacity + 0.06667f, 0f, 1f); + + // Handle frames and rotation. + Projectile.frameCounter++; + Projectile.frame = Projectile.frameCounter / 5 % Main.projFrames[Projectile.type]; + Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; + + // Home towards targets. + NPC potentialTarget = Projectile.Center.ClosestNPCAt(900f, false); + if (potentialTarget != null) + Projectile.velocity = Projectile.SuperhomeTowardsTarget(potentialTarget, 23f, 10f); + } + + public override void Kill(int timeLeft) + { + SoundEngine.PlaySound(SoundID.Item93, Projectile.Center); + + // Release a spread of plasma gas. + if (Main.netMode != NetmodeID.MultiplayerClient && Projectile.ai[1] != -1f) + { + int type = ModContent.ProjectileType(); + for (int i = 0; i < 15; i++) + { + Vector2 plasmaVelocity = Main.rand.NextVector2Circular(5f, 5f); + int gas = Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center, plasmaVelocity, type, Projectile.damage, 0f, Main.myPlayer); + if (Main.projectile.IndexInRange(gas)) + Main.projectile[gas].originalDamage = Projectile.originalDamage; + } + } + } + + public override bool PreDraw(ref Color lightColor) + { + lightColor.R = (byte)(255 * Projectile.Opacity); + lightColor.G = (byte)(255 * Projectile.Opacity); + lightColor.B = (byte)(255 * Projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); + return false; + } + } +} diff --git a/Projectiles/Summon/SmallAresArms/MinionPlasmaGas.cs b/Projectiles/Summon/SmallAresArms/MinionPlasmaGas.cs new file mode 100644 index 0000000000..2610821b3b --- /dev/null +++ b/Projectiles/Summon/SmallAresArms/MinionPlasmaGas.cs @@ -0,0 +1,67 @@ +using CalamityMod.DataStructures; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon.SmallAresArms +{ + public class MinionPlasmaGas : ModProjectile, IAdditiveDrawer + { + public ref float LightPower => ref Projectile.ai[0]; + + public ref float Time => ref Projectile.ai[1]; + + public override void SetStaticDefaults() => DisplayName.SetDefault("Superheated Plasma Cloud"); + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 50; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.timeLeft = 150; + Projectile.scale = 1.5f; + Projectile.hide = true; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.minion = true; + Projectile.minionSlots = 0f; + Projectile.DamageType = DamageClass.Summon; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 12; + } + + public override void AI() + { + // Decide scale and initial rotation on the first frame this projectile exists. + if (Projectile.localAI[0] == 0f) + { + Projectile.scale = Main.rand.NextFloat(1f, 1.7f); + Projectile.rotation = Main.rand.NextFloat(MathHelper.TwoPi); + Projectile.localAI[0] = 1f; + } + + // Calculate light power. This checks below the position of the fog to check if this fog is underground. + // Without this, it may render over the fullblack that the game renders for obscured tiles. + float lightPowerBelow = Lighting.GetColor((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16 + 6).ToVector3().Length() / (float)Math.Sqrt(3D); + LightPower = MathHelper.Lerp(LightPower, lightPowerBelow, 0.15f); + Projectile.Opacity = Utils.GetLerpValue(0f, 15f, Time, true) * Utils.GetLerpValue(0f, 60f, Projectile.timeLeft, true); + Projectile.rotation += Projectile.velocity.X * 0.004f; + Projectile.velocity *= 0.97f; + Time++; + } + + public void AdditiveDraw(SpriteBatch spriteBatch) + { + Texture2D texture = TextureAssets.Projectile[Projectile.type].Value; + Vector2 origin = texture.Size() * 0.5f; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float opacity = Utils.GetLerpValue(0f, 0.08f, LightPower, true) * Projectile.Opacity * 0.6f; + Color drawColor = new Color(141, 255, 105) * opacity; + Vector2 scale = Projectile.Size / texture.Size() * Projectile.scale * 1.35f; + spriteBatch.Draw(texture, drawPosition, null, drawColor, Projectile.rotation, origin, scale, SpriteEffects.None, 0f); + } + } +} diff --git a/Projectiles/Summon/SmallAresArms/MinionPlasmaGas.png b/Projectiles/Summon/SmallAresArms/MinionPlasmaGas.png new file mode 100644 index 0000000000..d26f30cbff Binary files /dev/null and b/Projectiles/Summon/SmallAresArms/MinionPlasmaGas.png differ diff --git a/Projectiles/Summon/SmallAresArms/MinionTeslaOrb.cs b/Projectiles/Summon/SmallAresArms/MinionTeslaOrb.cs new file mode 100644 index 0000000000..756b0a6a86 --- /dev/null +++ b/Projectiles/Summon/SmallAresArms/MinionTeslaOrb.cs @@ -0,0 +1,151 @@ +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.Boss; +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon.SmallAresArms +{ + public class MinionTeslaOrb : ModProjectile + { + public ref float Identity => ref Projectile.ai[0]; + + public ref float Time => ref Projectile.ai[1]; + + public PrimitiveTrail LightningDrawer; + + public PrimitiveTrail LightningBackgroundDrawer; + + public override string Texture => "CalamityMod/Projectiles/Boss/AresTeslaOrb"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tesla Sphere"); + Main.projFrames[Projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + ProjectileID.Sets.DrawScreenCheckFluff[Projectile.type] = 10000; + } + + public override void SetDefaults() + { + Projectile.width = 32; + Projectile.height = 32; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.minion = true; + Projectile.minionSlots = 0f; + Projectile.timeLeft = 420; + Projectile.Opacity = 0f; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 35; + Projectile.DamageType = DamageClass.Summon; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(Projectile.localAI[0]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + Projectile.localAI[0] = reader.ReadSingle(); + } + + public override void AI() + { + // Accelerate. + if (Projectile.velocity.Length() < 21f) + Projectile.velocity *= 1.012f; + + // Handle fade effects. + Projectile.Opacity = Utils.GetLerpValue(0f, 4f, Time, true) * Utils.GetLerpValue(0f, 15f, Projectile.timeLeft, true); + + // Emit electric light. + Lighting.AddLight(Projectile.Center, 0.1f * Projectile.Opacity, 0.25f * Projectile.Opacity, 0.25f * Projectile.Opacity); + + // Handle frames. + Projectile.frameCounter++; + Projectile.frame = Projectile.frameCounter / 5 % Main.projFrames[Projectile.type]; + + Time++; + } + + public Projectile GetOrbToAttachTo() + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type != Projectile.type || Main.projectile[i].ai[0] != Identity + 1f || !Main.projectile[i].active) + continue; + + if (!Main.projectile[i].WithinRange(Projectile.Center, AresExoskeleton.TeslaOrbDetatchDistance)) + continue; + + return Main.projectile[i]; + } + + return null; + } + + internal float WidthFunction(float completionRatio) + { + return MathHelper.Lerp(0.75f, 1.85f, (float)Math.Sin(MathHelper.Pi * completionRatio)) * Projectile.scale; + } + + internal Color ColorFunction(float completionRatio) + { + float fadeToWhite = MathHelper.Lerp(0f, 0.65f, (float)Math.Sin(MathHelper.TwoPi * completionRatio + Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 0.5f); + Color baseColor = Color.Lerp(Color.Cyan, Color.White, fadeToWhite); + return Color.Lerp(baseColor, Color.LightBlue, ((float)Math.Sin(MathHelper.Pi * completionRatio + Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 0.5f) * 0.8f) * Projectile.Opacity; + } + + internal float BackgroundWidthFunction(float completionRatio) => WidthFunction(completionRatio) * 4f; + + internal Color BackgroundColorFunction(float completionRatio) + { + Color color = Color.CornflowerBlue * Projectile.Opacity * 0.4f; + return color; + } + + public override bool PreDraw(ref Color lightColor) + { + if (LightningDrawer is null) + LightningDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction); + if (LightningBackgroundDrawer is null) + LightningBackgroundDrawer = new PrimitiveTrail(BackgroundWidthFunction, BackgroundColorFunction, PrimitiveTrail.RigidPointRetreivalFunction); + + Projectile orbToAttachTo = GetOrbToAttachTo(); + if (orbToAttachTo != null) + { + List arcPoints = AresTeslaOrb.DetermineElectricArcPoints(Projectile.Center, orbToAttachTo.Center, 117); + LightningBackgroundDrawer.Draw(arcPoints, -Main.screenPosition, 90); + LightningDrawer.Draw(arcPoints, -Main.screenPosition, 90); + } + + lightColor.R = (byte)(255 * Projectile.Opacity); + lightColor.G = (byte)(255 * Projectile.Opacity); + lightColor.B = (byte)(255 * Projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); + return false; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (projHitbox.Intersects(targetHitbox)) + return true; + + float _ = 0f; + Projectile orbToAttachTo = GetOrbToAttachTo(); + if (orbToAttachTo != null && Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, orbToAttachTo.Center, 8f, ref _)) + return true; + + return false; + } + } +} diff --git a/Projectiles/Typeless/VoidFieldGenerator.cs b/Projectiles/Typeless/VoidFieldGenerator.cs new file mode 100644 index 0000000000..e2c3c65bb0 --- /dev/null +++ b/Projectiles/Typeless/VoidFieldGenerator.cs @@ -0,0 +1,97 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Particles.Metaballs; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Audio; + +namespace CalamityMod.Projectiles.Typeless +{ + public class VoidFieldGenerator : ModProjectile + { + public bool start = true; + public BaseFusableParticleSet.FusableParticle voidaura; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Void Field Generator"); + } + + public override void SetDefaults() + { + Projectile.width = 50; + Projectile.height = 50; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.timeLeft *= 5; + Projectile.penetrate = 1; + Projectile.tileCollide = false; + } + + public override void AI() + { + Player player = Main.player[Projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + + if (!modPlayer.voidField) + { + Projectile.active = false; + return; + } + if (player.dead) + modPlayer.voidField = false; + if (modPlayer.voidField) + Projectile.timeLeft = 2; + + if (Projectile.ai[1] == 0) + { + SoundEngine.PlaySound(SoundID.Item20, Projectile.position); + } + + Vector2 vector = player.Center - Projectile.Center; + + Projectile.Center = player.Center + new Vector2(300, 0).RotatedBy(Projectile.ai[1] + Projectile.ai[0] * MathHelper.PiOver2); + + Projectile.ai[1] += 0.01f; + + Projectile.velocity.X = (vector.X > 0f) ? -0.000001f : 0f; + + for (int k = 0; k < Main.projectile.Length; k++) + { + var proj = Main.projectile[k]; + if (proj.active && proj.owner == Projectile.owner && proj.arrow && !proj.Calamity().nihilicArrow && proj.friendly && Vector2.Distance(proj.Center, Projectile.Center) < 65) + { + Main.projectile[k].damage = (int)(proj.damage * 1.2f); + proj.extraUpdates += 1; + Main.projectile[k].Calamity().nihilicArrow = true; + SoundEngine.PlaySound(SoundID.Item104 with { Volume = SoundID.Item104.Volume * 0.75f }, Projectile.Center); + + for (int i = 0; i < 12; i++) + { + Vector2 dustpos = Vector2.UnitX * (float)-(float)proj.width / 2f; + dustpos += -Vector2.UnitY.RotatedBy((double)((float)i * 3.14159274f / 6f), default) * new Vector2(8f, 16f); + dustpos = dustpos.RotatedBy((double)(proj.rotation - 1.57079637f), default); + int dust = Dust.NewDust(proj.Center, 0, 0, 27, 0f, 0f, 100, Color.HotPink, 1f); + Main.dust[dust].scale = 1.1f; + Main.dust[dust].noGravity = true; + Main.dust[dust].position = proj.Center + dustpos; + Main.dust[dust].velocity = proj.velocity * 0.1f; + Main.dust[dust].velocity = Vector2.Normalize(proj.Center - proj.velocity * 3f - Main.dust[dust].position) * 1.25f; + } + } + } + + if (voidaura == null) + { + voidaura = FusableParticleManager.GetParticleSetByType()?.SpawnParticle(Projectile.Center, 500); + } + else + { + voidaura.Center = Projectile.Center; + voidaura.Size = 500; + } + } + public override bool? CanCutTiles() => false; + } +} diff --git a/Projectiles/Typeless/VoidFieldGenerator.png b/Projectiles/Typeless/VoidFieldGenerator.png new file mode 100644 index 0000000000..9397c1da00 Binary files /dev/null and b/Projectiles/Typeless/VoidFieldGenerator.png differ diff --git a/Projectiles/Typeless/VoidFieldGenerator_Glow.png b/Projectiles/Typeless/VoidFieldGenerator_Glow.png new file mode 100644 index 0000000000..443ee697fa Binary files /dev/null and b/Projectiles/Typeless/VoidFieldGenerator_Glow.png differ diff --git a/Sounds/Item/SevensStrikerBust.ogg b/Sounds/Item/SevensStrikerBust.ogg new file mode 100644 index 0000000000..714d84a934 Binary files /dev/null and b/Sounds/Item/SevensStrikerBust.ogg differ diff --git a/Sounds/Item/SevensStrikerCoinShot.ogg b/Sounds/Item/SevensStrikerCoinShot.ogg new file mode 100644 index 0000000000..d845bb7dcb Binary files /dev/null and b/Sounds/Item/SevensStrikerCoinShot.ogg differ diff --git a/Sounds/Item/SevensStrikerDoubles.ogg b/Sounds/Item/SevensStrikerDoubles.ogg new file mode 100644 index 0000000000..f41ec9714d Binary files /dev/null and b/Sounds/Item/SevensStrikerDoubles.ogg differ diff --git a/Sounds/Item/SevensStrikerJackpot.ogg b/Sounds/Item/SevensStrikerJackpot.ogg new file mode 100644 index 0000000000..d257d2cb42 Binary files /dev/null and b/Sounds/Item/SevensStrikerJackpot.ogg differ diff --git a/Sounds/Item/SevensStrikerRoulette.ogg b/Sounds/Item/SevensStrikerRoulette.ogg new file mode 100644 index 0000000000..7d302e2e10 Binary files /dev/null and b/Sounds/Item/SevensStrikerRoulette.ogg differ diff --git a/Sounds/Item/SevensStrikerRouletteTick.ogg b/Sounds/Item/SevensStrikerRouletteTick.ogg new file mode 100644 index 0000000000..65d600b150 Binary files /dev/null and b/Sounds/Item/SevensStrikerRouletteTick.ogg differ diff --git a/Sounds/Item/SevensStrikerTriples.ogg b/Sounds/Item/SevensStrikerTriples.ogg new file mode 100644 index 0000000000..13fd366195 Binary files /dev/null and b/Sounds/Item/SevensStrikerTriples.ogg differ diff --git a/Utilities/MathematicalUtils.cs b/Utilities/MathematicalUtils.cs index bee4e29d61..0c8af6d4d2 100644 --- a/Utilities/MathematicalUtils.cs +++ b/Utilities/MathematicalUtils.cs @@ -199,6 +199,14 @@ namespace CalamityMod return dividend - (float)Math.Floor(dividend / divisor) * divisor; } + /// + /// Clamps the magnitude of a vector via safe normalization. + /// + /// The vector. + /// The minimum magnitude. + /// The maximum magnitude. + public static Vector2 ClampMagnitude(this Vector2 v, float min, float max) => v.SafeNormalize(Vector2.UnitY) * MathHelper.Clamp(v.Length(), min, max); + #region Easings /// /// Gets a value from 0 to 1 and returns an eased value.