diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs
index a133cd33c7..b0baa3fd39 100644
--- a/CalPlayer/CalamityPlayer.cs
+++ b/CalPlayer/CalamityPlayer.cs
@@ -112,6 +112,7 @@ namespace CalamityMod.CalPlayer
public double contactDamageReduction = 0D;
public double projectileDamageReduction = 0D;
public int hellbornShots = 0;
+ public int garandShots = 0;
public int searedPanCounter = 0;
public int searedPanTimer = 0;
/// Used to get around the hardcoded Potion Sickness duration to allow Hadal Stew's reduced duration.
@@ -3215,6 +3216,7 @@ namespace CalamityMod.CalPlayer
burningSeaBurnOut = 0;
flareGunOverheat = 0;
hellbornShots = 0;
+ garandShots = 0;
searedPanCounter = 0;
searedPanTimer = 0;
potionTimer = 0;
diff --git a/Cooldowns/M1GarandShots.cs b/Cooldowns/M1GarandShots.cs
new file mode 100644
index 0000000000..e6fd6f1f78
--- /dev/null
+++ b/Cooldowns/M1GarandShots.cs
@@ -0,0 +1,49 @@
+using System;
+using CalamityMod.Items.Accessories;
+using CalamityMod.Items.Weapons.Melee;
+using CalamityMod.Items.Weapons.Ranged;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+using Terraria;
+using Terraria.Audio;
+using Terraria.GameContent;
+using Terraria.Graphics.Shaders;
+using Terraria.ID;
+using Terraria.Localization;
+using static Terraria.ModLoader.ModContent;
+
+namespace CalamityMod.Cooldowns
+{
+ public class M1GarandShots : CooldownHandler
+ {
+ public float CompletionPercentage => MathF.Round(instance.Completion * 100);
+ private bool IsEmpty => CompletionPercentage == 100;
+ private float TextXOffset => -5.4f;
+ private Vector2 TextPosition => new(TextXOffset, 15);
+ private Color TextColor => Color.Silver;
+ private Color TextBorderColor = Color.DarkGoldenrod;
+
+ public static new string ID => "M1GarandShots";
+ public override bool CanTickDown => false;
+ public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}");
+ public override bool ShouldDisplay => instance.player.HeldItem.type == ItemType();
+ public override string Texture => "CalamityMod/Cooldowns/" + ID;
+
+ public override Color CooldownStartColor => IsEmpty ? Color.DimGray : Color.Lerp(Color.DarkGoldenrod, Color.SlateGray, instance.Completion);
+ public override Color CooldownEndColor => IsEmpty ? Color.DimGray : Color.Lerp(Color.LightGoldenrodYellow, Color.SlateGray, instance.Completion);
+
+ public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale)
+ {
+ base.DrawExpanded(spriteBatch, position, opacity, scale);
+
+ CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.player.Calamity().garandShots.ToString(), position + TextPosition, TextColor, TextBorderColor);
+ }
+
+ public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale)
+ {
+ base.DrawCompact(spriteBatch, position, opacity, scale);
+
+ CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.player.Calamity().garandShots.ToString(), position + TextPosition, TextColor, TextBorderColor);
+ }
+ }
+}
diff --git a/Cooldowns/M1GarandShots.png b/Cooldowns/M1GarandShots.png
new file mode 100644
index 0000000000..b50e512ae9
Binary files /dev/null and b/Cooldowns/M1GarandShots.png differ
diff --git a/Cooldowns/M1GarandShotsOutline.png b/Cooldowns/M1GarandShotsOutline.png
new file mode 100644
index 0000000000..495f87eb5c
Binary files /dev/null and b/Cooldowns/M1GarandShotsOutline.png differ
diff --git a/Cooldowns/M1GarandShotsOverlay.png b/Cooldowns/M1GarandShotsOverlay.png
new file mode 100644
index 0000000000..4d8b9e04e8
Binary files /dev/null and b/Cooldowns/M1GarandShotsOverlay.png differ
diff --git a/Items/Weapons/Ranged/M1Garand.cs b/Items/Weapons/Ranged/M1Garand.cs
new file mode 100644
index 0000000000..82e8ca5c06
--- /dev/null
+++ b/Items/Weapons/Ranged/M1Garand.cs
@@ -0,0 +1,63 @@
+using CalamityMod.Projectiles.Ranged;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+using Terraria;
+using Terraria.ID;
+using Terraria.ModLoader;
+using Terraria.DataStructures;
+using static Terraria.ModLoader.ModContent;
+using CalamityMod.Cooldowns;
+
+namespace CalamityMod.Items.Weapons.Ranged
+{
+ public class M1Garand : ModItem, ILocalizedModType
+ {
+ public new string LocalizationCategory => "Items.Weapons.Ranged";
+ public override void SetDefaults()
+ {
+ Item.width = 102;
+ Item.height = 22;
+ Item.damage = 52;
+ Item.DamageType = DamageClass.Ranged;
+
+ Item.useTime = 40;
+ Item.useAnimation = 40;
+ Item.useStyle = ItemUseStyleID.Shoot;
+ Item.noMelee = true;
+ Item.knockBack = 2f;
+ Item.autoReuse = false; // Because holdout
+ Item.channel = true; // Because holdout
+ Item.shoot = ModContent.ProjectileType();
+ Item.shootSpeed = 12f;
+ Item.useAmmo = AmmoID.Bullet;
+ Item.noUseGraphic = true; // Took me longer than I'd like to admit to find this.
+
+ Item.value = CalamityGlobalItem.RarityOrangeBuyPrice;
+ Item.rare = ItemRarityID.Orange;
+ }
+
+ public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 10;
+ public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0;
+ public override void HoldItem(Player player)
+ {
+ if (player.Calamity().cooldowns.TryGetValue(M1GarandShots.ID, out var cooldown))
+ {
+ cooldown.timeLeft = 8 - player.Calamity().garandShots;
+ }
+ else
+ {
+ player.AddCooldown(M1GarandShots.ID, 8);
+ }
+ }
+
+ public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
+ {
+ Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ProjectileType(), damage, knockback, player.whoAmI);
+
+ // Seting its velocity like this is what aims to the mouse
+ holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero);
+
+ return false;
+ }
+ }
+}
diff --git a/Items/Weapons/Ranged/M1Garand.png b/Items/Weapons/Ranged/M1Garand.png
new file mode 100644
index 0000000000..a0b47c6f6d
Binary files /dev/null and b/Items/Weapons/Ranged/M1Garand.png differ
diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson
index 021008f3c8..2d767078ac 100644
--- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson
+++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson
@@ -676,6 +676,17 @@ LunarianBow: {
'''
}
+M1Garand: {
+ DisplayName: M1 Garand
+ Tooltip:
+ '''
+ Shots fired only inherit the damage of the bullet used
+ Fires 8 bullets before ejecting the rifle's cartridge
+ Bullets which ricochet off coins can ricochet off cartridges too
+ 'Mind your thumb'
+ '''
+}
+
MagnaCannon: {
DisplayName: Magna Cannon
Tooltip:
diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson
index c6be216f3d..e7a674c92d 100644
--- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson
+++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson
@@ -262,3 +262,5 @@ LeviatitanMeteor.DisplayName: Leviatitan Meteor
LeviatitanExplosion.DisplayName: Leviatitan Explosion
SulphuricDrop.DisplayName: Sulphuric Drop
AcidRocket.DisplayName: Acid Rocket
+M1GarandBulletCasing.DisplayName: M1 Garand Bullet Casing
+M1GarandEmptyClip.DisplayName: M1 Garand Empty Clip
diff --git a/Localization/en-US/Mods.CalamityMod.UI.hjson b/Localization/en-US/Mods.CalamityMod.UI.hjson
index 21ba79f713..2a0d44bc1a 100644
--- a/Localization/en-US/Mods.CalamityMod.UI.hjson
+++ b/Localization/en-US/Mods.CalamityMod.UI.hjson
@@ -117,6 +117,7 @@ Cooldowns: {
KillModeCooldown: Kill Mode Cooldown
LifeSteal: Life Steal Cooldown
LionHeartShield: Energy Shell Cooldown
+ M1GarandShots: Chambered Rounds
MasterChefShieldDurability: MJOLNIR Shield Level
MasterChefShieldRecharge: MJOLNIR Shield Recharge
NebulousCore: Nebulous Core Cooldown
diff --git a/Projectiles/Ranged/M1GarandBulletCasing.cs b/Projectiles/Ranged/M1GarandBulletCasing.cs
new file mode 100644
index 0000000000..50acf6549c
--- /dev/null
+++ b/Projectiles/Ranged/M1GarandBulletCasing.cs
@@ -0,0 +1,66 @@
+using Microsoft.Xna.Framework;
+using Terraria;
+using Terraria.ModLoader;
+
+namespace CalamityMod.Projectiles.Ranged
+{
+ public class M1GarandBulletCasing : ModProjectile, ILocalizedModType
+ {
+ public new string LocalizationCategory => "Projectiles.Ranged";
+ public override string Texture => "CalamityMod/Projectiles/Ranged/M1GarandBulletCasing";
+ public int Time = 0;
+ public bool TouchedGrass = false;
+
+ public override void SetDefaults()
+ {
+ Projectile.width = 6;
+ Projectile.height = 12;
+ Projectile.friendly = true;
+ Projectile.ignoreWater = false;
+ Projectile.DamageType = DamageClass.Ranged;
+ Projectile.penetrate = -1;
+ Projectile.timeLeft = 300;
+ Projectile.tileCollide = false;
+ Projectile.usesLocalNPCImmunity = true;
+ Projectile.localNPCHitCooldown = -1;
+ }
+ public override void AI()
+ {
+ Projectile.scale = 1f;
+ Projectile.extraUpdates = 1;
+ Time++;
+ Player Owner = Main.player[Projectile.owner];
+ if (!TouchedGrass)
+ {
+ if (Projectile.timeLeft <= 240)
+ Projectile.rotation += 0.04f * Projectile.direction;
+ else
+ Projectile.rotation = (new Vector2(0, -5 * Projectile.direction) + Projectile.velocity * -1.2f).ToRotation();
+
+ Projectile.velocity.Y += 0.087f;
+ Projectile.velocity.X *= 0.99f;
+
+ if (Main.rand.NextBool(3))
+ {
+ Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity, 303, -Projectile.velocity.RotatedByRandom(0.1f) * Main.rand.NextFloat(0.2f, 1f), 140, default, Main.rand.NextFloat(0.35f, 0.5f));
+ dust.noGravity = false;
+ dust.color = Color.White;
+ }
+ }
+ else
+ {
+ Projectile.velocity = Vector2.Zero;
+ }
+ Projectile.alpha = (int)(255 * Utils.GetLerpValue(60, 0, Projectile.timeLeft, true));
+ if (Collision.SolidCollision(Projectile.Center - Projectile.velocity * 1.5f, 2, 2))
+ Projectile.tileCollide = true;
+ }
+ public override bool OnTileCollide(Vector2 oldVelocity)
+ {
+ Projectile.damage = 0;
+ TouchedGrass = true;
+ Projectile.velocity = Vector2.Zero;
+ return false;
+ }
+ }
+}
diff --git a/Projectiles/Ranged/M1GarandBulletCasing.png b/Projectiles/Ranged/M1GarandBulletCasing.png
new file mode 100644
index 0000000000..2e3aeeab4f
Binary files /dev/null and b/Projectiles/Ranged/M1GarandBulletCasing.png differ
diff --git a/Projectiles/Ranged/M1GarandEmptyClip.cs b/Projectiles/Ranged/M1GarandEmptyClip.cs
new file mode 100644
index 0000000000..cd235f3bf4
--- /dev/null
+++ b/Projectiles/Ranged/M1GarandEmptyClip.cs
@@ -0,0 +1,145 @@
+using System;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+using ReLogic.Content;
+using Terraria;
+using Terraria.Audio;
+using Terraria.ID;
+using Terraria.ModLoader;
+
+namespace CalamityMod.Projectiles.Ranged
+{
+ public class M1GarandEmptyClip : ModProjectile, ILocalizedModType
+ {
+ public new string LocalizationCategory => "Projectiles.Ranged";
+ internal static readonly SoundStyle BlingSound = new("CalamityMod/Sounds/Custom/Ultrabling") { PitchVariance = 0.5f };
+ internal static readonly SoundStyle BlingHitSound = new("CalamityMod/Sounds/Custom/UltrablingHit") { PitchVariance = 0.5f };
+ private static Asset sheenAsset;
+ private static Asset bloomAsset;
+
+ public static float UsedCoinGrabRangeMultiplier = 5f;
+ public static float ClipTossForce = 7.33f;
+
+ public static float MaxIntraClipRicoshotDistance = 1000f;
+
+ public static readonly float RicoshotSearchDistance = 2000f;
+
+ public static float SuperpredictionRatio = 0.1f;
+
+ public static float ClipBonus = 2.5f;
+ public static float ClipMulticlipBonus = 0.9f; // lmar
+
+ internal static readonly int UpdateCount = 4;
+ internal static readonly int ClipLifetime = UpdateCount * CalamityUtils.SecondsToFrames(7);
+
+ // Clips fade out for the last 30 frames of their existence.
+ private static readonly int FadeoutTime = UpdateCount * 30;
+ private static readonly float ForceFadeDistance = 2000f;
+ public static int CritDelayFrames = 22;
+ internal static int CritDelayTime => UpdateCount * CritDelayFrames;
+ internal ref float ShotFreezeTimer => ref Projectile.ai[1];
+ internal static int RicochetPause = UpdateCount * 22;
+ public bool HasBeenShot => Projectile.localAI[0] > 0f;
+
+ public Player Owner => Main.player[Projectile.owner];
+
+ public override void SetStaticDefaults()
+ {
+ ProjectileID.Sets.TrailCacheLength[Type] = 60;
+ ProjectileID.Sets.TrailingMode[Type] = 0;
+ Main.projFrames[Type] = 1; // Assuming a single frame for the clip.
+ ProjectileID.Sets.CultistIsResistantTo[Type] = true;
+ }
+
+ public override void SetDefaults()
+ {
+ Projectile.width = 12;
+ Projectile.height = 14;
+ Projectile.friendly = true;
+ Projectile.penetrate = -1;
+ Projectile.DamageType = DamageClass.Ranged;
+ Projectile.MaxUpdates = UpdateCount;
+ Projectile.timeLeft = ClipLifetime;
+ Projectile.scale = 1.5f;
+ }
+
+ public override bool? CanDamage() => false;
+
+ public override bool ShouldUpdatePosition() => ShotFreezeTimer <= 0;
+
+ public override void AI()
+ {
+ if (ShotFreezeTimer > 0f)
+ {
+ --ShotFreezeTimer;
+ if (ShotFreezeTimer <= 0)
+ {
+ Projectile.Kill();
+ return;
+ }
+ }
+
+ Lighting.AddLight(Projectile.Center, Color.LightGray.ToVector3() * 0.2f);
+
+ if (Main.rand.NextBool(10))
+ {
+ Dust d = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke);
+ d.noGravity = true;
+ }
+
+ Projectile.rotation = Projectile.velocity.X * 0.5f;
+
+ if (Projectile.FinalExtraUpdate())
+ {
+ float clipGravity = Player.defaultGravity / Projectile.MaxUpdates;
+ Projectile.velocity.Y += clipGravity / 1.75f;
+ }
+
+ if (Projectile.timeLeft > FadeoutTime && Projectile.Center.Distance(Owner.MountedCenter) > ForceFadeDistance)
+ Projectile.timeLeft = FadeoutTime;
+ }
+
+ public override bool OnTileCollide(Vector2 oldVelocity)
+ {
+ Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height);
+ return base.OnTileCollide(oldVelocity);
+ }
+
+ public override bool PreDraw(ref Color lightColor)
+ {
+ Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value;
+ Rectangle frame = tex.Frame(1, 1);
+ float fadingOpacity = Math.Clamp(Projectile.timeLeft / (float)FadeoutTime, 0f, 1f);
+ Color alphaColor = Projectile.GetAlpha(lightColor) * fadingOpacity;
+ Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, frame, alphaColor, Projectile.rotation, frame.Size() / 2f, Projectile.scale, SpriteEffects.None, 0);
+
+ int numUpdatesPassed = ClipLifetime - Projectile.timeLeft;
+ float x = Math.Clamp((float)numUpdatesPassed / CritDelayTime, 0f, 2f);
+ float sheenFunction = Math.Min(MathF.Pow(x + 0.1f, 10f), MathF.Pow(x - 2.1f, 10f));
+ float sheenOpacity = Math.Clamp(sheenFunction, 0f, 2f);
+
+ if (sheenOpacity > 0f)
+ {
+ Main.spriteBatch.End();
+ Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
+
+ sheenAsset ??= ModContent.Request("CalamityMod/Particles/HalfStar");
+ Texture2D shineTex = sheenAsset.Value;
+
+ bloomAsset ??= ModContent.Request("CalamityMod/Particles/BloomCircle");
+ Texture2D bloomTex = bloomAsset.Value;
+
+ Vector2 shineScale = new Vector2(1f, 3f - sheenOpacity * 2f);
+ Color shineColor = Color.LightGray;
+
+ Main.EntitySpriteDraw(bloomTex, Projectile.Center - Main.screenPosition, null, shineColor * sheenOpacity * 0.3f, MathHelper.PiOver2, bloomTex.Size() / 2f, shineScale * Projectile.scale, SpriteEffects.None, 0);
+ Main.EntitySpriteDraw(shineTex, Projectile.Center - Main.screenPosition, null, shineColor * sheenOpacity, MathHelper.PiOver2, shineTex.Size() / 2f, shineScale * Projectile.scale, SpriteEffects.None, 0);
+
+ Main.spriteBatch.End();
+ Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
+ }
+
+ return false;
+ }
+ }
+}
diff --git a/Projectiles/Ranged/M1GarandEmptyClip.png b/Projectiles/Ranged/M1GarandEmptyClip.png
new file mode 100644
index 0000000000..c08f6def56
Binary files /dev/null and b/Projectiles/Ranged/M1GarandEmptyClip.png differ
diff --git a/Projectiles/Ranged/M1GarandHoldout.cs b/Projectiles/Ranged/M1GarandHoldout.cs
new file mode 100644
index 0000000000..e17772f154
--- /dev/null
+++ b/Projectiles/Ranged/M1GarandHoldout.cs
@@ -0,0 +1,357 @@
+using CalamityMod.Items.Weapons.Ranged;
+using CalamityMod.Particles;
+using CalamityMod.Projectiles.BaseProjectiles;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+using ReLogic.Content;
+using Terraria;
+using Terraria.Audio;
+using Terraria.GameContent;
+using Terraria.ID;
+using Terraria.ModLoader;
+using System;
+using CalamityMod.Projectiles.Magic;
+
+namespace CalamityMod.Projectiles.Ranged
+{
+ public class M1GarandHoldout : BaseGunHoldoutProjectile
+ {
+ public override int AssociatedItemID => ModContent.ItemType();
+
+ public ref float CurrentState => ref Projectile.ai[0];
+ public ref float Timer => ref Projectile.ai[1];
+
+ private float muzzleFlashTimer;
+ private float flashVariant;
+
+ private int pingAnimationTimer = 0;
+ private const int PingAnimationDuration = 120;
+ private bool shouldPing = false;
+
+ public override float RecoilResolveSpeed => 0.13f;
+ public override float MaxOffsetLengthFromArm => 28f;
+ public override float BaseOffsetY => -4f;
+ public override float OffsetXUpwards => -6f;
+ public override float OffsetXDownwards => 0f;
+ public override float OffsetYUpwards => 0f;
+ public override float OffsetYDownwards => 0f;
+
+ // this pos needs tweaking
+ public override Vector2 GunTipPosition => (Projectile.Center + new Vector2(1.5f, -2.5f)) + Vector2.UnitX.RotatedBy(Projectile.rotation) * Projectile.width * 0.425f;
+ public override string Texture => "CalamityMod/Projectiles/Ranged/M1GarandHoldout";
+
+ // Muzzle flash textures
+ public static Asset MuzzleFlash;
+ public static Asset GlowTexture;
+
+ public static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/WulfrumBlunderbussFire") { PitchVariance = 0.1f };
+ public static readonly SoundStyle PingSound = new("CalamityMod/Sounds/Item/M1GarandPing");
+ public static readonly SoundStyle ReloadSound = new("CalamityMod/Sounds/Item/M1GarandReload");
+
+ public override void Load()
+ {
+ MuzzleFlash = ModContent.Request("CalamityMod/Projectiles/Ranged/M1GarandMuzzleFlash", AssetRequestMode.ImmediateLoad);
+ GlowTexture = ModContent.Request("CalamityMod/Projectiles/Ranged/M1GarandHoldoutGlow", AssetRequestMode.ImmediateLoad);
+ }
+
+ public override void SetStaticDefaults() => Main.projFrames[Type] = 6;
+
+ public override void KillHoldoutLogic()
+ {
+ // Only allow the projectile to kill if we're not reloading
+ if (CurrentState == 0 && HeldItem.type != Owner.ActiveItem().type)
+ {
+ Projectile.Kill();
+ Projectile.netUpdate = true;
+ }
+ }
+
+ public override void HoldoutAI()
+ {
+ // Decrements the timer which controls the duration of the flash
+ if (muzzleFlashTimer > 0f)
+ muzzleFlashTimer -= 1f;
+
+ switch (CurrentState)
+ {
+ // Normal Firing State
+ case 0:
+ // Time between firing (as the player continues to hold)
+ if (Projectile.frame == 5)
+ {
+ Projectile.frameCounter++;
+ if (Projectile.frameCounter >= MathHelper.Clamp(Owner.ActiveItem().useAnimation - 18, 0f, Owner.ActiveItem().useAnimation))
+ {
+ if (Owner.CantUseHoldout())
+ Projectile.Kill();
+
+ Projectile.frame = 0;
+ Projectile.frameCounter = 0;
+ }
+ }
+ // Begin firing
+ else if (Projectile.frame == 0)
+ {
+ if (Projectile.frameCounter != 1)
+ {
+ Projectile.frameCounter++;
+ if (Projectile.frameCounter >= 3)
+ {
+ Projectile.frame++;
+ Projectile.frameCounter = 0;
+ }
+ return;
+ }
+
+ Projectile.frameCounter++;
+
+ // Check if the player has any shots left
+ if (Owner.Calamity().garandShots > 0)
+ {
+ // -- Firing Logic & FX --
+ muzzleFlashTimer = 2f;
+ flashVariant = Main.rand.Next(3);
+ SoundEngine.PlaySound(FireSound, GunTipPosition);
+
+ if (Owner.Calamity().garandShots == 1)
+ {
+ SoundEngine.PlaySound(PingSound, GunTipPosition);
+ shouldPing = true;
+ }
+
+ OffsetLengthFromArm -= 3f;
+
+ // Consume a shot
+ Owner.Calamity().garandShots--;
+
+ Vector2 velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * HeldItem.shootSpeed;
+
+ // Eject bullet casing
+ Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity.RotatedBy(Main.rand.NextFloat(2.5f, 2.65f) * -Projectile.direction) * 0.5f, ModContent.ProjectileType(), 0, 0, Projectile.owner);
+
+ if (Owner.Calamity().garandShots == 0)
+ {
+ Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity.RotatedBy(Main.rand.NextFloat(1.175f, 1.25f) * -Projectile.direction) * 0.285f, ModContent.ProjectileType(), 0, 0, Projectile.owner);
+
+ GenericSparkle sparker = new GenericSparkle(Projectile.Center, Vector2.Zero, Color.PaleGoldenrod, Color.Gold * 0.25f, 1.25f, 5, Projectile.velocity.ToRotation() + Main.rand.NextFloat(-0.15f, 0.15f), 1f);
+ GeneralParticleHandler.SpawnParticle(sparker);
+ }
+
+ // Direct smoke
+ for (int i = 0; i < 8; i++)
+ {
+ Particle smoke = new HeavySmokeParticle(GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * 7f * Main.rand.NextFloat(0.4f, 1.5f), Color.Gray, Main.rand.Next(30, 50), Main.rand.NextFloat(0.22f, 0.44f), 0.35f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true);
+ GeneralParticleHandler.SpawnParticle(smoke);
+ }
+
+ // "Smoke" ring
+ Particle shootPulse = new DirectionalPulseRing(GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * 4f, Color.Gray * 0.5f, new Vector2(0.5f, 1f), Projectile.velocity.ToRotation(), 0.1f, 0.475f, 18);
+ GeneralParticleHandler.SpawnParticle(shootPulse);
+
+ // Shot starts from slightly behind the tip
+ Vector2 offsetPos = GunTipPosition - Projectile.velocity.SafeNormalize(Vector2.UnitY) * 18f;
+ Projectile.NewProjectile(Projectile.GetSource_FromThis(), offsetPos, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner);
+ }
+ else
+ {
+ OffsetLengthFromArm -= 1f;
+ CurrentState = 1; // Change state to reloading
+ Timer = 120;
+ }
+ }
+ // The firing animation
+ else if (Projectile.frame > 0)
+ {
+ Projectile.frameCounter++;
+ if (Projectile.frameCounter >= 3)
+ {
+ Projectile.frame++;
+ Projectile.frameCounter = 0;
+
+ }
+ }
+ break;
+
+ // Reloading
+ case 1:
+
+ Timer--;
+
+ // Keep the player from switching weapons
+ Owner.channel = true;
+
+ // The gun points slightly downwards during the first part
+ if (Timer <= 120 && Timer > 75)
+ {
+ Projectile.rotation += 0.15f * Projectile.spriteDirection;
+ }
+ // Lerp back to the normal pos
+ else if (Timer < 75 && Timer >= 64)
+ {
+ float progress = (75f - Timer) / (75f - 64f);
+ float lerpedOffset = MathHelper.Lerp(0.15f, 0f, progress);
+ Projectile.rotation += lerpedOffset * Projectile.spriteDirection;
+ }
+ else if (Timer == 39)
+ {
+ OffsetLengthFromArm -= 2f;
+ }
+
+ // Hold frame 3 until this point
+ if (Timer > 40)
+ {
+ Projectile.frame = 3;
+ Projectile.frameCounter = 0;
+ }
+
+ else if (Projectile.frame < Main.projFrames[Type] - 1)
+ {
+ Projectile.frameCounter++;
+ if (Projectile.frameCounter >= 3)
+ {
+ Projectile.frame++;
+ Projectile.frameCounter = 0;
+ }
+ }
+
+ else
+ {
+ // Hold
+ Projectile.frame = Main.projFrames[Type] - 1;
+ }
+
+ if (Timer == 110)
+ {
+ SoundEngine.PlaySound(ReloadSound, Projectile.Center);
+ }
+
+ // Reload and cull the projectile
+ if (Timer <= 0)
+ {
+ Owner.Calamity().garandShots += 8;
+ Projectile.Kill();
+ Projectile.netUpdate = true;
+ }
+
+ break;
+ }
+ }
+
+ public override bool? CanDamage() => muzzleFlashTimer > 0f;
+ public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(GunTipPosition + Vector2.UnitX.RotatedBy(Projectile.rotation) * MuzzleFlash.Width() * 0.5f, 64f, targetHitbox);
+
+ public override bool PreDraw(ref Color lightColor)
+ {
+ Texture2D texture = TextureAssets.Projectile[Type].Value;
+ Vector2 drawPosition = Projectile.Center - Main.screenPosition;
+ Rectangle frame = texture.Frame(verticalFrames: Main.projFrames[Type], frameY: Math.Clamp(Projectile.frame, 0, Main.projFrames[Type] - 1));
+ float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f);
+ float scale = Projectile.scale * Owner.gravDir;
+ SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
+
+ Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), drawRotation, frame.Size() * 0.5f, scale, flipSprite);
+
+ // Flash
+ if (muzzleFlashTimer > 0f)
+ {
+ Texture2D flashTex = MuzzleFlash.Value;
+ int flashFrameY = (int)flashVariant;
+ Vector2 flashPos = GunTipPosition + Vector2.UnitX.RotatedBy(Projectile.rotation) * MuzzleFlash.Width() * 0.5f - Main.screenPosition;
+ Rectangle flashFrame = flashTex.Frame(verticalFrames: 3, frameY: flashFrameY);
+ Main.EntitySpriteDraw(flashTex, flashPos, flashFrame, Color.White, drawRotation, flashFrame.Size() * 0.5f, scale * 0.8f, flipSprite);
+ }
+
+ // PING!
+ if (shouldPing)
+ {
+ pingAnimationTimer++;
+
+ if (pingAnimationTimer <= PingAnimationDuration)
+ {
+ Texture2D pingTexture = ModContent.Request("CalamityMod/Projectiles/Ranged/M1GarandPingText").Value;
+ Vector2 origin = pingTexture.Size() * 0.5f;
+ Vector2 pingDrawPosition;
+
+ Vector2 finalPosition = Owner.Center + new Vector2(40f * -Owner.direction, -40f);
+ float progress = (float)pingAnimationTimer / PingAnimationDuration;
+
+ if (pingAnimationTimer < 15)
+ {
+ float popOutProgress = (float)pingAnimationTimer / 15;
+ pingDrawPosition = Vector2.Lerp(Owner.Center, finalPosition, popOutProgress);
+ }
+ else
+ {
+ pingDrawPosition = finalPosition;
+ }
+
+ pingDrawPosition -= Main.screenPosition;
+
+ float stretchFactorY = 0f;
+
+ if (progress < 0.25f) // Stretch Up
+ {
+ float stretchProgress = progress / 0.25f;
+ stretchFactorY = MathHelper.Lerp(-1.4f, 0.5f, (float)Math.Sin(stretchProgress * MathHelper.PiOver2));
+ }
+ else if (progress < 0.5f) // Squash Down and overadjust
+ {
+ float squashProgress = (progress - 0.25f) / 0.3f;
+ stretchFactorY = MathHelper.Lerp(0.5f, -0.25f, squashProgress * squashProgress);
+ }
+ else if (progress < 0.8f) // Stretch up again at a slower pace to a bit above the normal scale
+ {
+ float stretchProgress = (progress - 0.6f) / 0.2f;
+ stretchFactorY = MathHelper.Lerp(-0.25f, 0f, stretchProgress * stretchProgress);
+ }
+ else // Return to normal
+ {
+ stretchFactorY = 0f;
+ }
+
+ Color drawColor = Color.White;
+
+ int fadeDuration = 30;
+ int fadeStartFrame = PingAnimationDuration - fadeDuration;
+
+ // Fade out over 30 frames
+ if (pingAnimationTimer >= fadeStartFrame)
+ {
+ float fadeProgress = (float)(pingAnimationTimer - fadeStartFrame) / fadeDuration;
+ drawColor = Color.White * MathHelper.Lerp(1f, 0f, fadeProgress);
+ }
+
+ float basePingDrawScale = 1f;
+ float stretchScaleY = 1f + stretchFactorY;
+ float stretchScaleX = 1f - (stretchFactorY * 0.5f);
+
+ Vector2 finalPingScale = new Vector2(basePingDrawScale * stretchScaleX, basePingDrawScale * stretchScaleY);
+ Main.EntitySpriteDraw(pingTexture, pingDrawPosition, null, drawColor, Owner.direction == 1 ? -0.25f : 0.25f, origin, finalPingScale, SpriteEffects.None, 0f);
+ }
+ else
+ {
+ // Reset the flag and timer once the animation is complete.
+ shouldPing = false;
+ pingAnimationTimer = 0;
+ }
+ }
+
+ return false;
+ }
+
+ public override void PostDraw(Color lightColor)
+ {
+ Texture2D texture = TextureAssets.Projectile[Type].Value;
+ Rectangle frame = texture.Frame(verticalFrames: Main.projFrames[Type], frameY: Math.Clamp(Projectile.frame, 0, Main.projFrames[Type] - 1));
+ Texture2D glowTexture = GlowTexture.Value;
+
+ Vector2 drawPosition = Projectile.Center - Main.screenPosition;
+ float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f);
+ Vector2 origin = frame.Size() * 0.5f;
+ float scale = Projectile.scale * Owner.gravDir;
+ SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
+
+ Main.EntitySpriteDraw(glowTexture, drawPosition, frame, Color.White, drawRotation, origin, scale, flipSprite);
+ }
+ }
+}
diff --git a/Projectiles/Ranged/M1GarandHoldout.png b/Projectiles/Ranged/M1GarandHoldout.png
new file mode 100644
index 0000000000..59767b1acd
Binary files /dev/null and b/Projectiles/Ranged/M1GarandHoldout.png differ
diff --git a/Projectiles/Ranged/M1GarandHoldoutGlow.png b/Projectiles/Ranged/M1GarandHoldoutGlow.png
new file mode 100644
index 0000000000..fff673165b
Binary files /dev/null and b/Projectiles/Ranged/M1GarandHoldoutGlow.png differ
diff --git a/Projectiles/Ranged/M1GarandMuzzleFlash.png b/Projectiles/Ranged/M1GarandMuzzleFlash.png
new file mode 100644
index 0000000000..30764d9ece
Binary files /dev/null and b/Projectiles/Ranged/M1GarandMuzzleFlash.png differ
diff --git a/Projectiles/Ranged/M1GarandPingText.png b/Projectiles/Ranged/M1GarandPingText.png
new file mode 100644
index 0000000000..2d49dc5f35
Binary files /dev/null and b/Projectiles/Ranged/M1GarandPingText.png differ
diff --git a/Projectiles/Ranged/MarksmanShot.cs b/Projectiles/Ranged/MarksmanShot.cs
index f0ed4e0c90..04fcd39397 100644
--- a/Projectiles/Ranged/MarksmanShot.cs
+++ b/Projectiles/Ranged/MarksmanShot.cs
@@ -91,7 +91,6 @@ namespace CalamityMod.Projectiles.Ranged
Projectile[] validCoins = Projectile.GetAvailableCoins();
Projectile struckCoin = null;
- // Check for collisions with valid coins
for (int i = 0; i < validCoins.Length; ++i)
{
Projectile coin = validCoins[i];
@@ -105,23 +104,26 @@ namespace CalamityMod.Projectiles.Ranged
}
}
- // If a coin was struck, set up the potential multi-ricoshot.
if (struckCoin is not null)
{
- // Assemble an array of the remaining coins.
Projectile[] otherCoins = validCoins.Where((proj) => proj.whoAmI != struckCoin.whoAmI).ToArray();
+ RicoshotTarget nextCoin = Projectile.FindRicochetTarget(Projectile.Center, otherCoins, true);
+ RicochetOffCoin(nextCoin, struckCoin);
- // Ricochet off of this coin to the next target.
- // This coin (and potential further coins) may have already been recursively frozen.
- // As long as those coins have not yet been struck, they are valid targets.
- RicoshotTarget nextTarget = Projectile.FindRicochetTarget(Projectile.Center, otherCoins, true);
- RicochetOffCoin(nextTarget, struckCoin);
-
- // If the next target is another coin, freeze it to (almost) guarantee it will be hit.
- if (nextTarget.type == RicoshotTargetType.Coin)
+ // If the next target is another coin/clip, freeze it.
+ if (nextCoin.type == RicoshotTargetType.Coin)
{
- Projectile nextCoin = Main.projectile[nextTarget.entityID];
- nextCoin.ai[1] = RicoshotCoin.RicochetPause;
+ Projectile nextCoinProj = Main.projectile[nextCoin.entityID];
+
+ // Use the correct RicochetPause value based on the projectile type
+ if (nextCoinProj.type == ModContent.ProjectileType())
+ {
+ nextCoinProj.ai[1] = M1GarandEmptyClip.RicochetPause;
+ }
+ else
+ {
+ nextCoinProj.ai[1] = RicoshotCoin.RicochetPause;
+ }
}
}
}
@@ -142,18 +144,51 @@ namespace CalamityMod.Projectiles.Ranged
if (NumRicochets == 0 && CalamityUtils.CanRicoshotCoinForceCrit(struckCoin))
cgp.forcedCrit = true;
- // Apply bonus damage to the projectile. This is an additive multiplier between multiple coins.
- float bonusDamageRatio = struckCoin.ai[0] switch
+ // Apply bonus damage to the projectile based on the projectile type.
+ float bonusDamageRatio = 0f;
+ if (struckCoin.type == ModContent.ProjectileType())
{
- 1f => NumRicochets > 0 ? RicoshotCoin.SilverMulticoinBonus : RicoshotCoin.SilverBonus,
- 2f => NumRicochets > 0 ? RicoshotCoin.GoldMulticoinBonus : RicoshotCoin.GoldBonus,
- _ => NumRicochets > 0 ? RicoshotCoin.CopperMulticoinBonus : RicoshotCoin.CopperBonus,
- };
+ bonusDamageRatio = struckCoin.ai[0] switch
+ {
+ 1f => NumRicochets > 0 ? RicoshotCoin.SilverMulticoinBonus : RicoshotCoin.SilverBonus,
+ 2f => NumRicochets > 0 ? RicoshotCoin.GoldMulticoinBonus : RicoshotCoin.GoldBonus,
+ _ => NumRicochets > 0 ? RicoshotCoin.CopperMulticoinBonus : RicoshotCoin.CopperBonus,
+ };
+ }
+ else if (struckCoin.type == ModContent.ProjectileType())
+ {
+ bonusDamageRatio = NumRicochets > 0 ? M1GarandEmptyClip.ClipMulticlipBonus : M1GarandEmptyClip.ClipBonus;
+ }
+
cgp.totalRicoshotDamageBonus += bonusDamageRatio;
// Increment the ricochet count, relegating further coins to only give the multicoin bonus damage.
NumRicochets++;
+ // If the target was valid, freeze the shot in place for a brief moment.
+ if (target.IsValid)
+ {
+ if (struckCoin.type == ModContent.ProjectileType())
+ {
+ RicochetFreezeTimer = M1GarandEmptyClip.RicochetPause;
+ }
+ else
+ {
+ RicochetFreezeTimer = RicoshotCoin.RicochetPause;
+ }
+ }
+
+ // If needs to be changed later
+ if (struckCoin.type == ModContent.ProjectileType())
+ {
+ SoundEngine.PlaySound(M1GarandEmptyClip.BlingHitSound, struckCoin.Center);
+ }
+
+ else
+ {
+ SoundEngine.PlaySound(RicoshotCoin.BlingHitSound, struckCoin.Center);
+ }
+
// If the target was valid, freeze the shot in place for a brief moment.
if (target.IsValid)
RicochetFreezeTimer = RicochetPause;
diff --git a/Sounds/Item/M1GarandPing.ogg b/Sounds/Item/M1GarandPing.ogg
new file mode 100644
index 0000000000..f05bb8a0da
Binary files /dev/null and b/Sounds/Item/M1GarandPing.ogg differ
diff --git a/Sounds/Item/M1GarandReload.ogg b/Sounds/Item/M1GarandReload.ogg
new file mode 100644
index 0000000000..d43965eff8
Binary files /dev/null and b/Sounds/Item/M1GarandReload.ogg differ
diff --git a/Utilities/RicoshotUtils.cs b/Utilities/RicoshotUtils.cs
index 1f54d392cb..f9911fbeab 100644
--- a/Utilities/RicoshotUtils.cs
+++ b/Utilities/RicoshotUtils.cs
@@ -30,13 +30,14 @@ namespace CalamityMod
public static int GetActiveRicoshotCoinCount(this Player player)
{
int count = 0;
- int id = ModContent.ProjectileType();
+ int coinID = ModContent.ProjectileType();
+ int clipID = ModContent.ProjectileType();
foreach (Projectile p in Main.ActiveProjectiles)
{
if (p.owner != player.whoAmI)
continue;
- if (p.type == id)
+ if (p.type == coinID || p.type == clipID)
++count;
}
return count;
@@ -45,10 +46,18 @@ namespace CalamityMod
// Intentionally not an extension so it doesn't clog the Visual Studio recommendation lists. This is not generally useful.
public static bool CanRicoshotCoinForceCrit(Projectile p)
{
- int id = ModContent.ProjectileType();
- if (!p.active || p.type != id)
+ int coinID = ModContent.ProjectileType();
+ int clipID = ModContent.ProjectileType();
+
+ if (!p.active || (p.type != coinID && p.type != clipID))
return false;
+ if (p.type == clipID)
+ {
+ int clipUpdateCount = M1GarandEmptyClip.ClipLifetime - p.timeLeft;
+ return clipUpdateCount >= M1GarandEmptyClip.CritDelayTime;
+ }
+
int coinUpdateCount = RicoshotCoin.CoinLifetime - p.timeLeft;
return coinUpdateCount >= RicoshotCoin.CritDelayTime;
}
@@ -99,18 +108,25 @@ namespace CalamityMod
// Search for all nearby coins.
// Coins do not necessarily have to be owned by the same player as the searching projectile!
int coinID = ModContent.ProjectileType();
+ int clipID = ModContent.ProjectileType();
+
foreach (Projectile proj in Main.ActiveProjectiles)
{
- if (proj.ModProjectile is null || proj.type != coinID)
+ if (proj.ModProjectile is null)
+ continue;
+
+ // Check if the projectile is either a coin or clip
+ if (proj.type != coinID && proj.type != clipID)
continue;
// Coins that have already been struck are ignored.
if (proj.localAI[0] > 0f)
continue;
- // Finally, do a distance check
+ // Use the appropriate distance check based on the projectile type
+ float maxDistance = proj.type == clipID ? M1GarandEmptyClip.MaxIntraClipRicoshotDistance : RicoshotCoin.MaxIntraCoinRicoshotDistance;
float dist = searchingShot.DistanceSQ(proj.Center);
- if (dist <= RicoshotCoin.MaxIntraCoinRicoshotDistance * RicoshotCoin.MaxIntraCoinRicoshotDistance)
+ if (dist <= maxDistance * maxDistance)
coins.Add(proj);
}
@@ -143,7 +159,11 @@ namespace CalamityMod
float closestCoinDistance = RicoshotCoin.MaxIntraCoinRicoshotDistance;
foreach (Projectile coin in availableCoins)
{
- // Skip coins which are already frozen (part of an ongoing ricoshot), unless considering them
+ // Determine the max ricochet distance based on the target type
+ float maxDistance = coin.type == ModContent.ProjectileType() ? M1GarandEmptyClip.MaxIntraClipRicoshotDistance : RicoshotCoin.MaxIntraCoinRicoshotDistance; // New line
+ if (coin.Distance(startPos) > maxDistance)
+ continue;
+
if (!considerFrozenCoins && coin.ai[1] > 0f)
continue;