diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 795f954a4a..26c4d6d61c 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -402,6 +402,7 @@ namespace CalamityMod.CalPlayer public bool pAmulet = false; public bool fBarrier = false; public bool aBrain = false; + public bool amalgam = false; public bool lol = false; public bool raiderTalisman = false; public int raiderStack = 0; @@ -1420,6 +1421,7 @@ namespace CalamityMod.CalPlayer pAmulet = false; fBarrier = false; aBrain = false; + amalgam = false; frostFlare = false; beeResist = false; uberBees = false; @@ -6438,34 +6440,41 @@ namespace CalamityMod.CalPlayer } } } - if (aBrain) + if (aBrain || amalgam) { for (int m = 0; m < Main.maxNPCs; m++) { if (Main.npc[m].active && !Main.npc[m].friendly) { - float arg_67A_0 = (Main.npc[m].Center - player.Center).Length(); - float num10 = (float)Main.rand.Next(200 + (int)damage / 2, 301 + (int)damage * 2); - if (num10 > 500f) + float npcDist = (Main.npc[m].Center - player.Center).Length(); + float range = (float)Main.rand.Next(200 + (int)damage / 2, 301 + (int)damage * 2); + if (range > 500f) { - num10 = 500f + (num10 - 500f) * 0.75f; + range = 500f + (range - 500f) * 0.75f; } - if (num10 > 700f) + if (range > 700f) { - num10 = 700f + (num10 - 700f) * 0.5f; + range = 700f + (range - 700f) * 0.5f; } - if (num10 > 900f) + if (range > 900f) { - num10 = 900f + (num10 - 900f) * 0.25f; + range = 900f + (range - 900f) * 0.25f; } - if (arg_67A_0 < num10) + if (npcDist < range) { - float num11 = (float)Main.rand.Next(90 + (int)damage / 3, 300 + (int)damage / 2); - Main.npc[m].AddBuff(BuffID.Confused, (int)num11, false); + float duration = (float)Main.rand.Next(90 + (int)damage / 3, 300 + (int)damage / 2); + Main.npc[m].AddBuff(BuffID.Confused, (int)duration, false); + if (amalgam) + { + Main.npc[m].AddBuff(ModContent.BuffType(), (int)duration, false); + Main.npc[m].AddBuff(ModContent.BuffType(), (int)duration, false); + Main.npc[m].AddBuff(ModContent.BuffType(), (int)duration, false); + Main.npc[m].AddBuff(ModContent.BuffType(), (int)duration, false); + } } } } - //spawn the harmless brain images that are actually projectiles + //Spawn the harmless brain images that are actually projectiles Projectile.NewProjectile(player.Center.X + (float)Main.rand.Next(-40, 40), player.Center.Y - (float)Main.rand.Next(20, 60), player.velocity.X * 0.3f, player.velocity.Y * 0.3f, ProjectileID.BrainOfConfusion, 0, 0f, player.whoAmI, 0f, 0f); } if (polarisBoost) diff --git a/Items/Accessories/FungalClump.cs b/Items/Accessories/FungalClump.cs index 7e157a9f74..cd885de770 100644 --- a/Items/Accessories/FungalClump.cs +++ b/Items/Accessories/FungalClump.cs @@ -7,6 +7,8 @@ namespace CalamityMod.Items.Accessories { public class FungalClump : ModItem { + public const int FungalClumpDamage = 10; + public override void SetStaticDefaults() { DisplayName.SetDefault("Fungal Clump"); @@ -24,15 +26,7 @@ namespace CalamityMod.Items.Accessories item.accessory = true; } - public override bool CanEquipAccessory(Player player, int slot) - { - CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.fungalClump) - { - return false; - } - return true; - } + public override bool CanEquipAccessory(Player player, int slot) => !player.Calamity().fungalClump; public override void UpdateAccessory(Player player, bool hideVisual) { @@ -46,7 +40,7 @@ namespace CalamityMod.Items.Accessories } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), (int)(10 * player.MinionDamage()), 1f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), (int)(FungalClumpDamage * player.MinionDamage()), 1f, player.whoAmI, 0f, 0f); } } } diff --git a/Items/Accessories/TheAmalgam.cs b/Items/Accessories/TheAmalgam.cs index 1ca24a1b49..7338190ab6 100644 --- a/Items/Accessories/TheAmalgam.cs +++ b/Items/Accessories/TheAmalgam.cs @@ -11,6 +11,7 @@ using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Accessories { @@ -18,21 +19,24 @@ namespace CalamityMod.Items.Accessories { public const int FireProjectiles = 2; public const float FireAngleSpread = 120; - public int FireCountdown = 0; + public int counter = 0; + public const int ProjectileDamage = 2000; + public const int FungalClumpDamage = 1000; + public const int AuraDamage = 300; + public bool WaterBonuses = false; public override void SetStaticDefaults() { DisplayName.SetDefault("The Amalgam"); Tooltip.SetDefault("15% increased damage\n" + - "Shade rains down when you are hit\n" + - "You will confuse nearby enemies when you are struck\n" + - "Drops brimstone fireballs from the sky occasionally\n" + - "Brimstone fire rains down while invincibility is active\n" + + "Shade and brimstone fire rain down when you are hit\n" + + "Nearby enemies receive a variety of debuffs when you are hit\n" + + "Brimstone fireballs drop from the sky occasionally\n" + + "Summons a fungal clump to fight for you that leaves behind poisonous seawater\n" + + "75% increased movement speed, 10% increase to all damage, and plus 40 defense while submerged in any liquid\n" + + "The above bonuses also apply when passing through the clump's poisonous seawater\n" + "Temporary immunity to lava, greatly reduces lava burn damage, and 15% increased damage while in lava\n" + - "Summons a fungal clump to fight for you\n" + - "You leave behind poisonous seawater as you move\n" + - "75% increased movement speed, 10% increase to all damage, and plus 40 defense while submerged in liquid\n" + - "If you are damaged while submerged in liquid you will gain a damaging aura for a short time\n" + + "You have a damaging aura that envenoms nearby enemies and increased movement in liquids\n" + "Provides heat protection in Death Mode"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(9, 6)); } @@ -47,147 +51,135 @@ namespace CalamityMod.Items.Accessories item.accessory = true; } - public override bool CanEquipAccessory(Player player, int slot) - { - CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.fungalClump) - { - return false; - } - return true; - } + public override bool CanEquipAccessory(Player player, int slot) => !player.Calamity().fungalClump; public override void UpdateAccessory(Player player, bool hideVisual) { + //Counter used for aura and Gehenna effects + counter++; + CalamityPlayer modPlayer = player.Calamity(); - modPlayer.aBrain = true; + modPlayer.amalgam = true; modPlayer.fungalClump = true; - if (player.whoAmI == Main.myPlayer) - { - if (player.FindBuffIndex(ModContent.BuffType()) == -1) - { - player.AddBuff(ModContent.BuffType(), 3600, true); - } - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), (int)(1000f * player.MinionDamage()), 1f, Main.myPlayer, 0f, 0f); - } - } - player.allDamage += 0.15f; player.ignoreWater = true; player.lavaRose = true; + player.allDamage += 0.15f; player.lavaMax += 240; if (player.lavaWet) { player.allDamage += 0.15f; } - if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) + + //emit light + Lighting.AddLight((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f), 0f, 0.5f, 1.25f); + + //Summon the Fungal Clump, ai[0] is 1f to indicate this is from the Amalgam, not the Fungal Clump + if (player.whoAmI == Main.myPlayer) + { + if (player.FindBuffIndex(BuffType()) == -1) + { + player.AddBuff(BuffType(), 3600, true); + } + if (player.ownedProjectileCounts[ProjectileType()] < 1) + { + Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ProjectileType(), (int)(FungalClumpDamage * player.MinionDamage()), 1f, player.whoAmI, 1f, 0f); + } + } + + Rectangle rectangle = new Rectangle((int)(player.position.X + player.velocity.X * 0.5f - 4f), (int)(player.position.Y + player.velocity.Y * 0.5f - 4f), player.width + 8, player.height + 8); + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + if (proj.active && proj.friendly && proj.type == ProjectileType() && proj.ai[0] == 1f && proj.damage > 0) + { + Rectangle rect = proj.getRect(); + if (rectangle.Intersects(rect)) + { + WaterBonuses = true; + } + } + } + if (WaterBonuses || player.IsUnderwater()) { player.allDamage += 0.1f; player.statDefense += 40; player.moveSpeed += 0.75f; } - if ((double)player.velocity.X > 0 || (double)player.velocity.Y > 0 || (double)player.velocity.X < -0.1 || (double)player.velocity.Y < -0.1) - { - if (player.whoAmI == Main.myPlayer) - { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(2000 * player.AverageDamage()), 0f, player.whoAmI, 0f, 0f); - } - } + if (player.immune) { if (Main.rand.NextBool(20)) { if (player.whoAmI == Main.myPlayer) { - for (int l = 0; l < 1; l++) - { - float x = player.position.X + (float)Main.rand.Next(-400, 400); - float y = player.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num15 = player.position.X + (float)(player.width / 2) - vector.X; - float num16 = player.position.Y + (float)(player.height / 2) - vector.Y; - num15 += (float)Main.rand.Next(-100, 101); - int num17 = 22; - float num18 = (float)Math.Sqrt((double)(num15 * num15 + num16 * num16)); - num18 = (float)num17 / num18; - num15 *= num18; - num16 *= num18; - int type = Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int num19 = Projectile.NewProjectile(x, y, num15, num16, type, (int)(2000 * player.AverageDamage()), 1f, player.whoAmI, 0f, 0f); - Main.projectile[num19].tileCollide = false; - Main.projectile[num19].usesLocalNPCImmunity = true; - Main.projectile[num19].localNPCHitCooldown = 10; - Main.projectile[num19].usesIDStaticNPCImmunity = false; - Main.projectile[num19].Calamity().forceTypeless = true; - } + float x = player.position.X + Main.rand.NextFloat(-400, 400); + float y = player.position.Y - Main.rand.NextFloat(500, 800); + Vector2 projOrigin = new Vector2(x, y); + float xDist = player.Center.X - projOrigin.X; + float yDist = player.Center.Y - projOrigin.Y; + xDist += Main.rand.NextFloat(-100, 100); + float speed = 22f; + Vector2 playerVector = new Vector2(xDist, yDist); + float playerDist = playerVector.Length(); + playerDist = speed / playerDist; + playerVector.X *= playerDist; + playerVector.Y *= playerDist; + int type = Main.rand.NextBool(2) ? ProjectileType() : ProjectileType(); + int rain = Projectile.NewProjectile(projOrigin, playerVector, type, (int)(ProjectileDamage * player.AverageDamage()), 1f, player.whoAmI, 0f, 0f); + Projectile proj = Main.projectile[rain]; + proj.tileCollide = false; + proj.usesLocalNPCImmunity = true; + proj.localNPCHitCooldown = 10; + proj.usesIDStaticNPCImmunity = false; + proj.Calamity().forceTypeless = true; } } } - int seaCounter = 0; - Lighting.AddLight((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f), 0f, 0.5f, 1.25f); - int num = BuffID.Venom; - float num2 = 300f; - bool flag = seaCounter % 60 == 0; - int num3 = (int)(320 * player.AverageDamage()); - int random = Main.rand.Next(5); + int buffType = BuffID.Venom; + float auraRange = 300f; + int auraDmg = (int)(AuraDamage * player.AverageDamage()); if (player.whoAmI == Main.myPlayer) { - if (random == 0 && player.immune && Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) - { - for (int l = 0; l < Main.maxNPCs; l++) - { - NPC nPC = Main.npc[l]; - if (nPC.active && !nPC.friendly && nPC.damage > 0 && !nPC.dontTakeDamage && !nPC.buffImmune[num] && Vector2.Distance(player.Center, nPC.Center) <= num2) - { - if (nPC.FindBuffIndex(num) == -1) - { - nPC.AddBuff(num, 300, false); - } - if (flag) - { - if (player.whoAmI == Main.myPlayer) - { - Projectile p = Projectile.NewProjectileDirect(nPC.Center, Vector2.Zero, ModContent.ProjectileType(), num3, 0f, player.whoAmI, l); - } - } - } - } - } - } - seaCounter++; - if (seaCounter >= 180) - { - } - if (FireCountdown == 0) - { - FireCountdown = 600; - } - if (FireCountdown > 0) - { - FireCountdown--; - if (FireCountdown == 0) - { - if (player.whoAmI == Main.myPlayer) - { - int speed2 = 25; - float spawnX = Main.rand.Next(1000) - 500 + player.Center.X; - float spawnY = -1000 + player.Center.Y; - Vector2 baseSpawn = new Vector2(spawnX, spawnY); - Vector2 baseVelocity = player.Center - baseSpawn; - baseVelocity.Normalize(); - baseVelocity *= speed2; - for (int i = 0; i < FireProjectiles; i++) - { - Vector2 spawn = baseSpawn; - spawn.X = spawn.X + i * 30 - (FireProjectiles * 15); - Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-FireAngleSpread / 2 + (FireAngleSpread * i / (float)FireProjectiles))); - velocity.X = velocity.X + 3 * Main.rand.NextFloat() - 1.5f; - Projectile.NewProjectile(spawn.X, spawn.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), (int)(2000 * player.AverageDamage()), 5f, Main.myPlayer, 0f, 0f); - } - } - } + for (int l = 0; l < Main.maxNPCs; l++) + { + NPC npc = Main.npc[l]; + if (npc.active && !npc.friendly && npc.damage > 0 && !npc.dontTakeDamage && Vector2.Distance(player.Center, npc.Center) <= auraRange) + { + if (npc.FindBuffIndex(buffType) == -1 && !npc.buffImmune[buffType]) + { + npc.AddBuff(buffType, 300, false); + } + if (counter % 30 == 0) + { + if (player.whoAmI == Main.myPlayer) + { + Projectile p = Projectile.NewProjectileDirect(npc.Center, Vector2.Zero, ProjectileType(), auraDmg, 0f, player.whoAmI, l); + } + } + } + } } + if (counter % 480 == 0) + { + if (player.whoAmI == Main.myPlayer) + { + int speed = 25; + float spawnX = Main.rand.Next(1000) - 500 + player.Center.X; + float spawnY = -1000 + player.Center.Y; + Vector2 baseSpawn = new Vector2(spawnX, spawnY); + Vector2 baseVelocity = player.Center - baseSpawn; + baseVelocity.Normalize(); + baseVelocity *= speed; + for (int i = 0; i < FireProjectiles; i++) + { + Vector2 spawn = baseSpawn; + spawn.X += i * 30 - (FireProjectiles * 15); + Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-FireAngleSpread / 2 + (FireAngleSpread * i / (float)FireProjectiles))); + velocity.X += 3 * Main.rand.NextFloat() - 1.5f; + Projectile.NewProjectile(spawn, velocity, ProjectileType(), (int)(ProjectileDamage * player.AverageDamage()), 5f, player.whoAmI, 0f, 0f); + } + } + } } public override void AddRecipes() diff --git a/Projectiles/Summon/FungalClumpMinion.cs b/Projectiles/Summon/FungalClumpMinion.cs index 5eeb251297..04f6c10f2b 100644 --- a/Projectiles/Summon/FungalClumpMinion.cs +++ b/Projectiles/Summon/FungalClumpMinion.cs @@ -1,6 +1,8 @@ using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Healing; +using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +11,8 @@ namespace CalamityMod.Projectiles.Summon { public class FungalClumpMinion : ModProjectile { + private bool returnToPlayer = false; + private bool amalgam = false; public override void SetStaticDefaults() { DisplayName.SetDefault("Fungal Clump"); @@ -25,7 +29,6 @@ namespace CalamityMod.Projectiles.Summon projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.minionSlots = 0f; - projectile.aiStyle = 54; projectile.timeLeft = 18000; projectile.penetrate = -1; projectile.timeLeft *= 5; @@ -35,15 +38,16 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - bool flag64 = projectile.type == ModContent.ProjectileType(); Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); + + bool correctMinion = projectile.type == ModContent.ProjectileType(); if (!modPlayer.fungalClump) { projectile.active = false; return; } - if (flag64) + if (correctMinion) { if (player.dead) { @@ -54,6 +58,9 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } + amalgam = projectile.ai[0] == 1f; + + //Initializing dust and damage if (projectile.localAI[0] == 0f) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); @@ -71,6 +78,8 @@ namespace CalamityMod.Projectiles.Summon } projectile.localAI[0] += 1f; } + + //Flexible damage correction if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / @@ -78,11 +87,178 @@ namespace CalamityMod.Projectiles.Summon player.MinionDamage()); projectile.damage = damage2; } + + //Periodically create dust if (Main.rand.NextBool(16)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 56, projectile.velocity.X * 0.05f, projectile.velocity.Y * 0.05f); } - } + + //Anti-sticky movement failsafe + float SAIMovement = 0.05f; + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + bool typeCheck = proj.type == ModContent.ProjectileType(); + if (i != projectile.whoAmI && proj.active && proj.owner == projectile.owner && typeCheck && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < (float)projectile.width) + { + if (projectile.position.X < proj.position.X) + { + projectile.velocity.X -= SAIMovement; + } + else + { + projectile.velocity.X += SAIMovement; + } + if (projectile.position.Y < proj.position.Y) + { + projectile.velocity.Y -= SAIMovement; + } + else + { + projectile.velocity.Y += SAIMovement; + } + } + } + + //If summoned by Amalgam, trail poisonous seawater + if (Math.Abs(projectile.velocity.X) > 0.1f || Math.Abs(projectile.velocity.Y) > 0.1f) + { + if (projectile.owner == Main.myPlayer) + { + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 1f, 0f); + } + } + + //If too far from player, increase speed to chase after player + float playerRange = 500f; + //Range is boosted if chasing after an enemy + if (projectile.ai[1] != 0f || projectile.friendly) + playerRange = amalgam ? 2000f : 1400f; + if (Math.Abs(projectile.Center.X - player.Center.X) + Math.Abs(projectile.Center.Y - player.Center.Y) > playerRange) + returnToPlayer = true; + + //Find an npc to target, or if minion targetting is used, choose that npc + Vector2 center = projectile.Center; + float range = 900f; + bool npcFound = false; + if (!returnToPlayer) + { + projectile.tileCollide = true; + NPC target = projectile.OwnerMinionAttackTargetNPC; + if (target != null && target.CanBeChasedBy(projectile, false)) + { + float extraDistance = (target.width / 2) + (target.height / 2); + + if (Vector2.Distance(target.Center, projectile.Center) < (range + extraDistance) && Collision.CanHit(projectile.position, projectile.width, projectile.height, target.position, target.width, target.height)) + { + center = target.Center; + npcFound = true; + } + } + if (!npcFound) + { + for (int index = 0; index < Main.maxNPCs; ++index) + { + NPC npc = Main.npc[index]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); + + if (Vector2.Distance(npc.Center, projectile.Center) < (range + extraDistance) && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) + { + center = npc.Center; + npcFound = true; + } + } + } + } + } + + //Tile collision depends on if returning to the player or not + projectile.tileCollide = !returnToPlayer; + + if (!npcFound) + { + projectile.friendly = true; + float homingSpeed = amalgam ? 12f : 8f; + float turnSpeed = 20f; + if (returnToPlayer) //move faster if returning to the player + homingSpeed = amalgam ? 30f : 12f; + Vector2 projPos = new Vector2(projectile.Center.X, projectile.Center.Y); + float xDist = player.Center.X - projPos.X; + float yDist = player.Center.Y - projPos.Y - 60f; + Vector2 playerVector = new Vector2(xDist, yDist); + float playerDist = playerVector.Length(); + if (playerDist < 100f && projectile.ai[0] == 1f && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + projectile.ai[0] = 0f; + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - projectile.width / 2; + projectile.position.Y = player.Center.Y - projectile.width / 2; + } + if (playerDist > 70f) + { + Vector2 homeInVector = projectile.DirectionTo(playerVector); + if (homeInVector.HasNaNs()) + homeInVector = Vector2.UnitY; + + projectile.velocity = (projectile.velocity * turnSpeed + homeInVector * homingSpeed) / (turnSpeed + 1f); + } + else + { + if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) + { + projectile.velocity.X = -0.15f; + projectile.velocity.Y = -0.05f; + } + projectile.velocity *= 1.01f; + } + projectile.friendly = false; + projectile.rotation = projectile.velocity.X * 0.05f; + if (Math.Abs(projectile.velocity.X) <= 0f) + return; + projectile.spriteDirection = -projectile.direction; + } + else + { + if (projectile.ai[1] == -1f) + projectile.ai[1] = 17f; + if (projectile.ai[1] > 0f) + { + projectile.ai[1] -= 1f; + } + if (projectile.ai[1] == 0f) + { + projectile.friendly = true; + float minionSpeed = amalgam ? 20f : 8f; + float turnSpeed = 14f; + Vector2 projPos = new Vector2(projectile.Center.X, projectile.Center.Y); + float xDist = center.X - projPos.X; + float yDist = center.Y - projPos.Y - 60f; + Vector2 targetVector = new Vector2(xDist, yDist); + float targetDist = targetVector.Length(); + if (targetDist < 100f) + minionSpeed = amalgam ? 25f : 10f; + + Vector2 homeInVector = projectile.DirectionTo(targetVector); + if (homeInVector.HasNaNs()) + homeInVector = Vector2.UnitY; + + projectile.velocity = (projectile.velocity * turnSpeed + homeInVector * minionSpeed) / (turnSpeed + 1f); + } + else + { + projectile.friendly = false; + if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < 10f) + projectile.velocity *= 1.05f; + } + projectile.rotation = projectile.velocity.X * 0.05f; + if (Math.Abs(projectile.velocity.X) <= 0.2f) + return; + projectile.spriteDirection = -projectile.direction; + } + } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { @@ -90,7 +266,7 @@ namespace CalamityMod.Projectiles.Summon { return; } - float healAmt = (float)damage * 0.25f; + float healAmt = damage * 0.25f; if ((int)healAmt == 0) { return;