Files
CalamityModPublic/Projectiles/Magic/Snowball.cs
T

66 lines
2.6 KiB
C#

using CalamityMod.Buffs.StatDebuffs;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
namespace CalamityMod.Projectiles.Magic
{
public class Snowball : ModProjectile
{
public override void SetDefaults()
{
Projectile.width = 16;
Projectile.height = 16;
Projectile.aiStyle = 1;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.Magic;
Projectile.coldDamage = true;
Projectile.penetrate = 1;
Projectile.extraUpdates = 1;
Projectile.coldDamage = true;
}
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Snowball");
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(BuffID.Frostburn, 180);
target.AddBuff(ModContent.BuffType<GlacialState>(), 30);
}
public override Color? GetAlpha(Color lightColor)
{
return new Color(200, 200, 200, Projectile.alpha);
}
public override void Kill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Item27, Projectile.position);
//crystal bullet shards
for (int index1 = 0; index1 < 10; ++index1)
{
int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 68, 0f, 0f, 0, new Color(), 1f);
Main.dust[index2].noGravity = true;
Main.dust[index2].velocity *= 2f;
}
if (Projectile.owner == Main.myPlayer)
{
for (int index = 0; index < 6; ++index)
{
float SpeedX = -Projectile.velocity.X * Main.rand.Next(40, 70) * 0.01f + Main.rand.Next(-20, 21) * 0.4f;
float SpeedY = -Projectile.velocity.Y * Main.rand.Next(40, 70) * 0.01f + Main.rand.Next(-20, 21) * 0.4f;
int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X + SpeedX, Projectile.Center.Y + SpeedY, SpeedX, SpeedY, ProjectileID.CrystalShard, Projectile.damage / 2, 0f, Projectile.owner);
// Main.projectile[p].ranged = false /* tModPorter - this is redundant, for more info see https://github.com/tModLoader/tModLoader/wiki/Update-Migration-Guide#damage-classes */ ;
Main.projectile[p].DamageType = DamageClass.Magic;
}
}
//insert ice shattering dust here
}
}
}