Files
CalamityModPublic/Projectiles/Summon/BloodSpit.cs
T

61 lines
2.2 KiB
C#

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class BloodSpit : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public const int OnDeathHealValue = 1;
public Player Owner => Main.player[Projectile.owner];
public override void SetStaticDefaults()
{
Main.projFrames[Projectile.type] = 3;
ProjectileID.Sets.MinionShot[Projectile.type] = true;
}
public override void SetDefaults()
{
Projectile.width = 8;
Projectile.height = 8;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.minion = true;
Projectile.minionSlots = 0f;
Projectile.timeLeft = 150;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 6;
Projectile.DamageType = DamageClass.Summon;
}
public override void AI()
{
Lighting.AddLight(Projectile.Center, Projectile.Opacity * 0.77f, Projectile.Opacity * 0.15f, Projectile.Opacity * 0.08f);
Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2;
if (Projectile.frameCounter++ > 4)
{
Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Projectile.type];
Projectile.frameCounter = 0;
}
}
public override void Kill(int timeLeft)
{
for (int i = 0; i < 15; i++)
{
Dust blood = Dust.NewDustDirect(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 5, Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f);
blood.velocity = Main.rand.NextVector2Circular(1f, 2f);
blood.noGravity = true;
}
Owner.HealEffect(OnDeathHealValue, false);
Owner.statLife += OnDeathHealValue;
if (Owner.statLife > Owner.statLifeMax2)
Owner.statLife = Owner.statLifeMax2;
}
}
}