diff --git a/Buffs/Summon/KingofConstellationsBuff.cs b/Buffs/Summon/KingofConstellationsBuff.cs new file mode 100644 index 0000000000..bb837dd790 --- /dev/null +++ b/Buffs/Summon/KingofConstellationsBuff.cs @@ -0,0 +1,35 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class KingofConstellationsBuff : ModBuff + { + public override void SetStaticDefaults() + { + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 || player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + modPlayer.celestialDragons = true; + } + if (!modPlayer.celestialDragons) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/KingofConstellationsBuff.png b/Buffs/Summon/KingofConstellationsBuff.png new file mode 100644 index 0000000000..2cfd99f961 Binary files /dev/null and b/Buffs/Summon/KingofConstellationsBuff.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index be4dd39b27..b0c8396301 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -971,6 +971,7 @@ namespace CalamityMod.CalPlayer public bool perditionBeacon = false; public bool MoonFist = false; public bool AresCannons = false; + public bool celestialDragons = false; public List PendingProjectilesToRespawn = new List(); @@ -2001,6 +2002,7 @@ namespace CalamityMod.CalPlayer perditionBeacon = false; MoonFist = false; AresCannons = false; + celestialDragons = false; disableVoodooSpawns = false; disablePerfCystSpawns = false; diff --git a/Items/Weapons/Ranged/DeepcoreGK2.cs b/Items/Weapons/Ranged/DeepcoreGK2.cs new file mode 100644 index 0000000000..ab7b26c421 --- /dev/null +++ b/Items/Weapons/Ranged/DeepcoreGK2.cs @@ -0,0 +1,52 @@ +using Terraria.DataStructures; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Ranged +{ + public class DeepcoreGK2 : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public override void SetDefaults() + { + Item.damage = 45; + Item.ArmorPenetration = 15; + Item.DamageType = DamageClass.Ranged; + Item.noMelee = true; + Item.width = 142; + Item.height = 64; + Item.useTime = Item.useAnimation = 16; + Item.useStyle = ItemUseStyleID.Shoot; + Item.knockBack = 7f; + Item.value = CalamityGlobalItem.Rarity5BuyPrice; + Item.rare = ItemRarityID.Pink; + Item.UseSound = SoundID.Item38; + Item.autoReuse = true; + Item.shoot = ProjectileID.Bullet; + Item.shootSpeed = 20f; + Item.useAmmo = AmmoID.Bullet; + Item.Calamity().donorItem = true; + Item.Calamity().canFirePointBlankShots = true; + } + + public override Vector2? HoldoutOffset() => new Vector2(-20, 0); + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Vector2 shootDirection = velocity.SafeNormalize(Vector2.UnitX * player.direction); + Vector2 gunTip = position + shootDirection * Item.scale * 120f; + gunTip.Y -= 18f; + + int p = Projectile.NewProjectile(source, gunTip, velocity, type, damage, knockback, player.whoAmI); + if (p.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[p].Calamity().deepcoreBullet = true; + Main.projectile[p].scale = 2; + } + return false; + } + } +} diff --git a/Items/Weapons/Ranged/DeepcoreGK2.png b/Items/Weapons/Ranged/DeepcoreGK2.png new file mode 100644 index 0000000000..e651e6d6fa Binary files /dev/null and b/Items/Weapons/Ranged/DeepcoreGK2.png differ diff --git a/Items/Weapons/Summon/KingofConstellationsTenryu.cs b/Items/Weapons/Summon/KingofConstellationsTenryu.cs new file mode 100644 index 0000000000..1630c5da10 --- /dev/null +++ b/Items/Weapons/Summon/KingofConstellationsTenryu.cs @@ -0,0 +1,77 @@ +using Terraria.DataStructures; +using CalamityMod.Items.Materials; +using CalamityMod.Rarities; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class KingofConstellationsTenryu : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Summon"; + + public override void SetDefaults() + { + Item.mana = 10; + Item.damage = 213; + Item.useStyle = ItemUseStyleID.HoldUp; + Item.shootSpeed = 10f; + Item.shoot = ModContent.ProjectileType(); + Item.width = 44; + Item.height = 62; + Item.UseSound = Flare.FlareSound; + Item.useAnimation = Item.useTime = 25; + + Item.value = CalamityGlobalItem.Rarity12BuyPrice; + Item.rare = ModContent.RarityType(); + Item.Calamity().donorItem = true; + + Item.noMelee = true; + Item.knockBack = 2f; + Item.DamageType = DamageClass.Summon; + Item.autoReuse = true; + } + + public override Vector2? HoldoutOffset() + { + return new Vector2(-20, 0); + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0 && player.maxMinions >= 4; + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Vector2 spawnPos = new Vector2(player.position.X - 200, player.position.Y - 200); + Vector2 spawnPos2 = new Vector2(player.position.X + 200, player.position.Y - 200); + SpawnDragon(ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), spawnPos2, player, source, damage, knockback); + SpawnDragon(ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), spawnPos, player, source, damage, knockback); + return false; + } + + public static void SpawnDragon(int head, int body, int tail, Vector2 spawnPos, Player player, EntitySource_ItemUse_WithAmmo source, int damage, float knockback) + { + Projectile.NewProjectile(source, spawnPos, player.DirectionTo(Main.MouseWorld) * 3, head, damage, knockback, player.whoAmI); + Projectile.NewProjectile(source, spawnPos, Vector2.Zero * 3, tail, damage, knockback, player.whoAmI); + for (var i = 0; i < 20; i++) + { + Projectile.NewProjectile(source, spawnPos, Vector2.Zero * 3, body, damage, knockback, player.whoAmI); + } + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.StardustDragonStaff). + AddIngredient(ItemID.LightShard). + AddIngredient(ItemID.DarkShard). + AddIngredient(ModContent.ItemType(), 3). + AddTile(TileID.LunarCraftingStation). + Register(); + } + } +} + diff --git a/Items/Weapons/Summon/KingofConstellationsTenryu.png b/Items/Weapons/Summon/KingofConstellationsTenryu.png new file mode 100644 index 0000000000..a6dbe8424d Binary files /dev/null and b/Items/Weapons/Summon/KingofConstellationsTenryu.png differ diff --git a/Localization/en-US/Mods.CalamityMod.Buffs.hjson b/Localization/en-US/Mods.CalamityMod.Buffs.hjson index 32ec24c6a9..ca2c699258 100644 --- a/Localization/en-US/Mods.CalamityMod.Buffs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Buffs.hjson @@ -1217,6 +1217,11 @@ IgneousExaltationBuff: { Description: A blade is orbiting you } +KingofConstellationsBuff: { + DisplayName: Celestial Dragons + Description: The celestial dragons will protect you +} + LilPlaguebringerBuff: { DisplayName: Lil' Plaguebringer Description: The Plaguebringer will protect you diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index c855c69ff1..dcd5b80bc6 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -347,6 +347,15 @@ DarkechoGreatbow: { ''' } +DeepcoreGK2: { + DisplayName: Deepcore GK2 + Tooltip: + ''' + Bullets are twice as large and ignores 15 points of enemy defense + 'For rock and stone!' + ''' +} + Deathwind: { DisplayName: Deathwind Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson index 62efd3668d..5ce50790c2 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson @@ -449,6 +449,15 @@ InfectedRemote: { ''' } +KingofConstellationsTenryu: { + DisplayName: King of Constellations, Tenryū + Tooltip: + ''' + Uses 4 minion slots to summon a pair of celestial dragons to fight for you + 'The ones who will devour the Unmoving Star' + ''' +} + Metastasis: { DisplayName: Metastasis Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson index 54b20c22dc..5781200a58 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson @@ -27,6 +27,9 @@ BabyBloodCrawler.DisplayName: Baby Blood Crawler BabyPlaguebringer.DisplayName: Baby Plaguebringer BelladonnaPetal.DisplayName: Belladonna Petal BelladonnaSpirit.DisplayName: Belladonna Spirit +BlackDragonBody.DisplayName: Black Celestial Dragon +BlackDragonHead.DisplayName: Black Celestial Dragon +BlackDragonTail.DisplayName: Black Celestial Dragon BlackHawkBullet.DisplayName: Black Hawk Bullet BlackHawkSummon.DisplayName: Black Hawk BloodBreath.DisplayName: Fire @@ -284,6 +287,9 @@ VolcanicFireballSummon.DisplayName: Volcanic Fireball WaterElementalMinion.DisplayName: Anahita WaterElementalSong.DisplayName: Siren Song WaterSpearFriendly.DisplayName: Spear +WhiteDragonBody.DisplayName: White Celestial Dragon +WhiteDragonHead.DisplayName: White Celestial Dragon +WhiteDragonTail.DisplayName: White Celestial Dragon WitherBlossom.DisplayName: Wither Blossom WitherBolt.DisplayName: Wither Bolt WulfrumDroid.DisplayName: Wulfrum Droid diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 9cc33e6384..e185505d62 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -1175,6 +1175,7 @@ namespace CalamityMod sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), new List() { ProjectileType(), ProjectileType(), ProjectileType()}, new List() {1-(1f/3f), 2f/3f, 2f/3f}); //Entropy's Vigil is a bruh moment sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), new List() { ProjectileType(), ProjectileType()}); + sAssociation.Call("AddMinionInfo", ItemType(), BuffType(), new List() { ProjectileType(), ProjectileType() }); } } } diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index d1b33d55dc..af1f3402dd 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -1592,6 +1592,7 @@ namespace CalamityMod.NPCs .AddWithCustomValue(ItemID.SpelunkerPotion, Item.buyPrice(gold: 4), potionSells, Condition.HappyEnough, Condition.DownedEowOrBoc) .AddWithCustomValue(ItemID.ObsidianSkinPotion, Item.buyPrice(gold: 4), potionSells, Condition.HappyEnough, Condition.DownedSkeletron); AddScalingPotion(ref shop, ItemID.EndurancePotion, Condition.DownedSkeletron); + shop.Add(ModContent.ItemType(), Condition.DownedMechBossAny); } if (type == NPCID.ArmsDealer) diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index f00384285c..6be524fa4e 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -7,6 +7,7 @@ using CalamityMod.EntitySources; using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.NPCs; +using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; @@ -70,6 +71,9 @@ namespace CalamityMod.Projectiles // If true, this projectile can apply the infinitely-stacking Shred debuff iconic to Soma Prime. public bool appliesSomaShred = false; + // If true, this projectile creates impact sparks upon hitting enemies + public bool deepcoreBullet = false; + // Amount of extra updates that are set in SetDefaults. public int defExtraUpdates = -1; @@ -2532,6 +2536,24 @@ namespace CalamityMod.Projectiles if (!WorldUtils.Find(projectile.Center.ToTileCoordinates(), Searches.Chain(new Searches.Down(12), new Conditions.IsSolid()), out _)) modifiers.SourceDamage /= 1.5f; } + + // create sparks on hit to hammer in the defense shredding + if (deepcoreBullet) + { + if (Main.netMode != NetmodeID.Server) + { + Vector2 cen = Vector2.Lerp(projectile.Center, target.Center, 0.65f); + int numSparks = Main.rand.Next(2, 5); + for (int i = 0; i < numSparks; i++) + { + Vector2 sparkVelocity = projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(0.6f) * Main.rand.NextFloat(2f, 8f); + Color sparkColor = Color.Lerp(Color.AliceBlue, Color.DarkSlateBlue, Main.rand.NextFloat(0.7f)); + sparkColor = Color.Lerp(sparkColor, Color.CornflowerBlue, Main.rand.NextFloat()); + SparkParticle sparke = new(cen, -sparkVelocity, false, 10, 0.5f, sparkColor); + GeneralParticleHandler.SpawnParticle(sparke); + } + } + } } #endregion diff --git a/Projectiles/Summon/BlackDragonBody.cs b/Projectiles/Summon/BlackDragonBody.cs new file mode 100644 index 0000000000..ba5906b4e2 --- /dev/null +++ b/Projectiles/Summon/BlackDragonBody.cs @@ -0,0 +1,124 @@ +using CalamityMod.Buffs.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class BlackDragonBody : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + public int segmentIndex = 1; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionSacrificable[Type] = false; + ProjectileID.Sets.MinionTargettingFeature[Type] = true; + } + + public override void SetDefaults() + { + Projectile.timeLeft = 10; + Projectile.width = 26; + Projectile.height = 26; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 180; + Projectile.idStaticNPCHitCooldown = 4; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.tileCollide = false; + Projectile.extraUpdates = 0; + Projectile.aiStyle = -1; + Projectile.DamageType = DamageClass.Summon; + Projectile.netImportant = true; + Projectile.minion = true; + + } + + public override void OnSpawn(IEntitySource source) + { + foreach (var projectile in Main.projectile) + { + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + { + segmentIndex = projectile.ModProjectile().segmentIndex; + projectile.ModProjectile().segmentIndex++; + } + } + } + + public override void AI() + { + Player player = Main.player[Projectile.owner]; + if (player.Calamity().celestialDragons) + { + Projectile.timeLeft = 2; + } + } + + internal void SegmentMove() + { + Player player = Main.player[Projectile.owner]; + var live = false; + Projectile nextSegment = new Projectile(); + BlackDragonHead head = new BlackDragonHead(); + for (int i = 0; i < Main.maxProjectiles; i++) + { + var projectile = Main.projectile[i]; + if (projectile.type == Type && projectile.owner == Projectile.owner && projectile.active) + { + if (projectile.ModProjectile().segmentIndex == segmentIndex - 1) + { + live = true; + nextSegment = projectile; + } + } + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + { + if (segmentIndex == 1) + { + live = true; + nextSegment = projectile; + } + head = projectile.ModProjectile(); + } + } + if (!live) Projectile.Kill(); + Vector2 destinationOffset = nextSegment.Center+nextSegment.velocity - Projectile.Center; + if (nextSegment.rotation != Projectile.rotation) + { + float angle = MathHelper.WrapAngle(nextSegment.rotation - Projectile.rotation); + //destinationOffset = Projectile.Center.DirectionTo(nextSegment.Center); + destinationOffset = destinationOffset.RotatedBy(angle * 0.1f); + } + Projectile.rotation = destinationOffset.ToRotation(); + if (destinationOffset != Vector2.Zero) + { + Projectile.Center = nextSegment.Center+nextSegment.velocity - destinationOffset.SafeNormalize(Vector2.Zero) * 20f; + } + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + } + + public override void Kill(int timeLeft) + { + if (Main.player[Projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + var projectile = Main.projectile[i]; + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + { + projectile.Kill(); + } + } + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.ShadowFlame, 300); + } +} diff --git a/Projectiles/Summon/BlackDragonBody.png b/Projectiles/Summon/BlackDragonBody.png new file mode 100644 index 0000000000..81e1e1a23e Binary files /dev/null and b/Projectiles/Summon/BlackDragonBody.png differ diff --git a/Projectiles/Summon/BlackDragonBody2.png b/Projectiles/Summon/BlackDragonBody2.png new file mode 100644 index 0000000000..843053ffdd Binary files /dev/null and b/Projectiles/Summon/BlackDragonBody2.png differ diff --git a/Projectiles/Summon/BlackDragonHead.cs b/Projectiles/Summon/BlackDragonHead.cs new file mode 100644 index 0000000000..6b8a7ea608 --- /dev/null +++ b/Projectiles/Summon/BlackDragonHead.cs @@ -0,0 +1,220 @@ +using CalamityMod.Buffs.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + // HUGE credit to Dozezoze for lending his worm projectile code + public class BlackDragonHead : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + Dictionary segments = new Dictionary(); + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionSacrificable[Type] = true; + ProjectileID.Sets.MinionTargettingFeature[Type] = true; + } + + public override void SetDefaults() + { + Projectile.timeLeft = 10; + Projectile.width = 26; + Projectile.height = 26; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 180; + Projectile.localNPCHitCooldown = 30; + Projectile.usesLocalNPCImmunity = true; + Projectile.tileCollide = false; + Projectile.extraUpdates = 0; + Projectile.aiStyle = -1; + Projectile.DamageType = DamageClass.Summon; + Projectile.netImportant = true; + Projectile.minionSlots = 2; + Projectile.minion = true; + + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 100; + } + + public override void AI() + { + Player player = Main.player[Projectile.owner]; + player.AddBuff(ModContent.BuffType(), 1); + if (Projectile.type == ModContent.ProjectileType()) + { + if (player.dead) + { + player.Calamity().celestialDragons = false; + } + if (player.Calamity().celestialDragons) + { + Projectile.timeLeft = 2; + } + } + Projectile.ai[0]++; + // Hover to the left because evil is not right or something + Vector2 idealPos = new Vector2(player.Center.X - 200, player.Center.Y - 50); + float distanceFromOwner = Projectile.Distance(idealPos); + + if (distanceFromOwner > 3000) + { + Projectile.Center = player.Center; + Projectile.netUpdate = true; + } + + NPC target = CalamityUtils.MinionHoming(Projectile.position, 2500, player, true, true); + if (target != null && Projectile.position.Distance(player.position) <= 2500) + { + AttackTarget(target); + } + else + { + float hoverAcceleration = 0.2f; + if (distanceFromOwner < 200f) + hoverAcceleration = 0.12f; + if (distanceFromOwner < 140f) + hoverAcceleration = 0.06f; + + if (distanceFromOwner > 100f) + { + if (Math.Abs(player.Center.X - Projectile.Center.X) > 20f) + Projectile.velocity.X += hoverAcceleration * Math.Sign(idealPos.X - Projectile.Center.X); + if (Math.Abs(player.Center.Y - Projectile.Center.Y) > 10f) + Projectile.velocity.Y += hoverAcceleration * Math.Sign(idealPos.Y - Projectile.Center.Y); + } + else if (Projectile.velocity.Length() > 1f) + Projectile.velocity *= 0.96f; + + if (Math.Abs(Projectile.velocity.Y) < 1f) + Projectile.velocity.Y -= 0.1f; + + if (Projectile.velocity.Length() > 25) + Projectile.velocity = Vector2.Normalize(Projectile.velocity) * 25; + } + + Projectile.rotation = Projectile.velocity.ToRotation(); + segments.Clear(); + foreach (var projectile in Main.projectile) + { + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active && !segments.ContainsKey(projectile.ModProjectile().segmentIndex)) + { + segments.Add(projectile.ModProjectile().segmentIndex, projectile); + } + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active && !segments.ContainsKey(projectile.ModProjectile().segmentIndex)) + { + segments.Add(projectile.ModProjectile().segmentIndex, projectile); + } + } + for (var i = 1; i <= segments.Count; i++) + { + if (i < segments.Count) + { + if (segments.ContainsKey(i)) + segments[i].ModProjectile().SegmentMove(); + } + else + { + if (segments.ContainsKey(i)) + segments[i].ModProjectile().SegmentMove(); + } + } + } + internal void AttackTarget(NPC target) + { + + float idealFlyAcceleration = 0.18f; + + Vector2 destination = target.Center; + float distanceFromDestination = Projectile.Distance(destination); + + // Get a swerve effect if somewhat far from the target. + if (Projectile.Distance(destination) > 425f) + { + Projectile.ai[2] = 0; + destination += (Projectile.ai[0] % 30f / 30f * MathHelper.TwoPi).ToRotationVector2() * 145f; + distanceFromDestination = Projectile.Distance(destination); + idealFlyAcceleration *= 2.5f; + } + + // Charge if the target is far away. + if (distanceFromDestination > 1500f) + idealFlyAcceleration = MathHelper.Min(6f, Projectile.ai[1] + 1f); + + Projectile.ai[1] = MathHelper.Lerp(Projectile.ai[1], idealFlyAcceleration, 0.3f); + + float directionToTargetOrthogonality = Vector2.Dot(Projectile.velocity.SafeNormalize(Vector2.Zero), Projectile.SafeDirectionTo(destination)); + + // Fly towards the target if it's far. + if (distanceFromDestination > 320f) + { + float speed = Projectile.velocity.Length(); + if (speed < 23f) + speed += 0.08f; + + if (speed > 32f) + speed -= 0.08f; + + // Go faster if the line of sight is aiming closely at the target. + if (directionToTargetOrthogonality < 0.85f && directionToTargetOrthogonality > 0.5f) + speed += 16f; + + // And go slower otherwise so that the dragon can angle towards the target more accurately. + if (directionToTargetOrthogonality < 0.5f && directionToTargetOrthogonality > -0.7f) + speed -= 16f; + + speed = MathHelper.Clamp(speed, 16f, 34f); + + Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.AngleTo(destination), Projectile.ai[1]).ToRotationVector2() * speed; + + // failsafe to prevent orbiting + Projectile.ai[2]++; + if (Projectile.ai[2] >= 90) + { + Projectile.velocity = Projectile.DirectionTo(destination) * 30; + Projectile.ai[2] = 0; + } + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = ModContent.Request(Texture).Value; + Texture2D texBody = ModContent.Request("CalamityMod/Projectiles/Summon/BlackDragonBody").Value; + Texture2D texBody2 = ModContent.Request("CalamityMod/Projectiles/Summon/BlackDragonBody2").Value; + Texture2D texTail = ModContent.Request("CalamityMod/Projectiles/Summon/BlackDragonTail").Value; + Texture2D texTail2 = ModContent.Request("CalamityMod/Projectiles/Summon/BlackDragonTail2").Value; + for (var i = segments.Count; i > 0; i--) + { + if (segments.ContainsKey(i)) + { + SpriteEffects fx = Math.Abs(segments[i].rotation) > MathHelper.PiOver2 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + if (i < segments.Count - 1) + { + Main.EntitySpriteDraw((i == 5 || i == 12) ? texBody2 : texBody, segments[i].Center - Main.screenPosition, null, segments[i].GetAlpha(lightColor), segments[i].rotation + MathHelper.Pi / 2f, texBody.Size() / 2f, segments[i].scale, fx, 0); + } + else if (i < segments.Count) + { + Main.EntitySpriteDraw(texTail, segments[i].Center - Main.screenPosition, null, segments[i].GetAlpha(lightColor), segments[i].rotation + MathHelper.Pi / 2f, texBody.Size() / 2f, segments[i].scale, fx, 0); + } + else + { + Main.EntitySpriteDraw(texTail2, segments[i].Center - Main.screenPosition - new Vector2(10, 0).RotatedBy(segments[i].rotation), null, segments[i].GetAlpha(lightColor), segments[i].rotation + MathHelper.Pi / 2f, texTail.Size() / 2f, segments[i].scale, fx, 0); + + } + } + } + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation + MathHelper.Pi / 2f, tex.Size() / 2f, Projectile.scale, Projectile.velocity.X > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); + return false; + + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.ShadowFlame, 300); + } +} diff --git a/Projectiles/Summon/BlackDragonHead.png b/Projectiles/Summon/BlackDragonHead.png new file mode 100644 index 0000000000..9f5c41f47a Binary files /dev/null and b/Projectiles/Summon/BlackDragonHead.png differ diff --git a/Projectiles/Summon/BlackDragonTail.cs b/Projectiles/Summon/BlackDragonTail.cs new file mode 100644 index 0000000000..c995b595d4 --- /dev/null +++ b/Projectiles/Summon/BlackDragonTail.cs @@ -0,0 +1,112 @@ +using CalamityMod.Buffs.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class BlackDragonTail : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + public int segmentIndex = 1; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionSacrificable[Type] = false; + ProjectileID.Sets.MinionTargettingFeature[Type] = true; + } + + public override void SetDefaults() + { + Projectile.timeLeft = 10; + Projectile.width = 26; + Projectile.height = 26; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 180; + Projectile.localNPCHitCooldown = 30; + Projectile.usesLocalNPCImmunity = true; + Projectile.tileCollide = false; + Projectile.extraUpdates = 0; + Projectile.aiStyle = -1; + Projectile.DamageType = DamageClass.Summon; + Projectile.netImportant = true; + Projectile.minion = true; + + } + public override void AI() + { + Player player = Main.player[Projectile.owner]; + if (player.Calamity().celestialDragons) + { + Projectile.timeLeft = 2; + } + } + internal void SegmentMove() + { + Player player = Main.player[Projectile.owner]; + var live = false; + Projectile nextSegment = new Projectile(); + BlackDragonHead head = new BlackDragonHead(); + + for (int i = 0; i < Main.maxProjectiles; i++) + { + var projectile = Main.projectile[i]; + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + { + if (projectile.ModProjectile().segmentIndex == segmentIndex - 1) + { + live = true; + nextSegment = projectile; + } + } + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + { + if (segmentIndex == 1) + { + live = true; + nextSegment = projectile; + } + head = projectile.ModProjectile(); + } + } + if (!live) Projectile.Kill(); + Vector2 destinationOffset = nextSegment.Center - Projectile.Center; + if (nextSegment.rotation != Projectile.rotation) + { + float angle = MathHelper.WrapAngle(nextSegment.rotation - Projectile.rotation); + //destinationOffset = Projectile.Center.DirectionTo(nextSegment.Center); + destinationOffset = destinationOffset.RotatedBy(angle * 0.1f); + } + Projectile.rotation = destinationOffset.ToRotation(); + if (destinationOffset != Vector2.Zero) + { + Projectile.Center = nextSegment.Center - destinationOffset.SafeNormalize(Vector2.Zero) * 20f; + } + Projectile.velocity = Vector2.Zero; + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + } + + public override void Kill(int timeLeft) + { + if (Main.player[Projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + var projectile = Main.projectile[i]; + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + { + projectile.Kill(); + } + } + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.ShadowFlame, 300); + } +} diff --git a/Projectiles/Summon/BlackDragonTail.png b/Projectiles/Summon/BlackDragonTail.png new file mode 100644 index 0000000000..c5a5dd9f5a Binary files /dev/null and b/Projectiles/Summon/BlackDragonTail.png differ diff --git a/Projectiles/Summon/BlackDragonTail2.png b/Projectiles/Summon/BlackDragonTail2.png new file mode 100644 index 0000000000..f890bc1382 Binary files /dev/null and b/Projectiles/Summon/BlackDragonTail2.png differ diff --git a/Projectiles/Summon/WhiteDragonBody.cs b/Projectiles/Summon/WhiteDragonBody.cs new file mode 100644 index 0000000000..97571df41b --- /dev/null +++ b/Projectiles/Summon/WhiteDragonBody.cs @@ -0,0 +1,121 @@ +using CalamityMod.Buffs.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class WhiteDragonBody : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + public int segmentIndex = 1; + + public override void SetStaticDefaults() + { + Main.projPet[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.timeLeft = 10; + Projectile.width = 26; + Projectile.height = 26; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 180; + Projectile.idStaticNPCHitCooldown = 4; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.tileCollide = false; + Projectile.extraUpdates = 0; + Projectile.aiStyle = -1; + Projectile.DamageType = DamageClass.Summon; + Projectile.netImportant = true; + Projectile.minion = true; + } + + public override void OnSpawn(IEntitySource source) + { + foreach (var projectile in Main.projectile) + { + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + { + segmentIndex = projectile.ModProjectile().segmentIndex; + projectile.ModProjectile().segmentIndex++; + } + } + } + public override void AI() + { + Player player = Main.player[Projectile.owner]; + if (player.Calamity().celestialDragons) + { + Projectile.timeLeft = 2; + } + } + + internal void SegmentMove() + { + Player player = Main.player[Projectile.owner]; + var live = false; + Projectile nextSegment = new Projectile(); + WhiteDragonHead head = new WhiteDragonHead(); + for (int i = 0; i < Main.maxProjectiles; i++) + { + var projectile = Main.projectile[i]; + if (projectile.type == Type && projectile.owner == Projectile.owner && projectile.active) + { + if (projectile.ModProjectile().segmentIndex == segmentIndex - 1) + { + live = true; + nextSegment = projectile; + } + } + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + { + if (segmentIndex == 1) + { + live = true; + nextSegment = projectile; + } + head = projectile.ModProjectile(); + } + } + if (!live) Projectile.Kill(); + Vector2 destinationOffset = nextSegment.Center+nextSegment.velocity - Projectile.Center; + if (nextSegment.rotation != Projectile.rotation) + { + float angle = MathHelper.WrapAngle(nextSegment.rotation - Projectile.rotation); + //destinationOffset = Projectile.Center.DirectionTo(nextSegment.Center); + destinationOffset = destinationOffset.RotatedBy(angle * 0.1f); + } + Projectile.rotation = destinationOffset.ToRotation(); + if (destinationOffset != Vector2.Zero) + { + Projectile.Center = nextSegment.Center+nextSegment.velocity - destinationOffset.SafeNormalize(Vector2.Zero) * 20f; + } + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + } + public override void Kill(int timeLeft) + { + if (Main.player[Projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + var projectile = Main.projectile[i]; + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + { + projectile.Kill(); + } + } + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Frostburn2, 300); + } +} diff --git a/Projectiles/Summon/WhiteDragonBody.png b/Projectiles/Summon/WhiteDragonBody.png new file mode 100644 index 0000000000..5ab2062df2 Binary files /dev/null and b/Projectiles/Summon/WhiteDragonBody.png differ diff --git a/Projectiles/Summon/WhiteDragonBody2.png b/Projectiles/Summon/WhiteDragonBody2.png new file mode 100644 index 0000000000..539499f742 Binary files /dev/null and b/Projectiles/Summon/WhiteDragonBody2.png differ diff --git a/Projectiles/Summon/WhiteDragonHead.cs b/Projectiles/Summon/WhiteDragonHead.cs new file mode 100644 index 0000000000..b9ef8df47b --- /dev/null +++ b/Projectiles/Summon/WhiteDragonHead.cs @@ -0,0 +1,218 @@ +using CalamityMod.Buffs.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + // HUGE credit to Dozezoze for lending his worm projectile code + public class WhiteDragonHead : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + + Dictionary segments = new Dictionary(); + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionSacrificable[Type] = true; + ProjectileID.Sets.MinionTargettingFeature[Type] = true; + } + + public override void SetDefaults() + { + Projectile.timeLeft = 10; + Projectile.width = 24; + Projectile.height = 24; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 180; + Projectile.localNPCHitCooldown = 30; + Projectile.usesLocalNPCImmunity = true; + Projectile.tileCollide = false; + Projectile.extraUpdates = 0; + Projectile.aiStyle = -1; + Projectile.DamageType = DamageClass.Summon; + Projectile.netImportant = true; + Projectile.minionSlots = 2; + Projectile.minion = true; + + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 100; + } + + public override void AI() + { + Player player = Main.player[Projectile.owner]; + player.AddBuff(ModContent.BuffType(), 1); + if (Projectile.type == ModContent.ProjectileType()) + { + if (player.dead) + { + player.Calamity().celestialDragons = false; + } + if (player.Calamity().celestialDragons) + { + Projectile.timeLeft = 2; + } + } + Projectile.ai[0]++; + // Hover to the right because light is right or something + Vector2 idealPos = new Vector2(player.Center.X + 200, player.Center.Y - 50); + float distanceFromOwner = Projectile.Distance(idealPos); + + if (distanceFromOwner > 5000) + { + Projectile.Center = player.Center; + } + + NPC target = CalamityUtils.MinionHoming(Projectile.position, 2500, player, true, true); + if (target != null && Projectile.position.Distance(player.position) <= 2500) + { + AttackTarget(target); + } + else + { + float hoverAcceleration = 0.2f; + if (distanceFromOwner < 200f) + hoverAcceleration = 0.12f; + if (distanceFromOwner < 140f) + hoverAcceleration = 0.06f; + + if (distanceFromOwner > 100f) + { + if (Math.Abs(player.Center.X - Projectile.Center.X) > 20f) + Projectile.velocity.X += hoverAcceleration * Math.Sign(idealPos.X - Projectile.Center.X); + if (Math.Abs(player.Center.Y - Projectile.Center.Y) > 10f) + Projectile.velocity.Y += hoverAcceleration * Math.Sign(idealPos.Y - Projectile.Center.Y); + } + else if (Projectile.velocity.Length() > 1f) + Projectile.velocity *= 0.96f; + + if (Math.Abs(Projectile.velocity.Y) < 1f) + Projectile.velocity.Y -= 0.1f; + + if (Projectile.velocity.Length() > 25) + Projectile.velocity = Vector2.Normalize(Projectile.velocity) * 25; + } + + Projectile.rotation = Projectile.velocity.ToRotation(); + segments.Clear(); + foreach (var projectile in Main.projectile) + { + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active && !segments.ContainsKey(projectile.ModProjectile().segmentIndex)) + { + segments.Add(projectile.ModProjectile().segmentIndex, projectile); + } + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + { + segments.Add(projectile.ModProjectile().segmentIndex, projectile); + } + } + for (var i = 1; i <= segments.Count; i++) + { + if (i < segments.Count) + { + if (segments.ContainsKey(i)) + segments[i].ModProjectile().SegmentMove(); + } + else + { + if (segments.ContainsKey(i)) + segments[i].ModProjectile().SegmentMove(); + } + } + } + internal void AttackTarget(NPC target) + { + float idealFlyAcceleration = 0.18f; + + Vector2 destination = target.Center; + float distanceFromDestination = Projectile.Distance(destination); + + // Get a swerve effect if somewhat far from the target. + if (Projectile.Distance(destination) > 425f) + { + Projectile.ai[2] = 0; + destination += (Projectile.ai[0] % 30f / 30f * MathHelper.TwoPi).ToRotationVector2() * 145f; + distanceFromDestination = Projectile.Distance(destination); + idealFlyAcceleration *= 2.5f; + } + + // Charge if the target is far away. + if (distanceFromDestination > 1500f) + idealFlyAcceleration = MathHelper.Min(6f, Projectile.ai[1] + 1f); + + Projectile.ai[1] = MathHelper.Lerp(Projectile.ai[1], idealFlyAcceleration, 0.3f); + + float directionToTargetOrthogonality = Vector2.Dot(Projectile.velocity.SafeNormalize(Vector2.Zero), Projectile.SafeDirectionTo(destination)); + + // Fly towards the target if it's far. + if (distanceFromDestination > 320f) + { + float speed = Projectile.velocity.Length(); + if (speed < 23f) + speed += 0.08f; + + if (speed > 32f) + speed -= 0.08f; + + // Go faster if the line of sight is aiming closely at the target. + if (directionToTargetOrthogonality < 0.85f && directionToTargetOrthogonality > 0.5f) + speed += 16f; + + // And go slower otherwise so that the dragon can angle towards the target more accurately. + if (directionToTargetOrthogonality < 0.5f && directionToTargetOrthogonality > -0.7f) + speed -= 16f; + + speed = MathHelper.Clamp(speed, 16f, 34f); + + Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.AngleTo(destination), Projectile.ai[1]).ToRotationVector2() * speed; + + // failsafe to prevent orbiting + Projectile.ai[2]++; + if (Projectile.ai[2] >= 90) + { + Projectile.velocity = Projectile.DirectionTo(destination) * 30; + Projectile.ai[2] = 0; + } + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = ModContent.Request(Texture).Value; + Texture2D texBody = ModContent.Request("CalamityMod/Projectiles/Summon/WhiteDragonBody").Value; + Texture2D texBody2 = ModContent.Request("CalamityMod/Projectiles/Summon/WhiteDragonBody2").Value; + Texture2D texTail = ModContent.Request("CalamityMod/Projectiles/Summon/WhiteDragonTail").Value; + Texture2D texTail2 = ModContent.Request("CalamityMod/Projectiles/Summon/WhiteDragonTail2").Value; + for (var i = segments.Count; i > 0; i--) + { + if (segments.ContainsKey(i)) + { + SpriteEffects fx = Math.Abs(segments[i].rotation) > MathHelper.PiOver2 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + if (i < segments.Count - 1) + { + Main.EntitySpriteDraw((i == 5 || i == 12) ? texBody2 : texBody, segments[i].Center - Main.screenPosition, null, segments[i].GetAlpha(lightColor), segments[i].rotation + MathHelper.Pi / 2f, texBody.Size() / (2f), segments[i].scale, fx, 0); + } + else if (i < segments.Count) + { + Main.EntitySpriteDraw(texTail, segments[i].Center - Main.screenPosition, null, segments[i].GetAlpha(lightColor), segments[i].rotation + MathHelper.Pi / 2f, texBody.Size() / 2f, segments[i].scale, fx, 0); + } + else + { + Main.EntitySpriteDraw(texTail2, segments[i].Center - Main.screenPosition - new Vector2(10, 0).RotatedBy(segments[i].rotation), null, segments[i].GetAlpha(lightColor), segments[i].rotation + MathHelper.Pi / 2f, texTail.Size() / 2f, segments[i].scale, fx, 0); + + } + } + } + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation + MathHelper.Pi / 2f, tex.Size() / 2f, Projectile.scale, Projectile.velocity.X > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); + return false; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Frostburn2, 300); + } +} diff --git a/Projectiles/Summon/WhiteDragonHead.png b/Projectiles/Summon/WhiteDragonHead.png new file mode 100644 index 0000000000..214360df85 Binary files /dev/null and b/Projectiles/Summon/WhiteDragonHead.png differ diff --git a/Projectiles/Summon/WhiteDragonTail.cs b/Projectiles/Summon/WhiteDragonTail.cs new file mode 100644 index 0000000000..f1850eb66a --- /dev/null +++ b/Projectiles/Summon/WhiteDragonTail.cs @@ -0,0 +1,113 @@ +using CalamityMod.Buffs.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class WhiteDragonTail : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + public int segmentIndex = 1; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionSacrificable[Type] = false; + ProjectileID.Sets.MinionTargettingFeature[Type] = true; + } + + public override void SetDefaults() + { + Projectile.timeLeft = 10; + Projectile.width = 26; + Projectile.height = 26; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 180; + Projectile.localNPCHitCooldown = 30; + Projectile.usesLocalNPCImmunity = true; + Projectile.tileCollide = false; + Projectile.extraUpdates = 0; + Projectile.aiStyle = -1; + Projectile.DamageType = DamageClass.Summon; + Projectile.netImportant = true; + Projectile.minion = true; + + } + public override void AI() + { + Player player = Main.player[Projectile.owner]; + if (player.Calamity().celestialDragons) + { + Projectile.timeLeft = 2; + } + } + internal void SegmentMove() + { + Player player = Main.player[Projectile.owner]; + var live = false; + Projectile nextSegment = new Projectile(); + WhiteDragonHead head = new WhiteDragonHead(); + + for (int i = 0; i < Main.maxProjectiles; i++) + { + var projectile = Main.projectile[i]; + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + { + if (projectile.ModProjectile().segmentIndex == segmentIndex - 1) + { + live = true; + nextSegment = projectile; + } + } + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + { + if (segmentIndex == 1) + { + live = true; + nextSegment = projectile; + } + head = projectile.ModProjectile(); + } + } + if (!live) Projectile.Kill(); + Vector2 destinationOffset = nextSegment.Center - Projectile.Center; + if (nextSegment.rotation != Projectile.rotation) + { + float angle = MathHelper.WrapAngle(nextSegment.rotation - Projectile.rotation); + //destinationOffset = Projectile.Center.DirectionTo(nextSegment.Center); + destinationOffset = destinationOffset.RotatedBy(angle * 0.1f); + } + Projectile.rotation = destinationOffset.ToRotation(); + if (destinationOffset != Vector2.Zero) + { + Projectile.Center = nextSegment.Center - destinationOffset.SafeNormalize(Vector2.Zero) * 20f; + } + Projectile.velocity = Vector2.Zero; + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + } + + public override void Kill(int timeLeft) + { + if (Main.player[Projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + var projectile = Main.projectile[i]; + if (projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.active) + { + projectile.Kill(); + } + } + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Frostburn2, 300); + } +} diff --git a/Projectiles/Summon/WhiteDragonTail.png b/Projectiles/Summon/WhiteDragonTail.png new file mode 100644 index 0000000000..8ffd19d92f Binary files /dev/null and b/Projectiles/Summon/WhiteDragonTail.png differ diff --git a/Projectiles/Summon/WhiteDragonTail2.png b/Projectiles/Summon/WhiteDragonTail2.png new file mode 100644 index 0000000000..3378986d1f Binary files /dev/null and b/Projectiles/Summon/WhiteDragonTail2.png differ