Files
CalamityModPublic/Projectiles/Melee/MantisClawHoldout.cs
T
CongratsIsTrash d829999ac3 Mantis Claws stuff
Balance, tooltip, other tune-ups
2024-07-03 14:53:04 -04:00

273 lines
12 KiB
C#

using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using CalamityMod.Items.BaseItems;
using Terraria.ModLoader;
using CalamityMod.Projectiles.BaseProjectiles;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using CalamityMod.Balancing;
using Terraria.Audio;
using CalamityMod.Items.Weapons.Melee;
using System;
using CalamityMod.Particles;
using Terraria.DataStructures;
using System.Collections.Generic;
using CalamityMod.Graphics.Primitives;
using Terraria.Graphics.Shaders;
namespace CalamityMod.Projectiles.Melee
{
public class MantisClawHoldout : BaseCustomUseStyleProjectile, ILocalizedModType
{
bool AnimationCooldown = false;
float JetDamageMultiplier => 7.5f;
int SlashSpeed => 6;
int BlastChargeUses => 3;
float SlashTimer = 0;
public override Vector2 SpriteOrigin => new(0, 20);
public override int AssignedItemID => ModContent.ItemType<MantisClaws>();
public float ClawOpenness = MathHelper.ToRadians(80);
public float BubbleSize = 0f;
public new string LocalizationCategory => "Projectiles.Melee";
public override string Texture => "CalamityMod/Items/Weapons/Melee/MantisClaws";
public override void ResetStyle()
{
if (AnimationCooldown)
{
if (NumberOfAnimations % 5 <= BlastChargeUses)
{
ClawOpenness = MathHelper.Lerp(ClawOpenness, MathHelper.ToRadians(80f), 0.15f);
BubbleSize *= 0.85f;
if (BubbleSize < 0.05f)
{
Projectile.scale -= 0.1f;
if (Projectile.scale < 0.1f)
Projectile.active = false;
}
}
else
{
Clamp();
}
Offset = new Vector2(MathHelper.Lerp(0, 12, BubbleSize / 2), 0).RotatedBy(Projectile.rotation);
}
}
public void Clamp()
{
if (BubbleSize != 0f)
{
Owner.Calamity().mouseWorldListener = true;
Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Owner.Center + new Vector2(20, 0).RotatedBy(Projectile.rotation),
Owner.DirectionTo(Owner.Calamity().mouseWorld) * 30, ModContent.ProjectileType<MantisClawJet>(), (int)(Projectile.damage * JetDamageMultiplier), 7, Owner.whoAmI);
for (int i = 0; i < 9; i++)
{
WaterFlavoredParticle waterFlavored = new WaterFlavoredParticle(Owner.Center, new Vector2(Main.rand.NextFloat(15, 25), 0).RotatedBy(Projectile.rotation + MathHelper.ToRadians(Main.rand.NextFloat(-45, 45))), true, 40, Main.rand.NextFloat(0.5f, 1.2f), MantisClawJet.WaterColor);
waterFlavored.AffectedByLight = true;
GeneralParticleHandler.SpawnParticle(waterFlavored);
}
SoundEngine.PlaySound((Main.rand.NextBool(2) ? SoundID.Item85 : SoundID.Item86).WithPitchOffset(-0.5f), Owner.Center);
SoundEngine.PlaySound(SoundID.NPCDeath14.WithPitchOffset(1f), Owner.Center);
Owner.Calamity().GeneralScreenShakePower = 3f;
GeneralParticleHandler.SpawnParticle(new MantisPunch(Owner.Center + new Vector2(26, 0).RotatedBy(Projectile.rotation), Projectile.rotation));
}
ClawOpenness = MathHelper.ToRadians(80);
BubbleSize = 0f;
}
public override void UseStyle()
{
if (Owner.altFunctionUse != 2)
{
if (AnimationCooldown)
{
if (!Owner.Calamity().mouseRight)
{
if (Owner.itemAnimation > 0)
{
Projectile.Kill();
}
DrawUnconditionally = true;
AnimationCooldown = true;
Owner.itemAnimation = 0;
Owner.itemTime = 0;
}
}
Projectile.scale = 1f;
DrawUnconditionally = false;
Owner.Calamity().mouseWorldListener = true;
{
if (SlashTimer % SlashSpeed == 0)
{
SoundStyle SlashStyle = new SoundStyle("CalamityMod/Sounds/Item/MantisSwipe" + (Main.rand.Next(2) + 1).ToString());
SlashStyle.PitchVariance = 0.3f;
SlashStyle.Volume = 0.7f;
SoundEngine.PlaySound(SlashStyle.WithPitchOffset(0.2f), Owner.Center);
Owner.Calamity().mouseWorldListener = true;
Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Owner.Center, Owner.DirectionTo(Owner.Calamity().mouseWorld) * 6f, ModContent.ProjectileType<MantisClawSlash>(), Projectile.damage, 4f, Owner.whoAmI).rotation = Owner.AngleTo(Owner.Calamity().mouseWorld) + MathHelper.ToRadians(Main.rand.NextFloat(-25, 25));
}
SlashTimer++;
}
Owner.direction = Math.Sign(Owner.Calamity().mouseWorld.X - Owner.Center.X);
Projectile.rotation = Owner.AngleTo(Owner.Calamity().mouseWorld);
Projectile.ai[2] = MathHelper.Lerp(Projectile.ai[2], MathHelper.ToRadians(135f * (SlashTimer % (SlashSpeed * 2) < SlashSpeed ? 1 : -1)), 0.2f);
ArmRotationOffset = MathHelper.ToRadians(-90f) - (Projectile.ai[2]) * Owner.direction;
ArmRotationOffsetBack = MathHelper.ToRadians(-90f) + (Projectile.ai[2]) * Owner.direction;
}
else
{
Projectile.scale = MathHelper.Lerp(Projectile.scale, 1f, 0.15f);
Projectile.scale = MathHelper.Clamp(Projectile.scale, 0f, 1f);
if (Owner.Calamity().mouseRight)
{
Owner.itemAnimation = 3;
float chargeFactor = (float)(NumberOfAnimations % 5f) / 3f;
DrawUnconditionally = true;
ArmRotationOffset = MathHelper.ToRadians(-90f) - (ClawOpenness / 5) * Owner.direction;
ArmRotationOffsetBack = MathHelper.ToRadians(-90f) + (ClawOpenness / 5) * Owner.direction;
if (NumberOfAnimations % 5 > BlastChargeUses)
{
Clamp();
}
else
{
Owner.Calamity().mouseWorldListener = true;
Owner.direction = Math.Sign(Owner.Calamity().mouseWorld.X - Owner.Center.X);
Projectile.rotation = Owner.AngleTo(Owner.Calamity().mouseWorld);
Projectile.ai[0]++;
if (AnimationProgress == 1)
{
if (NumberOfAnimations % 5 == 0)
{
ClawOpenness = MathHelper.ToRadians(80);
BubbleSize = 0f;
}
SoundEngine.PlaySound((Main.rand.NextBool(2) ? SoundID.Item85 : SoundID.Item86).WithPitchOffset((float)NumberOfAnimations % 5 / (float)BlastChargeUses), Owner.Center);
Projectile.ai[1] = MathHelper.Lerp(0.5f, 2f, chargeFactor);
Projectile.ai[2] = MathHelper.Lerp(MathHelper.ToRadians(100f), MathHelper.ToRadians(180f), chargeFactor);
}
BubbleSize = MathHelper.Lerp(BubbleSize, Projectile.ai[1], 0.2f);
ClawOpenness = MathHelper.Lerp(ClawOpenness, Projectile.ai[2], 0.2f);
}
Offset = new Vector2(MathHelper.Lerp(0, 12, BubbleSize / 2), 0).RotatedBy(Projectile.rotation);
}
else
{
if (Owner.controlUseItem)
{
Projectile.Kill();
}
DrawUnconditionally = true;
AnimationCooldown = true;
Owner.itemAnimation = 0;
Owner.itemTime = 0;
}
}
}
public override bool PreDraw(ref Color lightColor)
{
{
FlipAsSword = false;
float rot = 0f;
if (Owner.altFunctionUse != 2 && !AnimationCooldown)
{
rot = Projectile.ai[2];
if (Owner.direction == -1)
{
FlipAsSword = true;
RotationOffset = MathHelper.ToRadians(-90f);
Owner.compositeFrontArm.rotation -= RotationOffset;
Owner.compositeBackArm.rotation -= RotationOffset;
}
}
else
{
RotationOffset = 0f;
}
// Bubble texture drawing
Asset<Texture2D> Bubble = ModContent.Request<Texture2D>("CalamityMod/Particles/Bubble");
Main.EntitySpriteDraw(Bubble.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY) + new Vector2(20, 0).RotatedBy(Projectile.rotation + RotationOffset), Bubble.Frame(), lightColor, 0f, Bubble.Size() / 2, BubbleSize, SpriteEffects.None);
// Only draw the projectile if the projectile's owner is currently using the item this projectile is attached to.
if (Owner.itemAnimation > 0 || DrawUnconditionally)
{
Asset<Texture2D> tex = ModContent.Request<Texture2D>(Texture);
float r = FlipAsSword ? 0f : MathHelper.ToRadians(90);
Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY), tex.Frame(1, FrameCount, 0, Frame), lightColor, Projectile.rotation - ClawOpenness + rot + RotationOffset + r, FlipAsSword ? new Vector2(tex.Width() - SpriteOrigin.X, SpriteOrigin.Y) : SpriteOrigin, Projectile.scale, spriteEffects != SpriteEffects.None ? spriteEffects : (FlipAsSword ? SpriteEffects.FlipHorizontally : SpriteEffects.None));
}
if (Owner.itemAnimation > 0 || DrawUnconditionally)
{
if (Owner.altFunctionUse == 2 || AnimationCooldown)
{
Asset<Texture2D> tex = ModContent.Request<Texture2D>(Texture);
float r = FlipAsSword ? 0f : MathHelper.ToRadians(90);
Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY), tex.Frame(1, FrameCount, 0, Frame), lightColor, Projectile.rotation + ClawOpenness + RotationOffset + r, !FlipAsSword ? new Vector2(tex.Width() - SpriteOrigin.X, SpriteOrigin.Y) : SpriteOrigin, Projectile.scale, spriteEffects != SpriteEffects.None ? spriteEffects : (FlipAsSword ? SpriteEffects.None : SpriteEffects.FlipHorizontally));
}
else
{
Asset<Texture2D> tex = ModContent.Request<Texture2D>(Texture);
float r = FlipAsSword ? 0f : MathHelper.ToRadians(90);
Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY), tex.Frame(1, FrameCount, 0, Frame), lightColor, Projectile.rotation - ClawOpenness - rot + RotationOffset + r, FlipAsSword ? new Vector2(tex.Width() - SpriteOrigin.X, SpriteOrigin.Y) : SpriteOrigin, Projectile.scale, spriteEffects != SpriteEffects.None ? spriteEffects : (FlipAsSword ? SpriteEffects.FlipHorizontally : SpriteEffects.None));
}
}
}
return false;
}
// The holdout cannot deal damage.
public override bool? CanDamage() => false;
public override void OnSpawn(IEntitySource source) => Projectile.scale = 0f;
}
}