Some gun code cleanup
screenshake adjustments and removing unnecessary code
This commit is contained in:
1 parent
41fce499c3
commit
7a63a8aec6
2 files changed
+4
-25
No files matched your search
@@ -45,6 +45,7 @@ namespace CalamityMod.Items.Weapons.Magic
|
||||
{
|
||||
if (player.ownedProjectileCounts[Item.shoot] <= 0)
|
||||
player.statMana += manaConsumed;
|
||||
player.Calamity().GeneralScreenShakePower = 3f;
|
||||
}
|
||||
|
||||
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0;
|
||||
|
||||
@@ -64,6 +64,8 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
|
||||
public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback)
|
||||
{
|
||||
player.Calamity().GeneralScreenShakePower = 2f;
|
||||
|
||||
player.velocity += velocity.SafeNormalize(Vector2.UnitX) * -7f;
|
||||
if (type == ProjectileID.Bullet)
|
||||
type = ModContent.ProjectileType<NitroShot>();
|
||||
@@ -80,30 +82,6 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
Vector2 itemSize = new Vector2(Item.width, Item.height);
|
||||
Vector2 itemOrigin = new Vector2(-5, 6);
|
||||
|
||||
|
||||
//Sniper's horizontal recoil; can be a bit subtle but it is noticeable
|
||||
if (player.altFunctionUse == 2)
|
||||
{
|
||||
//Recoil:
|
||||
int anim = 0;
|
||||
for (int r = 0; r < Item.useAnimation; ++r)
|
||||
{
|
||||
if (anim == 10 && r < Item.useAnimation / 2) //animates every 10 frames so that the player notices a recoil because this happens way too fast
|
||||
{
|
||||
itemPosition.X -= player.direction * 0.025f;
|
||||
itemPosition.Y -= player.direction * 0.025f;
|
||||
anim = 0;
|
||||
}
|
||||
else if (anim == 10 && r > Item.useAnimation / 2)
|
||||
{
|
||||
itemPosition.X += player.direction * 0.025f;
|
||||
itemPosition.Y += player.direction * 0.025f;
|
||||
anim = 0;
|
||||
}
|
||||
++anim;
|
||||
}
|
||||
}
|
||||
|
||||
CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin);
|
||||
base.UseStyle(player, heldItemFrame);
|
||||
}
|
||||
@@ -116,7 +94,7 @@ namespace CalamityMod.Items.Weapons.Ranged
|
||||
float animProgress = 1 - player.itemTime / (float)player.itemTimeMax;
|
||||
float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2;
|
||||
if (animProgress < 0.5)
|
||||
rotation += (player.altFunctionUse == 2 ? -1f : -0.45f) * (float)Math.Pow((0.5f - animProgress) / 0.5f, 2) * player.direction;
|
||||
rotation += -0.45f * (float)Math.Pow((0.5f - animProgress) / 0.5f, 2) * player.direction;
|
||||
player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); //must be here otherwise it will vibrate
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user