67 lines
2.3 KiB
C#
67 lines
2.3 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using Terraria.Audio;
|
|
|
|
namespace CalamityMod.Projectiles.Ranged
|
|
{
|
|
public class ImpactRound : ModProjectile
|
|
{
|
|
public override string Texture => "CalamityMod/Projectiles/Ranged/AMRShot";
|
|
|
|
private bool initialized = false;
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Impact Round");
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 4;
|
|
Projectile.height = 4;
|
|
Projectile.light = 0.5f;
|
|
Projectile.alpha = 255;
|
|
Projectile.extraUpdates = 7;
|
|
Projectile.scale = 1.18f;
|
|
Projectile.friendly = true;
|
|
Projectile.DamageType = DamageClass.Ranged;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.aiStyle = 1;
|
|
AIType = ProjectileID.BulletHighVelocity;
|
|
Projectile.penetrate = -1;
|
|
Projectile.timeLeft = 600;
|
|
Projectile.tileCollide = false;
|
|
Projectile.usesLocalNPCImmunity = true;
|
|
Projectile.localNPCHitCooldown = 10;
|
|
Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
if (!initialized && Projectile.CountsAsClass(DamageClass.Ranged)) //Ranged check prevents quiver splits triggering the sound
|
|
{
|
|
initialized = true;
|
|
|
|
if (Main.netMode != NetmodeID.Server)
|
|
{
|
|
var sound = SoundLoader.GetLegacySoundSlot(Mod, "Sounds/Item/LargeWeaponFire");
|
|
sound = sound.WithVolume(sound.Volume * 0.45f);
|
|
SoundEngine.PlaySound(sound, Projectile.Center);
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
|
|
{
|
|
double damageMult = 1D;
|
|
if (crit)
|
|
damageMult += 0.25;
|
|
damage = (int)(damage * damageMult);
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor) => Projectile.timeLeft < 600;
|
|
}
|
|
}
|