Code Cleanup
This commit is contained in:
1 parent
7a2385b0f0
commit
1750373fbd
2 files changed
+51
-51
No files matched your search
@@ -1673,7 +1673,7 @@ namespace CalamityMod.CalPlayer
|
||||
if (numOfEnergy < energyCap)
|
||||
{
|
||||
int energyDamage = (int)Player.GetBestClassDamage().ApplyTo(22);
|
||||
Projectile energy = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), Player.Center, (Vector2.One * 4).RotatedByRandom(Math.PI), ModContent.ProjectileType<AmuletEnergy>(), energyDamage, 0f, Player.whoAmI, 0, numOfEnergy);
|
||||
Projectile energy = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), Player.Center, (Vector2.One * 4).RotatedByRandom(MathHelper.TwoPi), ModContent.ProjectileType<AmuletEnergy>(), energyDamage, 0f, Player.whoAmI, 0, numOfEnergy);
|
||||
if (numOfEnergy + 1 == energyCap && Player.Calamity().sSpiritAmuletVisual)
|
||||
{
|
||||
SoundStyle transform = new("CalamityMod/Sounds/Item/WaterSplash1");
|
||||
@@ -1681,7 +1681,7 @@ namespace CalamityMod.CalPlayer
|
||||
|
||||
for (int i = 0; i <= 14; i++)
|
||||
{
|
||||
Vector2 vel = (Vector2.One * 5).RotatedByRandom(Math.PI) * Main.rand.NextFloat(0.4f, 1.2f);
|
||||
Vector2 vel = (Vector2.One * 5).RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(0.4f, 1.2f);
|
||||
|
||||
Dust dust2 = Dust.NewDustPerfect(Player.Center, ModContent.DustType<LightDust>(), vel);
|
||||
dust2.scale = Main.rand.NextFloat(0.8f, 1.4f);
|
||||
@@ -1786,16 +1786,16 @@ namespace CalamityMod.CalPlayer
|
||||
{
|
||||
int energyDamage = (int)Player.GetBestClassDamage().ApplyTo(400);
|
||||
int energyType = (numOfEnergy % 3);
|
||||
Projectile energy = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), Player.Center, (Vector2.One * 4).RotatedByRandom(Math.PI), ModContent.ProjectileType<DiamondOfTheDeepProjectile>(), energyDamage, 0f, Player.whoAmI, 0, numOfEnergy);
|
||||
Projectile energy = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), Player.Center, (Vector2.One * 4).RotatedByRandom(MathHelper.TwoPi), ModContent.ProjectileType<DiamondOfTheDeepProjectile>(), energyDamage, 0f, Player.whoAmI, 0, numOfEnergy);
|
||||
energy.localAI[2] = energyType;
|
||||
if (numOfEnergy + 1 == energyCap && Player.Calamity().dOfTheDeepVisual)
|
||||
{
|
||||
SoundStyle transform = new("CalamityMod/Sounds/Item/WaterSplash1");
|
||||
SoundEngine.PlaySound(transform with { Volume = 0.25f, Pitch = 0.9f, MaxInstances = -1 }, Player.Center);
|
||||
SoundStyle max = new("CalamityMod/Sounds/Item/WaterSplash1");
|
||||
SoundEngine.PlaySound(max with { Volume = 0.35f, Pitch = 0.8f, MaxInstances = -1 }, Player.Center);
|
||||
|
||||
for (int i = 0; i <= 14; i++)
|
||||
{
|
||||
Vector2 vel = (Vector2.One * 5).RotatedByRandom(Math.PI) * Main.rand.NextFloat(0.4f, 1.2f);
|
||||
Vector2 vel = (Vector2.One * 5).RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(0.4f, 1.2f);
|
||||
|
||||
Dust dust2 = Dust.NewDustPerfect(Player.Center, ModContent.DustType<LightDust>(), vel);
|
||||
dust2.scale = Main.rand.NextFloat(0.8f, 1.4f);
|
||||
|
||||
@@ -3,12 +3,9 @@ using System.Collections.Generic;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles.Summon;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MonoMod.Core.Platforms;
|
||||
using ReLogic.Content;
|
||||
using ReLogic.Utilities;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
@@ -21,7 +18,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
public new string LocalizationCategory => "Projectiles.Typeless";
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
public Color bColor = Color.White;
|
||||
public Color bColor = Color.White; // Shifting color, used for most effects
|
||||
public Color color1 = Color.White;
|
||||
public Color color2 = Color.White;
|
||||
public bool canDamage = false;
|
||||
@@ -30,10 +27,8 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
public ref float energyNumber => ref Projectile.ai[1]; // The number assigned to this energy, ranging from 1 to the max number of projectiles
|
||||
public bool idle => Projectile.ai[2] == 0; // Floating around the player
|
||||
public bool healing = false; // If the projectiles should heal the player. If false they will attack
|
||||
public SlotId soundSlot;
|
||||
public NPC targeted;
|
||||
public int hitCooldown = 0;
|
||||
public bool specialRot = false;
|
||||
public NPC targeted; // Chosen target to home into
|
||||
public int hitCooldown = 0; // Only for VOID, time after hit that it turns around before another hit
|
||||
public ref float projType => ref Projectile.localAI[2];
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
@@ -60,6 +55,8 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
Vector2 velocity = Projectile.velocity;
|
||||
int startTime = (projType == 0 ? 70 : projType == 1 ? 140 : 210) + 15; // Time after launch when it will begin attacking/healing
|
||||
int endTime = 320; // Time after launch when it's movement code reaches it's cap on strength
|
||||
|
||||
#region Color Shifting
|
||||
if (time == 0 && idle)
|
||||
{
|
||||
switch (projType) // 0 = gravel/vines, 1 = hadal/hydrothermic, 2 = void/lumenyl
|
||||
@@ -96,6 +93,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
Color currentColor = eColors[colorIndex];
|
||||
Color nextColor = eColors[(colorIndex + 1) % eColors.Count];
|
||||
bColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f);
|
||||
#endregion
|
||||
|
||||
if (idle || time < startTime) // If not attacking/healing keep it alive
|
||||
Projectile.timeLeft++;
|
||||
@@ -114,9 +112,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
// Emit some light
|
||||
Lighting.AddLight(Projectile.Center, bColor.ToVector3() * 1.5f);
|
||||
|
||||
if (SoundEngine.TryGetActiveSound(soundSlot, out var sound) && sound.IsPlaying)
|
||||
sound.Position = Projectile.Center;
|
||||
|
||||
#region Dust Trails
|
||||
float velLerp = Utils.GetLerpValue(-1.5f, 3f, Projectile.velocity.Length(), true);
|
||||
if (projType == 0 && visuals)
|
||||
{
|
||||
@@ -158,7 +154,8 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
c.fadeIn = 2.3f;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
if (idle) // Following Ai
|
||||
{
|
||||
if (time == 0 && visuals) // On spawn fx
|
||||
@@ -208,7 +205,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
}
|
||||
if (healing)
|
||||
startTime = 100;
|
||||
if (time <= startTime)
|
||||
if (time <= startTime) // Get into position before the attack/heal
|
||||
{
|
||||
float timeLerp = Utils.GetLerpValue(0, startTime * 0.5f, time, true);
|
||||
int distFromPlayer = (int)(160 + (healing ? 240 * Utils.GetLerpValue(0, startTime * 0.8f, time, true) : 0));
|
||||
@@ -233,7 +230,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
}
|
||||
}
|
||||
|
||||
if (healing) // I wonder what this does :clueless:
|
||||
if (healing) // Heal/Buff player (only occurs below 50% HP)
|
||||
{
|
||||
if (time > startTime)
|
||||
{
|
||||
@@ -276,7 +273,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
{
|
||||
if (time > startTime)
|
||||
{
|
||||
if (canDamage == false)
|
||||
if (canDamage == false) // Effects for the moment they begin attacking
|
||||
{
|
||||
if (visuals)
|
||||
{
|
||||
@@ -360,7 +357,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
{
|
||||
if (hitCooldown > 0)
|
||||
hitCooldown--;
|
||||
float timeLerp = Utils.GetLerpValue(400, 800, Projectile.timeLeft, true);
|
||||
float timeLerp = Utils.GetLerpValue(400, 800, Projectile.timeLeft, true); // While a target is active, lifetime goes up, which increases homing power
|
||||
if (targeted == null && hitCooldown == 0)
|
||||
{
|
||||
CalamityUtils.HomeInOnSelectedNPC(Projectile, Owner.Calamity().mouseWorld.ClosestNPCAt(2300), true, 0.5f, 10, 0.99f, accelerate: true);
|
||||
@@ -382,6 +379,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
}
|
||||
}
|
||||
|
||||
// The main particle trail
|
||||
float squash = Utils.GetLerpValue(1, 3, Projectile.velocity.Length(), true);
|
||||
float targetDist = Vector2.Distance(Owner.Center, Projectile.Center);
|
||||
if (squash > 0.15f && visuals && targetDist < 1400)
|
||||
@@ -398,10 +396,6 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
}
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
|
||||
{
|
||||
Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center) - Vector2.UnitY;
|
||||
float launchPower = 10f;
|
||||
target.MoveNPC(launchVel, launchPower, true);
|
||||
|
||||
if (projType == 0)
|
||||
{
|
||||
if (visuals)
|
||||
@@ -432,28 +426,36 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
int debuffTime = 240;
|
||||
target.AddBuff(debuff, debuffTime);
|
||||
|
||||
Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType<BasicBurstExclusive>(), Projectile.damage, -5, Projectile.owner, blastSize, minMultiplier, hitsToMinMult);
|
||||
blast.timeLeft = 3;
|
||||
Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType<BasicBurstExclusive>(), Projectile.damage, -11, Projectile.owner, blastSize, minMultiplier, hitsToMinMult);
|
||||
blast.timeLeft = 14;
|
||||
blast.DamageType = Projectile.DamageType;
|
||||
blast.localAI[0] = target.whoAmI;
|
||||
blast.localAI[1] = debuff;
|
||||
blast.localAI[2] = debuffTime;
|
||||
Projectile.Kill();
|
||||
}
|
||||
else if (visuals)
|
||||
else
|
||||
{
|
||||
for (int i = 0; i <= Math.Max(2, 8 - Projectile.numHits); i++)
|
||||
{
|
||||
float variance = Main.rand.NextFloat(-0.3f, 0.3f);
|
||||
Vector2 vel = (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 24).RotatedBy(variance) * Main.rand.NextFloat(0.3f, 1f) * (1 - Math.Abs(variance));
|
||||
float scale = (Main.rand.NextFloat(1.5f, 1.7f) - Math.Abs(variance)) * 0.35f;
|
||||
// HADAL and VOID have knockback, GRAVEL has it's knockback on the explosion
|
||||
Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center) - Vector2.UnitY;
|
||||
float launchPower = 7f;
|
||||
target.MoveNPC(launchVel, launchPower, false);
|
||||
|
||||
Dust dust2 = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType<SquashDust>(), vel);
|
||||
dust2.scale = scale * 5;
|
||||
dust2.noGravity = true;
|
||||
dust2.color = bColor;
|
||||
dust2.noLightEmittence = true;
|
||||
dust2.fadeIn = 1.5f;
|
||||
if (visuals)
|
||||
{
|
||||
for (int i = 0; i <= Math.Max(2, 8 - Projectile.numHits); i++)
|
||||
{
|
||||
float variance = Main.rand.NextFloat(-0.3f, 0.3f);
|
||||
Vector2 vel = (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 24).RotatedBy(variance) * Main.rand.NextFloat(0.3f, 1f) * (1 - Math.Abs(variance));
|
||||
float scale = (Main.rand.NextFloat(1.5f, 1.7f) - Math.Abs(variance)) * 0.35f;
|
||||
|
||||
Dust dust2 = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType<SquashDust>(), vel);
|
||||
dust2.scale = scale * 5;
|
||||
dust2.noGravity = true;
|
||||
dust2.color = bColor;
|
||||
dust2.noLightEmittence = true;
|
||||
dust2.fadeIn = 1.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (projType == 1)
|
||||
@@ -464,7 +466,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
SoundEngine.PlaySound(s with { Volume = 0.5f, Pitch = (-0.3f + Projectile.numHits * 0.1f), MaxInstances = 6 }, Projectile.Center);
|
||||
}
|
||||
|
||||
target.AddBuff(BuffID.OnFire3, 300);
|
||||
target.AddBuff(BuffID.OnFire3, 300); // Should be replaced with "Steamscorched" or whatever the scoria debuff will be
|
||||
float minMult = 0.25f;
|
||||
int hitsToMinMult = 10;
|
||||
float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true);
|
||||
@@ -480,11 +482,11 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
}
|
||||
|
||||
Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 7;
|
||||
target.AddBuff(ModContent.BuffType<HadopelagicPressure>(), 30);
|
||||
target.AddBuff(ModContent.BuffType<HadopelagicPressure>(), 30); // Very stong debuff need very short time
|
||||
targeted = target;
|
||||
hitCooldown = 140;
|
||||
Projectile.timeLeft = 600;
|
||||
Projectile.extraUpdates += 3;
|
||||
Projectile.extraUpdates += 3; // Get faster on each hit
|
||||
if (Projectile.numHits >= 5)
|
||||
Projectile.Kill();
|
||||
}
|
||||
@@ -499,11 +501,8 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
Vector2 vel = (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 4).RotatedBy(variance) * Main.rand.NextFloat(0.3f, 1f) * (1 - Math.Abs(variance)) * 4;
|
||||
float scale = (Main.rand.NextFloat(1.5f, 1.7f) - Math.Abs(variance)) * 0.35f;
|
||||
|
||||
Particle sparks = new CustomSpark(Projectile.Center + vel, vel, "CalamityMod/Particles/BloomCircle", false, Main.rand.Next(13, 16 + 1), scale, bColor * 0.7f, new Vector2(1f, 1), true, true, 0, false, shrinkSpeed: 0.25f);
|
||||
GeneralParticleHandler.SpawnParticle(sparks);
|
||||
|
||||
Dust dust2 = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType<LightDust>(), vel);
|
||||
dust2.scale = scale * 3;
|
||||
dust2.scale = scale * 2;
|
||||
dust2.noGravity = false;
|
||||
dust2.color = bColor;
|
||||
dust2.noLight = true;
|
||||
@@ -537,6 +536,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
}
|
||||
}
|
||||
|
||||
// The main "glowy orb" part of the projectile
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
Color orbColor = Color.Lerp(bColor, color2, (i + 1) / 6) with { A = 0 } * 0.4f;
|
||||
@@ -545,7 +545,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
}
|
||||
|
||||
float velLerp = Utils.GetLerpValue(0.5f, 3f, Projectile.velocity.Length(), true);
|
||||
if (projType == 0 && visuals)
|
||||
if (projType == 0 && visuals) // GRAVEL circle
|
||||
{
|
||||
Asset<Texture2D> ring = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomRing");
|
||||
int orbs = 9;
|
||||
@@ -567,7 +567,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
for (int i = 0; i < 3; i++)
|
||||
Main.EntitySpriteDraw(ring.Value, Projectile.Center - Main.screenPosition, null, bColor with { A = 0 } * 0.9f * velLerp, Projectile.rotation, ring.Size() * 0.5f, 0.2f * velLerp * Projectile.scale + (0.15f * Math.Abs(sine)) + 0.02f * i, SpriteEffects.None);
|
||||
}
|
||||
if (projType == 1 && visuals)
|
||||
if (projType == 1 && visuals) // HALAD spires
|
||||
{
|
||||
int orbs = 9;
|
||||
for (int i = 0; i < orbs; i++)
|
||||
@@ -587,7 +587,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
Main.EntitySpriteDraw(block.Value, placement - Main.screenPosition, null, orbColor, Utils.DirectionTo(placement, Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 65f).ToRotation() + MathHelper.PiOver2, block.Size() * 0.5f, scale, outer ? SpriteEffects.FlipHorizontally : SpriteEffects.None);
|
||||
}
|
||||
}
|
||||
if (projType == 2 && visuals)
|
||||
if (projType == 2 && visuals) // VOID shards
|
||||
{
|
||||
float scalingValue = Main.GlobalTimeWrappedHourly * (90 + Projectile.numHits * 55);
|
||||
int orbs = 8;
|
||||
@@ -617,7 +617,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
{
|
||||
if (!target.CanBeChasedBy())
|
||||
return false;
|
||||
if (projType == 2)
|
||||
if (projType == 2) // VOID has multihit, so it needs extra checks. Can't have it inflicting post ML debuffs and piercing
|
||||
{
|
||||
if (hitCooldown > 0 || (targeted != null && target != targeted))
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user