Executioner's blade should no longer kill Yharon on 2:30 Deep wounder should no longer be dogshit Nerfed Fantasy Talismans Sacrifice projectiles made faster Nerfed Duststorm cloud's iframes and renamed the projectile so they show up on Cal Test Helpers Buffed Sandslasher's velocity Mega buffed Apoctolith Made Young Duke use Local Iframes Buffed AotC Rebalanced Kylie and Frostcrush Valari Buffed Plagued Fueled pack Rebalanced Totality Breakers Buffed Ballistic Poison bomb Rebalanced Monkey Darts Rebalanced Tarragon Darts a bit
132 lines
4.8 KiB
C#
132 lines
4.8 KiB
C#
using CalamityMod.CalPlayer;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Summon
|
|
{
|
|
public class YoungDuke : ModProjectile
|
|
{
|
|
public const float DistanceBeforeCharge = 420f;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Young Old Duke");
|
|
Main.projFrames[Projectile.type] = 16;
|
|
ProjectileID.Sets.MinionSacrificable[Projectile.type] = true;
|
|
ProjectileID.Sets.MinionTargettingFeature[Projectile.type] = true;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 30;
|
|
Projectile.height = 30;
|
|
Projectile.netImportant = true;
|
|
Projectile.friendly = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.timeLeft = 18000;
|
|
Projectile.penetrate = -1;
|
|
Projectile.tileCollide = false;
|
|
Projectile.timeLeft *= 5;
|
|
Projectile.minion = true;
|
|
Projectile.DamageType = DamageClass.Summon;
|
|
Projectile.usesLocalNPCImmunity = true;
|
|
Projectile.localNPCHitCooldown = 60;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Player player = Main.player[Projectile.owner];
|
|
CalamityPlayer modPlayer = player.Calamity();
|
|
if (!modPlayer.miniOldDuke && !modPlayer.miniOldDukeVanity)
|
|
{
|
|
Projectile.active = false;
|
|
return;
|
|
}
|
|
|
|
bool correctMinion = Projectile.type == ModContent.ProjectileType<YoungDuke>();
|
|
if (correctMinion)
|
|
{
|
|
if (player.dead)
|
|
{
|
|
modPlayer.youngDuke = false;
|
|
}
|
|
if (modPlayer.youngDuke)
|
|
{
|
|
Projectile.timeLeft = 2;
|
|
}
|
|
}
|
|
|
|
bool playerHalfLife = player.statLife <= player.statLifeMax2 * 0.5f;
|
|
|
|
// Frames
|
|
Projectile.frameCounter++;
|
|
if (Projectile.frameCounter > 6)
|
|
{
|
|
Projectile.frame++;
|
|
Projectile.frameCounter = 0;
|
|
}
|
|
if (Projectile.frame >= Main.projFrames[Projectile.type])
|
|
{
|
|
Projectile.frame = 0;
|
|
}
|
|
if (playerHalfLife && Projectile.frame < Main.projFrames[Projectile.type] / 2)
|
|
{
|
|
Projectile.frame += Main.projFrames[Projectile.type] / 2;
|
|
}
|
|
else if (!playerHalfLife && Projectile.frame >= Main.projFrames[Projectile.type] / 2)
|
|
{
|
|
Projectile.frame -= Main.projFrames[Projectile.type] / 2;
|
|
}
|
|
|
|
if (!modPlayer.miniOldDukeVanity)
|
|
{
|
|
NPC potentialTarget = Projectile.Center.ClosestNPCAt(1600f);
|
|
if (potentialTarget != null)
|
|
{
|
|
if (Projectile.Distance(potentialTarget.Center) < DistanceBeforeCharge)
|
|
{
|
|
Projectile.ai[0] += 1f;
|
|
int timePerCharge = playerHalfLife ? 25 : 35;
|
|
float chargeSpeed = playerHalfLife ? 25f : 20f;
|
|
if (Projectile.ai[0] >= timePerCharge)
|
|
{
|
|
Projectile.velocity = Projectile.SafeDirectionTo(potentialTarget.Center) * chargeSpeed;
|
|
Projectile.ai[0] = 0f;
|
|
}
|
|
else
|
|
Projectile.velocity *= 0.9825f;
|
|
}
|
|
else
|
|
{
|
|
float intertia = 0.94f;
|
|
float homeSpeed = playerHalfLife ? 38f : 32f;
|
|
Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(potentialTarget.Center) * homeSpeed, 1f - intertia);
|
|
}
|
|
}
|
|
else if (!Projectile.WithinRange(player.Center, 140f))
|
|
Projectile.velocity = (Projectile.velocity * 30f + Projectile.SafeDirectionTo(player.Center) * 16f) / 31f;
|
|
}
|
|
else if (!Projectile.WithinRange(player.Center, 140f))
|
|
Projectile.velocity = (Projectile.velocity * 30f + Projectile.SafeDirectionTo(player.Center) * 16f) / 31f;
|
|
|
|
Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0).ToDirectionInt();
|
|
}
|
|
|
|
public override bool? CanDamage()
|
|
{
|
|
Player player = Main.player[Projectile.owner];
|
|
CalamityPlayer modPlayer = player.Calamity();
|
|
if (modPlayer.miniOldDukeVanity)
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|