diff --git a/Buffs/Summon/IceClasperBuff.png b/Buffs/Summon/IceClasperBuff.png index 19db922ca6..c7db062669 100644 Binary files a/Buffs/Summon/IceClasperBuff.png and b/Buffs/Summon/IceClasperBuff.png differ diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index a18f47c540..b464d44c03 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -573,6 +573,9 @@ namespace CalamityMod.Items if (item.type == ItemID.FrozenTurtleShell) EditTooltipByNum(0, (line) => line.Text = "Puts a shell around the owner when below 50% life that reduces damage by 15%"); + if (item.type == ItemID.FrozenShield) + EditTooltipByNum(1, (line) => line.Text = "Puts a shell around the owner when below 50% life that reduces damage by 15%"); + // Ale and Sake rebalance. if (item.type == ItemID.Ale || item.type == ItemID.Sake) EditTooltipByNum(0, (line) => line.Text = "Increases melee damage and speed by 10% and reduces defense by 10%"); diff --git a/Items/Weapons/Rogue/WaveSkipper.cs b/Items/Weapons/Rogue/WaveSkipper.cs index bea3fd5ab7..d53d7ff8c4 100644 --- a/Items/Weapons/Rogue/WaveSkipper.cs +++ b/Items/Weapons/Rogue/WaveSkipper.cs @@ -9,10 +9,12 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue -{ +{ [LegacyName("DuneHopper")] public class WaveSkipper : RogueWeapon { + public static int SpreadAngle = 8; + public override void SetDefaults() { Item.width = 44; @@ -27,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.height = 44; Item.value = CalamityGlobalItem.Rarity5BuyPrice; Item.rare = ItemRarityID.Pink; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 12f; Item.DamageType = RogueDamageClass.Instance; } @@ -36,12 +38,10 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int numProj = 3; - float rotation = MathHelper.ToRadians(3); - for (int i = 0; i < numProj; i++) + for (int i = -SpreadAngle; i < SpreadAngle * 2; i += SpreadAngle) { - Vector2 perturbedSpeed = new Vector2(velocity.X - 3f, velocity.Y - 3f).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - int stealth = Projectile.NewProjectile(source, position, perturbedSpeed, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + Vector2 spreadVelocity = player.SafeDirectionTo(Main.MouseWorld).RotatedBy(MathHelper.ToRadians(i)) * Item.shootSpeed; + int stealth = Projectile.NewProjectile(source, position, spreadVelocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); if (stealth.WithinBounds(Main.maxProjectiles)) Main.projectile[stealth].Calamity().stealthStrike = true; } diff --git a/Items/Weapons/Summon/AncientIceChunk.cs b/Items/Weapons/Summon/AncientIceChunk.cs index 64d477aec4..746906a0d5 100644 --- a/Items/Weapons/Summon/AncientIceChunk.cs +++ b/Items/Weapons/Summon/AncientIceChunk.cs @@ -1,7 +1,6 @@ using Terraria.DataStructures; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,10 +9,24 @@ namespace CalamityMod.Items.Weapons.Summon { public class AncientIceChunk : ModItem, ILocalizedModType { + #region Other stats + + public static int IFrames = 20; + public static float EnemyDistanceDetection = 1200f; + public static float MaxDistanceFromOwner = 400f; // Max distance the minions can be while shooting or idling. + public static float DistanceToDash = 250f; // Min distance to start dashing. + public static float DistanceToStopDash = 800f; // Max distance the player can be so the minions continue dashing. + public static float MinVelocity = 12f; + public static float TimeToShoot = 80f; // In frames. + public static float ProjectileDMGMultiplier = 1.5f; // They're kinda' weak. + + #endregion + public new string LocalizationCategory => "Items.Weapons.Summon"; + public override void SetDefaults() { - Item.damage = 31; + Item.damage = 25; Item.mana = 10; Item.width = 30; Item.height = 30; @@ -26,35 +39,12 @@ namespace CalamityMod.Items.Weapons.Summon Item.UseSound = SoundID.Item30; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (player.gravDir == -1f) - { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; - } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) - { - num78 = (float)player.direction; - } - else - { - num80 = num72 / num80; - } - num78 = 0f; - num79 = 0f; - vector2.X = (float)Main.mouseX + Main.screenPosition.X; - vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; - int clasper = Projectile.NewProjectile(source, vector2.X, vector2.Y, num78, num79, type, damage, knockback, player.whoAmI, 0f, 0f); + int clasper = Projectile.NewProjectile(source, Main.MouseWorld, new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f)), type, damage, knockback, player.whoAmI); if (Main.projectile.IndexInRange(clasper)) Main.projectile[clasper].originalDamage = Item.damage; diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 30b1d1de04..4fcd7f1ae2 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -1285,7 +1285,7 @@ RampartofDeities: { ''' Causes stars to fall and gives increased immune time when damaged Provides life regeneration and reduces the cooldown of healing potions - Absorbs 25% of damage done to players on your team + Absorbs 15% of damage done to players on your team This effect is only active above 25% life Grants immunity to knockback Puts a shell around the owner when below 50% life that reduces damage taken diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson index 5ce50790c2..b5ac9707bc 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson @@ -12,7 +12,12 @@ AbandonedSlimeStaff: { AncientIceChunk: { DisplayName: Ancient Ice Chunk - Tooltip: Summons an ice clasper to fight for you + Tooltip: + ''' + Summons an ice clasper to fight for you + The clasper fires ice shards at distant enemies + While you are close to enemies, it will aggressively bash them with frozen fury + ''' } AquasScepter: { diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Enemy.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Enemy.hjson index 57d92e02b8..cd628cecf4 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Enemy.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Enemy.hjson @@ -35,4 +35,4 @@ SulphuricAcidMist.DisplayName: Acid Mist TornadoHostile.DisplayName: Tornado ToxicMinnowCloud.DisplayName: Toxic Cloud TrilobiteSpike.DisplayName: Spike -IceClasperProjectile.DisplayName: Ice Clasper Projectile \ No newline at end of file +IceClasperEnemyProjectile.DisplayName: Ice Shard \ No newline at end of file diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson index 86b010913a..b48f4563d9 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson @@ -80,7 +80,6 @@ DestructionStar.DisplayName: Star of Destruction DragonShit.DisplayName: Fire DukesDecapitatorBubble.DisplayName: Bubble DukesDecapitatorProj.DisplayName: Decapitator -DuneHopperProjectile.DisplayName: Scourge DuststormCloud.DisplayName: Dust Cloud DuststormCloudStealth.DisplayName: Dust Cloud DuststormInABottleProj.DisplayName: Duststorm @@ -322,4 +321,5 @@ WebBallBol.DisplayName: Web Ball WrathwingCinder.DisplayName: Wrathwing Eruption WrathwingFireball.DisplayName: Wrathwing Fireball WrathwingSpear.DisplayName: Wrathwing -WulfrumKnifeProj.DisplayName: Knife \ No newline at end of file +WulfrumKnifeProj.DisplayName: Knife +WaveSkipperProjectile.DisplayName: Scourge \ No newline at end of file diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson index 5781200a58..37168b1091 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson @@ -296,4 +296,5 @@ WulfrumDroid.DisplayName: Wulfrum Droid WulfrumEnergyBurst.DisplayName: Bolt WulfrumFusionBolt.DisplayName: Fusion Bolt YharonMinionFireball.DisplayName: Dragon Fireball -YoungDuke.DisplayName: Young Old Duke \ No newline at end of file +YoungDuke.DisplayName: Young Old Duke +IceClasperSummonProjectile.DisplayName: Ice Shard \ No newline at end of file diff --git a/NPCs/NormalNPCs/IceClasper.cs b/NPCs/NormalNPCs/IceClasper.cs index 3311ca099e..d2194ecbea 100644 --- a/NPCs/NormalNPCs/IceClasper.cs +++ b/NPCs/NormalNPCs/IceClasper.cs @@ -13,6 +13,7 @@ using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; using Terraria.GameContent; +using System.IO; namespace CalamityMod.NPCs.NormalNPCs { @@ -50,14 +51,15 @@ namespace CalamityMod.NPCs.NormalNPCs public float MaxVelocity = 10f; public float DistanceFromPlayer = 500f; + // Although it is weird that Death Mode less projectiles, the AI also changes, making it a shotgun spread of 3 projectiles, so it'd be 2*3. public float AmountOfProjectiles = (CalamityWorld.death) ? 2f : (CalamityWorld.revenge) ? 4f : (Main.expertMode) ? 3f : 3f; - public float TimeBetweenProjectiles = (CalamityWorld.death) ? 50f : (CalamityWorld.revenge) ? 25f : (Main.expertMode) ? 35f : 45f; + public float TimeBetweenProjectiles = (CalamityWorld.death) ? 50f : (CalamityWorld.revenge) ? 35f : (Main.expertMode) ? 40f : 45f; public float TimeBetweenBurst = (CalamityWorld.death) ? 240f : 180f; - public float ProjectileSpeed = 10f; + public float ProjectileSpeed = 8f; public float TimeBeforeDash = (CalamityWorld.revenge) ? 100f : 120f; public float TimeDashing = 100f; - public float DashSpeed = 8f; + public float DashSpeed = 6f; #endregion @@ -81,8 +83,8 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 50; NPC.height = 50; NPC.defense = 12; - NPC.lifeMax = 600; - NPC.knockBackResist = 0.35f; + NPC.lifeMax = 500; + NPC.knockBackResist = 0.25f; NPC.noTileCollide = true; NPC.aiStyle = -1; AIType = -1; @@ -109,6 +111,18 @@ namespace CalamityMod.NPCs.NormalNPCs }); } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(rotationDir); + writer.Write(checkedRotationDir); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + rotationDir = reader.ReadInt32(); + checkedRotationDir = reader.ReadBoolean(); + } + public override void AI() { if (NPC.target < 0 || NPC.target == Main.maxPlayers || player.dead || !player.active) @@ -141,6 +155,7 @@ namespace CalamityMod.NPCs.NormalNPCs { rotationDir = (Main.rand.NextBool(2)).ToDirectionInt(); checkedRotationDir = true; + NPC.netUpdate = true; } Vector2 shootingPos = player.Center + new Vector2(MathF.Cos(RotationIncrease) * rotationDir, MathF.Sin(RotationIncrease) * rotationDir) * DistanceFromPlayer; @@ -148,6 +163,8 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.velocity = Vector2.Lerp(NPC.velocity, (shootingPos - NPC.Center).SafeNormalize(Vector2.Zero) * 6f, .1f); NPC.velocity = Vector2.Clamp(NPC.velocity, new Vector2(-MaxVelocity, -MaxVelocity), new Vector2(MaxVelocity, MaxVelocity)); + + NPC.netUpdate = true; } public void State_Shooting(Player player) @@ -164,6 +181,7 @@ namespace CalamityMod.NPCs.NormalNPCs { Vector2 vecToPlayer = NPC.SafeDirectionTo(player.Center); Vector2 projVelocity = vecToPlayer * ProjectileSpeed; + int type = ModContent.ProjectileType(); // If Death Mode on, the enemy will shoot out a spead of projectiles, instead of a burst. if (death) @@ -174,23 +192,25 @@ namespace CalamityMod.NPCs.NormalNPCs int projectile = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projVelocity.SafeNormalize(Vector2.Zero) * 10f, spreadVelocity, - ModContent.ProjectileType(), + type, 24, 0f, Main.myPlayer); Main.projectile[projectile].timeLeft = 300; } + NPC.netUpdate = true; } else { int projectile = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projVelocity.SafeNormalize(Vector2.Zero) * 10f, projVelocity, - ModContent.ProjectileType(), + type, 24, 0f, Main.myPlayer); Main.projectile[projectile].timeLeft = 300; + NPC.netUpdate = true; } // Recoil effect when shooting. @@ -215,8 +235,9 @@ namespace CalamityMod.NPCs.NormalNPCs else if (AITimer >= TimeBetweenBurst / 2f && AITimer < TimeBetweenBurst) { Vector2 randPos = Main.rand.NextVector2CircularEdge(100f, 100f); - Dust telegraphDust = Dust.NewDustPerfect(NPC.Center + randPos, 172, NPC.DirectionFrom(NPC.Center + NPC.velocity + randPos) * Main.rand.NextFloat(5f, 7f)); + Dust telegraphDust = Dust.NewDustPerfect(NPC.Center + randPos, 172, NPC.DirectionFrom(NPC.Center + NPC.velocity + randPos) * Main.rand.NextFloat(5f, 7f), 0, default, 1.5f); telegraphDust.noGravity = true; + NPC.netUpdate = true; } } @@ -293,6 +314,8 @@ namespace CalamityMod.NPCs.NormalNPCs } } + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => (isDashing) ? true : false; + public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ModContent.ItemType()); @@ -318,7 +341,7 @@ namespace CalamityMod.NPCs.NormalNPCs { for (int i = 0; i < NPC.oldPos.Length; i++) { - Color afterimageDrawColor = Color.Cyan with { A = 125 } * NPC.Opacity * (1f - i / (float)NPC.oldPos.Length) * AfterimageFade; + Color afterimageDrawColor = new Color(0.79f, 0.94f, 0.98f) with { A = 125 } * NPC.Opacity * (1f - i / (float)NPC.oldPos.Length) * AfterimageFade; Vector2 afterimageDrawPosition = NPC.oldPos[i] + NPC.Size * 0.5f - screenPos; spriteBatch.Draw(texture, afterimageDrawPosition, NPC.frame, afterimageDrawColor, NPC.rotation - MathHelper.PiOver2, origin, NPC.scale, SpriteEffects.None, 0f); } diff --git a/Projectiles/Enemy/IceClasperProjectile.cs b/Projectiles/Enemy/IceClasperEnemyProjectile.cs similarity index 96% rename from Projectiles/Enemy/IceClasperProjectile.cs rename to Projectiles/Enemy/IceClasperEnemyProjectile.cs index d7fd7b7b26..6272399762 100644 --- a/Projectiles/Enemy/IceClasperProjectile.cs +++ b/Projectiles/Enemy/IceClasperEnemyProjectile.cs @@ -6,7 +6,7 @@ using Microsoft.Xna.Framework; namespace CalamityMod.Projectiles.Enemy { - public class IceClasperProjectile : ModProjectile, ILocalizedModType + public class IceClasperEnemyProjectile : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Enemy"; diff --git a/Projectiles/Rogue/DuneHopperProjectile.cs b/Projectiles/Rogue/WaveSkipperProjectile.cs similarity index 94% rename from Projectiles/Rogue/DuneHopperProjectile.cs rename to Projectiles/Rogue/WaveSkipperProjectile.cs index de56b54683..3d1277da7d 100644 --- a/Projectiles/Rogue/DuneHopperProjectile.cs +++ b/Projectiles/Rogue/WaveSkipperProjectile.cs @@ -2,9 +2,11 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Rogue { - public class DuneHopperProjectile : ModProjectile, ILocalizedModType + [LegacyName("DuneHopperProjectile")] + public class WaveSkipperProjectile : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Items/Weapons/Rogue/WaveSkipper"; diff --git a/Projectiles/Summon/IceClasperMinion.cs b/Projectiles/Summon/IceClasperMinion.cs index 78840b49c8..afcf7f17d3 100644 --- a/Projectiles/Summon/IceClasperMinion.cs +++ b/Projectiles/Summon/IceClasperMinion.cs @@ -1,102 +1,269 @@ using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Summon; using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework.Graphics; +using Terraria.Audio; namespace CalamityMod.Projectiles.Summon { public class IceClasperMinion : ModProjectile, ILocalizedModType { - public new string LocalizationCategory => "Projectiles.Summon"; + public Player Owner => Main.player[Projectile.owner]; - private int dust = 3; + public CalamityPlayer ModdedOwner => Owner.Calamity(); + + public enum IceClasperAIState + { + FollowOwner, + Ram + } + + public IceClasperAIState CurrentState + { + get => (IceClasperAIState)Projectile.ai[0]; + set => Projectile.ai[0] = (int)value; + } + + public ref float TimerForShooting => ref Projectile.ai[1]; + + public ref float AfterimageInterpolant => ref Projectile.localAI[0]; + + public bool hasSpawned = false; + + public new string LocalizationCategory => "Projectiles.Summon"; public override void SetStaticDefaults() { Main.projFrames[Projectile.type] = 6; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 6; ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; ProjectileID.Sets.MinionTargettingFeature[Projectile.type] = true; } public override void SetDefaults() { - Projectile.width = 30; - Projectile.height = 30; + Projectile.localNPCHitCooldown = AncientIceChunk.IFrames; + Projectile.minionSlots = 1f; + Projectile.penetrate = -1; + Projectile.coldDamage = true; + + Projectile.width = 62; + Projectile.height = 62; + Projectile.DamageType = DamageClass.Summon; + Projectile.usesLocalNPCImmunity = true; + Projectile.minion = true; Projectile.netImportant = true; Projectile.friendly = true; Projectile.ignoreWater = true; - Projectile.minionSlots = 1f; - Projectile.timeLeft = 18000; - Projectile.penetrate = -1; Projectile.tileCollide = false; - Projectile.timeLeft *= 5; - Projectile.minion = true; - Projectile.coldDamage = true; - Projectile.DamageType = DamageClass.Summon; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 16; } public override void AI() - { - Player player = Main.player[Projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - if (dust > 0) + { + CheckMinionExistence(); + + if (!hasSpawned) { - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) - { - Vector2 vector6 = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + Projectile.Center; - Vector2 vector7 = vector6 - Projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 67, vector7.X * 1.75f, vector7.Y * 1.75f, 100, default, 1.1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].velocity = vector7; - } - dust--; - } - Projectile.frameCounter++; - if (Projectile.frameCounter > 6) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame > 5) - { - Projectile.frame = 0; - } - Lighting.AddLight((int)(Projectile.Center.X / 16f), (int)(Projectile.Center.Y / 16f), 0.05f, 0.15f, 0.2f); - bool flag64 = Projectile.type == ModContent.ProjectileType(); - player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) - { - if (player.dead) - { - modPlayer.iClasper = false; - } - if (modPlayer.iClasper) - { - Projectile.timeLeft = 2; - } + SpawnEffect(); + hasSpawned = true; } - Projectile.ChargingMinionAI(1200f, 1500f, 2200f, 150f, 0, 12f, 9f, 4f, new Vector2(0f, -60f), 12f, 18f, true, true, 2); + // Detects a target at a given distance. + NPC potentialTarget = Projectile.Center.MinionHoming(AncientIceChunk.EnemyDistanceDetection, Owner); + switch (CurrentState) + { + case IceClasperAIState.FollowOwner: + State_FollowOwner(potentialTarget); + break; + case IceClasperAIState.Ram: + State_Ram(potentialTarget); + break; + } - Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; + // Flavor dust visual to show that it is ghostly. + if (Main.rand.NextBool(10)) + { + int ghostDust = Dust.NewDust(Projectile.position, 31, 62, 56, -0.5f * Projectile.rotation.ToRotationVector2().X, -0.5f * Projectile.rotation.ToRotationVector2().Y); + Main.dust[ghostDust].noLight = true; + Main.dust[ghostDust].noLightEmittence = true; + } + + DoAnimation(); + DoRotation(potentialTarget); + Lighting.AddLight(Projectile.Center, Color.Cyan.ToVector3()); + Projectile.MinionAntiClump(0.5f); } + #region Methods + + public void State_FollowOwner(NPC target) + { + // If the minion starts to get far, force the minion to go to you. + if (Projectile.WithinRange(Owner.Center, AncientIceChunk.EnemyDistanceDetection) && !Projectile.WithinRange(Owner.Center, AncientIceChunk.MaxDistanceFromOwner + 100f)) + { + Projectile.velocity = (Owner.Center - Projectile.Center) / 30f; + Projectile.netUpdate = true; + } + + // The minion will change directions to you if it's going away from you, meaning it'll just hover around you. + else if (!Projectile.WithinRange(Owner.Center, AncientIceChunk.MaxDistanceFromOwner)) + { + Projectile.velocity = (Projectile.velocity * 37f + Projectile.SafeDirectionTo(Owner.Center) * 17f) / 40f; + Projectile.netUpdate = true; + } + + // Teleport to the owner if sufficiently far away. + if (!Projectile.WithinRange(Owner.Center, AncientIceChunk.EnemyDistanceDetection)) + { + Projectile.Center = Owner.Center; + Projectile.velocity *= .3f; + Projectile.netUpdate = true; + } + + // If the target is not null but not in range to dash: shoot. + // If in range to dash: dash. + if (target is not null) + { + if (Owner.WithinRange(target.Center, AncientIceChunk.DistanceToDash)) + { + CurrentState = IceClasperAIState.Ram; + Projectile.netUpdate = true; + } + else + ShootTarget(target); + } + } + + public void State_Ram(NPC target) + { + // If there's no target while dashing or the player's gone far enough from the target: back to shooting. + if (target is null || !Owner.WithinRange(Projectile.Center, AncientIceChunk.DistanceToStopDash)) + { + CurrentState = IceClasperAIState.FollowOwner; + Projectile.netUpdate = true; + } + else if (target is not null) + { + // The distance to the target plus a small number so it's not 0, it'd break calculations. + float distToTarget = Projectile.Distance(target.Center) + .01f; + + // The minion will head towards it's rotation. + // If the target's close, the minion'll speed up, and viceversa, so it doesn't circle around the target doing nothing. + Projectile.velocity = Projectile.rotation.ToRotationVector2() * (AncientIceChunk.MinVelocity + (12f / (distToTarget * .01f))); + Projectile.velocity = Vector2.Clamp(Projectile.velocity, Vector2.One * -25f, Vector2.One * 25f); + Projectile.rotation = Projectile.rotation.AngleTowards(Projectile.AngleTo(target.Center), .001f * distToTarget); + } + } + + public void ShootTarget(NPC target) + { + if (TimerForShooting >= AncientIceChunk.TimeToShoot && Projectile.owner == Main.myPlayer) + { + Vector2 velocity = CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, target, 20f); + + int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), + Projectile.Center, + velocity, + ModContent.ProjectileType(), + (int)(Projectile.damage * AncientIceChunk.ProjectileDMGMultiplier), + Projectile.knockBack, + Projectile.owner); + + if (Main.projectile.IndexInRange(p)) + Main.projectile[p].originalDamage = (int)(Projectile.originalDamage * AncientIceChunk.ProjectileDMGMultiplier); + + // Flavor recoil effect. + Projectile.velocity -= velocity * .1f; + + // For the fucking love of any god you can think of, this sound sucks but I can't find another one that fits better. + SoundEngine.PlaySound(SoundID.Item28, Projectile.Center); + + TimerForShooting = 0f; + Projectile.netUpdate = true; + } + + if (TimerForShooting < AncientIceChunk.TimeToShoot) + TimerForShooting++; + } + + public void DoRotation(NPC target) + { + if (target is null) + Projectile.rotation = Projectile.rotation.AngleTowards(Projectile.velocity.ToRotation(), .15f); + else if (target is not null && !Projectile.WithinRange(target.Center, AncientIceChunk.DistanceToDash)) + Projectile.rotation = Projectile.rotation.AngleTowards(Projectile.AngleTo(target.Center), .15f); + } + + public void DoAnimation() + { + Projectile.frameCounter++; + if (Projectile.frameCounter % 5 == 0) + Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Projectile.type]; + } + + public void CheckMinionExistence() + { + Owner.AddBuff(ModContent.BuffType(), 3600); + if (Projectile.type == ModContent.ProjectileType()) + { + if (Owner.dead) + ModdedOwner.iClasper = false; + if (ModdedOwner.iClasper) + Projectile.timeLeft = 2; + } + } + + public void SpawnEffect() + { + int dustAmt = 45; + for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) + { + float angle = MathHelper.TwoPi / dustAmt * dustIndex; + Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(3f, 7f); + Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, 56, velocity); + spawnDust.customData = false; + spawnDust.noGravity = true; + spawnDust.velocity *= .75f; + spawnDust.scale = velocity.Length() * .2f; + } + } + + public override bool? CanDamage() => (CurrentState == IceClasperAIState.Ram) ? null : false; + public override bool PreDraw(ref Color lightColor) { - Texture2D texture2D13 = ModContent.Request(Texture).Value; - int num214 = texture2D13.Height / Main.projFrames[Projectile.type]; - int y6 = num214 * Projectile.frame; - Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); + NPC target = Projectile.Center.MinionHoming(1200f, Owner); + + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + + // Flavor fade-in-and-out for afterimages. + AfterimageInterpolant += ((target is not null && Owner.WithinRange(target.Center, 450f)) || CurrentState == IceClasperAIState.Ram) ? .05f : -.05f; + AfterimageInterpolant = MathHelper.Clamp(AfterimageInterpolant, 0f, 1f); + float AfterimageFade = MathHelper.Lerp(0f, 1f, AfterimageInterpolant); + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + Color afterimageDrawColor = new Color(0.05f, 0.33f, 0.63f) with { A = 25 } * Projectile.Opacity * (1f - i / (float)Projectile.oldPos.Length) * AfterimageFade; + Vector2 afterimageDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; + Main.EntitySpriteDraw(texture, afterimageDrawPosition, frame, afterimageDrawColor, Projectile.rotation - MathHelper.PiOver2, origin, Projectile.scale, SpriteEffects.None, 0); + } + } + + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation - MathHelper.PiOver2, origin, Projectile.scale, SpriteEffects.None, 0); + return false; } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.immune[Projectile.owner] = 7; + #endregion } } diff --git a/Projectiles/Summon/IceClasperMinion.png b/Projectiles/Summon/IceClasperMinion.png index 5d35882b80..bfdea9a04e 100644 Binary files a/Projectiles/Summon/IceClasperMinion.png and b/Projectiles/Summon/IceClasperMinion.png differ diff --git a/Projectiles/Summon/IceClasperSummonProjectile.cs b/Projectiles/Summon/IceClasperSummonProjectile.cs new file mode 100644 index 0000000000..ea14bbdde1 --- /dev/null +++ b/Projectiles/Summon/IceClasperSummonProjectile.cs @@ -0,0 +1,56 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class IceClasperSummonProjectile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + + public Player Owner => Main.player[Projectile.owner]; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionShot[Projectile.type] = true; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 5; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + + public override void SetDefaults() + { + Projectile.idStaticNPCHitCooldown = 10; + Projectile.timeLeft = 300; + + Projectile.width = 28; + Projectile.height = 28; + Projectile.DamageType = DamageClass.Summon; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.minion = true; + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + int trailDust = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 172, Projectile.velocity.X, Projectile.velocity.Y, 0, default, 1.5f); + Main.dust[trailDust].noGravity = true; + + Lighting.AddLight(Projectile.Center, Color.Cyan.ToVector3()); + } + + public override bool OnTileCollide(Vector2 oldVelocity) => false; + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Frostburn, 180); + + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); + return true; + } + } +} diff --git a/Projectiles/Summon/IceClasperSummonProjectile.png b/Projectiles/Summon/IceClasperSummonProjectile.png new file mode 100644 index 0000000000..98bedb5a00 Binary files /dev/null and b/Projectiles/Summon/IceClasperSummonProjectile.png differ