Added Seraphim
This commit is contained in:
1 parent
6e00a073ab
commit
2ff8fae8fc
12 files changed
+607
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 859 B |
@@ -0,0 +1,74 @@
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Projectiles.Rogue;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Rogue
|
||||
{
|
||||
public class Seraphim : RogueWeapon
|
||||
{
|
||||
public const int SplitDaggerCount = 6;
|
||||
public const int StealthStrikeLightCount = 9;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Seraphim");
|
||||
Tooltip.SetDefault("Throws an extraordinarily fast dagger which slows down exponentially and dissipates into light\n" +
|
||||
$"Once dissipation has ended, {SplitDaggerCount} fast, splitting blades that aim at and slice nearby targets are released, along\n" +
|
||||
"with a large laserbeam\n" +
|
||||
$"Stealth strikes release a volley of {StealthStrikeLightCount} lights which explode into smaller laser beams along with the dagger");
|
||||
}
|
||||
|
||||
public override void SafeSetDefaults()
|
||||
{
|
||||
item.width = 82;
|
||||
item.height = 82;
|
||||
item.damage = 350;
|
||||
item.noMelee = true;
|
||||
item.noUseGraphic = true;
|
||||
item.useAnimation = 12;
|
||||
item.useTime = 12;
|
||||
item.useStyle = ItemUseStyleID.SwingThrow;
|
||||
item.knockBack = 6f;
|
||||
item.UseSound = SoundID.Item1;
|
||||
item.autoReuse = true;
|
||||
item.value = CalamityGlobalItem.RarityVioletBuyPrice;
|
||||
item.rare = ItemRarityID.Purple;
|
||||
item.Calamity().customRarity = CalamityRarity.Violet;
|
||||
item.shoot = ModContent.ProjectileType<SeraphimProjectile>();
|
||||
item.shootSpeed = SeraphimProjectile.InitialSpeed;
|
||||
item.Calamity().rogue = true;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
ModRecipe recipe = new ModRecipe(mod);
|
||||
recipe.AddIngredient(ModContent.ItemType<ShatteredSun>());
|
||||
recipe.AddIngredient(ModContent.ItemType<AuricBar>(), 5);
|
||||
recipe.AddTile(TileID.LunarCraftingStation);
|
||||
recipe.SetResult(this);
|
||||
recipe.AddRecipe();
|
||||
}
|
||||
|
||||
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
|
||||
{
|
||||
Vector2 velocity = new Vector2(speedX, speedY);
|
||||
int knife = Projectile.NewProjectile(position + velocity, velocity, type, damage, knockBack, player.whoAmI);
|
||||
if (Main.projectile.IndexInRange(knife))
|
||||
Main.projectile[knife].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable();
|
||||
|
||||
// Have stealth strikes release bursts of light that explode.
|
||||
if (player.Calamity().StealthStrikeAvailable())
|
||||
{
|
||||
for (int i = 0; i < StealthStrikeLightCount; i++)
|
||||
{
|
||||
float offsetAngle = MathHelper.Lerp(-0.97f, 0.97f, i / (float)(StealthStrikeLightCount - 1f));
|
||||
Vector2 lightShootVelocity = velocity.SafeNormalize(Vector2.UnitY).RotatedBy(offsetAngle) * 23f;
|
||||
Projectile.NewProjectile(position, lightShootVelocity, ModContent.ProjectileType<SeraphimAngelicLight2>(), damage, knife, player.whoAmI, 1f);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,64 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
public class SeraphimAngelicLight : ModProjectile
|
||||
{
|
||||
public ref float Time => ref projectile.ai[0];
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Light Orb");
|
||||
Main.projFrames[projectile.type] = 10;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 82;
|
||||
projectile.height = 82;
|
||||
projectile.friendly = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.timeLeft = 10;
|
||||
projectile.tileCollide = false;
|
||||
projectile.Calamity().rogue = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
projectile.scale = CalamityUtils.Convert01To010(projectile.timeLeft / 10f);
|
||||
projectile.Opacity = (float)Math.Sqrt(projectile.scale);
|
||||
projectile.velocity *= 0.8f;
|
||||
projectile.frame = Main.projFrames[projectile.type] - projectile.timeLeft;
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
// Release a puff of golden light dust.
|
||||
for (int i = 0; i < 24; i++)
|
||||
{
|
||||
Dust light = Dust.NewDustPerfect(projectile.Center, 267);
|
||||
light.color = Color.Lerp(Color.Gold, Color.White, Main.rand.NextFloat(0.5f, 1f));
|
||||
light.velocity = (MathHelper.TwoPi * i / 16f).ToRotationVector2() * 5f;
|
||||
light.scale = 1.35f;
|
||||
light.noGravity = true;
|
||||
}
|
||||
|
||||
// Release a laser at the nearest target, if one exists.
|
||||
NPC potentialTarget = projectile.Center.ClosestNPCAt(1300f, true, true);
|
||||
if (Main.myPlayer != projectile.owner || potentialTarget is null)
|
||||
return;
|
||||
|
||||
int damage = projectile.damage;
|
||||
Vector2 laserDirection = projectile.SafeDirectionTo(potentialTarget.Center);
|
||||
Projectile.NewProjectile(projectile.Center, laserDirection, ModContent.ProjectileType<SeraphimBeamLarge>(), damage, 0f, projectile.owner);
|
||||
}
|
||||
|
||||
public override Color? GetAlpha(Color lightColor) => new Color(255, 255, 255, 255 - projectile.alpha);
|
||||
|
||||
public override bool CanDamage() => false;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,69 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
public class SeraphimAngelicLight2 : ModProjectile
|
||||
{
|
||||
public bool FireSmallLaser => projectile.ai[0] == 1f;
|
||||
public ref float Time => ref projectile.ai[1];
|
||||
public const int Lifetime = SeraphimProjectile.SlowdownTime + SeraphimDagger.SlowdownTime;
|
||||
|
||||
public override string Texture => "CalamityMod/Projectiles/Rogue/SeraphimAngelicLight";
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Light Orb");
|
||||
Main.projFrames[projectile.type] = 10;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 82;
|
||||
projectile.height = 82;
|
||||
projectile.friendly = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.timeLeft = Lifetime;
|
||||
projectile.tileCollide = false;
|
||||
projectile.Calamity().rogue = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
projectile.scale = CalamityUtils.Convert01To010(projectile.timeLeft / (float)Lifetime);
|
||||
projectile.Opacity = (float)Math.Sqrt(projectile.scale);
|
||||
projectile.velocity *= 0.8f;
|
||||
projectile.frame = (int)(Utils.InverseLerp(Lifetime, 0f, projectile.timeLeft, true) * Main.projFrames[projectile.type]);
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
// Release a puff of golden light dust.
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
Dust light = Dust.NewDustPerfect(projectile.Center, 267);
|
||||
light.color = Color.Lerp(Color.Gold, Color.White, Main.rand.NextFloat(0.5f, 1f));
|
||||
light.velocity = (MathHelper.TwoPi * i / 16f).ToRotationVector2() * 5f;
|
||||
light.scale = 0.9f;
|
||||
light.noGravity = true;
|
||||
}
|
||||
|
||||
// Release a laser at the nearest target, if one exists.
|
||||
NPC potentialTarget = projectile.Center.ClosestNPCAt(1300f, true, true);
|
||||
if (Main.myPlayer != projectile.owner || potentialTarget is null)
|
||||
return;
|
||||
|
||||
int damage = projectile.damage;
|
||||
Vector2 laserDirection = projectile.SafeDirectionTo(potentialTarget.Center);
|
||||
int laser = Projectile.NewProjectile(projectile.Center, laserDirection, ModContent.ProjectileType<SeraphimBeamLarge>(), damage, 0f, projectile.owner);
|
||||
if (Main.projectile.IndexInRange(laser))
|
||||
Main.projectile[laser].scale = 0.5f;
|
||||
}
|
||||
|
||||
public override Color? GetAlpha(Color lightColor) => new Color(255, 255, 255, 255 - projectile.alpha);
|
||||
|
||||
public override bool CanDamage() => false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
using CalamityMod.Projectiles.BaseProjectiles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
public class SeraphimBeamLarge : BaseLaserbeamProjectile
|
||||
{
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public int OwnerIndex
|
||||
{
|
||||
get => (int)projectile.ai[1];
|
||||
set => projectile.ai[1] = value;
|
||||
}
|
||||
public override float MaxScale => 1f;
|
||||
public override float MaxLaserLength => 1600f;
|
||||
public override float Lifetime => 50;
|
||||
public override Color LaserOverlayColor
|
||||
{
|
||||
get
|
||||
{
|
||||
Color c1 = Color.Goldenrod;
|
||||
Color c2 = Color.Orange;
|
||||
Color color = Color.Lerp(c1, c2, projectile.identity % 5f / 5f) * 1.1f;
|
||||
color.A = 25;
|
||||
return color;
|
||||
}
|
||||
}
|
||||
public override Color LightCastColor => Color.White;
|
||||
public override Texture2D LaserBeginTexture => ModContent.GetTexture("CalamityMod/Projectiles/Rogue/SeraphimBeamLarge");
|
||||
public override Texture2D LaserMiddleTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/SeraphimBeamLargeMiddle");
|
||||
public override Texture2D LaserEndTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/SeraphimBeamLargeEnd");
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Holy Beam");
|
||||
Main.projFrames[projectile.type] = 10;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 30;
|
||||
projectile.height = 30;
|
||||
projectile.friendly = true;
|
||||
projectile.alpha = 255;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.timeLeft = 600;
|
||||
projectile.usesIDStaticNPCImmunity = true;
|
||||
projectile.idStaticNPCHitCooldown = 18;
|
||||
projectile.Calamity().rogue = true;
|
||||
cooldownSlot = 1;
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(projectile.localAI[0]);
|
||||
writer.Write(projectile.localAI[1]);
|
||||
writer.Write(projectile.scale);
|
||||
}
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
projectile.localAI[0] = reader.ReadSingle();
|
||||
projectile.localAI[1] = reader.ReadSingle();
|
||||
projectile.scale = reader.ReadSingle();
|
||||
}
|
||||
|
||||
public override void AttachToSomething() { }
|
||||
|
||||
public override void UpdateLaserMotion()
|
||||
{
|
||||
// Update the direction and rotation of the laser.
|
||||
projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitY);
|
||||
projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2;
|
||||
}
|
||||
|
||||
public override float DetermineLaserLength()
|
||||
{
|
||||
float[] sampledLengths = new float[10];
|
||||
Collision.LaserScan(projectile.Center, projectile.velocity, projectile.width * projectile.scale, MaxLaserLength, sampledLengths);
|
||||
float newLaserLength = sampledLengths.Average();
|
||||
|
||||
if (Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
|
||||
return MaxLaserLength;
|
||||
|
||||
return newLaserLength;
|
||||
}
|
||||
|
||||
public override void PostAI()
|
||||
{
|
||||
if (projectile.frameCounter == 0)
|
||||
Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), projectile.Center);
|
||||
|
||||
// Determine frames.
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter % 5f == 4f)
|
||||
projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type];
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
// This should never happen, but just in case-
|
||||
if (projectile.velocity == Vector2.Zero)
|
||||
return false;
|
||||
|
||||
Color beamColor = LaserOverlayColor;
|
||||
Rectangle startFrameArea = LaserBeginTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame);
|
||||
Rectangle middleFrameArea = LaserMiddleTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame);
|
||||
Rectangle endFrameArea = LaserEndTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame);
|
||||
|
||||
// Start texture drawing.
|
||||
Vector2 centerOnLaser = projectile.Center + projectile.velocity * projectile.scale * 116f;
|
||||
spriteBatch.Draw(LaserBeginTexture,
|
||||
centerOnLaser - Main.screenPosition,
|
||||
startFrameArea,
|
||||
beamColor,
|
||||
projectile.rotation,
|
||||
LaserBeginTexture.Size() / 2f,
|
||||
projectile.scale,
|
||||
SpriteEffects.None,
|
||||
0f);
|
||||
|
||||
// Prepare things for body drawing.
|
||||
float laserBodyLength = LaserLength + middleFrameArea.Height;
|
||||
|
||||
// Body drawing.
|
||||
if (laserBodyLength > 0f)
|
||||
{
|
||||
float laserOffset = middleFrameArea.Height * projectile.scale;
|
||||
float incrementalBodyLength = 0f;
|
||||
while (incrementalBodyLength + 1f < laserBodyLength)
|
||||
{
|
||||
centerOnLaser += projectile.velocity * laserOffset;
|
||||
incrementalBodyLength += laserOffset;
|
||||
spriteBatch.Draw(LaserMiddleTexture,
|
||||
centerOnLaser - Main.screenPosition,
|
||||
middleFrameArea,
|
||||
beamColor,
|
||||
projectile.rotation,
|
||||
LaserMiddleTexture.Size() * 0.5f,
|
||||
projectile.scale,
|
||||
SpriteEffects.None,
|
||||
0f);
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 laserEndCenter = centerOnLaser + projectile.velocity * endFrameArea.Height - Main.screenPosition;
|
||||
spriteBatch.Draw(LaserEndTexture,
|
||||
laserEndCenter,
|
||||
endFrameArea,
|
||||
beamColor,
|
||||
projectile.rotation,
|
||||
LaserEndTexture.Size() * 0.5f,
|
||||
projectile.scale,
|
||||
SpriteEffects.None,
|
||||
0f);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@@ -0,0 +1,112 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
public class SeraphimDagger : ModProjectile
|
||||
{
|
||||
public const int SlowdownTime = 45;
|
||||
public const int AimTime = 25;
|
||||
public ref float Time => ref projectile.ai[0];
|
||||
public override void SetStaticDefaults() => DisplayName.SetDefault("Seraphim");
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 50;
|
||||
projectile.height = 50;
|
||||
projectile.friendly = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.timeLeft = 150;
|
||||
projectile.MaxUpdates = 2;
|
||||
projectile.alpha = 0;
|
||||
projectile.tileCollide = false;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = projectile.MaxUpdates * 15;
|
||||
projectile.Calamity().rogue = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
// Initialize rotation.
|
||||
if (projectile.localAI[0] == 0f)
|
||||
{
|
||||
projectile.ai[1] = Main.rand.NextFloat(-0.8f, 0.8f);
|
||||
projectile.localAI[0] = 1f;
|
||||
}
|
||||
|
||||
// Handle fade effects.
|
||||
projectile.Opacity = Utils.InverseLerp(0f, 8f, Time, true) * Utils.InverseLerp(0f, 8f, projectile.timeLeft, true);
|
||||
|
||||
// Very rapidly slow down and spin.
|
||||
if (Time <= SlowdownTime)
|
||||
{
|
||||
float angularVelocityInterpolant = (float)Math.Pow(1f - Utils.InverseLerp(0f, SlowdownTime, Time, true), 2D);
|
||||
float angularVelocity = angularVelocityInterpolant * MathHelper.Pi / 6f;
|
||||
projectile.rotation += angularVelocity;
|
||||
projectile.velocity *= 0.95f;
|
||||
}
|
||||
|
||||
// Aim at nearby targets.
|
||||
else if (Time <= SlowdownTime + AimTime)
|
||||
{
|
||||
if (Time == SlowdownTime + 25f)
|
||||
{
|
||||
Main.PlaySound(SoundID.DD2_WyvernDiveDown, projectile.Center);
|
||||
Main.PlaySound(SoundID.DD2_DarkMageHealImpact, projectile.Center);
|
||||
}
|
||||
|
||||
NPC potentialTarget = projectile.Center.ClosestNPCAt(1600f);
|
||||
float idealRotation = projectile.AngleTo(potentialTarget?.Center ?? projectile.Center - Vector2.UnitY) + MathHelper.PiOver4;
|
||||
projectile.rotation = projectile.rotation.AngleLerp(idealRotation, 0.08f).AngleTowards(idealRotation, 0.1f);
|
||||
projectile.velocity *= 0.9f;
|
||||
|
||||
// And fire.
|
||||
if (Time == SlowdownTime + AimTime)
|
||||
{
|
||||
projectile.rotation = idealRotation;
|
||||
projectile.velocity = (idealRotation - MathHelper.PiOver4).ToRotationVector2() * 14f;
|
||||
}
|
||||
}
|
||||
|
||||
// Accelerate.
|
||||
else if (projectile.velocity.Length() < 28f)
|
||||
projectile.velocity *= 1.045f;
|
||||
|
||||
Time++;
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
Texture2D texture = Main.projectileTexture[projectile.type];
|
||||
Vector2 origin = texture.Size() * 0.5f;
|
||||
Vector2 baseDrawPosition = projectile.Center - Main.screenPosition;
|
||||
|
||||
float endFade = Utils.InverseLerp(0f, 12f, projectile.timeLeft, true);
|
||||
Color mainColor = Color.Goldenrod * projectile.Opacity * endFade * 1.5f;
|
||||
mainColor.A = 74;
|
||||
Color afterimageLightColor = Color.White * endFade;
|
||||
afterimageLightColor.A = 74;
|
||||
|
||||
// Distribute many knives as they dissipate into light.
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
Vector2 drawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 12f).ToRotationVector2() * (1f - projectile.Opacity) * 6f;
|
||||
spriteBatch.Draw(texture, drawPosition, null, afterimageLightColor, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f);
|
||||
}
|
||||
|
||||
// Draw specialized afterimages.
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Vector2 drawPosition = baseDrawPosition - projectile.velocity * i * 0.45f;
|
||||
Color afterimageColor = mainColor * (1f - i / 10f);
|
||||
spriteBatch.Draw(texture, drawPosition, null, afterimageColor, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 770 B |
@@ -0,0 +1,122 @@
|
||||
using CalamityMod.Items.Weapons.Rogue;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
public class SeraphimProjectile : ModProjectile
|
||||
{
|
||||
public const float InitialSpeed = 64f;
|
||||
public const float SlowdownSpeed = 7f;
|
||||
public const int SlowdownTime = 50;
|
||||
public static readonly float SlowdownFactor = (float)Math.Pow(SlowdownSpeed / InitialSpeed, 1f / SlowdownTime);
|
||||
|
||||
public ref float Time => ref projectile.ai[0];
|
||||
|
||||
public override string Texture => "CalamityMod/Items/Weapons/Rogue/Seraphim";
|
||||
|
||||
public override void SetStaticDefaults() => DisplayName.SetDefault("Seraphim");
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 82;
|
||||
projectile.height = 82;
|
||||
projectile.friendly = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.timeLeft = SlowdownTime;
|
||||
projectile.alpha = 0;
|
||||
projectile.tileCollide = false;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 14;
|
||||
projectile.Calamity().rogue = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4;
|
||||
|
||||
// Very rapidly slow down and fade out, transforming into light.
|
||||
if (Time <= SlowdownTime)
|
||||
{
|
||||
projectile.Opacity = (float)Math.Pow(1f - Time / SlowdownTime, 2D);
|
||||
projectile.velocity *= SlowdownFactor;
|
||||
|
||||
int lightDustCount = (int)MathHelper.Lerp(10f, 1f, projectile.Opacity);
|
||||
for (int i = 0; i < lightDustCount; i++)
|
||||
{
|
||||
Vector2 dustSpawnPosition = projectile.Center + Main.rand.NextVector2Unit() * (1f - projectile.Opacity) * 45f;
|
||||
Dust light = Dust.NewDustPerfect(dustSpawnPosition, 267);
|
||||
light.color = Color.Lerp(Color.Gold, Color.White, Main.rand.NextFloat(0.5f, 1f));
|
||||
light.velocity = Main.rand.NextVector2Circular(10f, 10f);
|
||||
light.scale = MathHelper.Lerp(1.3f, 0.8f, projectile.Opacity) * Main.rand.NextFloat(0.8f, 1.2f);
|
||||
light.noGravity = true;
|
||||
}
|
||||
}
|
||||
|
||||
Time++;
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
if (Main.myPlayer != projectile.owner)
|
||||
return;
|
||||
|
||||
// Create a light projectile that explodes into a laserbeam.
|
||||
int damage = projectile.damage;
|
||||
float kb = projectile.knockBack;
|
||||
Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType<SeraphimAngelicLight>(), damage, kb, projectile.owner);
|
||||
|
||||
// As well as a fan of light daggers.
|
||||
NPC potentialTarget = projectile.Center.ClosestNPCAt(1600f);
|
||||
for (int i = 0; i < Seraphim.SplitDaggerCount; i++)
|
||||
{
|
||||
float offsetAngle = MathHelper.Lerp(-0.9f, 0.9f, i / (float)(Seraphim.SplitDaggerCount - 1f));
|
||||
|
||||
// Make the fan point away from nearby targets.
|
||||
if (potentialTarget != null)
|
||||
offsetAngle -= projectile.AngleTo(potentialTarget.Center);
|
||||
|
||||
Vector2 fanVelocity = offsetAngle.ToRotationVector2() * 10f;
|
||||
Projectile.NewProjectile(projectile.Center, fanVelocity, ModContent.ProjectileType<SeraphimDagger>(), damage / 2, kb, projectile.owner, i);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
{
|
||||
projectile.velocity *= 0.4f;
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
Texture2D texture = Main.projectileTexture[projectile.type];
|
||||
Vector2 origin = texture.Size() * 0.5f;
|
||||
Vector2 baseDrawPosition = projectile.Center - Main.screenPosition;
|
||||
|
||||
float endFade = Utils.InverseLerp(0f, 12f, projectile.timeLeft, true);
|
||||
Color mainColor = Color.White * projectile.Opacity * endFade * 1.5f;
|
||||
mainColor.A = (byte)(255 - projectile.alpha);
|
||||
Color afterimageLightColor = Color.White * endFade;
|
||||
afterimageLightColor.A = (byte)(255 - projectile.alpha);
|
||||
|
||||
// Distribute many knives as they dissipate into light.
|
||||
for (int i = 0; i < 18; i++)
|
||||
{
|
||||
Vector2 drawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 18f).ToRotationVector2() * (1f - projectile.Opacity) * 16f;
|
||||
spriteBatch.Draw(texture, drawPosition, null, afterimageLightColor, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f);
|
||||
}
|
||||
|
||||
// Draw specialized afterimages.
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
Vector2 drawPosition = baseDrawPosition - projectile.velocity * i * 0.3f;
|
||||
Color afterimageColor = mainColor * (1f - i / 8f);
|
||||
spriteBatch.Draw(texture, drawPosition, null, afterimageColor, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user