Slight aim assist & Better recovery

This commit is contained in:
IbanPlay authored and Cameron Ewell committed 2022-07-11 19:05:37 -04:00
1 parent a618e7c515
commit 54a46f02a5
4 files changed
+120 -26

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

+4 -2
View File
@@ -32,8 +32,10 @@ namespace CalamityMod.Items.Weapons.Melee
public static float ScrewTime = 40;
public static Asset<Texture2D> ScrewTex;
public static Asset<Texture2D> ScrewOutlineTex;
public static float ScrewBaseDamageMult = 3f;
public static float ScrewBazingaModeDamageMult = 3f;
public static float ScrewBaseDamageMult = 2f;
public static float ScrewBazingaModeDamageMult = 4.5f;
public static float ScrewBazingaAimAssistAngle = 0.52f; //This may look high but remebmer this is the FULL angle, so it actually checks for half that angle deviation
public static float ScrewBazingaAimAssistReach = 600f;
public override void SetStaticDefaults()
{
+43 -4
View File
@@ -35,6 +35,8 @@ namespace CalamityMod.Projectiles.Melee
public ref float BazingaTime => ref Projectile.ai[0];
public static float BazingaTimeMax = 120f;
public float BazingaTimeCompletion => (BazingaTimeMax - BazingaTime) / BazingaTimeMax;
public float FadePercent => Math.Clamp(Projectile.timeLeft / FadeTime, 0f, 1f);
public static float FadeTime => 30f;
public Player Owner => Main.player[Projectile.owner];
public static Asset<Texture2D> SheenTex;
@@ -54,7 +56,6 @@ namespace CalamityMod.Projectiles.Melee
Projectile.scale = 1.2f;
}
public override void AI()
{
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
@@ -79,12 +80,43 @@ namespace CalamityMod.Projectiles.Melee
if (!Main.rand.NextBool(5))
chust.noLightEmittence = true;
}
//Projectile.velocity = Vector2.Zero;
if (Projectile.Center.Distance(Owner.MountedCenter) > 1300 && Projectile.timeLeft > FadeTime)
Projectile.timeLeft = (int)FadeTime;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
SoundEngine.PlaySound(WulfrumKnife.TileHitSound, Projectile.Center);
bool screwRegained = false;
//50% chance to gain back the screw on kill.
if (target.life - damage <= 0)
{
if (Main.rand.NextBool() && Main.myPlayer == Owner.whoAmI)
{
if (Owner.HeldItem.ModItem is WulfrumScrewdriver screwdriver && !screwdriver.ScrewStored)
{
WulfrumScrewdriver.ScrewStart = new Vector3(Projectile.Center + Projectile.velocity * 14f * Main.rand.NextFloat() - Main.screenPosition, Main.rand.NextFloat(MathHelper.PiOver2 - MathHelper.PiOver4));
WulfrumScrewdriver.ScrewTimer = WulfrumScrewdriver.ScrewTime;
screwdriver.ScrewStored = true;
SoundEngine.PlaySound(SoundID.Item156);
screwRegained = true;
}
}
}
if (!screwRegained && Main.netMode != NetmodeID.Server)
{
Gore screwGore = Gore.NewGorePerfect(Projectile.GetSource_Death(), Projectile.position, -Vector2.UnitY.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(4f, 6f) + Projectile.velocity * 0.7f, Mod.Find<ModGore>("WulfrumScrewGore").Type);
screwGore.timeLeft = 20;
}
//Screenstun
}
@@ -96,6 +128,13 @@ namespace CalamityMod.Projectiles.Melee
SoundEngine.PlaySound(CommonCalamitySounds.WulfrumNPCDeathSound, Projectile.Center);
SoundEngine.PlaySound(WulfrumKnife.TileHitSound, Projectile.Center);
if (Main.netMode != NetmodeID.Server)
{
Gore screwGore = Gore.NewGorePerfect(Projectile.GetSource_Death(), Projectile.position, -Vector2.UnitY.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(1f, 3f) + Projectile.velocity * 0.7f, Mod.Find<ModGore>("WulfrumScrewGore").Type);
screwGore.timeLeft = 20;
}
return base.OnTileCollide(oldVelocity);
}
@@ -155,7 +194,7 @@ namespace CalamityMod.Projectiles.Melee
opacity = BazingaTimeCompletion;
opacity = BazingaTimeCompletion * FadePercent;
if (BazingaTime > 0)
{
@@ -206,7 +245,7 @@ namespace CalamityMod.Projectiles.Melee
else
{
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0);
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor) * FadePercent, Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0);
}
return false;
}
+73 -20
View File
@@ -24,6 +24,7 @@ namespace CalamityMod.Projectiles.Melee
public static int MaxTime = 14;
public ref float EndLag => ref Projectile.ai[0];
public ref float TrueDirection => ref Projectile.ai[1];
public Player Owner => Main.player[Projectile.owner];
public static Asset<Texture2D> SmearTex;
@@ -66,6 +67,7 @@ namespace CalamityMod.Projectiles.Melee
{
EndLag = (float)Math.Max(Owner.ActiveItem().useTime - MaxTime, 1);
Projectile.timeLeft = MaxTime;
TrueDirection = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero).ToRotation(); //Store this for the screw hit
Projectile.velocity = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero).RotatedByRandom(MathHelper.PiOver4 * 0.15f);
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
}
@@ -81,20 +83,27 @@ namespace CalamityMod.Projectiles.Melee
Owner.itemTime = 2;
Owner.itemAnimation = 2;
//Check for launchable screws.
for (int i = 0; i < Main.maxProjectiles; i++)
{
Projectile proj = Main.projectile[i];
if (proj.ModProjectile != null && proj.owner == Projectile.owner && proj.ModProjectile is WulfrumScrew screw && screw.BazingaTime == 0)
{
float collisionPoint = 0f;
float bladeLenght = 86f * Projectile.scale;
if (Collision.CheckAABBvLineCollision(proj.Hitbox.TopLeft(), proj.Hitbox.Size(), Owner.Center + OffsetFromPlayer, Owner.Center + OffsetFromPlayer + (Projectile.velocity * bladeLenght), 34, ref collisionPoint))
{
Vector2 thudVelocity = TrueDirection.ToRotationVector2() * 6f;
NPC potentialAimAssist = FindTarget();
if (potentialAimAssist != null)
thudVelocity = (potentialAimAssist.Center - proj.Center).SafeNormalize(Vector2.Zero) * 6f;
screw.BazingaTime = WulfrumScrew.BazingaTimeMax;
proj.velocity = Projectile.velocity * 6f;
proj.velocity = thudVelocity;
proj.damage = (int)(proj.damage * WulfrumScrewdriver.ScrewBazingaModeDamageMult);
proj.timeLeft = WulfrumScrew.Lifetime;
proj.knockBack *= 2.5f;
SoundEngine.PlaySound(WulfrumScrewdriver.ScrewHitSound);
@@ -102,34 +111,53 @@ namespace CalamityMod.Projectiles.Melee
{
Owner.Calamity().GeneralScreenShakePower = 6f;
}
return;
}
return;
}
}
}
public override bool PreDraw(ref Color lightColor)
public NPC FindTarget()
{
Texture2D tex = ModContent.Request<Texture2D>(Texture).Value;
float bestScore = 0;
NPC bestTarget = null;
if (SmearTex == null)
SmearTex = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/MediumLongThrust");
Texture2D smearTex = SmearTex.Value;
Vector2 drawOrigin = new Vector2(tex.Width / 2f, tex.Height);
Vector2 scale = new Vector2(Math.Abs((float)Math.Sin(LifetimeCompletion * MathHelper.TwoPi * 0.5f)), 1f);
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, lightColor, Projectile.rotation, drawOrigin, scale * Projectile.scale, 0f, 0);
if (LifetimeCompletion < 0.6f)
for (int i = 0; i < Main.maxNPCs; i++)
{
int frameCount = (int)Math.Floor((LifetimeCompletion / 0.6f) * 3f);
Rectangle frame = new Rectangle(0, (smearTex.Height / 3) * frameCount, smearTex.Width, smearTex.Height / 3);
float opacity = 1 - (float)Math.Pow(LifetimeCompletion / 0.6f, 0.5f);
NPC potentialTarget = Main.npc[i];
Main.spriteBatch.Draw(smearTex, Projectile.Center + Projectile.velocity * 67f - Main.screenPosition, frame, Color.White * opacity, Projectile.rotation, frame.Size() / 2f, 0.9f, 0, 0);
if (!potentialTarget.CanBeChasedBy(null, false))
continue;
float distance = potentialTarget.Distance(Projectile.Center);
float angle = TrueDirection.ToRotationVector2().AngleBetween((potentialTarget.Center - Projectile.Center));
float extraDistance = potentialTarget.width / 2 + potentialTarget.height / 2;
if (distance - extraDistance < WulfrumScrewdriver.ScrewBazingaAimAssistReach && angle < WulfrumScrewdriver.ScrewBazingaAimAssistAngle / 2f)
{
if (!Collision.CanHit(Projectile.Center, 1, 1, potentialTarget.Center, 1, 1) && extraDistance < distance)
continue;
float attemptedScore = EvaluatePotentialTarget(distance - extraDistance, angle / 2f);
if (attemptedScore > bestScore)
{
bestTarget = potentialTarget;
bestScore = attemptedScore;
}
}
}
return false;
return bestTarget;
}
public float EvaluatePotentialTarget(float distance, float angle)
{
float score = 1 - distance / WulfrumScrewdriver.ScrewBazingaAimAssistReach * 0.2f;
//Prioritize angle over distance
score += (1 - Math.Abs(angle) / (WulfrumScrewdriver.ScrewBazingaAimAssistAngle / 2f)) * 0.8f;
return score;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
@@ -137,6 +165,7 @@ namespace CalamityMod.Projectiles.Melee
SoundEngine.PlaySound(WulfrumScrewdriver.ThudSound, target.Center);
Projectile.timeLeft = 0;
//Chance to gain a screw
if (Main.rand.NextBool(5) && Main.myPlayer == Owner.whoAmI)
{
if (Owner.HeldItem.ModItem is WulfrumScrewdriver screwdriver && !screwdriver.ScrewStored)
@@ -174,5 +203,29 @@ namespace CalamityMod.Projectiles.Melee
Owner.itemAnimation = 0;
}
}
public override bool PreDraw(ref Color lightColor)
{
Texture2D tex = ModContent.Request<Texture2D>(Texture).Value;
if (SmearTex == null)
SmearTex = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/MediumLongThrust");
Texture2D smearTex = SmearTex.Value;
Vector2 drawOrigin = new Vector2(tex.Width / 2f, tex.Height);
Vector2 scale = new Vector2(Math.Abs((float)Math.Sin(LifetimeCompletion * MathHelper.TwoPi * 0.5f)), 1f);
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, lightColor, Projectile.rotation, drawOrigin, scale * Projectile.scale, 0f, 0);
if (LifetimeCompletion < 0.6f)
{
int frameCount = (int)Math.Floor((LifetimeCompletion / 0.6f) * 3f);
Rectangle frame = new Rectangle(0, (smearTex.Height / 3) * frameCount, smearTex.Width, smearTex.Height / 3);
float opacity = 1 - (float)Math.Pow(LifetimeCompletion / 0.6f, 0.5f);
Main.spriteBatch.Draw(smearTex, Projectile.Center + Projectile.velocity * 67f - Main.screenPosition, frame, Color.White * opacity, Projectile.rotation, frame.Size() / 2f, 0.9f, 0, 0);
}
return false;
}
}
}