64 lines
2.4 KiB
C#
64 lines
2.4 KiB
C#
using CalamityMod.Balancing;
|
|
using System;
|
|
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 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 = Projectile.height = 8;
|
|
Projectile.friendly = true;
|
|
Projectile.ignoreWater = true;
|
|
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 OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
|
{
|
|
for (int i = 0; i < 15; i++)
|
|
{
|
|
Dust blood = Dust.NewDustDirect(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Blood, Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f);
|
|
blood.velocity = Main.rand.NextVector2Circular(1f, 2f);
|
|
blood.noGravity = true;
|
|
}
|
|
|
|
int heal = (int)Math.Round(hit.Damage * 0.01);
|
|
if (heal > BalancingConstants.LifeStealCap)
|
|
heal = BalancingConstants.LifeStealCap;
|
|
|
|
if (Main.player[Main.myPlayer].lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5)
|
|
return;
|
|
|
|
CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange);
|
|
}
|
|
}
|
|
}
|