From 4c8b34fb54faeefdec66eb03e9c4991c1386b3e4 Mon Sep 17 00:00:00 2001 From: IbanPlay <56191483+IbanPlay@users.noreply.github.com> Date: Wed, 15 Jun 2022 11:58:47 +0200 Subject: [PATCH] Illustrious knives hitbox fix --- Projectiles/Melee/IllustriousKnife.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Projectiles/Melee/IllustriousKnife.cs b/Projectiles/Melee/IllustriousKnife.cs index 5a4342f23c..0853ffa2ae 100644 --- a/Projectiles/Melee/IllustriousKnife.cs +++ b/Projectiles/Melee/IllustriousKnife.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; using System; @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.knockBack = (int)(Projectile.knockBack * 0.95); } if (Projectile.ai[0] < 240f) - Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + 1.57f; + Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; else { Projectile.rotation += 0.5f; @@ -47,6 +47,18 @@ namespace CalamityMod.Projectiles.Melee Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 20, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); } + //Give it a custom hitbox shape so it may remain rectangular and elongated + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + float collisionPoint = 0f; + float bladeHalfLenght = Projectile.height * Projectile.scale / 2f; + float bladeWidth = Projectile.width * Projectile.scale; + + Vector2 direction = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2(); + + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center - direction * bladeHalfLenght, Projectile.Center + direction * bladeHalfLenght, bladeWidth, ref collisionPoint); + } + public override void Kill(int timeLeft) { for (int num303 = 0; num303 < 3; num303++)