Fixed contact gun hitboxes
This commit is contained in:
1 parent
4cecd9e151
commit
b98a1e657b
3 files changed
+38
-1
No files matched your search
@@ -48,6 +48,18 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
|
||||
public override Vector2? HoldoutOffset() => new Vector2(-10, 0);
|
||||
|
||||
//Custom melee hitbox
|
||||
public override bool? CanHitNPC(Player player, NPC target)
|
||||
{
|
||||
Rectangle targetHitbox = target.Hitbox;
|
||||
|
||||
float collisionPoint = 0f;
|
||||
float gunLenght = 66f;
|
||||
float gunHeight = 15;
|
||||
|
||||
return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), player.MountedCenter, player.MountedCenter + ((player.itemRotation + (player.direction < 0 ? MathHelper.Pi : 0f)).ToRotationVector2() * gunLenght), gunHeight, ref collisionPoint);
|
||||
}
|
||||
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
||||
{
|
||||
for (int index = 0; index < 3; index++)
|
||||
|
||||
@@ -42,6 +42,18 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
return new Vector2(-5, 0);
|
||||
}
|
||||
|
||||
//Custom melee hitbox
|
||||
public override bool? CanHitNPC(Player player, NPC target)
|
||||
{
|
||||
Rectangle targetHitbox = target.Hitbox;
|
||||
|
||||
float collisionPoint = 0f;
|
||||
float gunLenght = 60f;
|
||||
float gunHeight = 26f;
|
||||
|
||||
return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), player.MountedCenter, player.MountedCenter + ((player.itemRotation + (player.direction < 0 ? MathHelper.Pi : 0f)).ToRotationVector2() * gunLenght), gunHeight, ref collisionPoint);
|
||||
}
|
||||
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
||||
{
|
||||
for (int index = 0; index < 2; ++index)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Ranged
|
||||
{
|
||||
@@ -9,7 +11,6 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Marnite Bayonet");
|
||||
// TODO -- Marnite Bayonet hitboxes are screwed because it's not a holdout
|
||||
Tooltip.SetDefault("The gun damages enemies that touch it");
|
||||
SacrificeTotal = 1;
|
||||
}
|
||||
@@ -34,6 +35,18 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
Item.Calamity().canFirePointBlankShots = true;
|
||||
}
|
||||
|
||||
//Custom melee hitbox
|
||||
public override bool? CanHitNPC(Player player, NPC target)
|
||||
{
|
||||
Rectangle targetHitbox = target.Hitbox;
|
||||
|
||||
float collisionPoint = 0f;
|
||||
float gunLenght = 66f;
|
||||
float gunHeight = 20f;
|
||||
|
||||
return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), player.MountedCenter, player.MountedCenter + ((player.itemRotation + (player.direction < 0 ? MathHelper.Pi : 0f)).ToRotationVector2() * gunLenght), gunHeight, ref collisionPoint);
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
CreateRecipe().
|
||||
|
||||
Reference in new issue
Block a user