diff --git a/Buffs/Summon/MidnightSunBuff.cs b/Buffs/Summon/MidnightSunBuff.cs new file mode 100644 index 0000000000..30b0cc66e6 --- /dev/null +++ b/Buffs/Summon/MidnightSunBuff.cs @@ -0,0 +1,36 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class MidnightSunBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Midnight Sun UFO"); + Description.SetDefault("A strange UFO is observing you, and it's making you very uncomfortable"); + 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) + { + modPlayer.midnightUFO = true; + } + if (!modPlayer.midnightUFO) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/MidnightSunBuff.png b/Buffs/Summon/MidnightSunBuff.png new file mode 100644 index 0000000000..fd2f2637d7 Binary files /dev/null and b/Buffs/Summon/MidnightSunBuff.png differ diff --git a/Buffs/Summon/TacticalPlagueEngineBuff.cs b/Buffs/Summon/TacticalPlagueEngineBuff.cs new file mode 100644 index 0000000000..365620e246 --- /dev/null +++ b/Buffs/Summon/TacticalPlagueEngineBuff.cs @@ -0,0 +1,36 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class TacticalPlagueEngineBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Tactical Plague Engine"); + Description.SetDefault("A giant plague engine is following you"); + 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) + { + modPlayer.plagueEngine = true; + } + if (!modPlayer.plagueEngine) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/TacticalPlagueEngineBuff.png b/Buffs/Summon/TacticalPlagueEngineBuff.png new file mode 100644 index 0000000000..19c105eed0 Binary files /dev/null and b/Buffs/Summon/TacticalPlagueEngineBuff.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 4fa0e5e7b0..d8c4fa07d5 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -752,6 +752,8 @@ namespace CalamityMod.CalPlayer public bool belladonaSpirit = false; public bool vileFeeder = false; public bool scabRipper = false; + public bool midnightUFO = false; + public bool plagueEngine = false; // Biome public bool ZoneCalamity = false; @@ -1582,6 +1584,8 @@ namespace CalamityMod.CalPlayer belladonaSpirit = false; vileFeeder = false; scabRipper = false; + midnightUFO = false; + plagueEngine = false; abyssalDivingSuitPrevious = abyssalDivingSuit; abyssalDivingSuit = abyssalDivingSuitHide = abyssalDivingSuitForce = abyssalDivingSuitPower = false; diff --git a/ExtraTextures/Lasers/MidnightSunBeamBegin.png b/ExtraTextures/Lasers/MidnightSunBeamBegin.png new file mode 100644 index 0000000000..d85e68b29d Binary files /dev/null and b/ExtraTextures/Lasers/MidnightSunBeamBegin.png differ diff --git a/ExtraTextures/Lasers/MidnightSunBeamEnd.png b/ExtraTextures/Lasers/MidnightSunBeamEnd.png new file mode 100644 index 0000000000..3f657e198f Binary files /dev/null and b/ExtraTextures/Lasers/MidnightSunBeamEnd.png differ diff --git a/ExtraTextures/Lasers/MidnightSunBeamMid.png b/ExtraTextures/Lasers/MidnightSunBeamMid.png new file mode 100644 index 0000000000..c7f5315d99 Binary files /dev/null and b/ExtraTextures/Lasers/MidnightSunBeamMid.png differ diff --git a/Items/Fishing/SulphurCatches/AbyssalCrate.cs b/Items/Fishing/SulphurCatches/AbyssalCrate.cs index e88f901d70..678dacafdc 100644 --- a/Items/Fishing/SulphurCatches/AbyssalCrate.cs +++ b/Items/Fishing/SulphurCatches/AbyssalCrate.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Accessories; using CalamityMod.Items.Pets; using CalamityMod.Items.Placeables; +using CalamityMod.Items.SummonItems.Invasion; using CalamityMod.Items.Potions; using CalamityMod.Tiles.Abyss; using CalamityMod.World; @@ -65,6 +66,12 @@ namespace CalamityMod.Items.Fishing.SulphurCatches DropHelper.DropItemChance(player, ModContent.ItemType(), 0.25f, 5, 10); } + // Acid Rain summoner + if (NPC.downedBoss1) + { + DropHelper.DropItemChance(player, ModContent.ItemType(), 0.25f); + } + // Equipment DropHelper.DropItemFromSetCondition(player, NPC.downedBoss3, 0.25f, ModContent.ItemType(), diff --git a/Items/Weapons/Summon/MidnightSunBeacon.cs b/Items/Weapons/Summon/MidnightSunBeacon.cs new file mode 100644 index 0000000000..3cf68898f2 --- /dev/null +++ b/Items/Weapons/Summon/MidnightSunBeacon.cs @@ -0,0 +1,56 @@ +using CalamityMod.Projectiles.Summon; +using CalamityMod.Items.Materials; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class MidnightSunBeacon : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Midnight Sun Beacon"); + Tooltip.SetDefault("Summons a UFO to vaporize enemies"); + } + + public override void SetDefaults() + { + item.damage = 330; + item.mana = 12; + item.width = item.height = 32; + item.useTime = item.useAnimation = 10; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.noUseGraphic = true; + item.knockBack = 1f; + item.UseSound = SoundID.Item90; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; + + item.value = Item.buyPrice(2, 50, 0, 0); + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.Violet; + } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.XenoStaff); + recipe.AddIngredient(ItemID.MoonlordTurretStaff); + recipe.AddIngredient(ModContent.ItemType(), 25); + recipe.AddIngredient(ModContent.ItemType(), 25); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Summon/MidnightSunBeacon.png b/Items/Weapons/Summon/MidnightSunBeacon.png new file mode 100644 index 0000000000..fc4de89b2d Binary files /dev/null and b/Items/Weapons/Summon/MidnightSunBeacon.png differ diff --git a/Items/Weapons/Summon/TacticalPlagueEngine.cs b/Items/Weapons/Summon/TacticalPlagueEngine.cs new file mode 100644 index 0000000000..8db3eeba64 --- /dev/null +++ b/Items/Weapons/Summon/TacticalPlagueEngine.cs @@ -0,0 +1,62 @@ +using CalamityMod.Projectiles.Summon; +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class TacticalPlagueEngine : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tactical Plague Engine"); + Tooltip.SetDefault("Summons a plague engine to pummel your enemies into submission\n" + + "Consumes bullets\n" + + "Sometimes shoots a missile instead of a bullet"); + } + + public override void SetDefaults() + { + item.damage = 100; + item.mana = 10; + item.width = 28; + item.height = 20; + item.useTime = item.useAnimation = 15; + item.useStyle = 4; + item.noMelee = true; + item.knockBack = 0.5f; + item.value = Item.buyPrice(1, 20, 0, 0); + item.rare = 1; + item.UseSound = SoundID.Item14; + item.autoReuse = true; + item.summon = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 16f; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + if (player.altFunctionUse != 2) + { + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); + } + return false; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ItemID.LunarBar, 10); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Summon/TacticalPlagueEngine.png b/Items/Weapons/Summon/TacticalPlagueEngine.png new file mode 100644 index 0000000000..edb71d4853 Binary files /dev/null and b/Items/Weapons/Summon/TacticalPlagueEngine.png differ diff --git a/Projectiles/Summon/BelladonnaSpirit.cs b/Projectiles/Summon/BelladonnaSpirit.cs index 0d661a34ad..420581938d 100644 --- a/Projectiles/Summon/BelladonnaSpirit.cs +++ b/Projectiles/Summon/BelladonnaSpirit.cs @@ -28,6 +28,7 @@ namespace CalamityMod.Projectiles.Summon projectile.penetrate = -1; projectile.timeLeft *= 5; projectile.minion = true; + projectile.tileCollide = false; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } @@ -90,7 +91,7 @@ namespace CalamityMod.Projectiles.Summon Vector2 targetPosition = player.Bottom; if (potentialTarget == null) { - projectile.velocity.X = (player.Center.X + player.direction * 75f - projectile.Center.X) / 110f; + projectile.velocity.X = (player.Center.X + player.direction * 75f - projectile.Center.X) / 60f; if (projectile.Distance(player.Center) > 2500f || targetPosition.Y - projectile.Top.Y > 360f) { @@ -99,11 +100,11 @@ namespace CalamityMod.Projectiles.Summon } else if (targetPosition.Y - projectile.Top.Y < -550f) { - projectile.velocity.Y += Math.Sign(targetPosition.Y - targetPosition.Y) * 0.05f; + projectile.velocity.Y += Math.Sign(targetPosition.Y - targetPosition.Y) * 0.08f; } else { - projectile.velocity.Y = (targetPosition.Y - projectile.Center.Y) / 110f; + projectile.velocity.Y = (targetPosition.Y - projectile.Center.Y) / 60f; } } else @@ -168,13 +169,5 @@ namespace CalamityMod.Projectiles.Summon } } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } } } diff --git a/Projectiles/Summon/IgneousBlade.cs b/Projectiles/Summon/IgneousBlade.cs index 56c6d78bc1..10c87d0d32 100644 --- a/Projectiles/Summon/IgneousBlade.cs +++ b/Projectiles/Summon/IgneousBlade.cs @@ -159,6 +159,9 @@ namespace CalamityMod.Projectiles.Summon rectangle.Size() / 2f, scale, spriteEffects, 0f); } } + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Rectangle?(rectangle), Color.White, + projectile.rotation, + rectangle.Size() / 2f, 1.35f, spriteEffects, 0f); return false; } return true; diff --git a/Projectiles/Summon/MK2FlaskSummon.cs b/Projectiles/Summon/MK2FlaskSummon.cs index 2bb6eb04f7..3d0ad4db21 100644 --- a/Projectiles/Summon/MK2FlaskSummon.cs +++ b/Projectiles/Summon/MK2FlaskSummon.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Projectiles.Summon { DisplayName.SetDefault("Flask"); ProjectileID.Sets.MinionShot[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; } public override void SetDefaults() @@ -42,7 +43,15 @@ namespace CalamityMod.Projectiles.Summon } Main.PlaySound(SoundID.Item107, projectile.Center); int idx = Projectile.NewProjectile(projectile.Center, Vector2.UnitY * 6f, ModContent.ProjectileType(), projectile.damage, 4f, projectile.owner); - Main.projectile[idx].ai[1] = CalamityUtils.CountProjectiles(ModContent.ProjectileType()); + int beeArrayIndex = 0; + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].active && Main.projectile[i].owner == projectile.owner && Main.projectile[i].type == ModContent.ProjectileType()) + { + Main.projectile[i].ai[1] = beeArrayIndex; + beeArrayIndex++; + } + } } } public override bool CanDamage() => false; diff --git a/Projectiles/Summon/MidnightSunBeaconProj.cs b/Projectiles/Summon/MidnightSunBeaconProj.cs new file mode 100644 index 0000000000..30275b3835 --- /dev/null +++ b/Projectiles/Summon/MidnightSunBeaconProj.cs @@ -0,0 +1,61 @@ +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class MidnightSunBeaconProj : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Beacon"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.friendly = true; + projectile.width = 32; + projectile.height = 32; + projectile.minion = true; + projectile.minionSlots = 0f; + projectile.ignoreWater = true; + projectile.tileCollide = true; + projectile.timeLeft = 420; + } + + public override void AI() + { + projectile.rotation = projectile.rotation.AngleLerp(-MathHelper.PiOver4, 0.03f); + if (Math.Abs(projectile.rotation + MathHelper.PiOver4) < 0.02f && projectile.ai[0] == 0f) + { + for (int i = 1; i <= 4; i++) + { + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 150, 0f, projectile.owner, + projectile.whoAmI, i - 2); + } + projectile.ai[1] = MidnightSunSkyBeam.TrueTimeLeft + 60f; + projectile.ai[0] = 1f; + } + if (projectile.ai[1] == 1f) + { + Projectile.NewProjectile(projectile.Center, Vector2.UnitY * 30f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, + projectile.owner); + projectile.Kill(); + } + if (projectile.ai[1] > 0) + projectile.ai[1]--; + if (projectile.ai[1] > 1f && + projectile.ai[1] <= 60f) + { + projectile.velocity.Y -= 0.4f; + } + else + projectile.velocity *= 0.96f; + } + public override bool CanDamage() => false; + } +} diff --git a/Projectiles/Summon/MidnightSunBeaconProj.png b/Projectiles/Summon/MidnightSunBeaconProj.png new file mode 100644 index 0000000000..fc4de89b2d Binary files /dev/null and b/Projectiles/Summon/MidnightSunBeaconProj.png differ diff --git a/Projectiles/Summon/MidnightSunBeam.cs b/Projectiles/Summon/MidnightSunBeam.cs new file mode 100644 index 0000000000..6de9189653 --- /dev/null +++ b/Projectiles/Summon/MidnightSunBeam.cs @@ -0,0 +1,209 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.Enums; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class MidnightSunBeam : ModProjectile + { + // How long this laser can exist before it is deleted. + public const int TrueTimeLeft = 120; + + // Pretty self explanatory + private const float maximumLength = 1600f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Beam"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 18; + projectile.height = 14; + projectile.friendly = true; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft = TrueTimeLeft; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 6; + } + + // Netcode for sending and receiving shit + // localAI[0] is the timer, localAI[1] is the laser length + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.localAI[0]); + writer.Write(projectile.localAI[1]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + projectile.localAI[1] = reader.ReadSingle(); + } + + public override void AI() + { + Projectile body = Main.projectile[(int)projectile.ai[1]]; + if (body.type != ModContent.ProjectileType() || !body.active) + projectile.Kill(); + + if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) + { + projectile.velocity = -Vector2.UnitY; + } + + if (Main.projectile[(int)projectile.ai[1]].active) + { + projectile.Center = Main.projectile[(int)projectile.ai[1]].Center; + } + + if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) + { + projectile.velocity = -Vector2.UnitY; + } + + // How fat the laser is + float laserSize = 1f; + + projectile.localAI[0] += 1f; + if (projectile.localAI[0] >= TrueTimeLeft) + { + projectile.Kill(); + return; + } + + // Causes the effect where the laser appears to expand/contract at the beginning and end of its life + projectile.scale = (float)Math.Sin(projectile.localAI[0] * MathHelper.Pi / TrueTimeLeft) * 10f * laserSize; + if (projectile.scale > laserSize) + { + projectile.scale = laserSize; + } + + // The heart of the "sweeping rotation" part of the laser + // Basically converts the velocity to a rotation, increments some value to that rotation, + // and then converts the rotation to a velocity + float velocityAsRotation = body.rotation + MathHelper.PiOver2; + projectile.rotation = velocityAsRotation - MathHelper.PiOver2; + projectile.velocity = velocityAsRotation.ToRotationVector2(); + + Vector2 samplingPoint = projectile.Center; + + float[] samples = new float[3]; + + float determinedLength = 0f; + Collision.LaserScan(samplingPoint, projectile.velocity, projectile.width * projectile.scale, maximumLength, samples); + for (int i = 0; i < samples.Length; i++) + { + determinedLength += samples[i]; + } + determinedLength /= samples.Length; + + float lerpDelta = 0.5f; + projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], determinedLength, lerpDelta); + Vector2 beamEndPosiiton = projectile.Center + projectile.velocity * (projectile.localAI[1] - 6f); + for (int i = 0; i < 4; i++) + { + float theta = projectile.velocity.ToRotation() + Main.rand.NextBool(2).ToDirectionInt() * MathHelper.PiOver2; + float speed = (float)Main.rand.NextDouble() * 2f + 2f; + Vector2 velocity = theta.ToRotationVector2() * speed; + Dust dust = Dust.NewDustDirect(beamEndPosiiton, 0, 0, 185, velocity.X, velocity.Y, 0, default, 1f); + dust.noGravity = true; + dust.scale = 1.7f; + } + + for (int i = 0; i < 8; i++) + { + Dust dust = Dust.NewDustPerfect(beamEndPosiiton, 185); + dust.velocity = Vector2.UnitY.RotatedByRandom(MathHelper.ToRadians(55f)).RotatedBy(projectile.rotation); + dust.noGravity = true; + dust.scale = 1.2f; + } + + // Draw light blue light across the laser + DelegateMethods.v3_1 = new Vector3(0.52f, 0.93f, 0.97f); + Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.velocity == Vector2.Zero) + { + return false; + } + Texture2D laserTailTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/MidnightSunBeamBegin"); + Texture2D laserBodyTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/MidnightSunBeamMid"); + Texture2D laserHeadTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/MidnightSunBeamEnd"); + float laserLength = projectile.localAI[1]; + Color drawColor = new Color(1f, 1f, 1f) * 0.9f; + + // Laser tail logic + + Main.spriteBatch.Draw(laserTailTexture, projectile.Center - Main.screenPosition, null, drawColor, projectile.rotation, laserTailTexture.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); + + // Laser body logic + + laserLength -= (laserTailTexture.Height / 2 + laserHeadTexture.Height) * projectile.scale; + Vector2 centerDelta = projectile.Center; + centerDelta += projectile.velocity * projectile.scale * (float)laserTailTexture.Height / 2f; + if (laserLength > 0f) + { + float laserLengthDelta = 0f; + Rectangle sourceRectangle = new Rectangle(0, 16 * (projectile.timeLeft / 3 % 5), laserBodyTexture.Width, 16); + while (laserLengthDelta + 1f < laserLength) + { + if (laserLength - laserLengthDelta < sourceRectangle.Height) + { + sourceRectangle.Height = (int)(laserLength - laserLengthDelta); + } + Main.spriteBatch.Draw(laserBodyTexture, centerDelta - Main.screenPosition, new Rectangle?(sourceRectangle), drawColor, projectile.rotation, new Vector2(sourceRectangle.Width / 2f, 0f), projectile.scale, SpriteEffects.None, 0f); + laserLengthDelta += sourceRectangle.Height * projectile.scale; + centerDelta += projectile.velocity * sourceRectangle.Height * projectile.scale; + sourceRectangle.Y += 16; + if (sourceRectangle.Y + sourceRectangle.Height > laserBodyTexture.Height) + { + sourceRectangle.Y = 0; + } + } + } + + // Laser head logic + + Main.spriteBatch.Draw(laserHeadTexture, centerDelta - Main.screenPosition, null, drawColor, projectile.rotation, laserHeadTexture.Frame(1, 1, 0, 0).Top(), projectile.scale, SpriteEffects.None, 0f); + return false; + } + + public override void CutTiles() + { + DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; + Vector2 unit = projectile.velocity; + Utils.PlotTileLine(projectile.Center, projectile.Center + unit * projectile.localAI[1], (float)projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (projHitbox.Intersects(targetHitbox)) + { + return true; + } + float value = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 22f * projectile.scale, ref value)) + { + return true; + } + return false; + } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.Electrified, 300); + } + } +} diff --git a/Projectiles/Summon/MidnightSunBeam.png b/Projectiles/Summon/MidnightSunBeam.png new file mode 100644 index 0000000000..d85e68b29d Binary files /dev/null and b/Projectiles/Summon/MidnightSunBeam.png differ diff --git a/Projectiles/Summon/MidnightSunLaser.cs b/Projectiles/Summon/MidnightSunLaser.cs new file mode 100644 index 0000000000..58d85e89d1 --- /dev/null +++ b/Projectiles/Summon/MidnightSunLaser.cs @@ -0,0 +1,41 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class MidnightSunLaser : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Laser"); + Main.projFrames[projectile.type] = 1; + ProjectileID.Sets.MinionShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.light = 0.5f; + projectile.alpha = 255; + projectile.extraUpdates = 2; + projectile.tileCollide = false; + projectile.friendly = true; + projectile.minion = true; + projectile.minionSlots = 0f; + projectile.ignoreWater = true; + projectile.aiStyle = 1; + aiType = 242; + projectile.penetrate = 1; + projectile.timeLeft = 600; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 2); + return false; + } + } +} diff --git a/Projectiles/Summon/MidnightSunLaser.png b/Projectiles/Summon/MidnightSunLaser.png new file mode 100644 index 0000000000..6ddf20047c Binary files /dev/null and b/Projectiles/Summon/MidnightSunLaser.png differ diff --git a/Projectiles/Summon/MidnightSunSkyBeam.cs b/Projectiles/Summon/MidnightSunSkyBeam.cs new file mode 100644 index 0000000000..a616eba1d7 --- /dev/null +++ b/Projectiles/Summon/MidnightSunSkyBeam.cs @@ -0,0 +1,204 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.Enums; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class MidnightSunSkyBeam : ModProjectile + { + // How long this laser can exist before it is deleted. + public const int TrueTimeLeft = 180; + + // Pretty self explanatory + private const float maximumLength = 2000f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Beam"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 18; + projectile.height = 14; + projectile.friendly = true; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft = TrueTimeLeft; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } + + // Netcode for sending and receiving shit + // localAI[0] is the timer, localAI[1] is the laser length + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.localAI[0]); + writer.Write(projectile.localAI[1]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + projectile.localAI[1] = reader.ReadSingle(); + } + + public override void AI() + { + Projectile body = Main.projectile[(int)projectile.ai[0]]; + if (body.type != ModContent.ProjectileType() || !body.active) + projectile.Kill(); + + if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) + { + projectile.velocity = -Vector2.UnitY; + } + + if (body.active) + { + float angleVarianceRatio = projectile.localAI[0] / TrueTimeLeft; + float angleVariance = MathHelper.TwoPi * (projectile.ai[1] - 2f) / 2f * angleVarianceRatio * 1.25f; + float xDelta = 45f * (float)Math.Sin(angleVariance) * angleVarianceRatio; + projectile.Center = body.Center - new Vector2(xDelta, maximumLength / 2f); + } + + if (projectile.velocity.HasNaNs() || projectile.velocity == Vector2.Zero) + { + projectile.velocity = -Vector2.UnitY; + } + + // How fat the laser is + float laserSize = 1f; + + projectile.localAI[0] += 1f; + if (projectile.localAI[0] >= TrueTimeLeft) + { + projectile.Kill(); + return; + } + + // Causes the effect where the laser appears to expand/contract at the beginning and end of its life + projectile.scale = (float)Math.Sin(projectile.localAI[0] * MathHelper.Pi / TrueTimeLeft) * 10f * laserSize; + if (projectile.scale > laserSize) + { + projectile.scale = laserSize; + } + + projectile.rotation = 0f; + projectile.velocity = Vector2.UnitY; + + Vector2 samplingPoint = projectile.Center; + + float[] samples = new float[3]; + + float determinedLength = 0f; + Collision.LaserScan(samplingPoint, projectile.velocity, projectile.width * projectile.scale, maximumLength, samples); + for (int i = 0; i < samples.Length; i++) + { + determinedLength += samples[i]; + } + determinedLength /= samples.Length; + + float lerpDelta = 0.5f; + projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], determinedLength, lerpDelta); + Vector2 beamEndPosiiton = projectile.Center + projectile.velocity * (projectile.localAI[1] - 6f); + for (int i = 0; i < 4; i++) + { + float theta = projectile.velocity.ToRotation() + Main.rand.NextBool(2).ToDirectionInt() * MathHelper.PiOver2; + float speed = (float)Main.rand.NextDouble() * 2f + 2f; + Vector2 velocity = theta.ToRotationVector2() * speed; + Dust dust = Dust.NewDustDirect(beamEndPosiiton, 0, 0, 185, velocity.X, velocity.Y, 0, default, 1f); + dust.noGravity = true; + dust.scale = 1.7f; + } + + for (int i = 0; i < 8; i++) + { + Dust dust = Dust.NewDustPerfect(beamEndPosiiton, 185); + dust.velocity = Vector2.UnitY.RotatedByRandom(MathHelper.ToRadians(55f)).RotatedBy(projectile.rotation); + dust.noGravity = true; + dust.scale = 1.2f; + } + + // Draw light blue light across the laser + DelegateMethods.v3_1 = new Vector3(0.52f, 0.93f, 0.97f); + Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.velocity == Vector2.Zero) + { + return false; + } + Texture2D laserTailTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/MidnightSunBeamBegin"); + Texture2D laserBodyTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/MidnightSunBeamMid"); + Texture2D laserHeadTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/MidnightSunBeamEnd"); + float laserLength = projectile.localAI[1]; + Color drawColor = new Color(1f, 1f, 1f) * 0.9f; + + // Laser tail logic + + Main.spriteBatch.Draw(laserTailTexture, projectile.Center - Main.screenPosition, null, drawColor, projectile.rotation, laserTailTexture.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); + + // Laser body logic + + laserLength -= (laserTailTexture.Height / 2 + laserHeadTexture.Height) * projectile.scale; + Vector2 centerDelta = projectile.Center; + centerDelta += projectile.velocity * projectile.scale * (float)laserTailTexture.Height / 2f; + if (laserLength > 0f) + { + float laserLengthDelta = 0f; + Rectangle sourceRectangle = new Rectangle(0, 16 * (projectile.timeLeft / 3 % 5), laserBodyTexture.Width, 16); + while (laserLengthDelta + 1f < laserLength) + { + if (laserLength - laserLengthDelta < sourceRectangle.Height) + { + sourceRectangle.Height = (int)(laserLength - laserLengthDelta); + } + Main.spriteBatch.Draw(laserBodyTexture, centerDelta - Main.screenPosition, new Rectangle?(sourceRectangle), drawColor, projectile.rotation, new Vector2(sourceRectangle.Width / 2f, 0f), projectile.scale, SpriteEffects.None, 0f); + laserLengthDelta += sourceRectangle.Height * projectile.scale; + centerDelta += projectile.velocity * sourceRectangle.Height * projectile.scale; + sourceRectangle.Y += 16; + if (sourceRectangle.Y + sourceRectangle.Height > laserBodyTexture.Height) + { + sourceRectangle.Y = 0; + } + } + } + + // Laser head logic + + Main.spriteBatch.Draw(laserHeadTexture, centerDelta - Main.screenPosition, null, drawColor, projectile.rotation, laserHeadTexture.Frame(1, 1, 0, 0).Top(), projectile.scale, SpriteEffects.None, 0f); + return false; + } + + public override void CutTiles() + { + DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; + Vector2 unit = projectile.velocity; + Utils.PlotTileLine(projectile.Center, projectile.Center + unit * projectile.localAI[1], (float)projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (projHitbox.Intersects(targetHitbox)) + { + return true; + } + float value = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 22f * projectile.scale, ref value)) + { + return true; + } + return false; + } + } +} diff --git a/Projectiles/Summon/MidnightSunSkyBeam.png b/Projectiles/Summon/MidnightSunSkyBeam.png new file mode 100644 index 0000000000..d85e68b29d Binary files /dev/null and b/Projectiles/Summon/MidnightSunSkyBeam.png differ diff --git a/Projectiles/Summon/MidnightSunUFO.cs b/Projectiles/Summon/MidnightSunUFO.cs new file mode 100644 index 0000000000..db71e85737 --- /dev/null +++ b/Projectiles/Summon/MidnightSunUFO.cs @@ -0,0 +1,199 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class MidnightSunUFO : ModProjectile + { + public const float DistanceToCheck = 2600f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Midnight Sun UFO"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + ProjectileID.Sets.SentryShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 26; + projectile.height = 58; + 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.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 9; + } + + public override void AI() + { + Lighting.AddLight(projectile.Center, Color.SkyBlue.ToVector3()); + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + if (projectile.localAI[0] == 0f) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + projectile.velocity.Y = Main.rand.NextFloat(8f, 11f) * Main.rand.NextBool(2).ToDirectionInt(); + projectile.velocity.Y = Main.rand.NextFloat(3f, 5f) * Main.rand.NextBool(2).ToDirectionInt(); + projectile.localAI[0] = 1f; + } + if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / + projectile.Calamity().spawnedPlayerMinionDamageValue * + player.MinionDamage()); + projectile.damage = trueDamage; + } + bool isProperProjectile = projectile.type == ModContent.ProjectileType(); + player.AddBuff(ModContent.BuffType(), 3600); + if (isProperProjectile) + { + if (player.dead) + { + modPlayer.midnightUFO = false; + } + if (modPlayer.midnightUFO) + { + projectile.timeLeft = 2; + } + } + + NPC potentialTarget = projectile.Center.MinionHoming(DistanceToCheck, player); + + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } + + if (potentialTarget != null) + { + if (projectile.ai[0]++ % 360 < 180) + { + projectile.rotation = projectile.rotation.AngleTowards(0f, 0.2f); + if (projectile.ai[1] != 0f) + { + projectile.ai[1] = 0f; + } + float angle = MathHelper.ToRadians(2f * projectile.ai[0] % 180f); + Vector2 destination = potentialTarget.Center - new Vector2((float)Math.Cos(angle) * potentialTarget.width * 0.65f, 250f); + projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.DirectionTo(destination) * 24f, 0.03f); + if (projectile.ai[0] % 3f == 2f && potentialTarget.Top.Y > projectile.Bottom.Y) + { + Projectile.NewProjectile(projectile.Bottom, projectile.DirectionTo(potentialTarget.Center).RotatedByRandom(0.15f) * 25f, + ModContent.ProjectileType(), + projectile.damage, projectile.knockBack, projectile.owner); + } + float acceleration = 0.35f; + for (int index = 0; index < Main.projectile.Length; index++) + { + Projectile proj = Main.projectile[index]; + if (index != projectile.whoAmI && proj.active && proj.owner == projectile.owner && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) + { + if (projectile.position.X < proj.position.X) + { + projectile.velocity.X -= acceleration; + } + else + { + projectile.velocity.X += acceleration; + } + if (projectile.position.Y < proj.position.Y) + { + projectile.velocity.Y -= acceleration; + } + else + { + projectile.velocity.Y += acceleration; + } + } + } + } + else + { + const float framesUsedSpinning = MidnightSunBeam.TrueTimeLeft; + float totalRadiansToSpin = MathHelper.ToRadians(120f); + float totalRadiansNegativeRange = totalRadiansToSpin - (totalRadiansToSpin / 2); + float radiansToSpinPerFrame = totalRadiansNegativeRange / framesUsedSpinning * 2f; + if (projectile.ai[0] % 180 < 180 - framesUsedSpinning) + { + projectile.rotation = projectile.rotation.AngleLerp(projectile.AngleTo(potentialTarget.Center) - MathHelper.PiOver2 - totalRadiansNegativeRange, 0.15f); + + Vector2 spawnPosition = projectile.Center + Utils.NextVector2Unit(Main.rand).RotatedBy(projectile.rotation) * new Vector2(13f, 6f) / 2f; + int idx = Dust.NewDust(spawnPosition - Vector2.One * 8f, 16, 16, 229, projectile.velocity.X / 2f, projectile.velocity.Y / 2f, 0, default, 1f); + Main.dust[idx].velocity = Vector2.Normalize(projectile.Center - spawnPosition) * 2.6f; + Main.dust[idx].noGravity = true; + Main.dust[idx].scale = 0.9f; + } + else + { + projectile.rotation += radiansToSpinPerFrame; + if (projectile.ai[1] == 0f) + { + Main.PlaySound(SoundID.Item122, projectile.Center); + Projectile.NewProjectile(projectile.Center, (projectile.velocity.ToRotation() + MathHelper.PiOver2).ToRotationVector2(), + ModContent.ProjectileType(), projectile.damage * 2, projectile.knockBack, projectile.owner, + radiansToSpinPerFrame, projectile.whoAmI); + projectile.ai[1] = 1f; + } + } + projectile.velocity *= 0.935f; + } + } + else + { + projectile.velocity = (projectile.velocity * 15f + projectile.DirectionTo(player.Center - new Vector2(player.direction * -80f, 160f)) * 19f) / 16f; + + float acceleration = 0.35f; + for (int index = 0; index < Main.projectile.Length; index++) + { + Projectile proj = Main.projectile[index]; + if (index != projectile.whoAmI && proj.active && proj.owner == projectile.owner && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) + { + if (projectile.position.X < proj.position.X) + { + projectile.velocity.X -= acceleration; + } + else + { + projectile.velocity.X += acceleration; + } + if (projectile.position.Y < proj.position.Y) + { + projectile.velocity.Y -= acceleration; + } + else + { + projectile.velocity.Y += acceleration; + } + } + } + projectile.rotation = projectile.velocity.X * 0.03f; + } + } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); + return false; + } + } +} diff --git a/Projectiles/Summon/MidnightSunUFO.png b/Projectiles/Summon/MidnightSunUFO.png new file mode 100644 index 0000000000..5b51bfecda Binary files /dev/null and b/Projectiles/Summon/MidnightSunUFO.png differ diff --git a/Projectiles/Summon/PlaguebringerMK2.cs b/Projectiles/Summon/PlaguebringerMK2.cs index 9bea93e1cb..bfa9ef0a3e 100644 --- a/Projectiles/Summon/PlaguebringerMK2.cs +++ b/Projectiles/Summon/PlaguebringerMK2.cs @@ -68,8 +68,10 @@ namespace CalamityMod.Projectiles.Summon if (potentialTarget != null) { int sign = (potentialTarget.Center.X - projectile.Center.X < 0).ToDirectionInt(); - Vector2 destination = potentialTarget.Center + new Vector2((125f + 40f * projectile.ai[1]) * sign, -160f); - if (projectile.Distance(destination) < 65f) + float x = (125f + 40f * (int)(projectile.ai[1] % 10f)) * sign; + int y = -160 - 50 * (int)(projectile.ai[1] / 10); + Vector2 destination = potentialTarget.Center + new Vector2(x, y); + if (projectile.Distance(destination) < 6f) { projectile.velocity *= 0.9f; } @@ -102,10 +104,9 @@ namespace CalamityMod.Projectiles.Summon else { projectile.localAI[1] = 0; - Vector2 distanceToDestination = player.Center - projectile.Center; - distanceToDestination.X -= 10f * player.direction; - distanceToDestination.X -= projectile.ai[1] * 40 * player.direction; - distanceToDestination.Y -= 10f; + float x = (45f + 35f * (int)(projectile.ai[1] % 10f)) * -player.direction; + int y = -60 - 50 * (int)(projectile.ai[1] / 10); + Vector2 distanceToDestination = player.Center - projectile.Center + new Vector2(x, y); float distance = distanceToDestination.Length(); if (distance > 10f) { diff --git a/Projectiles/Summon/TacticalPlagueEngineSummon.cs b/Projectiles/Summon/TacticalPlagueEngineSummon.cs new file mode 100644 index 0000000000..154eb578ce --- /dev/null +++ b/Projectiles/Summon/TacticalPlagueEngineSummon.cs @@ -0,0 +1,193 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.Dusts; +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class TacticalPlagueEngineSummon : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tactical Plague Engine"); + Main.projFrames[projectile.type] = 3; + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 52; + projectile.height = 32; + projectile.netImportant = true; + projectile.friendly = true; + projectile.minionSlots = 1; + projectile.timeLeft = 18000; + projectile.penetrate = -1; + projectile.timeLeft *= 5; + projectile.minion = true; + projectile.tileCollide = false; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 9; + } + + public override void AI() + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + if (projectile.localAI[0] == 0f) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = (player.allDamage + player.minionDamage - 1f); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + for (int i = 0; i < 45; i++) + { + float angle = MathHelper.TwoPi / 45f * i; + Vector2 velocity = angle.ToRotationVector2() * 4f; + Dust dust = Dust.NewDustPerfect(projectile.Center + velocity * 2f, (int)CalamityDusts.Plague, velocity); + dust.noGravity = true; + } + projectile.localAI[0] = 1f; + } + if (projectile.frameCounter++ > 6f) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } + if ((player.allDamage + player.minionDamage - 1f) != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int trueDamage = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / + projectile.Calamity().spawnedPlayerMinionDamageValue * + (player.allDamage + player.minionDamage - 1f)); + projectile.damage = trueDamage; + } + bool isCorrectProjectile = projectile.type == ModContent.ProjectileType(); + player.AddBuff(ModContent.BuffType(), 3600); + if (isCorrectProjectile) + { + if (player.dead) + { + modPlayer.plagueEngine = false; + } + if (modPlayer.plagueEngine) + { + projectile.timeLeft = 2; + } + } + NPC potentialTarget = projectile.Center.MinionHoming(1560f, player); + + Item exampleGun = new Item() + { + useAmmo = AmmoID.Bullet + }; + + if (potentialTarget == null || !player.HasAmmo(exampleGun, false)) + { + float acceleration = 0.1f; + Vector2 distanceVector = player.Center - projectile.Center; + if (distanceVector.Length() < 200f) + { + acceleration = 0.07f; + } + if (distanceVector.Length() < 140f) + { + acceleration = 0.035f; + } + if (distanceVector.Length() > 100f) + { + if (Math.Abs(player.Center.X - projectile.Center.X) > 20f) + { + projectile.velocity.X += acceleration * Math.Sign(player.Center.X - projectile.Center.X); + } + if (Math.Abs(player.Center.Y - projectile.Center.Y) > 10f) + { + projectile.velocity.Y += acceleration * Math.Sign(player.Center.Y - projectile.Center.Y); + } + } + else if (projectile.velocity.Length() > 4f) + { + projectile.velocity *= 0.95f; + } + if (Math.Abs(projectile.velocity.Y) < 2f) + { + projectile.velocity.Y += 0.1f * Math.Sign(player.Center.Y - projectile.Center.Y); + } + if (projectile.velocity.Length() > 9f) + { + projectile.velocity = Vector2.Normalize(projectile.velocity) * 9f; + } + + if (projectile.velocity.X > 0.25f) + { + projectile.spriteDirection = 1; + } + else if (projectile.velocity.X < -0.25f) + { + projectile.spriteDirection = -1; + } + projectile.rotation = projectile.rotation.AngleTowards(0f, 0.2f); + } + else + { + projectile.spriteDirection = 1; + Vector2 idealVelocity = projectile.DirectionTo(potentialTarget.Center - Vector2.UnitY * 195f) * 17f; + projectile.velocity = Vector2.Lerp(projectile.velocity, idealVelocity, 0.035f); + projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(potentialTarget.Center), 0.1f); + + if (projectile.ai[0]++ % 25f == 24f) + { + int damage = projectile.damage; + if (Main.rand.NextBool(20)) + { + int idx = Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center) * 18f, ModContent.ProjectileType(), + damage, 5f, projectile.owner); + Main.projectile[idx].Calamity().forceMinion = true; + } + else + { + int shoot = 0; + float shootSpeed = 0f; + bool canShoot = true; + float knockBack = projectile.knockBack * 0.5f; + player.PickAmmo(exampleGun, ref shoot, ref shootSpeed, ref canShoot, ref damage, ref knockBack); + int idx = Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center) * shootSpeed, shoot, + damage, knockBack, projectile.owner); + Main.projectile[idx].Calamity().forceMinion = true; + } + } + float SAImovement = 0.25f; + for (int index = 0; index < Main.projectile.Length; index++) + { + Projectile proj = Main.projectile[index]; + if (index != projectile.whoAmI && + proj.active && proj.owner == projectile.owner && + proj.type == projectile.type && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < 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; + } + } + } + } + } + } +} diff --git a/Projectiles/Summon/TacticalPlagueEngineSummon.png b/Projectiles/Summon/TacticalPlagueEngineSummon.png new file mode 100644 index 0000000000..9dc69c1a3e Binary files /dev/null and b/Projectiles/Summon/TacticalPlagueEngineSummon.png differ