69 lines
2.7 KiB
C#
69 lines
2.7 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.Audio;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
namespace CalamityMod.Projectiles.Ranged
|
|
{
|
|
public class CardClub : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Ranged";
|
|
public override void SetStaticDefaults()
|
|
{
|
|
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 5;
|
|
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 14;
|
|
Projectile.height = 14;
|
|
Projectile.friendly = true;
|
|
Projectile.alpha = 255;
|
|
Projectile.penetrate = 1;
|
|
Projectile.timeLeft = 600;
|
|
Projectile.DamageType = DamageClass.Ranged;
|
|
Projectile.extraUpdates = 1;
|
|
Projectile.aiStyle = ProjAIStyleID.Arrow;
|
|
AIType = ProjectileID.Bullet;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0f / 255f);
|
|
Projectile.rotation -= (MathHelper.ToRadians(90) * Projectile.direction);
|
|
Projectile.spriteDirection = Projectile.direction;
|
|
if (Main.rand.NextBool())
|
|
{
|
|
int dust = Dust.NewDust(Projectile.position, 1, 1, DustID.Web, 0f, 0f, 0, default, 0.5f);
|
|
Main.dust[dust].velocity *= 0f;
|
|
Main.dust[dust].noGravity = true;
|
|
}
|
|
}
|
|
|
|
public override bool OnTileCollide(Vector2 oldVelocity)
|
|
{
|
|
Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height);
|
|
SoundEngine.PlaySound(SoundID.Dig, Projectile.position);
|
|
return true;
|
|
}
|
|
|
|
public override void OnKill(int timeLeft)
|
|
{
|
|
for (int i = -8; i <= 8; i += 8)
|
|
{
|
|
Vector2 perturbedSpeed = new Vector2(Projectile.velocity.X, Projectile.velocity.Y).RotatedBy(MathHelper.ToRadians(i));
|
|
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, ModContent.ProjectileType<CardClubSplit>(), Projectile.damage / 2, 0f, Projectile.owner, 0f, 0f);
|
|
}
|
|
SoundEngine.PlaySound(SoundID.Item110, Projectile.Center);
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
|
|
return false;
|
|
}
|
|
}
|
|
}
|