Files
CalamityModPublic/Projectiles/Ranged/ImpactRound.cs
T

74 lines
3.4 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class ImpactRound : ModProjectile
{
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.ranged = true;
projectile.ignoreWater = true;
projectile.aiStyle = 1;
aiType = ProjectileID.BulletHighVelocity;
projectile.penetrate = -1;
projectile.timeLeft = 600;
projectile.tileCollide = false;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 10;
}
public override void AI()
{
if (!initialized)
{
initialized = true;
Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeWeaponFire"), (int)projectile.position.X, (int)projectile.position.Y);
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.timeLeft < 600;
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;
}
if (target.HitSound != SoundID.NPCHit1 && target.HitSound != SoundID.NPCHit6 && target.HitSound != SoundID.NPCHit7 &&
target.HitSound != SoundID.NPCHit8 && target.HitSound != SoundID.NPCHit9 && target.HitSound != SoundID.NPCHit12 &&
target.HitSound != SoundID.NPCHit13 && target.HitSound != SoundID.NPCHit14 && target.HitSound != SoundID.NPCHit18 &&
target.HitSound != SoundID.NPCHit19 && target.HitSound != SoundID.NPCHit20 && target.HitSound != SoundID.NPCHit21 &&
target.HitSound != SoundID.NPCHit22 && target.HitSound != SoundID.NPCHit23 && target.HitSound != SoundID.NPCHit24 &&
target.HitSound != SoundID.NPCHit25 && target.HitSound != SoundID.NPCHit26 && target.HitSound != SoundID.NPCHit27 &&
target.HitSound != SoundID.NPCHit28 && target.HitSound != SoundID.NPCHit29 && target.HitSound != SoundID.NPCHit31 &&
target.HitSound != SoundID.NPCHit32 && target.HitSound != SoundID.NPCHit33 && target.HitSound != SoundID.NPCHit35 &&
target.HitSound != SoundID.NPCHit37 && target.HitSound != SoundID.NPCHit38 && target.HitSound != SoundID.NPCHit40 &&
target.HitSound != SoundID.NPCHit43 && target.HitSound != SoundID.NPCHit44 && target.HitSound != SoundID.NPCHit45 &&
target.HitSound != SoundID.NPCHit46 && target.HitSound != SoundID.NPCHit47 && target.HitSound != SoundID.NPCHit48 &&
target.HitSound != SoundID.NPCHit50 && target.HitSound != SoundID.NPCHit51 && target.HitSound != SoundID.NPCHit55 &&
target.HitSound != SoundID.NPCHit56 && target.HitSound != SoundID.NPCHit57)
{
damageMult += 0.1;
}
damage = (int)(damage * damageMult);
}
}
}