Add Nullified debuff, add Transcendent weapons and tool
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace ForgottenWawiTech.Content.Projectiles.Transcendent
|
||||
{
|
||||
public class TranscendentBladeShard : ModProjectile
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 12;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 2;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 18;
|
||||
Projectile.height = 18;
|
||||
Projectile.friendly = true;
|
||||
Projectile.hostile = false;
|
||||
Projectile.penetrate = 4;
|
||||
Projectile.timeLeft = 180;
|
||||
Projectile.alpha = 40;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.extraUpdates = 1;
|
||||
Projectile.DamageType = DamageClass.Melee;
|
||||
Projectile.ignoreWater = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Projectile.rotation += 0.4f * Projectile.direction;
|
||||
Lighting.AddLight(Projectile.Center, 0.35f, 0.25f, 0.55f);
|
||||
|
||||
if (Projectile.localAI[0] == 0f)
|
||||
{
|
||||
Projectile.localAI[0] = 1f;
|
||||
Projectile.velocity *= 1.1f;
|
||||
}
|
||||
|
||||
NPC target = FindTarget(720f);
|
||||
if (target != null)
|
||||
{
|
||||
float homingStrength = 0.18f;
|
||||
float desiredSpeed = 20f;
|
||||
Vector2 desiredVelocity = Projectile.DirectionTo(target.Center) * desiredSpeed;
|
||||
Projectile.velocity = Vector2.Lerp(Projectile.velocity, desiredVelocity, homingStrength);
|
||||
}
|
||||
|
||||
if (Main.rand.NextBool(3))
|
||||
{
|
||||
int dustIndex = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowTorch, 0f, 0f, 150, default, 1.2f);
|
||||
Dust dust = Main.dust[dustIndex];
|
||||
dust.noGravity = true;
|
||||
dust.velocity = Projectile.velocity * 0.3f;
|
||||
}
|
||||
}
|
||||
|
||||
private NPC FindTarget(float maxDetectDistance)
|
||||
{
|
||||
NPC selected = null;
|
||||
float sqr = maxDetectDistance * maxDetectDistance;
|
||||
for (int i = 0; i < Main.maxNPCs; i++)
|
||||
{
|
||||
NPC npc = Main.npc[i];
|
||||
if (npc.CanBeChasedBy())
|
||||
{
|
||||
float dist = Vector2.DistanceSquared(npc.Center, Projectile.Center);
|
||||
if (dist < sqr)
|
||||
{
|
||||
sqr = dist;
|
||||
selected = npc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return selected;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
target.AddBuff(BuffID.Daybreak, 300);
|
||||
target.AddBuff(ModContent.BuffType<Content.Buffs.Debuffs.TypeNull>(), 300);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user