Made Surge Driver use 2 mode sprites

This commit is contained in:
DominicKarma committed 2021-03-18 22:44:43 -05:00
1 parent 2db8878782
commit 97aa0afddd
6 files changed
+120 -11

No files matched your search

+18 -9
View File
@@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged
public override void SetDefaults()
{
item.damage = 1200;
item.damage = 800;
item.ranged = true;
item.width = 164;
item.height = 58;
@@ -34,25 +34,38 @@ namespace CalamityMod.Items.Weapons.Ranged
item.useAmmo = AmmoID.Bullet;
}
public override Vector2? HoldoutOffset() => Vector2.UnitX * -50f;
public override Vector2? HoldoutOffset() => new Vector2(-50f, -8f);
public override bool AltFunctionUse(Player player) => true;
public override bool CanUseItem(Player player)
{
if (player.altFunctionUse == 2)
{
item.noUseGraphic = false;
item.reuseDelay = 0;
item.UseSound = SoundID.Item14;
item.channel = false;
}
else
{
item.noUseGraphic = true;
item.reuseDelay = 28;
item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon");
item.channel = true;
return player.ownedProjectileCounts[ModContent.ProjectileType<SurgeDriverHoldout>()] <= 0;
}
return base.CanUseItem(player);
}
public override float UseTimeMultiplier(Player player) => player.altFunctionUse == 2 ? 5f : 1f;
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Vector2 shootVelocity = new Vector2(speedX, speedY);
Vector2 shootDirection = shootVelocity.SafeNormalize(Vector2.UnitX * player.direction);
Vector2 gunTip = position + shootDirection * item.scale * 132f;
Vector2 gunTip = position + shootDirection * item.scale * 126f;
gunTip.Y -= 6f;
// Large bullet/rocket releasing.
if (player.altFunctionUse == 2)
@@ -65,13 +78,9 @@ namespace CalamityMod.Items.Weapons.Ranged
}
}
// Snipe blast.
// Snipe blast. Done via a held projectile.
else
{
shootVelocity *= 0.64f;
damage = (int)(damage * 6.66);
Projectile.NewProjectile(gunTip, shootVelocity, ModContent.ProjectileType<PrismaticEnergyBlast>(), damage, knockBack, player.whoAmI);
}
Projectile.NewProjectile(gunTip, shootVelocity, ModContent.ProjectileType<SurgeDriverHoldout>(), 0, knockBack, player.whoAmI);
return false;
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

+1 -1
View File
@@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Ranged
public override void SetDefaults()
{
projectile.width = projectile.height = 24;
projectile.width = projectile.height = 14;
projectile.friendly = true;
projectile.ranged = true;
projectile.tileCollide = false;
+100
View File
@@ -0,0 +1,100 @@
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class SurgeDriverHoldout : ModProjectile
{
public Player Owner => Main.player[projectile.owner];
public bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem(), true) && !Owner.noItems && !Owner.CCed;
public ref float ShootCountdown => ref projectile.ai[0];
public override void SetStaticDefaults() => DisplayName.SetDefault("Storm Driver");
public override void SetDefaults()
{
projectile.width = 192;
projectile.height = 52;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.tileCollide = false;
projectile.ranged = true;
projectile.ignoreWater = true;
}
public override void AI()
{
if (!OwnerCanShoot)
projectile.Kill();
Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true);
armPosition += projectile.velocity.SafeNormalize(Owner.direction * Vector2.UnitX) * 32f;
armPosition.Y -= 12f;
UpdateProjectileHeldVariables(armPosition);
ManipulatePlayerVariables();
ShootCountdown--;
if (ShootCountdown <= 0f)
{
if (Main.myPlayer == projectile.owner)
{
ShootProjectiles(armPosition);
ShootCountdown = 28f;
projectile.netUpdate = true;
}
Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), projectile.Center);
}
}
public void ShootProjectiles(Vector2 armPosition)
{
if (Main.myPlayer != projectile.owner)
return;
Item heldItem = Owner.ActiveItem();
int projectileType = ModContent.ProjectileType<PrismaticEnergyBlast>();
float shootSpeed = heldItem.shootSpeed * projectile.scale * 0.64f;
int damage = (int)(Owner.GetWeaponDamage(heldItem) * 6.66);
float knockback = heldItem.knockBack;
bool uselessFuckYou = OwnerCanShoot;
Owner.PickAmmo(heldItem, ref projectileType, ref shootSpeed, ref uselessFuckYou, ref damage, ref knockback, false);
projectileType = ModContent.ProjectileType<PrismaticEnergyBlast>();
knockback = Owner.GetWeaponKnockback(heldItem, knockback);
Vector2 shootDirection = (Main.MouseWorld - projectile.Center).SafeNormalize(-Vector2.UnitY);
Vector2 shootVelocity = shootDirection * shootSpeed;
// Sync if the shoot direction changes.
if (shootDirection.X != projectile.velocity.X || shootDirection.Y != projectile.velocity.Y)
projectile.netUpdate = true;
Vector2 gunTip = armPosition + shootDirection * heldItem.scale * 130f;
Projectile.NewProjectile(gunTip, shootVelocity, projectileType, damage, knockback, projectile.owner, 0f, 0f);
projectile.velocity = shootDirection;
}
public void UpdateProjectileHeldVariables(Vector2 armPosition)
{
projectile.position = armPosition - projectile.Size * 0.5f;
projectile.rotation = projectile.velocity.ToRotation();
if (projectile.spriteDirection == -1)
projectile.rotation += MathHelper.Pi;
projectile.spriteDirection = projectile.direction;
projectile.timeLeft = 2;
}
public void ManipulatePlayerVariables()
{
Owner.ChangeDir(projectile.direction);
Owner.heldProj = projectile.whoAmI;
Owner.itemTime = 2;
Owner.itemAnimation = 2;
Owner.itemRotation = (projectile.velocity * projectile.direction).ToRotation();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1011 B

@@ -14,7 +14,7 @@ namespace CalamityMod.Projectiles.Rogue
public ref float HitTargetIndex => ref projectile.ai[0];
public ref float Time => ref projectile.ai[1];
public override string Texture => "CalamityMod/Items/Weapons/Rogue/PrismJavelin";
public override string Texture => "CalamityMod/Items/Weapons/Rogue/TheAtomSplitter";
public override void SetStaticDefaults() => DisplayName.SetDefault("Atom Splitter");