diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 2140e448d6..a8bb99ba4d 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -802,6 +802,7 @@ namespace CalamityMod.CalPlayer #endregion #region Accessory + public int friendlyMinions = 0; public bool shieldOfTheHighRulerDashVelocityBoosted = false; public bool yharimsGift = false; public bool luxorsGift = false; @@ -2243,6 +2244,7 @@ namespace CalamityMod.CalPlayer if (!pSoulArtifact) pSoulShieldDurability = 0; } + friendlyMinions = 0; pSoulShieldVisible = false; roverDrive = false; roverDriveShieldVisible = false; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 085ae24558..f01a70a522 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -1685,6 +1685,16 @@ namespace CalamityMod.CalPlayer if (rOfResilienceCooldown > 0) rOfResilienceCooldown--; + if (Player.Calamity().friendlyMinions > 0) + { + int numOfPigs = Player.ownedProjectileCounts[ModContent.ProjectileType()]; + if (numOfPigs < Player.Calamity().friendlyMinions) + { + int pigDamage = 12; + Projectile.NewProjectileDirect(Player.GetSource_FromThis(), Player.Center, new Vector2(0, 16).RotatedByRandom(MathHelper.TwoPi), ModContent.ProjectileType(), pigDamage, 0f, Player.whoAmI, 0, numOfPigs + 1); + } + } + if (transformer && Player.Calamity().transformerCooldown == 0 && transformerDelay == 0) // The code for this acursed thing took much... MUCH, too long to make { float zoneSize = 150; @@ -3279,7 +3289,6 @@ namespace CalamityMod.CalPlayer #region Other Buff Effects private void OtherBuffEffects() { - if (gravityNormalizer) { Player.buffImmune[BuffID.VortexDebuff] = true; diff --git a/Items/Weapons/Melee/Orderbringer.cs b/Items/Weapons/Melee/Orderbringer.cs index 3fc0e1639a..30886f64d4 100644 --- a/Items/Weapons/Melee/Orderbringer.cs +++ b/Items/Weapons/Melee/Orderbringer.cs @@ -120,7 +120,7 @@ namespace CalamityMod.Items.Weapons.Melee } } - Particle swipe = new CustomSpark(player.Center - shootDir * 5, shootDir.RotatedBy(0.4f * (dir * (swingCount % 2 == 0 ? 1 : -1))) * 2.5f, "CalamityMod/Particles/VerticalSmearLarge", false, (int)(14 / player.GetAttackSpeed(DamageClass.Melee)), 0.8f, player.Calamity().lightRGB, new Vector2(1f, 1f), true, false, 0, false, false); + Particle swipe = new CustomSpark(player.Center - shootDir * 5 * Item.scale, shootDir.RotatedBy(0.4f * (dir * (swingCount % 2 == 0 ? 1 : -1))) * 2.5f, "CalamityMod/Particles/VerticalSmearLarge", false, (int)(14 / player.GetAttackSpeed(DamageClass.Melee)), 0.8f * Item.scale, player.Calamity().lightRGB, new Vector2(1f, 1f), true, false, 0, false, false); GeneralParticleHandler.SpawnParticle(swipe); SoundEngine.PlaySound(SoundID.Item60, player.Center); diff --git a/Localization/en-US/Mods.CalamityMod.Prefixes.hjson b/Localization/en-US/Mods.CalamityMod.Prefixes.hjson index e8127c2e3e..cefd97c27c 100644 --- a/Localization/en-US/Mods.CalamityMod.Prefixes.hjson +++ b/Localization/en-US/Mods.CalamityMod.Prefixes.hjson @@ -2,13 +2,16 @@ Accessory: { Silent.DisplayName: Silent Invigorating.DisplayName: Invigorating Dauntless.DisplayName: Dauntless + Friendly.DisplayName: Friendly // New modifier effects (this is only positive) StealthGenTooltip: +{0}% stealth generation LifeRegenTooltip: +{0} HP/s life regen MaxLifeBoostTooltip: +{0} max life + FriendlyTooltip: +{0} Minion } Weapon: { + Horrible.DisplayName: Horrible Atrocious.DisplayName: Atrocious Blunt.DisplayName: Blunt Feathered.DisplayName: Feathered diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson index cda4323410..9a89768bea 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson @@ -171,3 +171,4 @@ XykDeathAnim.DisplayName: Xyk Death Animation XykWings.DisplayName: Xyk Wings StratusBlackHole.DisplayName: Stratus Singularity DebuffSpreadEffect.DisplayName: Debuff Spread Effect +Pigion.DisplayName: Pigion diff --git a/Prefixes/AccessoryPrefix.cs b/Prefixes/AccessoryPrefix.cs index 389f304da9..db22f8f780 100644 --- a/Prefixes/AccessoryPrefix.cs +++ b/Prefixes/AccessoryPrefix.cs @@ -66,4 +66,33 @@ namespace CalamityMod.Prefixes return 15; } } + + public class Friendly : ModPrefix, ILocalizedModType + { + public new string LocalizationCategory => "Prefixes.Accessory"; + public override PrefixCategory Category => PrefixCategory.Accessory; + + public override void ApplyAccessoryEffects(Player player) + { + // give Minion + player.Calamity().friendlyMinions++; + } + public override void ModifyValue(ref float valueMult) + { + valueMult = 2.5f; + } + public override float RollChance(Item item) => 10; // Is manually applied by an item, can't be rerolled normally + public override bool CanRoll(Item item) + { + return true; + } + public LocalizedText FriendlyTooltip => CalamityUtils.GetText($"{LocalizationCategory}.FriendlyTooltip"); + public override IEnumerable GetTooltipLines(Item item) + { + yield return new TooltipLine(Mod, "CalamityMod:PrefixFriendly", FriendlyTooltip.Format(1)) + { + IsModifier = true + }; + } + } } diff --git a/Prefixes/HorribleWeaponPrefix.cs b/Prefixes/HorribleWeaponPrefix.cs new file mode 100644 index 0000000000..a4cb2c4fab --- /dev/null +++ b/Prefixes/HorribleWeaponPrefix.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using CalamityMod.Items; +using Terraria; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Prefixes +{ + + public class Horrible : HorribleWeaponPrefix + { + public override float damageMult => 0.50f; + public override float sizeMult => 3f; + } + public abstract class HorribleWeaponPrefix : ModPrefix, ILocalizedModType + { + public new string LocalizationCategory => "Prefixes.Weapon"; + + // Stats + public virtual float damageMult => 1f; + public virtual float sizeMult => 1f; + + public override PrefixCategory Category => PrefixCategory.AnyWeapon; + public override float RollChance(Item item) => 10; // Is manually applied by an item, can't be rerolled normally + public override bool CanRoll(Item item) + { + return item.DamageType != null && item.DamageType != DamageClass.Default; + } + // Applying normal weapon stats + public override void SetStats(ref float damageMult, ref float knockbackMult, ref float useTimeMult, ref float scaleMult, ref float shootSpeedMult, ref float manaMult, ref int critBonus) + { + damageMult = this.damageMult; + scaleMult = this.sizeMult; + } + public override void ModifyValue(ref float valueMult) + { + valueMult = 2.5f; + } + } +} diff --git a/Projectiles/Typeless/Pigion.cs b/Projectiles/Typeless/Pigion.cs new file mode 100644 index 0000000000..9d9c21f1d7 --- /dev/null +++ b/Projectiles/Typeless/Pigion.cs @@ -0,0 +1,320 @@ +using System; +using System.IO; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.CalPlayer; +using CalamityMod.Dusts; +using CalamityMod.NPCs; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class Pigion : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public Player Owner => Main.player[Projectile.owner]; + public CalamityPlayer moddedOwner => Owner.Calamity(); + public bool canDamage = false; + public Color cl1 = Color.Gold; + public Color cl2 = Color.Goldenrod; + public bool clicked = false; + public int hopTimer = 0; + public int hopMax = 100; + public bool hitGround = false; + public bool hitWall = false; + public Vector2 lastUnmodVel; + public Vector2 mousePos; + public int thrownTimer = 0; + public int thrownTimerMax = 300; + public bool deadPig = false; + public ref float time => ref Projectile.ai[0]; + public ref float minionNumber => ref Projectile.ai[1]; + public bool pigGrabbed => Projectile.ai[2] == 5; + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 2; + } + public override void SetDefaults() + { + Projectile.width = 21; + Projectile.height = 28; + Projectile.friendly = true; + Projectile.DamageType = AverageDamageClass.Instance; + Projectile.ignoreWater = true; + Projectile.tileCollide = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 600; + Projectile.extraUpdates = 1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 60 * Projectile.MaxUpdates; + Projectile.ArmorPenetration = 25; + } + public void Frames() + { + Projectile.frameCounter++; + if (Projectile.frameCounter > 6 * Projectile.MaxUpdates) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame >= 2) + Projectile.frame = 0; + } + public override void AI() + { + mousePos = Owner.ClampedMouseWorld(); + if (time == 0) + { + time = Main.rand.Next(1, 800 + 1); + Projectile.spriteDirection = Main.rand.NextBool() ? -1 : 1; + lastUnmodVel = Projectile.velocity; + } + + Frames(); + + // Make an idle sound + if (Main.rand.NextBool(280) && Projectile.soundDelay == 0) + { + SoundStyle oink = new("CalamityMod/Sounds/Item/Swine", 2); + SoundEngine.PlaySound(oink with { Volume = 0.35f, Pitch = Main.rand.NextFloat(0.3f, 0.5f), MaxInstances = 5 }, Projectile.Center); + Projectile.soundDelay = 180; + } + + // Teleport back to player if too far away + if (Projectile.Center.Distance(Owner.Center) > 1500) + { + Projectile.velocity = (Vector2.UnitX * 16).RotatedByRandom(MathHelper.TwoPi); + Projectile.Center = Owner.Center; + } + + // Check if being clicked and no other Pigions are being clicked + if (Owner.controlUseItem && Projectile.Center.Distance(mousePos) <= 60 && !pigGrabbed && Projectile.ai[2] == 0) + SetGrab(true); + + float hitboxSizeMult = 0.45f; + bool touchingWall = Collision.SolidCollision(Vector2.Lerp(Projectile.TopLeft, Projectile.Left, 0.15f) + Vector2.UnitX * Projectile.velocity.X, 1, (int)(Projectile.height * hitboxSizeMult)) || Collision.SolidCollision(Vector2.Lerp(Projectile.TopRight, Projectile.Right, 0.15f) + Vector2.UnitX * Projectile.velocity.X, 1, (int)(Projectile.height * hitboxSizeMult)); + if (touchingWall) + { + FlipDirection(-Projectile.spriteDirection); + Projectile.velocity.X += Projectile.spriteDirection; + } + if (!pigGrabbed) + Slam(touchingWall, hitboxSizeMult); + else + thrownTimer = thrownTimerMax; + lastUnmodVel = Projectile.velocity; + + Movement(); + + // Push away enemies it touches + NPC npc = Projectile.Center.ClosestNPCAt(40, false); + if (npc != null && !pigGrabbed) + npc.MoveNPC(Utils.DirectionTo(Projectile.Center, npc.Center), 6, true); + + if (thrownTimer > 0) + thrownTimer--; + hopTimer--; + time++; + Projectile.timeLeft++; + if (moddedOwner.friendlyMinions < minionNumber || Owner.dead || deadPig) + { + Projectile.Kill(); + return; + } + } + public void Slam(bool touchingWall, float hitboxSizeMult) + { + bool onPlatform = false; + float thrownMult = Utils.Remap(thrownTimer, 0, thrownTimerMax, 0.6f, 1f); + if (Projectile.velocity.Y > 0) + { + for (int i = 4; i < 8; i++) + { + Point bottom = (Projectile.Bottom + Vector2.UnitY * i).ToTileCoordinates(); + if (TileID.Sets.Platforms[CalamityUtils.ParanoidTileRetrieval(bottom.X, bottom.Y).TileType]) + { + onPlatform = true; + } + } + } + float velX = MathF.Abs(lastUnmodVel.X); + float velY = MathF.Abs(lastUnmodVel.Y); + float minMoveSpeed = 5; + bool hitDown = velY > minMoveSpeed && (Collision.SolidCollision(Projectile.Bottom + Vector2.UnitY * Projectile.velocity.Y, (int)(Projectile.width * hitboxSizeMult), 1) || onPlatform); + bool hitUp = velY > minMoveSpeed && Collision.SolidCollision(Projectile.Top + Vector2.UnitY * Projectile.velocity.Y, (int)(Projectile.width * hitboxSizeMult), 1); + bool hitSide = velX > minMoveSpeed && touchingWall; + bool hardHit = Projectile.velocity.Length() > 25; + float volumeMult = Utils.GetLerpValue(minMoveSpeed - 2, minMoveSpeed * 5, Projectile.velocity.Length(), true); + + if (hitDown || hitUp) + { + if (!hitGround && MathF.Abs(lastUnmodVel.Y) > 1) + { + if (hardHit) + { + deadPig = true; + return; + } + Projectile.velocity.Y = -lastUnmodVel.Y * thrownMult; + MakeDustAndSound(false, volumeMult); + hitGround = true; + } + } + else + hitGround = false; + + if (hitSide) + { + if (!hitWall && MathF.Abs(lastUnmodVel.X) > 1) + { + if (hardHit) + { + deadPig = true; + return; + } + Projectile.velocity.X = -lastUnmodVel.X * thrownMult; + MakeDustAndSound(true, volumeMult); + hitWall = true; + } + } + else + hitWall = false; + } + public void MakeDustAndSound(bool wall, float volumeMult) + { + SoundStyle splat = new("CalamityMod/Sounds/NPCHit/PerfSmallHit", 3); + SoundEngine.PlaySound(splat with { Volume = 0.8f * volumeMult, Pitch = Main.rand.NextFloat(0.3f, 0.4f) - volumeMult * 0.3f }, Projectile.Center); + + Vector2 vel = Projectile.velocity.SafeNormalize(Vector2.UnitX); + float power = 0.2f + Utils.GetLerpValue(0, 40, Projectile.velocity.Length()); + for (int i = 0; i < (int)(12 * power); i++) + { + float variance = Main.rand.NextFloat(-0.8f, 0.8f); + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), + vel.RotatedBy(variance).RotatedByRandom(MathF.Abs(variance) / 3) * Main.rand.NextFloat(15.0f, 18.0f) * MathF.Pow((1 - MathF.Abs(variance)), 2), 0, default, power * Main.rand.NextFloat(2.3f, 3.2f) - MathF.Abs(variance)); + dust.noGravity = Main.rand.NextBool(2, 3); + dust.color = Main.rand.NextBool() ? cl1 : cl2; + dust.customData = new Vector2(0.8f, 1.1f); + dust.fadeIn = 3.5f * power; + } + } + public void FlipDirection(int newDirection) + { + Projectile.spriteDirection = newDirection; + time = 1; + } + public void SetGrab(bool isGrabbed) => Projectile.ai[2] = (isGrabbed ? 5 : 0); + public void Movement() + { + // Flip movement direction every once in a while + if (time % 900 == 0) + FlipDirection(-Projectile.spriteDirection); + + Projectile.velocity.X *= 0.97f; + if (pigGrabbed) + { + FlipDirection(MathF.Sign(Projectile.Center.DirectionTo(mousePos).X)); + Vector2 goalVel = (mousePos - Projectile.Center) / (18); + Projectile.velocity = goalVel; + } + if (!Owner.controlUseItem) + SetGrab(false); + + if (Projectile.velocity.Y < 14) + Projectile.velocity.Y += 0.3f * Utils.GetLerpValue(100, 0, hopTimer, true); + + int walkRate = 90; // Walk along slowly + if (!pigGrabbed && time % walkRate == 0) + { + Projectile.velocity.X += 1 * Projectile.spriteDirection; + } + + // lil hops when near other Pigions + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + bool validPig = projectile.active && projectile.type == Projectile.type && projectile != Projectile; + float distance = Vector2.Distance(Projectile.Center, projectile.Center); + if (validPig) + { + if (pigGrabbed) + projectile.ai[2] = 1; // set all other Pigions to be counted as not grabable + if (distance <= 80 && distance != 0 && hopTimer <= 0 && thrownTimer == 0) + { + int directionOfJump = -MathF.Sign(Projectile.Center.DirectionTo(projectile.Center).X); + Projectile.velocity += new Vector2(Main.rand.NextFloat(-2.5f, -4) * directionOfJump, -2); + FlipDirection(-directionOfJump); + hopTimer = 100; + } + } + } + + float minSpeed = 4; + float maxSpeed = 14; + float goalRot = Utils.AngleLerp(0, Projectile.velocity.ToRotation() + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0), Utils.GetLerpValue(minSpeed, maxSpeed, Projectile.velocity.Length(), true)); + Projectile.rotation = goalRot; + + } + public override void OnKill(int timeLeft) + { + int damage = (int)(Projectile.damage * MathF.Pow(Owner.GetBestClassDamage().ApplyTo(1), 0.3f + Owner.ownedProjectileCounts[Projectile.type] * 0.7f)); // Damage scales with number of pigions at 0.7 power + float blastSize = 100; + float minMultiplier = 0.1f; + int hitsToMinMult = 6; + Projectile blast = Projectile.NewProjectileDirect(Owner.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(damage), -15, Owner.whoAmI, blastSize, minMultiplier, hitsToMinMult); + blast.timeLeft = 5; + blast.DamageType = AverageDamageClass.Instance; + blast.CritChance = 100; + + Owner.SetScreenshake(3); + SoundStyle die = new("CalamityMod/Sounds/Item/PigionSqueal"); + SoundEngine.PlaySound(die with { Volume = 0.55f, Pitch = Main.rand.NextFloat(-0.2f, 0.4f), MaxInstances = 7 }, Projectile.Center); + SoundStyle die2 = new("CalamityMod/Sounds/NPCKilled/PerfMediumDeath"); + SoundEngine.PlaySound(die2 with { Volume = 0.6f, Pitch = Main.rand.NextFloat(0.2f, 0.3f) }, Projectile.Center); + for (int i = 0; i < 24; i++) + { + Vector2 dustVel = (Vector2.One * 6).RotatedByRandom(100); + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), dustVel * Main.rand.NextFloat(0.1f, 0.8f)); + dust.noGravity = Main.rand.NextBool(2, 3); + dust.scale = Main.rand.NextFloat(0.5f, 0.8f); + dust.color = Color.Red; + dust.noLightEmittence = true; + dust.fadeIn = -0.4f; + + if (i % 2 == 0) + { + Particle pulse1 = new CustomSpark(Projectile.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(1, 6), "CalamityMod/Particles/BloomCircle", false, Main.rand.Next(20, 35 + 1), Main.rand.NextFloat(0.2f, 0.35f), Color.Red * 0.55f, new Vector2(1f, 1f), noShrink: true); + GeneralParticleHandler.SpawnParticle(pulse1); + pulse1.Pixelate = true; + } + } + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + return false; + } + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) + { + fallThrough = (pigGrabbed && mousePos.Y > Projectile.Center.Y); + return true; + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Rectangle frame = texture.Frame(1, 2, 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + float minSpeed = 4; + float maxSpeed = 20; + Vector2 squash = new Vector2(Utils.Remap(Projectile.velocity.Length(), minSpeed, maxSpeed, 1, 2), Utils.Remap(Projectile.velocity.Length(), minSpeed, maxSpeed, 1, 0.5f)); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, frame, lightColor, Projectile.rotation, origin, squash * Projectile.scale, Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + return false; + } + public override bool? CanDamage() => canDamage ? null : false; + public override bool? CanCutTiles() => false; + } +} diff --git a/Projectiles/Typeless/Pigion.png b/Projectiles/Typeless/Pigion.png new file mode 100644 index 0000000000..36858f908c Binary files /dev/null and b/Projectiles/Typeless/Pigion.png differ diff --git a/Sounds/Item/PigionSqueal.ogg b/Sounds/Item/PigionSqueal.ogg new file mode 100644 index 0000000000..bbea056193 Binary files /dev/null and b/Sounds/Item/PigionSqueal.ogg differ