Reworked Stellar Contempt

"Gigafucks whatever the hell it's aimed at"
Stellar Striker now has a similar function to the reworked FPH except that every 5th hit, the hammer will grow and begin charging energy as it does. After charging it then flies towards the last hit enemy where it explodes for huge damage.
This commit is contained in:
Xyk committed 2023-07-18 02:28:23 -07:00
1 parent 3b498f3cb7
commit 1d2fc032a4
11 files changed
+433 -186

No files matched your search

+2
View File
@@ -192,6 +192,8 @@ namespace CalamityMod.CalPlayer
#region Timer and Counter
public int gaelSwipes = 0;
public int PHAThammer = 0;
public int StellarHammer = 0;
public int gaelRageAttackCooldown = 0;
public int hideOfDeusMeleeBoostTimer = 0;
public int nebulaManaNerfCounter = 0;
+5 -5
View File
@@ -8,8 +8,8 @@ namespace CalamityMod.Items.Weapons.Melee
public class StellarContempt : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.Melee";
public static int BaseDamage = 300;
public static float Speed = 18f;
public static int BaseDamage = 800;
public static float Speed = 25f;
public override void SetDefaults()
{
@@ -17,9 +17,9 @@ namespace CalamityMod.Items.Weapons.Melee
Item.height = 74;
Item.DamageType = DamageClass.MeleeNoSpeed;
Item.damage = BaseDamage;
Item.knockBack = 9f;
Item.useTime = 13;
Item.useAnimation = 13;
Item.knockBack = 28f;
Item.useTime = 45;
Item.useAnimation = 45;
Item.autoReuse = true;
Item.noMelee = true;
Item.noUseGraphic = true;
@@ -1016,7 +1016,11 @@ StarnightLance: {
StellarContempt: {
DisplayName: Stellar Contempt
Tooltip: Lunar flares rain down on enemy hits
Tooltip:
'''
Throws a heavy, gravity-affected hammer that will return to you after striking an enemy
Every fifth hit, the hammer will charge with lunar energy and eviscerate whatever it hits
'''
}
StellarStriker: {
@@ -148,6 +148,4 @@ VileClot.DisplayName: Vile Clot
WaterSpear.DisplayName: Water Spear
YharonBulletHellVortex.DisplayName: Bullet Hell Vortex
YharonFireball.DisplayName: Dragon Fireball
YharonFireball2.DisplayName: Dragon Fireball
ThornBallSpike.DisplayName: Thorn Ball Spike
HomingGasBulb.DisplayName: Homing Gas Bulb
YharonFireball2.DisplayName: Dragon Fireball
@@ -349,4 +349,6 @@ SmokingCometYoyo.DisplayName: Smoking Comet
SolarFlareYoyo.DisplayName: Solar Flare
SulphurousGrabberYoyo.DisplayName: Sulphurous Grabber Yoyo
VerdantYoyo.DisplayName: Verdant
YinYoyo.DisplayName: Yin-Yo
YinYoyo.DisplayName: Yin-Yo
FallenPaladinsHammerEcho.DisplayName: Fallen Paladins Hammer Echo
StellarContemptEcho.DisplayName: Stellar Contempt Echo
+5 -5
View File
@@ -18,9 +18,9 @@ namespace CalamityMod.Particles
public float FinalDistanceFromPlayer;
public Color StartColor;
public Color EndColor;
public Vector2 Position;
public Vector2 OverridePosition;
public ManaDrainStreak(Player owner, float thickness, Vector2 startVector, float finalDistance, Color colorStart, Color colorEnd, int lifetime, Vector2 position = default)
public ManaDrainStreak(Player owner, float thickness, Vector2 startVector, float finalDistance, Color colorStart, Color colorEnd, int lifetime, Vector2 overridePosition = default)
{
Owner = owner;
Scale = thickness;
@@ -32,7 +32,7 @@ namespace CalamityMod.Particles
EndColor = colorEnd;
Color = colorStart;
Lifetime = lifetime;
Position = position;
OverridePosition = overridePosition;
}
public override void Update()
@@ -40,8 +40,8 @@ namespace CalamityMod.Particles
if (Owner == null || !Owner.active || Owner.dead)
return;
if (Position == default)
Position = Owner.MountedCenter + Rotation.ToRotationVector2() * MathHelper.Lerp(StartDistanceFromPlayer, FinalDistanceFromPlayer, (float)Math.Pow(LifetimeCompletion, 2));
Vector2 setPosition = OverridePosition != default ? OverridePosition : Owner.MountedCenter;
Position = setPosition + Rotation.ToRotationVector2() * MathHelper.Lerp(StartDistanceFromPlayer, FinalDistanceFromPlayer, (float)Math.Pow(LifetimeCompletion, 2));
Color = Color.Lerp(StartColor, EndColor, LifetimeCompletion);
Lighting.AddLight(Position, Color.ToVector3() * 0.2f);
+195
View File
@@ -0,0 +1,195 @@
using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
namespace CalamityMod.Projectiles.Melee
{
public class StellarContemptEcho : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public static readonly SoundStyle SlamHamSound = new("CalamityMod/Sounds/Item/StellarContemptImpact") { Volume = 1f};
public float rotatehammer = 35f;
public int ColorAlpha = 225;
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 15;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
//This is all copied straight from PwnagehammerEcho with some minor edits.
public override void SetDefaults()
{
Projectile.width = 78;
Projectile.scale = 1.8f;
Projectile.height = 78;
Projectile.aiStyle = 0;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.MeleeNoSpeed;
Projectile.penetrate = 1;
Projectile.tileCollide = false;
Projectile.ignoreWater = true;
Projectile.usesLocalNPCImmunity = true;
}
public override Color? GetAlpha(Color lightColor)
{
return new Color(64, 224, 208, ColorAlpha);
}
public override void AI()
{
ColorAlpha -= 4;
rotatehammer--;
Projectile.rotation += MathHelper.ToRadians(rotatehammer) * Projectile.direction;
Projectile.ai[0] += 1f;
if (Projectile.ai[0] < 42f)
{
Projectile.velocity *= 0.9575f;
Projectile.rotation += MathHelper.ToRadians(Projectile.ai[0] * 0.5f) * Projectile.localAI[0];
}
else if (Projectile.ai[0] < 44f)
{
Projectile.extraUpdates = 1;
if (Projectile.ai[1] < 0f)
{
Projectile.Kill();
return;
}
NPC target = Main.npc[(int)Projectile.ai[1]];
if (!target.CanBeChasedBy(Projectile, false) || !target.active)
Projectile.Kill();
else
{
float velConst = 24f;
Projectile.velocity = new Vector2((target.Center.X - Projectile.Center.X) / velConst, (target.Center.Y - Projectile.Center.Y) / velConst);
Projectile.rotation += MathHelper.ToRadians(48f) * Projectile.localAI[0];
}
}
if (Main.rand.NextBool(2))
{
Vector2 offset = new Vector2(7, 0).RotatedByRandom(MathHelper.ToRadians(360f));
Vector2 velOffset = new Vector2(3, 0).RotatedBy(offset.ToRotation());
Dust dust = Dust.NewDustPerfect(new Vector2(Projectile.position.X, Projectile.position.Y) + offset, DustID.Terragrim, new Vector2(Projectile.velocity.X * 0.2f + velOffset.X, Projectile.velocity.Y * 0.2f + velOffset.Y), 100);
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(2.2f, 3.6f);
}
if (Main.rand.NextBool(6))
{
Vector2 offset = new Vector2(7, 0).RotatedByRandom(MathHelper.ToRadians(360f));
Vector2 velOffset = new Vector2(3, 0).RotatedBy(offset.ToRotation());
Dust dust = Dust.NewDustPerfect(new Vector2(Projectile.position.X, Projectile.position.Y) + offset, DustID.Vortex, new Vector2(Projectile.velocity.X * 0.5f + velOffset.X, Projectile.velocity.Y * 0.5f + velOffset.Y), 100);
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(2.2f, 3.6f);
}
}
public override bool? CanHitNPC(NPC target)
{
if (Projectile.ai[0] <= 42f)
return false;
return null;
}
public override bool CanHitPvp(Player target) => Projectile.ai[0] > 42f;
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
Projectile.localAI[0] = target.whoAmI;
}
public override bool PreKill(int timeLeft)
{
Player player = Main.player[Projectile.owner];
//This is what we call fucking IMPACT.
SoundEngine.PlaySound(SlamHamSound, Projectile.Center);
float numberOfDusts = 156f;
float rotFactor = 360f / numberOfDusts;
for (int i = 0; i < numberOfDusts; i++)
{
float rot = MathHelper.ToRadians(i * rotFactor);
Vector2 offset = new Vector2(30f, 5.8f).RotatedBy(rot);
Vector2 velOffset = new Vector2(20.8f, 10.5f).RotatedBy(rot);
int dust = Dust.NewDust(Projectile.position + offset, Projectile.width, Projectile.height, 229, velOffset.X, velOffset.Y);
Main.dust[dust].noGravity = true;
Main.dust[dust].velocity = velOffset;
Main.dust[dust].scale = 3.8f;
}
for (int i = 0; i < 88; ++i)
{
// Pick a random type of dust
int dustID;
switch (Main.rand.Next(6))
{
case 0:
dustID = 156;
break;
case 1:
case 2:
dustID = 229;
break;
default:
dustID = 229;
break;
}
// Choose a random speed and angle for the dust
float dustSpeed = Main.rand.NextFloat(6.0f, 29.0f);
float angleRandom = 0.09f;
Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation());
dustVel = dustVel.RotatedBy(-angleRandom);
dustVel = dustVel.RotatedByRandom(2.0f * angleRandom);
// Pick a size for the dust particle
float scale = Main.rand.NextFloat(2.2f, 4.8f);
// Actually spawn the dust
int idx = Dust.NewDust(Projectile.Center, 1, 1, dustID, dustVel.X, dustVel.Y, 0, default, scale);
Main.dust[idx].noGravity = true;
Main.dust[idx].position = Projectile.Center;
}
float distance = 272f;
for (int k = 0; k < Main.maxNPCs; k++)
{
NPC npc = Main.npc[k];
Vector2 vec = npc.Center - Projectile.Center;
float distanceTo = (float)Math.Sqrt(vec.X * vec.X + vec.Y * vec.Y);
if (distanceTo < distance && npc.CanBeChasedBy(Projectile, false) && k != Projectile.localAI[0])
{
float alldamage = Projectile.damage * 0.5f;
double damage = npc.StrikeNPC(npc.CalculateHitInfo((int)alldamage, Projectile.velocity.X > 0f ? 1 : -1, true, Projectile.knockBack));
player.addDPS((int)damage);
}
}
return false;
}
public override bool PreDraw(ref Color lightColor)
{
SpriteEffects spriteEffects = SpriteEffects.None;
if (Projectile.spriteDirection == -1)
spriteEffects = SpriteEffects.FlipHorizontally;
Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
Rectangle sourceRectangle = new Rectangle(0, 0, texture.Width + 12, texture.Height + 12);
Vector2 origin = sourceRectangle.Size() / 2f;
for (int i = 0; i < Projectile.oldPos.Length; i++)
{
float rot = MathHelper.ToRadians(22.5f) * Math.Sign(Projectile.velocity.X);
Vector2 drawPos = Projectile.oldPos[i] - Main.screenPosition + origin + new Vector2(0f, Projectile.gfxOffY);
Color color = Projectile.GetAlpha(lightColor) * ((Projectile.oldPos.Length - i) / (float)Projectile.oldPos.Length);
Main.EntitySpriteDraw(texture, drawPos, new Rectangle?(), color, Projectile.rotation - i * rot, origin, Projectile.scale, spriteEffects, 0);
}
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

+217 -171
View File
@@ -6,6 +6,7 @@ using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
using CalamityMod.Particles;
namespace CalamityMod.Projectiles.Melee
{
@@ -13,206 +14,251 @@ namespace CalamityMod.Projectiles.Melee
{
public new string LocalizationCategory => "Projectiles.Melee";
public override string Texture => "CalamityMod/Items/Weapons/Melee/StellarContempt";
private static float RotationIncrement = 0.22f;
private static int Lifetime = 240;
private static float ReboundTime = 26f;
public static readonly SoundStyle UseSound = new("CalamityMod/Sounds/Item/PwnagehammerSound") { Volume = 0.35f, PitchVariance = 0.3f };
public static readonly SoundStyle HomingSound = new("CalamityMod/Sounds/Item/PwnagehammerHoming") { Volume = 0.3f, PitchVariance = 0.3f };
public static readonly SoundStyle RedHamSound = new("CalamityMod/Sounds/Item/StellarContemptClone") { Volume = 1f};
private static float StartDustQuantity = 26f;
public ref int EmpoweredHammer => ref Main.player[Projectile.owner].Calamity().StellarHammer;
public int returnhammer = 0;
public int DustOnce = 1;
public float rotatehammer = 8f;
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8;
ProjectileID.Sets.TrailingMode[Projectile.type] = 1;
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 44;
Projectile.height = 44;
Projectile.width = 62;
Projectile.height = 62;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.MeleeNoSpeed;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.penetrate = -1;
Projectile.extraUpdates = 3;
Projectile.timeLeft = Lifetime;
Projectile.extraUpdates = 1;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 120;
}
public override void AI()
{
DrawOffsetX = -11;
DrawOriginOffsetY = -10;
DrawOriginOffsetX = 0;
//returnhammer determines if the hammer is slowing down after hitting an enemy, or homing in o0n the player.
Player player = Main.player[Projectile.owner];
Projectile.direction = Projectile.spriteDirection = Projectile.velocity.X > 0f ? 1 : -1;
Projectile.rotation += MathHelper.ToRadians(rotatehammer) * Projectile.direction;
if (EmpoweredHammer >= 5)
EmpoweredHammer = 0;
Lighting.AddLight(Projectile.Center, 0.7f, 0.3f, 0.6f);
// The hammer makes sound while flying.
if (Projectile.soundDelay == 0)
if (returnhammer == 0)
{
Projectile.soundDelay = 8;
SoundEngine.PlaySound(SoundID.Item7, Projectile.position);
Projectile.velocity.X *= 0.981f;
Projectile.velocity.Y += 0.226f;
}
if (returnhammer == 1)
{
if (EmpoweredHammer == 4)
{
if (DustOnce == 1)
{
for (int i = 0; i < 20; ++i)
{
// Pick a random type of dust
int dustID;
switch (Main.rand.Next(6))
{
case 0:
dustID = 156;
break;
case 1:
case 2:
dustID = 229;
break;
default:
dustID = 229;
break;
}
// ai[0] stores whether the hammer is returning. If 0, it isn't. If 1, it is.
if (Projectile.ai[0] == 0f)
// Choose a random speed and angle for the dust
float dustSpeed = Main.rand.NextFloat(3.0f, 19.0f);
float angleRandom = 0.09f;
Vector2 dustVel = new Vector2(0.0f, dustSpeed * -1f);
dustVel = dustVel.RotatedBy(-angleRandom);
dustVel = dustVel.RotatedByRandom(2.0f * angleRandom);
// Pick a size for the dust particle
float scale = Main.rand.NextFloat(1.7f, 3.8f);
// Actually spawn the dust
int idx = Dust.NewDust(Projectile.Center, 1, 1, dustID, dustVel.X, dustVel.Y, 0, default, scale);
Main.dust[idx].noGravity = true;
Main.dust[idx].position = Projectile.Center;
}
DustOnce = 0;
}
Projectile.velocity.X *= 0.281f;
Projectile.velocity.Y -= 0.8f;
rotatehammer++;
if (Projectile.velocity.Y < -18f)
{
returnhammer = 3;
}
}
else
{
Projectile.velocity.Y *= 0.896f;
Projectile.velocity.X *= 0.811f;
if (Projectile.velocity.X > -1.05f && Projectile.velocity.X < 1.05f & Projectile.velocity.Y > -1.05f && Projectile.velocity.Y < 1.05f)
returnhammer = 2;
}
}
if (returnhammer == 2)
{
Projectile.extraUpdates = 2;
float returnSpeed = StellarContempt.Speed;
float acceleration = 1.1f;
Player owner = Main.player[Projectile.owner];
Vector2 playerCenter = owner.Center;
float xDist = playerCenter.X - Projectile.Center.X;
float yDist = playerCenter.Y - Projectile.Center.Y;
float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist);
dist = returnSpeed / dist;
xDist *= dist;
yDist *= dist;
if (Projectile.velocity.X < xDist)
{
Projectile.velocity.X = Projectile.velocity.X + acceleration;
if (Projectile.velocity.X < 0f && xDist > 0f)
Projectile.velocity.X += acceleration;
}
else if (Projectile.velocity.X > xDist)
{
Projectile.velocity.X = Projectile.velocity.X - acceleration;
if (Projectile.velocity.X > 0f && xDist < 0f)
Projectile.velocity.X -= acceleration;
}
if (Projectile.velocity.Y < yDist)
{
Projectile.velocity.Y = Projectile.velocity.Y + acceleration;
if (Projectile.velocity.Y < 0f && yDist > 0f)
Projectile.velocity.Y += acceleration;
}
else if (Projectile.velocity.Y > yDist)
{
Projectile.velocity.Y = Projectile.velocity.Y - acceleration;
if (Projectile.velocity.Y > 0f && yDist < 0f)
Projectile.velocity.Y -= acceleration;
}
// Delete the projectile if it touches its owner, increase counter to the big hammer, and spawn a dustsplosion on the player that scales with how close they are to getting a big hammer.
if (Main.myPlayer == Projectile.owner)
{
if (Projectile.Hitbox.Intersects(player.Hitbox))
{
EmpoweredHammer++;
SoundEngine.PlaySound(SoundID.DD2_BetsysWrathShot with { Volume = 0.4f }, Projectile.Center);
for (int i = 0; i < 30; i++)
{
Dust fire = Dust.NewDustPerfect(Projectile.Center, 156);
fire.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(0.8f) * new Vector2(4f, 1.25f) * Main.rand.NextFloat(0.9f, 1f);
fire.velocity = fire.velocity.RotatedBy(Projectile.rotation - MathHelper.PiOver2);
fire.velocity += Projectile.velocity * (EmpoweredHammer * 0.04f);
fire.noGravity = true;
fire.scale = Main.rand.NextFloat(0.2f, 0.6f) * EmpoweredHammer;
fire = Dust.CloneDust(fire);
fire.velocity = Main.rand.NextVector2Circular(3f, 3f);
fire.velocity += Projectile.velocity * (EmpoweredHammer * 0.04f);
}
Projectile.Kill();
}
}
}
if (returnhammer == 3)
{
Projectile.ai[1] += 1f;
if (Projectile.ai[1] >= ReboundTime)
{
Projectile.ai[0] = 1f;
Projectile.ai[1] = 0f;
Projectile.netUpdate = true;
}
}
else
{
Projectile.tileCollide = false;
float returnSpeed = StellarContempt.Speed;
float acceleration = 3.2f;
Player owner = Main.player[Projectile.owner];
// Delete the hammer if it's excessively far away.
Vector2 playerCenter = owner.Center;
float xDist = playerCenter.X - Projectile.Center.X;
float yDist = playerCenter.Y - Projectile.Center.Y;
float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist);
if (dist > 3000f)
Projectile.Kill();
dist = returnSpeed / dist;
xDist *= dist;
yDist *= dist;
// Home back in on the player.
if (Projectile.velocity.X < xDist)
{
Projectile.velocity.X = Projectile.velocity.X + acceleration;
if (Projectile.velocity.X < 0f && xDist > 0f)
Projectile.velocity.X += acceleration;
}
else if (Projectile.velocity.X > xDist)
{
Projectile.velocity.X = Projectile.velocity.X - acceleration;
if (Projectile.velocity.X > 0f && xDist < 0f)
Projectile.velocity.X -= acceleration;
}
if (Projectile.velocity.Y < yDist)
{
Projectile.velocity.Y = Projectile.velocity.Y + acceleration;
if (Projectile.velocity.Y < 0f && yDist > 0f)
Projectile.velocity.Y += acceleration;
}
else if (Projectile.velocity.Y > yDist)
{
Projectile.velocity.Y = Projectile.velocity.Y - acceleration;
if (Projectile.velocity.Y > 0f && yDist < 0f)
Projectile.velocity.Y -= acceleration;
}
// Delete the projectile if it touches its owner.
if (Main.myPlayer == Projectile.owner)
if (Projectile.Hitbox.Intersects(owner.Hitbox))
if (Projectile.velocity.Y < 0f)
{
Particle streak = new ManaDrainStreak(player, Main.rand.NextFloat(0.9f, 1.5f), Main.rand.NextVector2CircularEdge(2f, 2f) * Main.rand.NextFloat(85f, 335f), Main.rand.NextFloat(30f, 44f), Color.PaleTurquoise, Color.Turquoise, Main.rand.Next(15, 30), Projectile.Center);
GeneralParticleHandler.SpawnParticle(streak);
Projectile.velocity.Y += 0.6f;
Projectile.scale += 0.03f;
}
else
{
Projectile.velocity *= 0f;
SoundEngine.PlaySound(RedHamSound, Projectile.Center);
int hammer = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity, ModContent.ProjectileType<StellarContemptEcho>(), Projectile.damage * 5, Projectile.knockBack * 1.5f, Projectile.owner, 0f, Projectile.ai[1]);
Main.projectile[hammer].localAI[0] = Math.Sign(Projectile.velocity.X);
Main.projectile[hammer].netUpdate = true;
EmpoweredHammer = 0;
Projectile.Kill();
}
}
//Spawn dust as the hammer travels.
if (Main.rand.NextBool(2))
{
Vector2 offset = new Vector2(12, 0).RotatedByRandom(MathHelper.ToRadians(360f));
Vector2 velOffset = new Vector2(4, 0).RotatedBy(offset.ToRotation());
Dust dust = Dust.NewDustPerfect(new Vector2(Projectile.Center.X, Projectile.Center.Y) + offset, DustID.UltraBrightTorch, new Vector2(Projectile.velocity.X * 0.3f + velOffset.X, Projectile.velocity.Y * 0.3f + velOffset.Y), 100);
dust.noGravity = true;
}
// Rotate the hammer as it flies.
Projectile.rotation += RotationIncrement;
if (Main.rand.NextBool(6))
{
Vector2 offset = new Vector2(12, 0).RotatedByRandom(MathHelper.ToRadians(360f));
Vector2 velOffset = new Vector2(4, 0).RotatedBy(offset.ToRotation());
Dust dust = Dust.NewDustPerfect(new Vector2(Projectile.Center.X, Projectile.Center.Y) + offset, DustID.UltraBrightTorch, new Vector2(Projectile.velocity.X * 0.2f + velOffset.X, Projectile.velocity.Y * 0.2f + velOffset.Y), 100);
dust.noGravity = true;
}
}
// On hit play GONG and spawn dust.
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
Player player = Main.player[Projectile.owner];
if (returnhammer == 0)
{
SoundEngine.PlaySound(UseSound, Projectile.Center);
if (EmpoweredHammer == 4)
{
Projectile.velocity.Y *= 0f;
Projectile.velocity.X *= 0f;
}
returnhammer = 1;
}
float numberOfDusts = 40f;
float rotFactor = 360f / numberOfDusts;
for (int i = 0; i < numberOfDusts; i++)
{
float rot = MathHelper.ToRadians(i * rotFactor);
Vector2 offset = new Vector2(4.8f, 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 4.1f));
Vector2 velOffset = new Vector2(4f, 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 4.1f));
Dust dust = Dust.NewDustPerfect(Projectile.position + offset, 229, new Vector2(velOffset.X, velOffset.Y));
dust.noGravity = true;
dust.velocity = velOffset;
dust.scale = Main.rand.NextFloat(1.5f, 3.2f);
}
SoundEngine.PlaySound(SoundID.Item14 with { Volume = 0.22f }, Projectile.Center);
Projectile.ai[1] = target.whoAmI;
}
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
{
Projectile.damage = (int)(Projectile.damage * 0.9f);
if (Projectile.damage < 1)
Projectile.damage = 1;
}
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
return false;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
// Some dust gets produced on impact.
int dustCount = Main.rand.Next(20, 24);
int dustRadius = 6;
Vector2 corner = new Vector2(target.Center.X - dustRadius, target.Center.Y - dustRadius);
for (int i = 0; i < dustCount; ++i)
{
int dustType = 229;
float scale = 0.8f + Main.rand.NextFloat(1.1f);
int idx = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, dustType);
Main.dust[idx].noGravity = true;
Main.dust[idx].velocity *= 3f;
Main.dust[idx].scale = scale;
}
// Applies Nightwither on contact at night.
if (!Main.dayTime)
target.AddBuff(ModContent.BuffType<Nightwither>(), 240);
SpawnFlares(target.Center, target.width, target.height);
}
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
// Some dust gets produced on impact.
int dustCount = Main.rand.Next(20, 24);
int dustRadius = 6;
Vector2 corner = new Vector2(target.Center.X - dustRadius, target.Center.Y - dustRadius);
for (int i = 0; i < dustCount; ++i)
{
int dustType = 229;
float scale = 0.8f + Main.rand.NextFloat(1.1f);
int idx = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, dustType);
Main.dust[idx].noGravity = true;
Main.dust[idx].velocity *= 3f;
Main.dust[idx].scale = scale;
}
// Applies Nightwither on contact at night.
if (!Main.dayTime)
target.AddBuff(ModContent.BuffType<Nightwither>(), 240);
SpawnFlares(target.Center, target.width, target.height);
}
private void SpawnFlares(Vector2 targetPos, int width, int height)
{
// Play the Lunar Flare sound centered on the user, not the target (consistent with Lunar Flare and Stellar Striker)
Player user = Main.player[Projectile.owner];
SoundEngine.PlaySound(SoundID.Item88, Projectile.position);
Projectile.netUpdate = true;
int numFlares = 2;
int flareDamage = (int)(0.3f * Projectile.damage);
float flareKB = 4f;
for (int i = 0; i < numFlares; ++i)
{
float flareSpeed = Main.rand.NextFloat(8f, 11f);
// Flares never come from straight up, there is always at least an 80 pixel horizontal offset
float xDist = Main.rand.NextFloat(80f, 320f) * (Main.rand.NextBool() ? -1f : 1f);
float yDist = Main.rand.NextFloat(1200f, 1440f);
Vector2 startPoint = targetPos + new Vector2(xDist, -yDist);
// The flare is somewhat inaccurate based on the size of the target.
float xVariance = width / 4f;
if (xVariance < 8f)
xVariance = 8f;
float yVariance = height / 4f;
if (yVariance < 8f)
yVariance = 8f;
float xOffset = Main.rand.NextFloat(-xVariance, xVariance);
float yOffset = Main.rand.NextFloat(-yVariance, yVariance);
Vector2 offsetTarget = targetPos + new Vector2(xOffset, yOffset);
// Finalize the velocity vector and make sure it's going at the right speed.
Vector2 velocity = offsetTarget - startPoint;
velocity.Normalize();
velocity *= flareSpeed;
float AI1 = Main.rand.Next(3);
if (Projectile.owner == Main.myPlayer)
{
int proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), startPoint, velocity, ProjectileID.LunarFlare, flareDamage, flareKB, Main.myPlayer, 0f, AI1);
if (proj.WithinBounds(Main.maxProjectiles))
Main.projectile[proj].DamageType = DamageClass.MeleeNoSpeed;
}
}
}
}
}
Binary file not shown.
Binary file not shown.