Warp Mechanics
This commit is contained in:
1 parent
87b71d7dd9
commit
3f9f1e9f5c
10 files changed
+553
-45
No files matched your search
@@ -8,7 +8,7 @@ using CalamityMod.Items.Materials;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Magic
|
||||
{
|
||||
public class UnstableCastersGauntlet : ModItem, ILocalizedModType
|
||||
public class UnstableCastersGauntlet : ModItem, ILocalizedModType, IHoldShiftTooltipItem
|
||||
{
|
||||
public static int UseTime = 20;
|
||||
public new string LocalizationCategory => "Items.Weapons.Magic";
|
||||
@@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Magic
|
||||
{
|
||||
Item.width = 62;
|
||||
Item.height = 60;
|
||||
Item.damage = 100;
|
||||
Item.damage = 240;
|
||||
Item.DamageType = DamageClass.Magic;
|
||||
Item.mana = 0;
|
||||
Item.useAnimation = Item.useTime = UseTime;
|
||||
@@ -28,6 +28,7 @@ namespace CalamityMod.Items.Weapons.Magic
|
||||
Item.knockBack = 3f;
|
||||
Item.value = CalamityGlobalItem.RarityRedBuyPrice;
|
||||
Item.rare = ItemRarityID.Red;
|
||||
Item.Calamity().donorItem = true;
|
||||
Item.autoReuse = true;
|
||||
Item.shoot = ModContent.ProjectileType<UnstableCastersGauntletHoldout>();
|
||||
Item.shootSpeed = 15f;
|
||||
|
||||
@@ -953,16 +953,21 @@ UnstableCastersGauntlet: {
|
||||
Tooltip:
|
||||
'''
|
||||
<left> to fire piercing needles
|
||||
<right> to summon 6 sigils, each representing a primordial element
|
||||
<right> to summon a ring of sigils, each representing a primordial element
|
||||
Hold <left> with sigils available to consume random sigils, each unleashing an attack
|
||||
Ordo sigils always land critical strikes and pierce infinitely
|
||||
Perditio sigils pierce and ignore 25 points of enemy defense
|
||||
Ignis sigils inflict Daybroken
|
||||
Aqua sigils inflict Crush Depth
|
||||
Aer sigils boast impeccable knockback
|
||||
Terra sigils split into sharp rocks
|
||||
All actions require sufficient Vis to use
|
||||
Vis is restored over time
|
||||
<right> again while the elemental ring is out to replace all empty slots with [c/DD84E8:Warped] sigils
|
||||
[c/DD84E8:Warped] sigils automatically fire barrages of inaccurate purple blasts
|
||||
All actions require sufficient [c/EADAF5:Vis] to use
|
||||
[c/EADAF5:Vis] is restored over time
|
||||
'''
|
||||
HoldShiftTooltip:
|
||||
'''
|
||||
[c/DBD7CA:Ordo] sigils always land critical strikes and pierce infinitely
|
||||
[c/ABB6D4:Perdito] sigils ignore 25 points of enemy defense
|
||||
[c/E89B8E:Ignis] sigils inflict Daybroken
|
||||
[c/8ECBE8:Aqua] sigils inflict Crush Depth
|
||||
[c/E1E88E:Aer] sigils boast impeccable knockback
|
||||
[c/ACCF9F:Terra] sigils split into sharp rocks
|
||||
'''
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ namespace CalamityMod.Projectiles.Magic
|
||||
SoundEngine.PlaySound(new("CalamityMod/Sounds/Item/OntologicalDespoilerLargeShot") { Volume = 0.5f, PitchVariance = 0.1f }, Projectile.Center);
|
||||
|
||||
Player owner = Main.player[Projectile.owner];
|
||||
|
||||
owner.Calamity().GeneralScreenShakePower = 3f;
|
||||
Vector2 targetDirection = Projectile.Center.DirectionTo(Main.MouseWorld).SafeNormalize(Vector2.UnitX);
|
||||
|
||||
spawnedProjectile = true;
|
||||
|
||||
@@ -6,6 +6,7 @@ using Terraria;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using ReLogic.Content;
|
||||
|
||||
namespace CalamityMod.Projectiles.Magic
|
||||
{
|
||||
@@ -13,6 +14,11 @@ namespace CalamityMod.Projectiles.Magic
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Magic";
|
||||
public ref float FadeoutFlag => ref Projectile.ai[2];
|
||||
private const float StartRadius = 240f;
|
||||
private const float BaseRadius = 150f;
|
||||
private const float GhostFlashDuration = 22f;
|
||||
public ref float RuneTimer => ref Projectile.localAI[2];
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.projFrames[Type] = 4;
|
||||
@@ -31,16 +37,16 @@ namespace CalamityMod.Projectiles.Magic
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
// Culling Logic
|
||||
Player p = Main.player[Projectile.owner];
|
||||
// Culling Logic
|
||||
Player p = Main.player[Projectile.owner];
|
||||
if (p == null || !p.active || p.dead || p.HeldItem.type != ModContent.ItemType<UnstableCastersGauntlet>())
|
||||
{
|
||||
Projectile.Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
// Visuals
|
||||
Projectile.Center = p.MountedCenter + Vector2.UnitY * p.gfxOffY;
|
||||
// Visuals
|
||||
Projectile.Center = p.MountedCenter + Vector2.UnitY * p.gfxOffY;
|
||||
Projectile.rotation += 0.01f;
|
||||
Lighting.AddLight(Projectile.Center, 1f, 1f, 1f);
|
||||
|
||||
@@ -53,8 +59,8 @@ namespace CalamityMod.Projectiles.Magic
|
||||
}
|
||||
}
|
||||
|
||||
// Fading logic
|
||||
if (FadeoutFlag == 1f)
|
||||
// Fading logic
|
||||
if (FadeoutFlag == 1f)
|
||||
{
|
||||
Projectile.alpha += 13;
|
||||
if (Projectile.alpha >= 255)
|
||||
@@ -67,9 +73,11 @@ namespace CalamityMod.Projectiles.Magic
|
||||
Projectile.alpha = Utils.Clamp(Projectile.alpha - 25, 0, 255);
|
||||
}
|
||||
|
||||
RuneTimer++;
|
||||
|
||||
if (Projectile.ai[1] == 0) // spawn flag
|
||||
{
|
||||
|
||||
if (Projectile.ai[1] == 0) // spawn flag
|
||||
{
|
||||
int[] sigilTypes = new int[]
|
||||
{
|
||||
ModContent.ProjectileType<IgnisSigil>(),
|
||||
@@ -79,6 +87,7 @@ namespace CalamityMod.Projectiles.Magic
|
||||
ModContent.ProjectileType<OrdoSigil>(),
|
||||
ModContent.ProjectileType<PerditoSigil>()
|
||||
};
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, sigilTypes[i], Projectile.damage, Projectile.knockBack, Projectile.owner, Projectile.identity, i);
|
||||
@@ -87,22 +96,26 @@ namespace CalamityMod.Projectiles.Magic
|
||||
// Make it not happen again
|
||||
Projectile.ai[1] = 1;
|
||||
}
|
||||
else // Sigils exist
|
||||
{
|
||||
else // Sigils exist
|
||||
{
|
||||
int activeSigilCount = 0;
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
{
|
||||
Projectile proj = Main.projectile[i];
|
||||
if (proj.active && proj.ai[0] == Projectile.identity)
|
||||
if (proj.active && proj.ai[0] == Projectile.identity && proj.owner == Projectile.owner)
|
||||
{
|
||||
// Check if the sigil is not currently fading out
|
||||
if (proj.type == ModContent.ProjectileType<IgnisSigil>() ||
|
||||
proj.type == ModContent.ProjectileType<AquaSigil>() ||
|
||||
proj.type == ModContent.ProjectileType<TerraSigil>() ||
|
||||
proj.type == ModContent.ProjectileType<AerSigil>() ||
|
||||
proj.type == ModContent.ProjectileType<OrdoSigil>() ||
|
||||
proj.type == ModContent.ProjectileType<PerditoSigil>())
|
||||
int projType = proj.type;
|
||||
|
||||
// Check if it's any sigil that occupies a slot
|
||||
if (projType == ModContent.ProjectileType<IgnisSigil>() ||
|
||||
projType == ModContent.ProjectileType<AquaSigil>() ||
|
||||
projType == ModContent.ProjectileType<TerraSigil>() ||
|
||||
projType == ModContent.ProjectileType<AerSigil>() ||
|
||||
projType == ModContent.ProjectileType<OrdoSigil>() ||
|
||||
projType == ModContent.ProjectileType<PerditoSigil>() ||
|
||||
projType == ModContent.ProjectileType<WarpSigil>())
|
||||
{
|
||||
|
||||
if (proj.ai[2] <= 0)
|
||||
{
|
||||
activeSigilCount++;
|
||||
@@ -133,19 +146,74 @@ namespace CalamityMod.Projectiles.Magic
|
||||
Texture2D main = TextureAssets.Projectile[Type].Value;
|
||||
Texture2D smol = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Magic/ThaumRingSmall").Value;
|
||||
Texture2D rune = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Magic/ThaumRune").Value;
|
||||
Asset<Texture2D> ghostTextureAsset = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Magic/ThaumRuneGhost");
|
||||
|
||||
// Modify opacity again so it doesn't override changes to alpha in AI
|
||||
float drawOpacity = 1f - Projectile.alpha / 255f;
|
||||
Main.EntitySpriteDraw(smol, Projectile.Center - Main.screenPosition, null, Color.White * 0.5f * drawOpacity, Projectile.rotation, smol.Size() / 2, Projectile.scale + MathF.Cos(2 * Main.GlobalTimeWrappedHourly + 5) * 0.0027f, SpriteEffects.None);
|
||||
Main.EntitySpriteDraw(main, Projectile.Center - Main.screenPosition, main.Frame(1, 4, 0, Projectile.frame), Color.White * 0.5f * drawOpacity, Projectile.rotation, new Vector2(main.Width / 2, main.Height / 8), Projectile.scale, SpriteEffects.None);
|
||||
|
||||
// -- Normal Runes --
|
||||
for (int i = 0; i < 14; i++)
|
||||
{
|
||||
float runeStartTick = i * RuneDelayTime;
|
||||
|
||||
float t = MathHelper.Clamp((RuneTimer - runeStartTick) / RuneLerpTime, 0f, 1f);
|
||||
float ease = MathHelper.SmoothStep(0f, 1f, t);
|
||||
|
||||
float baseDist = BaseRadius + MathF.Sin(Main.GlobalTimeWrappedHourly * 2) * 10;
|
||||
float lerpedRadius = MathHelper.Lerp(StartRadius, baseDist, ease);
|
||||
|
||||
float angle = MathHelper.TwoPi * i / 14f;
|
||||
Vector2 circleOffset = Vector2.UnitX.RotatedBy(angle) * lerpedRadius;
|
||||
circleOffset = circleOffset.RotatedBy(-Projectile.rotation * 0.6f);
|
||||
Vector2 animatedPos = Projectile.Center + circleOffset;
|
||||
float runeAlpha = ease;
|
||||
|
||||
Main.EntitySpriteDraw(rune, animatedPos - Main.screenPosition, rune.Frame(1, 7, 0, i % 6), Color.White * 0.5f * drawOpacity * runeAlpha, (animatedPos - Projectile.Center).ToRotation() + MathHelper.PiOver2, new Vector2(rune.Width / 2, rune.Height / 14), Projectile.scale, SpriteEffects.None);
|
||||
}
|
||||
|
||||
|
||||
// --- White/Flash layer --
|
||||
// Used in spawn anim for the runes
|
||||
Main.spriteBatch.End();
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix);
|
||||
|
||||
Texture2D ghostTexture = ghostTextureAsset.Value;
|
||||
|
||||
// Ring components
|
||||
Main.EntitySpriteDraw(smol, Projectile.Center - Main.screenPosition, null, Color.White * 0.5f * drawOpacity, Projectile.rotation, smol.Size() / 2, Projectile.scale + MathF.Cos(2 * Main.GlobalTimeWrappedHourly + 5) * 0.0027f, 0);
|
||||
Main.EntitySpriteDraw(main, Projectile.Center - Main.screenPosition, main.Frame(1, 4, 0, Projectile.frame), Color.White * 0.5f * drawOpacity, Projectile.rotation, new Vector2(main.Width / 2, main.Height / 8), Projectile.scale, 0);
|
||||
for (int i = 0; i < 14; i++)
|
||||
{
|
||||
float dist = 150f + MathF.Sin(Main.GlobalTimeWrappedHourly * 2) * 10;
|
||||
Vector2 runePos = Projectile.Center + (Vector2.UnitX.RotatedBy(MathHelper.Lerp(0, MathHelper.TwoPi, i / 14f)) * dist).RotatedBy(-Projectile.rotation * 0.6f);
|
||||
Main.EntitySpriteDraw(rune, runePos - Main.screenPosition, rune.Frame(1, 7, 0, i % 6), Color.White * 0.5f * drawOpacity, runePos.DirectionTo(Projectile.Center).ToRotation() + MathHelper.PiOver2, new Vector2(rune.Width / 2, rune.Height / 14), Projectile.scale, 0);
|
||||
float runeStartTick = i * RuneDelayTime;
|
||||
float t = MathHelper.Clamp((RuneTimer - runeStartTick) / RuneLerpTime, 0f, 1f);
|
||||
float ease = MathHelper.SmoothStep(0f, 1f, t);
|
||||
|
||||
float peakTime = 0.25f;
|
||||
float endTime = 1f;
|
||||
|
||||
float rampUp = Utils.GetLerpValue(0f, peakTime, t, clamped: true);
|
||||
float rampDown = Utils.GetLerpValue(endTime, peakTime, t, clamped: true);
|
||||
|
||||
float ghostOpacity = Math.Min(rampUp, rampDown);
|
||||
|
||||
if (ghostOpacity > 0f)
|
||||
{
|
||||
// Recalculate position (same as solid rune)
|
||||
float baseDist = BaseRadius + MathF.Sin(Main.GlobalTimeWrappedHourly * 2) * 10;
|
||||
float lerpedRadius = MathHelper.Lerp(StartRadius, baseDist, ease);
|
||||
|
||||
float angle = MathHelper.TwoPi * i / 14f;
|
||||
Vector2 circleOffset = Vector2.UnitX.RotatedBy(angle) * lerpedRadius;
|
||||
circleOffset = circleOffset.RotatedBy(-Projectile.rotation * 0.6f);
|
||||
Vector2 animatedPos = Projectile.Center + circleOffset;
|
||||
|
||||
Rectangle runeFrame = ghostTexture.Frame(1, 7, 0, i % 6);
|
||||
Vector2 runeOrigin = new Vector2(runeFrame.Width / 2, runeFrame.Height / 2);
|
||||
|
||||
Main.EntitySpriteDraw(ghostTexture, animatedPos - Main.screenPosition, runeFrame, Color.White * drawOpacity * ghostOpacity * 0.6f, (animatedPos - Projectile.Center).ToRotation() + MathHelper.PiOver2, runeOrigin, Projectile.scale * (1f + ghostOpacity * 0.3f), SpriteEffects.None);
|
||||
}
|
||||
}
|
||||
Main.spriteBatch.End();
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Terraria.ModLoader;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.Audio;
|
||||
|
||||
namespace CalamityMod.Projectiles.Magic
|
||||
{
|
||||
@@ -43,12 +44,12 @@ namespace CalamityMod.Projectiles.Magic
|
||||
|
||||
if (Projectile.localAI[0] >= 35 && !spawnedProjectile)
|
||||
{
|
||||
spawnedProjectile = true;
|
||||
SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/Providence/ProvidenceHolyBlastShoot") { Volume = 0.45f, PitchVariance = 0.1f }, Projectile.Center);
|
||||
|
||||
Player owner = Main.player[Projectile.owner];
|
||||
|
||||
Vector2 targetDirection = Projectile.Center.DirectionTo(Main.MouseWorld).SafeNormalize(Vector2.UnitX);
|
||||
|
||||
spawnedProjectile = true;
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, targetDirection * 32f, ModContent.ProjectileType<TerraSigilLargeRock>(), Projectile.damage * 2, Projectile.knockBack, Projectile.owner);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
@@ -20,8 +20,8 @@ namespace CalamityMod.Projectiles.Magic
|
||||
public ref float shootingTimer => ref Projectile.ai[0];
|
||||
|
||||
private float currentRecoilRotation;
|
||||
private float RecoilRotationAmount = 0.22f;
|
||||
private float RotationResolveSpeed = 0.22f;
|
||||
private float RecoilRotationAmount = 0.24f;
|
||||
private float RotationResolveSpeed = 0.24f;
|
||||
|
||||
// Normal weapon usetime is 20. This is used throughout the AI to make the holdout's components scale with attack speed.
|
||||
public float speedModifier => HeldItem.useTime / 20f;
|
||||
@@ -64,7 +64,8 @@ namespace CalamityMod.Projectiles.Magic
|
||||
proj.type == ModContent.ProjectileType<TerraSigil>() ||
|
||||
proj.type == ModContent.ProjectileType<AerSigil>() ||
|
||||
proj.type == ModContent.ProjectileType<OrdoSigil>() ||
|
||||
proj.type == ModContent.ProjectileType<PerditoSigil>())
|
||||
proj.type == ModContent.ProjectileType<PerditoSigil>() ||
|
||||
proj.type == ModContent.ProjectileType<WarpSigil>())
|
||||
{
|
||||
// Make sure sigil isn't already consumed
|
||||
if (proj.ai[2] <= 0)
|
||||
@@ -83,7 +84,13 @@ namespace CalamityMod.Projectiles.Magic
|
||||
|
||||
// Start fadeout
|
||||
chosenSigil.ai[2] = 1.0f;
|
||||
shootingTimer = 0f;
|
||||
|
||||
// Less delay than normal
|
||||
if (chosenSigil.type == ModContent.ProjectileType<WarpSigil>())
|
||||
shootingTimer = (HeldItem.useTime * 1.65f);
|
||||
else
|
||||
shootingTimer = 0f;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,16 +120,15 @@ namespace CalamityMod.Projectiles.Magic
|
||||
dust.velocity *= 0.5f;
|
||||
dust.fadeIn = 0.5f;
|
||||
dust.scale *= 0.4f;
|
||||
|
||||
|
||||
Lighting.AddLight(GunTipPosition, 0.4f * Color.DarkMagenta.ToVector3());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- NEEDLES --
|
||||
else
|
||||
else if (Owner.altFunctionUse == 0)
|
||||
{
|
||||
int needleFireRate = (int)(12 * speedModifier);
|
||||
if (shootingTimer >= needleFireRate)
|
||||
@@ -157,7 +163,7 @@ namespace CalamityMod.Projectiles.Magic
|
||||
|
||||
|
||||
// -- SIGIL SPAWNING --
|
||||
if (Owner.altFunctionUse == 2 && calPlayer.unstableCastersGauntletVis >= 6f)
|
||||
if (Owner.altFunctionUse == 2 && calPlayer.unstableCastersGauntletVis >= 6f && Owner.ownedProjectileCounts[ModContent.ProjectileType<SigilSet>()] <= 0)
|
||||
{
|
||||
float sigilFireRate = HeldItem.useTime * 4f;
|
||||
|
||||
@@ -172,6 +178,106 @@ namespace CalamityMod.Projectiles.Magic
|
||||
}
|
||||
}
|
||||
|
||||
// Warp Sigil Spawning
|
||||
else if (Owner.altFunctionUse == 2 && Owner.ownedProjectileCounts[ModContent.ProjectileType<SigilSet>()] == 1)
|
||||
{
|
||||
int parentType = ModContent.ProjectileType<SigilSet>();
|
||||
Projectile thisParent = null;
|
||||
|
||||
// Find parent
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (p.type == parentType && p.owner == Projectile.owner)
|
||||
{
|
||||
thisParent = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (thisParent != null)
|
||||
{
|
||||
|
||||
int maxSigils = 6;
|
||||
bool[] slotIsOccupied = new bool[maxSigils];
|
||||
int nonConsumedSigils = 0;
|
||||
|
||||
int[] sigilVariants = new int[]
|
||||
{
|
||||
ModContent.ProjectileType<IgnisSigil>(),
|
||||
ModContent.ProjectileType<AquaSigil>(),
|
||||
ModContent.ProjectileType<TerraSigil>(),
|
||||
ModContent.ProjectileType<AerSigil>(),
|
||||
ModContent.ProjectileType<OrdoSigil>(),
|
||||
ModContent.ProjectileType<PerditoSigil>(),
|
||||
ModContent.ProjectileType<WarpSigil>()
|
||||
};
|
||||
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
{
|
||||
Projectile proj = Main.projectile[i];
|
||||
// Check if projectile is active, belongs to this player, and is a child of this SigilSet
|
||||
if (proj.active && proj.owner == Projectile.owner && proj.ai[0] == thisParent.identity)
|
||||
{
|
||||
// Check if it's a type of sigil
|
||||
bool isASigil = false;
|
||||
foreach (int sigilType in sigilVariants)
|
||||
{
|
||||
if (proj.type == sigilType)
|
||||
{
|
||||
isASigil = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isASigil)
|
||||
{
|
||||
// Use the sigil's index to mark as occupied
|
||||
int sigilIndex = (int)proj.ai[1];
|
||||
if (sigilIndex >= 0 && sigilIndex < maxSigils)
|
||||
{
|
||||
slotIsOccupied[sigilIndex] = true;
|
||||
}
|
||||
|
||||
if (proj.ai[2] <= 0)
|
||||
{
|
||||
nonConsumedSigils++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<int> availableIndices = new List<int>();
|
||||
|
||||
for (int i = 0; i < maxSigils; i++)
|
||||
{
|
||||
if (!slotIsOccupied[i])
|
||||
{
|
||||
availableIndices.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
int emptySlots = availableIndices.Count;
|
||||
|
||||
if (emptySlots > 0 && nonConsumedSigils > 0)
|
||||
{
|
||||
// Check if the player has enough vis
|
||||
if (calPlayer.unstableCastersGauntletVis >= 6f)
|
||||
{
|
||||
calPlayer.unstableCastersGauntletVis -= 6f;
|
||||
|
||||
SoundEngine.PlaySound(SoundID.DD2_EtherianPortalOpen with { Volume = 0.6f }, Projectile.Center);
|
||||
|
||||
// Spawn Warp Sigils for each empty slot
|
||||
foreach (int sigilIndex in availableIndices)
|
||||
{
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), thisParent.Center, Vector2.Zero, ModContent.ProjectileType<WarpSigil>(), Projectile.damage, Projectile.knockBack, Projectile.owner, thisParent.identity, sigilIndex);
|
||||
}
|
||||
|
||||
shootingTimer = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -- RECOIL --
|
||||
ExtraFrontArmRotation = currentRecoilRotation;
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using CalamityMod.Particles;
|
||||
|
||||
namespace CalamityMod.Projectiles.Magic
|
||||
{
|
||||
public class WarpSigil : ModProjectile
|
||||
{
|
||||
private bool spawnedProjectile = false;
|
||||
private bool spawnedIntroParticle = false;
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = Projectile.height = 74;
|
||||
Projectile.friendly = false;
|
||||
Projectile.DamageType = DamageClass.Magic;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Projectile parent = Main.projectile[(int)Projectile.ai[0]];
|
||||
bool parentActive = parent != null && parent.active && parent.type == ModContent.ProjectileType<SigilSet>();
|
||||
|
||||
if (!parentActive && Projectile.ai[2] == 0)
|
||||
{
|
||||
Projectile.Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
int i = (int)Projectile.ai[1];
|
||||
float dist = i % 3 == 0 ? 270f : 280f;
|
||||
float extraRot = i % 3 == 0 ? 0 : i % 3 == 1 ? MathHelper.ToRadians(-3.33f) : MathHelper.ToRadians(3.33f);
|
||||
|
||||
Vector2 sigilPos = parent.Center + (Vector2.UnitX.RotatedBy(MathHelper.Lerp(0, MathHelper.TwoPi, i / 6f)) * dist).RotatedBy(parent.rotation + extraRot);
|
||||
Projectile.Center = sigilPos;
|
||||
|
||||
if (Projectile.ai[2] > 0)
|
||||
{
|
||||
Projectile.localAI[0]++;
|
||||
|
||||
if (Projectile.localAI[0] >= 25 && !spawnedProjectile)
|
||||
{
|
||||
// ai[1] and ai[2] will inherit this sigil's position and timeLeft as its own
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Main.MouseWorld, Vector2.Zero, ModContent.ProjectileType<WarpSigilShotCreator>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, Projectile.whoAmI, Projectile.timeLeft);
|
||||
spawnedProjectile = true;
|
||||
}
|
||||
|
||||
if (Projectile.localAI[0] >= 70)
|
||||
{
|
||||
Projectile.Kill();
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Projectile.rotation = 0;
|
||||
Projectile.alpha = parent.alpha;
|
||||
}
|
||||
|
||||
if (parentActive)
|
||||
{
|
||||
Projectile.timeLeft = parent.timeLeft;
|
||||
}
|
||||
|
||||
if (!spawnedIntroParticle)
|
||||
for (int j = 0; j < 13; j++)
|
||||
{
|
||||
spawnedIntroParticle = true;
|
||||
GeneralParticleHandler.SpawnParticle(new SquishyLightParticle(Projectile.Center, new Vector2(Main.rand.NextFloat(3f, 7f), 0f).RotatedByRandom(MathHelper.TwoPi), Projectile.scale * Main.rand.NextFloat(0.25f, 0.55f), Main.rand.NextBool() ? Color.Magenta : Color.White, Main.rand.Next(10, 19), 1f, 0f, 1f));
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D mainTexture = Terraria.GameContent.TextureAssets.Projectile[Type].Value;
|
||||
Texture2D blankTexture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Magic/BlankSigil").Value;
|
||||
|
||||
float finalScale = Projectile.scale;
|
||||
float alphaOpacity = 1f - (Projectile.alpha / 255f);
|
||||
float maskOpacity = 0f;
|
||||
|
||||
// Apply animation effects if the fade-out is active
|
||||
if (Projectile.ai[2] > 0)
|
||||
{
|
||||
float animationTime = Projectile.localAI[0];
|
||||
|
||||
if (animationTime <= 18)
|
||||
{
|
||||
maskOpacity = Utils.GetLerpValue(0f, 18f, animationTime, clamped: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
maskOpacity = 1f;
|
||||
}
|
||||
|
||||
if (animationTime >= 55)
|
||||
{
|
||||
float scaleFactor = Utils.GetLerpValue(55f, 70f, animationTime, clamped: true);
|
||||
finalScale = MathHelper.Lerp(Projectile.scale, 0f, scaleFactor);
|
||||
alphaOpacity = MathHelper.Lerp(alphaOpacity, 0f, scaleFactor);
|
||||
}
|
||||
}
|
||||
|
||||
Main.EntitySpriteDraw(mainTexture, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor) * alphaOpacity, Projectile.rotation, mainTexture.Size() / 2, finalScale, SpriteEffects.None, 0);
|
||||
|
||||
if (Projectile.ai[2] > 0)
|
||||
{
|
||||
Main.EntitySpriteDraw(blankTexture, Projectile.Center - Main.screenPosition, null, Color.White * maskOpacity, Projectile.rotation, blankTexture.Size() / 2, finalScale, SpriteEffects.None, 0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ID;
|
||||
using Terraria.Audio;
|
||||
using CalamityMod.Graphics.Primitives;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using CalamityMod.Particles;
|
||||
using System;
|
||||
using CalamityMod.Dusts;
|
||||
using Humanizer;
|
||||
|
||||
namespace CalamityMod.Projectiles.Magic
|
||||
{
|
||||
public class WarpSigilShot : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
public ref float FixedOffsetX => ref Projectile.ai[0];
|
||||
public ref float FixedOffsetY => ref Projectile.ai[1];
|
||||
public ref float DamageStatus => ref Projectile.ai[2];
|
||||
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 20;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 2;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 36;
|
||||
Projectile.height = 36;
|
||||
Projectile.friendly = false; // Only deals damage after it has passed over its targeted point
|
||||
Projectile.hostile = false;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.timeLeft = 28;
|
||||
Projectile.DamageType = DamageClass.Magic;
|
||||
Projectile.penetrate = 1;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
// Called here so that the projectile dissapears instantly after the frame it is able to damage something
|
||||
if (DamageStatus == 1 && Projectile.timeLeft <= 6)
|
||||
Projectile.Kill();
|
||||
|
||||
Vector2 fixedOffset = new Vector2(FixedOffsetX, FixedOffsetY);
|
||||
Vector2 targetPosition = Main.MouseWorld + fixedOffset;
|
||||
|
||||
Vector2 direction = targetPosition - Projectile.Center;
|
||||
float distanceToTarget = direction.Length();
|
||||
direction.Normalize();
|
||||
|
||||
float homingStrength = 0f;
|
||||
if (Projectile.timeLeft <= 22)
|
||||
homingStrength = 0.475f;
|
||||
|
||||
float maxSpeed = 60f;
|
||||
|
||||
Projectile.velocity = Vector2.Lerp(Projectile.velocity, direction * maxSpeed, homingStrength * 0.4f);
|
||||
|
||||
Projectile.velocity *= 1.05f;
|
||||
|
||||
if (Projectile.velocity.Length() > maxSpeed)
|
||||
{
|
||||
Projectile.velocity = Vector2.Normalize(Projectile.velocity) * maxSpeed;
|
||||
}
|
||||
|
||||
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
|
||||
Vector2 vectorToTarget = targetPosition - Projectile.Center;
|
||||
|
||||
// Checking for if the projectile is over it's targeted point
|
||||
if (Vector2.Dot(Projectile.velocity, vectorToTarget) < 0f)
|
||||
{
|
||||
DamageStatus = 1;
|
||||
}
|
||||
Projectile.friendly = DamageStatus == 1 ? true : false;
|
||||
|
||||
// Main orb/center of the projectile
|
||||
GeneralParticleHandler.SpawnParticle(new SquishyLightParticle(Projectile.Center, Projectile.velocity, Projectile.scale * 0.425f, Color.Magenta, 2, 1f, 0f, 1f));
|
||||
|
||||
float sine = (float)Math.Sin(Projectile.timeLeft * 0.575f / MathHelper.Pi);
|
||||
Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 16f;
|
||||
if (Main.rand.NextBool(5))
|
||||
{
|
||||
Dust dust3 = Dust.NewDustPerfect(Projectile.Center - offset, ModContent.DustType<LightDust>(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f));
|
||||
dust3.noGravity = true;
|
||||
dust3.scale = Main.rand.NextFloat(0.4f, 0.85f);
|
||||
dust3.color = Color.Violet;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private float WidthFunction(float completionRatio) => MathHelper.Lerp(0f, MathHelper.Lerp(32f, 0f, completionRatio), MathF.Pow(completionRatio, 1f / 2.5f));
|
||||
|
||||
private Color ColorFunction(float completionRatio)
|
||||
{
|
||||
float offsetTime = Main.GlobalTimeWrappedHourly;
|
||||
float fadeOpacity = Utils.GetLerpValue(0.5f, 0f, completionRatio, true) * Projectile.Opacity;
|
||||
Color endColor = Color.Lerp(Color.Magenta, Color.DarkMagenta, (float)Math.Sin(completionRatio * MathHelper.Pi * 1.6f - offsetTime * 4f) * 0.5f + 0.5f);
|
||||
return Color.Lerp(endColor, Color.White, completionRatio) * fadeOpacity;
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/SylvestaffStreak"));
|
||||
PrimitiveRenderer.RenderTrail(Projectile.oldPos, new PrimitiveSettings(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, pixelate: false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 32);
|
||||
|
||||
Texture2D texture = TextureAssets.Projectile[Type].Value;
|
||||
int frameHeight = texture.Height / Main.projFrames[Type];
|
||||
Rectangle sourceRect = new Rectangle(0, frameHeight * Projectile.frame, texture.Width, frameHeight);
|
||||
|
||||
Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, sourceRect, Color.White, Projectile.rotation, sourceRect.Size() * 0.5f, 1f, SpriteEffects.None, 0);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
SoundStyle w = new("CalamityMod/Sounds/Custom/PlagueSounds/PlagueBoom4");
|
||||
SoundEngine.PlaySound(w with { Volume = 0.25f, Pitch = 0f, MaxInstances = 4 }, Projectile.Center);
|
||||
|
||||
Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkMagenta * 2f, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.04f, 14, true, 1f);
|
||||
GeneralParticleHandler.SpawnParticle(blastRing);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center, 173, Main.rand.NextVector2Circular(2f, 2f));
|
||||
dust.noGravity = true;
|
||||
dust.scale = 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Magic
|
||||
{
|
||||
public class WarpSigilShotCreator : ModProjectile
|
||||
{
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public ref float FiringTimer => ref Projectile.ai[0];
|
||||
public ref float ParentIndex => ref Projectile.ai[1];
|
||||
|
||||
private const int DelayBetweenShots = 5;
|
||||
private const float ShotSpeed = 20f;
|
||||
private const float SpawnDistance = 250f;
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 1;
|
||||
Projectile.height = 1;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Magic;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.penetrate = -1;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Projectile parent = Main.projectile[(int)ParentIndex];
|
||||
bool parentActive = parent != null && parent.active && parent.type == ModContent.ProjectileType<WarpSigil>();
|
||||
|
||||
if (!parentActive)
|
||||
{
|
||||
Projectile.Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
Projectile.Center = parent.Center;
|
||||
Projectile.timeLeft = parent.timeLeft;
|
||||
Vector2 targetCenter = Main.MouseWorld;
|
||||
|
||||
FiringTimer++;
|
||||
if (FiringTimer % DelayBetweenShots == 0)
|
||||
{
|
||||
SoundEngine.PlaySound(new("CalamityMod/Sounds/Item/UnstableCastersGauntlet/VisNeedleFire") { Volume = 0.35f, Pitch = -0.3f, PitchVariance = 0.1f }, Projectile.Center);
|
||||
|
||||
Vector2 fixedTargetOffset = Main.rand.NextVector2Circular(36f, 36f);
|
||||
|
||||
float startAngle = Main.rand.NextFloat(MathHelper.TwoPi);
|
||||
Vector2 spawnOffset = startAngle.ToRotationVector2() * SpawnDistance;
|
||||
Vector2 spawnPosition = targetCenter + spawnOffset;
|
||||
|
||||
Vector2 initialTargetLocation = targetCenter + fixedTargetOffset;
|
||||
Vector2 velocity = (initialTargetLocation - spawnPosition).SafeNormalize(Vector2.UnitX) * ShotSpeed;
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType<WarpSigilShot>(), Projectile.damage, Projectile.knockBack, Projectile.owner, ai0: fixedTargetOffset.X, ai1: fixedTargetOffset.Y);
|
||||
}
|
||||
|
||||
}
|
||||
public override bool PreDraw(ref Color lightColor) => false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user