Shard of Antumbra

This commit is contained in:
Xyk authored and Cameron Ewell committed 2024-06-30 02:48:37 +02:00
1 parent 919fabac2a
commit 19fec68d74
19 files changed
+447 -260

No files matched your search

+13
View File
@@ -40,6 +40,7 @@ namespace CalamityMod.Items.Accessories.Wings
if (player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual)
{
Vector2 spawnPos = player.Center + new Vector2(-25 * player.direction, 0) + Main.rand.NextVector2Circular(20, 20);
Vector2 spawnPos2 = player.Center + new Vector2(15 * player.direction, 0) + Main.rand.NextVector2Circular(20, 20);
float partScale = Main.rand.NextFloat(0.3f, 0.8f);
Vector2 partVel = new Vector2(0, 5).RotatedBy(0.5f * player.direction).RotatedByRandom(0.5f) * Main.rand.NextFloat(0.5f, 0.8f);
@@ -52,6 +53,18 @@ namespace CalamityMod.Items.Accessories.Wings
Particle spark3 = new GlowOrbParticle(spawnPos, partVel, false, 19, partScale, Color.LightGreen, true, false, false);
GeneralParticleHandler.SpawnParticle(spark3);
}
if (Main.rand.NextBool())
{
Particle smoke2 = new HeavySmokeParticle(spawnPos2, partVel, Color.Black, 13, partScale * 0.6f, 0.7f, Main.rand.NextFloat(-0.2f, 0.2f), false);
GeneralParticleHandler.SpawnParticle(smoke2);
if (Main.rand.NextBool((player.controlJump ? 2 : 4)))
{
Particle spark3 = new GlowOrbParticle(spawnPos2, partVel, false, 19, partScale * 0.7f, Color.LightGreen, true, false, false);
GeneralParticleHandler.SpawnParticle(spark3);
}
}
}
player.wingTimeMax = 180;
player.noFallDmg = true;
@@ -62,7 +62,6 @@ namespace CalamityMod.Items.Weapons.Magic
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<TomeofFates>().
AddIngredient(ItemID.ShadowFlameHexDoll).
AddIngredient<EldritchTome>().
AddIngredient(ItemID.LunarBar, 5).
+28 -11
View File
@@ -1,7 +1,9 @@
using CalamityMod.Items.Materials;
using System;
using CalamityMod.Items.Materials;
using CalamityMod.Particles;
using CalamityMod.Projectiles.Melee;
using Microsoft.Xna.Framework;
using Steamworks;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
@@ -21,31 +23,36 @@ namespace CalamityMod.Items.Weapons.Melee
{
Item.width = 130;
Item.height = 130;
Item.damage = 80;
Item.damage = 100;
Item.DamageType = DamageClass.Melee;
Item.useAnimation = 20;
Item.useAnimation = 30;
Item.useStyle = ItemUseStyleID.Swing;
Item.useTime = 20;
Item.useTime = 30;
Item.useTurn = true;
Item.knockBack = 5.25f;
Item.UseSound = SoundID.Item1;
Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/SwingMid") with { Volume = 0.5f, Pitch = Main.rand.NextFloat(-0.3f, -0.4f) };
Item.autoReuse = true;
Item.value = CalamityGlobalItem.RarityRedBuyPrice;
Item.rare = ItemRarityID.Red;
Item.shoot = ModContent.ProjectileType<EntropicFlechetteSmall>();
Item.shoot = ModContent.ProjectileType<EntropicFlechette>();
Item.shootSpeed = 12f;
}
public override void UseItemHitbox(Player player, ref Rectangle hitbox, ref bool noHitbox)
{
hitbox = CalamityUtils.FixSwingHitbox(130, 130);
//int hitX = (int)(player.itemLocation + (swingRotation + MathHelper.ToRadians(90f)).ToRotationVector2() * 90).X;
//int hitY = (int)(player.itemLocation + (swingRotation + MathHelper.ToRadians(90f)).ToRotationVector2() * 90).Y;
//hitbox = new Rectangle(hitX, hitY, Item.width / 3, Item.height / 3);
//Particle spark2 = new GlowOrbParticle(new Vector2(hitX, hitY), Vector2.Zero, false, 5, 1, Color.Red);
//GeneralParticleHandler.SpawnParticle(spark2);
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
for (int i = 0; i < 4; i++)
for (int i = 0; i < 6; i++)
{
Projectile.NewProjectileDirect(source, position, velocity.RotatedByRandom(0.6f), type, damage / 5, knockback * 0.5f, player.whoAmI, 0f, 0f);
Projectile.NewProjectileDirect(source, position, velocity.RotatedByRandom(0.6f) * Main.rand.NextFloat(0.7f, 1.1f), type, damage / 2, knockback * 0.5f, player.whoAmI, 0f, 0f);
}
return false;
}
@@ -61,8 +68,18 @@ namespace CalamityMod.Items.Weapons.Melee
player.itemRotation = swingRotation - 1.7f * swordDirection;
player.itemLocation = player.Center;
player.direction = swordDirection;
//swingRotation += swordDirection == 1 ? 0.16f : -0.16f;
swingRotation = Utils.Remap(time, 0, player.itemAnimationMax, 0, 2.88f * swordDirection);
float val = MathF.Abs(time - player.itemAnimationMax * 0.75f) / player.itemAnimationMax;
float goalRot = Utils.Remap(time, 0, player.itemAnimationMax, -0.5f, 4.9f * swordDirection);
float swingEasing = Utils.GetLerpValue(0, player.itemAnimationMax * 0.4f, time, true) * (0.5f - val);
if (time < player.itemAnimationMax)
{
swingRotation = MathHelper.Lerp(swingRotation, goalRot, swingEasing);
}
player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, swingRotation + MathHelper.ToRadians(120f * swordDirection));
if (Main.rand.NextBool())
{
Vector2 dustVel = new Vector2(5 * swordDirection, -5).RotatedByRandom(1.55f) * Main.rand.NextFloat(0.7f, 1.3f) * 2;
+9 -9
View File
@@ -20,21 +20,18 @@ namespace CalamityMod.Items.Weapons.Rogue
{
Item.width = 48;
Item.height = 48;
Item.damage = 240;
Item.damage = 140;
Item.noMelee = true;
Item.consumable = true;
Item.noUseGraphic = true;
Item.useAnimation = 20;
Item.useAnimation = 17;
Item.useStyle = ItemUseStyleID.Swing;
Item.useTime = 20;
Item.useTime = 17;
Item.knockBack = 8f;
Item.UseSound = SoundID.Item1;
Item.autoReuse = true;
Item.maxStack = 9999;
Item.value = 10000;
Item.rare = ItemRarityID.Red;
Item.shoot = ModContent.ProjectileType<AntumbraShardProjectile>();
Item.shootSpeed = 24f;
Item.shootSpeed = 13f;
Item.DamageType = RogueDamageClass.Instance;
}
@@ -46,15 +43,18 @@ namespace CalamityMod.Items.Weapons.Rogue
{
int stealth = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI);
if (stealth.WithinBounds(Main.maxProjectiles))
{
Main.projectile[stealth].Calamity().stealthStrike = true;
Main.projectile[stealth].extraUpdates = 4;
}
}
return !player.Calamity().StealthStrikeAvailable();
}
public override void AddRecipes()
{
CreateRecipe(150).
AddIngredient<MeldConstruct>().
CreateRecipe().
AddIngredient<MeldConstruct>(12).
AddTile(TileID.LunarCraftingStation).
Register();
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

@@ -106,8 +106,6 @@ ElementBall.DisplayName: Elemental Ball
ElementBallShiv.DisplayName: Shiv
EmpyreanKnife.DisplayName: Empyrean Knife
EntropicFlechette.DisplayName: Entropic Flechette
EntropicFlechetteLarge.DisplayName: Entropic Flechette
EntropicFlechetteSmall.DisplayName: Entropic Flechette
EonBolt.DisplayName: Eon Bolt
EssenceFlame2.DisplayName: Essence Flame
EssenceScythe.DisplayName: Essence Scythe
+5 -5
View File
@@ -134,11 +134,11 @@ namespace CalamityMod.Projectiles.Magic
for (int i = 0; i <= 12; i++)
{
int dustStyle = Main.rand.NextBool() ? 66 : 263;
Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 191 : dustStyle, Projectile.velocity);
Dust dust = Dust.NewDustPerfect(Projectile.Center, dustStyle, Projectile.velocity);
dust.scale = Main.rand.NextFloat(0.5f, 0.8f);
dust.velocity = new Vector2(7, 7).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f);
dust.noGravity = true;
dust.color = dust.type == dustStyle ? InnerColor : default;
dust.color = Color.LightGreen;
}
preDamage = false;
moving = true;
@@ -149,7 +149,7 @@ namespace CalamityMod.Projectiles.Magic
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
SoundStyle fire = new("CalamityMod/Sounds/Item/FinalDawnSlash");
SoundStyle fire = new("CalamityMod/Sounds/Item/MeldShoot");
SoundEngine.PlaySound(fire with { Volume = 0.3f, Pitch = 0.9f }, Projectile.Center);
}
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
@@ -163,11 +163,11 @@ namespace CalamityMod.Projectiles.Magic
for (int i = 0; i <= 8; i++)
{
int dustStyle = Main.rand.NextBool() ? 66 : 263;
Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 191 : dustStyle, Projectile.velocity);
Dust dust = Dust.NewDustPerfect(Projectile.Center, dustStyle, Projectile.velocity);
dust.scale = Main.rand.NextFloat(0.5f, 0.8f);
dust.velocity = Projectile.velocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.3f, 3.1f);
dust.noGravity = true;
dust.color = dust.type == dustStyle ? InnerColor : default;
dust.color = InnerColor;
}
}
public override bool? CanDamage() => preDamage ? false : null;
+85 -30
View File
@@ -1,5 +1,10 @@
using Microsoft.Xna.Framework;
using CalamityMod.Buffs.Potions;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
@@ -8,54 +13,104 @@ namespace CalamityMod.Projectiles.Melee
public class EntropicFlechette : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10;
ProjectileID.Sets.TrailingMode[Projectile.type] = 1;
}
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public float sizeVariance = 2;
public int time = 60;
public int spinDir = 100;
public int waveOften = 40;
public float scaleVariance = 1;
public override void SetDefaults()
{
Projectile.width = 12;
Projectile.height = 12;
Projectile.width = 50;
Projectile.height = 50;
Projectile.friendly = true;
Projectile.penetrate = 1;
Projectile.extraUpdates = 1;
Projectile.DamageType = DamageClass.Melee;
Projectile.timeLeft = 600;
Projectile.timeLeft = 450;
}
public override void AI()
{
Projectile.rotation = Projectile.velocity.ToRotation();
Vector2 rotateVector = new Vector2(6f, 12f);
Projectile.localAI[0] += 1f;
if (Projectile.localAI[0] == 48f)
Player Owner = Main.player[Projectile.owner];
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
if (spinDir == 100)
{
Projectile.localAI[0] = 0f;
spinDir = Main.rand.NextBool() ? 1 : -1;
waveOften = Main.rand.Next(10, 40 + 1);
scaleVariance = Main.rand.NextFloat(0.65f, 1f);
}
else
if (time % 18 == 0)
sizeVariance = Main.rand.NextFloat(1.5f, 2.5f) * scaleVariance;
Projectile.scale = MathHelper.Lerp(Projectile.scale, sizeVariance, 0.09f);
if (time % 2 == 0 && time > 5)
{
for (int i = 0; i < 2; i++)
Particle spark = new AltSparkParticle(Projectile.Center, -Projectile.velocity * 0.3f, false, 6, 0.7f, Color.Black);
GeneralParticleHandler.SpawnParticle(spark);
}
if (Main.rand.NextBool(8))
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(6) ? 278 : 263, -Projectile.velocity);
dust.scale = dust.type == 278 ? Main.rand.NextFloat(0.3f, 0.6f) : Main.rand.NextFloat(0.6f, 1.4f);
dust.velocity = -Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.7f);
dust.noGravity = true;
dust.color = Color.LightGreen;
}
if (time >= 5)
{
NPC target = Projectile.Center.ClosestNPCAt(250);
if (target == null)
{
Vector2 dustRotate = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)i * 3.14159274f), default) * rotateVector;
int darkDust = Dust.NewDust(Projectile.Center, 0, 0, DustID.Shadowflame, 0f, 0f, 160, default, 1f);
Main.dust[darkDust].scale = 1f;
Main.dust[darkDust].noGravity = true;
Main.dust[darkDust].position = Projectile.Center + dustRotate;
Main.dust[darkDust].velocity = Projectile.velocity;
Vector2 moveToMouse = (Owner.Calamity().mouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX);
if (Projectile.velocity.Length() < 14)
Projectile.velocity += moveToMouse * 0.3f;
else
Projectile.velocity *= 0.8f;
if (time % waveOften == 0)
spinDir *= -1;
Projectile.velocity = Projectile.velocity.RotatedBy(Main.rand.NextFloat(0.05f, 0.15f) * spinDir * Utils.GetLerpValue(60, 180, time, true));
}
else
{
Vector2 moveToEnemy = (target.Center - Projectile.Center).SafeNormalize(Vector2.UnitX);
if (Projectile.velocity.Length() < 14)
Projectile.velocity += moveToEnemy * 0.8f;
else
Projectile.velocity *= 0.7f;
}
}
int darkestDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Shadowflame, 0f, 0f, 100, default, 0.8f);
Main.dust[darkestDust].noGravity = true;
Main.dust[darkestDust].velocity *= 0f;
CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 12f, 20f);
time++;
}
public override void OnKill(int timeLeft)
{
if (Projectile.numHits > 0)
{
SoundStyle sound = new("CalamityMod/Sounds/Item/MeldBurn");
SoundEngine.PlaySound(sound with { Volume = 0.35f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, Projectile.Center);
}
for (int i = 0; i <= 9; i++)
{
int dustStyle = Main.rand.NextBool() ? 66 : 263;
Dust dust = Dust.NewDustPerfect(Projectile.Center, dustStyle, Projectile.velocity);
dust.scale = Main.rand.NextFloat(0.5f, 1.2f);
dust.velocity = Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 2.1f);
dust.noGravity = true;
dust.color = Color.LightGreen;
}
}
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 2);
Asset<Texture2D> tex = ModContent.Request<Texture2D>("CalamityMod/Particles/WaterFlavored");
Vector2 generalDrawPos = Projectile.Center - Main.screenPosition;
Main.EntitySpriteDraw(tex.Value, generalDrawPos, null, Color.Black, Projectile.rotation, tex.Size() * 0.5f, new Vector2(0.4f, 1) * Projectile.scale, SpriteEffects.None);
Main.EntitySpriteDraw(tex.Value, generalDrawPos, null, Color.LightGreen with { A = 0 }, Projectile.rotation, tex.Size() * 0.5f, new Vector2(0.4f, 1) * Projectile.scale * 0.7f, SpriteEffects.None);
Main.EntitySpriteDraw(tex.Value, generalDrawPos, null, Color.LightGreen with { A = 0 }, Projectile.rotation, tex.Size() * 0.5f, new Vector2(0.4f, 1) * Projectile.scale * 0.5f, SpriteEffects.None);
return false;
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 387 B

@@ -1,62 +0,0 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Melee
{
public class EntropicFlechetteLarge : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10;
ProjectileID.Sets.TrailingMode[Projectile.type] = 1;
}
public override void SetDefaults()
{
Projectile.width = 18;
Projectile.height = 18;
Projectile.friendly = true;
Projectile.penetrate = 1;
Projectile.DamageType = DamageClass.Melee;
Projectile.timeLeft = 600;
}
public override void AI()
{
Projectile.rotation = Projectile.velocity.ToRotation();
Vector2 rotateVector = new Vector2(6f, 12f);
Projectile.localAI[0] += 1f;
if (Projectile.localAI[0] == 48f)
{
Projectile.localAI[0] = 0f;
}
else
{
for (int i = 0; i < 2; i++)
{
Vector2 dustRotate = -Vector2.UnitY.RotatedBy((double)(Projectile.localAI[0] * 0.1308997f + (float)i * 3.14159274f), default) * rotateVector;
int darkDust = Dust.NewDust(Projectile.Center, 0, 0, DustID.Shadowflame, 0f, 0f, 160, default, 1f);
Main.dust[darkDust].scale = 1f;
Main.dust[darkDust].noGravity = true;
Main.dust[darkDust].position = Projectile.Center + dustRotate;
Main.dust[darkDust].velocity = Projectile.velocity;
}
}
int darkestDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Shadowflame, 0f, 0f, 100, default, 0.8f);
Main.dust[darkestDust].noGravity = true;
Main.dust[darkestDust].velocity *= 0f;
CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 12f, 20f);
}
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 2);
return false;
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 666 B

-108
View File
@@ -1,108 +0,0 @@
using CalamityMod.Buffs.Potions;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Melee
{
public class EntropicFlechetteSmall : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public float sizeVariance = 2;
public int time = 60;
public int spinDir = 100;
public int waveOften = 30;
public override void SetDefaults()
{
Projectile.width = 25;
Projectile.height = 25;
Projectile.friendly = true;
Projectile.penetrate = 1;
Projectile.extraUpdates = 1;
Projectile.DamageType = DamageClass.Melee;
Projectile.timeLeft = 450;
}
public override void AI()
{
Player Owner = Main.player[Projectile.owner];
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
if (spinDir == 100)
{
spinDir = Main.rand.NextBool() ? 1 : -1;
waveOften = Main.rand.Next(15, 30 + 1);
}
if (time % 18 == 0)
sizeVariance = Main.rand.NextFloat(1.5f, 2.5f) * 0.7f;
Projectile.scale = MathHelper.Lerp(Projectile.scale, sizeVariance, 0.09f);
if (time % 2 == 0 && time > 5)
{
Particle spark = new AltSparkParticle(Projectile.Center, -Projectile.velocity * 0.3f, false, 6, 0.7f, Color.Black);
GeneralParticleHandler.SpawnParticle(spark);
}
if (Main.rand.NextBool(8))
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(6) ? 278 : 263, -Projectile.velocity);
dust.scale = dust.type == 278 ? Main.rand.NextFloat(0.3f, 0.6f) : Main.rand.NextFloat(0.6f, 1.4f);
dust.velocity = -Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.7f);
dust.noGravity = true;
dust.color = Color.LightGreen;
}
if (time >= 5)
{
NPC target = Projectile.Center.ClosestNPCAt(250);
if (target == null)
{
Vector2 moveToMouse = (Owner.Calamity().mouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX);
if (Projectile.velocity.Length() < 12)
Projectile.velocity += moveToMouse * 0.2f;
else
Projectile.velocity *= 0.9f;
if (time % waveOften == 0)
spinDir *= -1;
Projectile.velocity = Projectile.velocity.RotatedBy(Main.rand.NextFloat(0.05f, 0.15f) * spinDir * Utils.GetLerpValue(60, 180, time, true));
}
else
{
Vector2 moveToEnemy = (target.Center - Projectile.Center).SafeNormalize(Vector2.UnitX);
if (Projectile.velocity.Length() < 12)
Projectile.velocity += moveToEnemy * 0.8f;
else
Projectile.velocity *= 0.7f;
}
}
time++;
}
public override void OnKill(int timeLeft)
{
for (int i = 0; i <= 9; i++)
{
int dustStyle = Main.rand.NextBool() ? 66 : 263;
Dust dust = Dust.NewDustPerfect(Projectile.Center, dustStyle, Projectile.velocity);
dust.scale = Main.rand.NextFloat(0.5f, 1.2f);
dust.velocity = Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 2.1f);
dust.noGravity = true;
dust.color = Color.LightGreen;
}
}
public override bool PreDraw(ref Color lightColor)
{
Asset<Texture2D> tex = ModContent.Request<Texture2D>("CalamityMod/Particles/WaterFlavored");
Vector2 generalDrawPos = Projectile.Center - Main.screenPosition;
Main.EntitySpriteDraw(tex.Value, generalDrawPos, null, Color.Black, Projectile.rotation, tex.Size() * 0.5f, new Vector2(0.4f, 1) * Projectile.scale, SpriteEffects.None);
Main.EntitySpriteDraw(tex.Value, generalDrawPos, null, Color.LightGreen with { A = 0 }, Projectile.rotation, tex.Size() * 0.5f, new Vector2(0.4f, 1) * Projectile.scale * 0.7f, SpriteEffects.None);
Main.EntitySpriteDraw(tex.Value, generalDrawPos, null, Color.LightGreen with { A = 0 }, Projectile.rotation, tex.Size() * 0.5f, new Vector2(0.4f, 1) * Projectile.scale * 0.5f, SpriteEffects.None);
return false;
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 B

+307 -32
View File
@@ -1,7 +1,14 @@
using CalamityMod.Items.Weapons.Rogue;
using System;
using CalamityMod.Buffs.Potions;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Particles;
using CalamityMod.Projectiles.Ranged;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
@@ -16,70 +23,338 @@ namespace CalamityMod.Projectiles.Rogue
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 5;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
public ref float time => ref Projectile.ai[0];
// Vanilla sticky code is jank, So I did my own (for better or worse)
public NPC chosenTarget;
public bool stuckInTarget = false;
public bool stuckInGround = false;
public bool canDamage = true;
public bool canStick = true;
public int stuckTimer = 180;
public Vector2 placementCenter;
float placementDistance;
Vector2 placementVelocity;
public Vector2 storedVelocity;
public bool collideWithTiles = true;
public Vector2 startingVel;
public bool jitter = false;
public Vector2 portalSpot;
public Vector2 shadowPlacement;
NPC closestTarget;
public override void SetDefaults()
{
Projectile.width = 20;
Projectile.height = 20;
Projectile.width = 2;
Projectile.height = 2;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.penetrate = -1;
Projectile.MaxUpdates = 2;
Projectile.aiStyle = ProjAIStyleID.StickProjectile;
Projectile.extraUpdates = 2;
Projectile.timeLeft = 600;
AIType = ProjectileID.BoneJavelin;
Projectile.DamageType = RogueDamageClass.Instance;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10 * Projectile.MaxUpdates; // 10 effective, 20 total
Projectile.localNPCHitCooldown = -1;
Projectile.tileCollide = false;
}
public override void AI()
{
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(45f);
if (Projectile.spriteDirection == -1)
Player Owner = Main.player[Projectile.owner];
float targetDist = Vector2.Distance(Owner.Center, Projectile.Center);
if (closestTarget != null && closestTarget.life <= 0)
closestTarget = null;
if (Projectile.ai[2] > 0 && time == 0)
{
Projectile.rotation -= MathHelper.PiOver2;
closestTarget = Projectile.Center.ClosestNPCAt(2000);
storedVelocity = ((closestTarget == null ? Owner.Calamity().mouseWorld : closestTarget.Center) - Projectile.Center).SafeNormalize(Vector2.UnitX);
Projectile.alpha = 255;
Projectile.velocity = Vector2.Zero;
stuckInTarget = true;
collideWithTiles = false;
canDamage = false;
portalSpot = Projectile.Center;
}
if (Main.rand.NextBool(3))
if (time == 0)
{
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.PurpleTorch, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f);
startingVel = Projectile.velocity;
}
if (Projectile.timeLeft % 12 == 0)
float fading = stuckInTarget ? Utils.GetLerpValue(0, 180, stuckTimer) : 0.5f;
if (stuckInTarget && time % ((int)(10 * fading) + 1) == 0)
{
if (Projectile.owner == Main.myPlayer)
shadowPlacement = Main.rand.NextVector2Circular(30, 30);
jitter = !jitter;
}
if (stuckInGround)
{
Projectile.rotation = storedVelocity.ToRotation() + MathHelper.ToRadians(45f * (storedVelocity.X > 0 ? 1 : -1));
}
if (!stuckInTarget && !stuckInGround)
{
storedVelocity = Projectile.velocity;
Projectile.rotation = (storedVelocity).ToRotation() + MathHelper.ToRadians(45f * (storedVelocity.X > 0 ? 1 : -1));
if (Projectile.spriteDirection == -1)
{
if (Projectile.Calamity().stealthStrike)
Projectile.rotation -= MathHelper.PiOver2;
}
if (time > 5 && !stuckInTarget)
{
if (Main.rand.NextBool(4) && canStick)
{
int star = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f, ModContent.ProjectileType<EmpyreanStellarDetritus>(), (int)(Projectile.damage * 0.5), Projectile.knockBack, Projectile.owner, 0f, 0f);
Main.projectile[star].DamageType = RogueDamageClass.Instance;
Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(6) ? 278 : 263, -Projectile.velocity);
dust.scale = dust.type == 278 ? Main.rand.NextFloat(0.3f, 0.6f) : Main.rand.NextFloat(0.6f, 1.4f);
dust.velocity = -Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.7f);
dust.noGravity = true;
dust.color = Color.LightGreen;
}
if ((Projectile.Calamity().stealthStrike || Projectile.ai[1] == 1) && targetDist < 1400)
{
float randVel = Main.rand.NextFloat(0.3f, 1.2f);
int lifetime = Projectile.Calamity().stealthStrike ? 24 : 8;
Particle spark = new AltSparkParticle(Projectile.Center, -Projectile.velocity * randVel, false, lifetime, 1.2f, Color.Black);
GeneralParticleHandler.SpawnParticle(spark);
Particle spark2 = new SparkParticle(Projectile.Center, -Projectile.velocity * randVel, false, lifetime, 0.9f, Color.LightGreen);
GeneralParticleHandler.SpawnParticle(spark2);
if (Main.rand.NextBool() && !Projectile.Calamity().stealthStrike)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, 278);
dust.noGravity = true;
dust.velocity = Projectile.velocity * randVel;
dust.scale = Main.rand.NextFloat(0.6f, 0.8f);
dust.color = Color.LightGreen;
}
}
if (targetDist < 1400f && time % 3 == 0 && !canStick && Projectile.ai[1] == 0)
{
Vector2 placement = Projectile.Center + Main.rand.NextVector2Circular(15, 15);
float speed = Main.rand.NextFloat(0.2f, 0.7f);
Particle spark = new AltSparkParticle(placement, -Projectile.velocity * speed, false, 11, 0.8f, Color.Black);
GeneralParticleHandler.SpawnParticle(spark);
Particle spark2 = new SparkParticle(placement, -Projectile.velocity * speed, false, 11, 0.5f, Color.LightGreen);
GeneralParticleHandler.SpawnParticle(spark2);
}
if (closestTarget != null && Projectile.numHits < 1 && closestTarget.CanBeChasedBy(Projectile))
{
Vector2 moveTotarget = (closestTarget.Center - Projectile.Center).SafeNormalize(Vector2.UnitX);
if (Projectile.velocity.Length() < 16)
Projectile.velocity += moveTotarget * 0.85f;
else
Projectile.velocity *= 0.8f;
}
}
}
}
else if (stuckInTarget)
{
Projectile.rotation = (storedVelocity).SafeNormalize(Vector2.UnitX).ToRotation() + MathHelper.ToRadians(45f * (storedVelocity.X > 0 ? 1 : -1));
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
return false;
}
if (Projectile.ai[2] == 0)
{
placementCenter = chosenTarget.Center + placementVelocity * placementDistance + storedVelocity * 2;
Projectile.Center = placementCenter;
if (Main.rand.NextBool())
{
int dustStyle = Main.rand.NextBool() ? 66 : 263;
Dust dust = Dust.NewDustPerfect(portalSpot, dustStyle, Projectile.velocity);
dust.scale = Main.rand.NextFloat(0.4f, 0.8f);
dust.velocity = new Vector2(12, 12).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f) * Utils.GetLerpValue(180, 0, stuckTimer);
dust.noGravity = true;
dust.color = Color.LightGreen;
}
if (stuckTimer <= 20)
Projectile.scale *= 0.97f;
}
if (closestTarget == null)
closestTarget = Projectile.Center.ClosestNPCAt(2000);
if (Projectile.Calamity().stealthStrike && time % 20 == 0)
{
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + Main.rand.NextVector2CircularEdge(450, 450) * Main.rand.NextFloat(0.7f, 1.3f), Vector2.Zero, ModContent.ProjectileType<AntumbraShardProjectile>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 1, 5);
}
stuckTimer--;
if (Projectile.ai[2] == 0)
{
if (chosenTarget.life <= 0 || chosenTarget == null)
stuckTimer = 0;
}
if (stuckTimer <= 0)
{
for (int i = 0; i < Main.maxNPCs; i++)
Projectile.localNPCImmunity[i] = 0;
SoundStyle sound = new("CalamityMod/Sounds/Item/MeldExplosion");
SoundEngine.PlaySound(sound with { Volume = 0.3f, Pitch = 0.8f }, Projectile.Center);
Projectile.ai[2] = 0;
Projectile.numHits = 0;
Projectile.scale = 1;
jitter = false;
canDamage = true;
canStick = false;
stuckInTarget = false;
Projectile.extraUpdates = 4;
Projectile.Center = portalSpot;
if (closestTarget == null)
Projectile.velocity = (Projectile.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * -12;
else
Projectile.velocity = (Projectile.Center - closestTarget.Center).SafeNormalize(Vector2.UnitX) * -12;
for (int i = 0; i <= 12; i++)
{
int dustStyle = Main.rand.NextBool() ? 66 : 263;
Dust dust2 = Dust.NewDustPerfect(Projectile.Center, dustStyle, Projectile.velocity);
dust2.scale = Main.rand.NextFloat(0.5f, 1.1f);
dust2.velocity = new Vector2(7, 7).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f);
dust2.noGravity = true;
dust2.color = Color.LightGreen;
}
Particle bolt2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.LightGreen * 0.85f, "CalamityMod/Particles/BloomRing", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 1f, 18);
GeneralParticleHandler.SpawnParticle(bolt2);
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(45f * (storedVelocity.X > 0 ? 1 : -1));
}
}
time++;
if (collideWithTiles && Collision.SolidCollision(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 68, 4, 4)) // Vanilla tile collision messes with velocity so we use this instead
{
canDamage = false;
if (Projectile.timeLeft > 180)
Projectile.timeLeft = 180;
stuckInGround = true;
storedVelocity = Projectile.velocity;
Projectile.velocity = Vector2.Zero;
SoundStyle sound = new("CalamityMod/Sounds/NPCHit/RavagerRockPillarHit1");
SoundEngine.PlaySound(sound with { Volume = 0.25f, Pitch = Main.rand.NextFloat(-0.3f, -0.6f) }, Projectile.Center);
Projectile.rotation = storedVelocity.ToRotation() + MathHelper.ToRadians(45f * (storedVelocity.X > 0 ? 1 : -1));
collideWithTiles = false;
for (int k = 0; k < 8; k++)
{
Vector2 partPos = Projectile.Center + storedVelocity.SafeNormalize(Vector2.UnitX) * 68;
Color colorType = Main.rand.NextBool() ? Color.LightGreen : Color.Black;
Particle spark3 = new GlowOrbParticle(partPos, new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), false, 19, Main.rand.NextFloat(0.6f, 1f), colorType, colorType == Color.Black ? false : true, false, colorType == Color.Black ? false : true);
GeneralParticleHandler.SpawnParticle(spark3);
}
}
if (Projectile.ai[2] == 0)
Projectile.alpha = (int)(Utils.Remap(Projectile.timeLeft, 0, 60, 255, 0));
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
if (Projectile.numHits > 0)
Projectile.damage = (int)(Projectile.damage * 0.9f);
Projectile.damage = (int)(Projectile.damage * 0.88f);
if (Projectile.damage < 1)
{
Projectile.damage = 1;
}
}
public override void OnHitPlayer(Player target, Player.HurtInfo info)
{
Projectile.damage /= 2;
if (Projectile.damage < 1)
if (!stuckInTarget && canStick)
{
Projectile.damage = 1;
if (Projectile.timeLeft < 600)
Projectile.timeLeft = 600;
collideWithTiles = false;
canDamage = false;
placementDistance = -Vector2.Distance(target.Center, Projectile.Center);
placementVelocity = (target.Center - Projectile.Center).SafeNormalize(Vector2.UnitX);
placementCenter = placementVelocity * (placementDistance * 0.01f);
chosenTarget = target;
stuckInTarget = true;
storedVelocity = Projectile.velocity;
Projectile.velocity = Vector2.Zero;
portalSpot = Projectile.Center + Main.rand.NextVector2CircularEdge(350, 350) * Main.rand.NextFloat(0.8f, 1.1f);
SoundStyle sound = new("CalamityMod/Sounds/Item/WulfrumKnifeTileHit2");
SoundEngine.PlaySound(sound with { Volume = 0.5f, Pitch = Main.rand.NextFloat(-0.3f, -0.4f) }, Projectile.Center);
for (int i = 0; i <= 11; i++)
{
int dustStyle = Main.rand.NextBool() ? 66 : 263;
Dust dust = Dust.NewDustPerfect(Projectile.Center + storedVelocity.SafeNormalize(Vector2.UnitX) * 68 + Main.rand.NextVector2Circular(12, 12), dustStyle, Projectile.velocity);
dust.scale = Main.rand.NextFloat(0.7f, 1.1f);
dust.velocity = storedVelocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.8f, 2.1f);
dust.noGravity = true;
dust.color = Color.LimeGreen;
}
}
if (!canStick)
{
SoundStyle sound = new("CalamityMod/Sounds/Item/MeldSlice");
SoundEngine.PlaySound(sound with { Volume = 0.7f, Pitch = 0.4f }, Projectile.Center);
SoundStyle sound2 = new("CalamityMod/Sounds/Item/ExobladeBeamSlash");
SoundEngine.PlaySound(sound2 with { Volume = 0.15f, Pitch = 0.7f }, Projectile.Center);
}
}
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
{
modifiers.SourceDamage *= canStick ? 0.7f : 1f;
}
public override bool PreDraw(ref Color lightColor)
{
Player Owner = Main.player[Projectile.owner];
if (time <= 4)
return false;
Asset<Texture2D> tex = ModContent.Request<Texture2D>(Texture);
Asset<Texture2D> tex2 = ModContent.Request<Texture2D>("CalamityMod/Items/Weapons/Rogue/ShardofAntumbraGhost");
Asset<Texture2D> portal = ModContent.Request<Texture2D>("CalamityMod/Particles/Light");
float alpha = Utils.GetLerpValue(255, 0, Projectile.alpha);
float fading = stuckInTarget ? Utils.GetLerpValue(0, 180, stuckTimer) : 0.5f;
float portalFading = Utils.GetLerpValue(75, 0, stuckTimer, true);
Vector2 generalDrawPos = Projectile.Center - Main.screenPosition;
Vector2 portalDrawPos = portalSpot - Main.screenPosition;
if (jitter && stuckInTarget)
{
Main.EntitySpriteDraw(tex2.Value, generalDrawPos + (shadowPlacement * (1 - fading)), null, Color.Black * alpha, Projectile.rotation, tex2.Size() * 0.5f, Projectile.scale, storedVelocity.X > 0 ? SpriteEffects.None : SpriteEffects.FlipVertically);
Main.EntitySpriteDraw(tex2.Value, generalDrawPos + (-shadowPlacement * (1 - fading)), null, Color.Black * alpha, Projectile.rotation, tex2.Size() * 0.5f, Projectile.scale, storedVelocity.X > 0 ? SpriteEffects.None : SpriteEffects.FlipVertically);
Main.EntitySpriteDraw(portal.Value, portalDrawPos, null, Color.Black * (1 - fading * 0.3f), 0, portal.Size() * 0.5f, 1.8f * portalFading, SpriteEffects.None);
Main.EntitySpriteDraw(portal.Value, portalDrawPos, null, Color.LightGreen with { A = 0 } * (1 - fading), 0, portal.Size() * 0.5f, 1.1f * portalFading, SpriteEffects.None);
Vector2 expectedVel = ((closestTarget == null ? Owner.Calamity().mouseWorld : closestTarget.Center) - portalSpot).SafeNormalize(Vector2.UnitX);
if (true)
{
for (int i = 0; i < 4; i++)
{
Main.EntitySpriteDraw(tex2.Value, portalDrawPos, null, Color.LightGreen with { A = 0 } * portalFading * 0.7f, expectedVel.ToRotation() + MathHelper.ToRadians(45f * (expectedVel.X > 0 ? 1 : -1)), tex2.Size() * 0.5f, (1 - (i * 0.05f)) * (1 - fading), expectedVel.X > 0 ? SpriteEffects.None : SpriteEffects.FlipVertically);
}
}
}
else if (stuckInTarget)
Main.EntitySpriteDraw(portal.Value, portalDrawPos, null, Color.Black * (1 - fading * 0.3f), 0, portal.Size() * 0.5f, 1.5f * portalFading, SpriteEffects.None);
if (!canStick || stuckInTarget)
{
for (int i = 0; i < 4; i++)
{
Color auraColor = Color.Lerp(Color.LightGreen, Color.White, Utils.GetLerpValue(0, 4, i)) * (1 - fading);
Vector2 rotationalDrawOffset = (MathHelper.TwoPi * i / 7f + Main.GlobalTimeWrappedHourly * 17f).ToRotationVector2();
rotationalDrawOffset *= MathHelper.Lerp(3f, 5.25f, (float)Math.Cos(Main.GlobalTimeWrappedHourly * 6f) * 0.5f + (!canStick ? 1.5f : 0));
Main.EntitySpriteDraw(tex2.Value, Projectile.Center - Main.screenPosition + rotationalDrawOffset, null, (auraColor * alpha) with { A = 0 }, Projectile.rotation, tex2.Size() * 0.5f, Projectile.scale, storedVelocity.X > 0 ? SpriteEffects.None : SpriteEffects.FlipVertically);
}
}
Main.EntitySpriteDraw(tex.Value, generalDrawPos, null, lightColor * alpha * (stuckInTarget ? fading : 1), Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, storedVelocity.X > 0 ? SpriteEffects.None : SpriteEffects.FlipVertically);
if (stuckInTarget)
{
Main.EntitySpriteDraw(tex2.Value, generalDrawPos, null, Color.LightGreen with { A = 0 } * alpha * (1 - fading) * 0.7f, Projectile.rotation, tex2.Size() * 0.5f, Projectile.scale, storedVelocity.X > 0 ? SpriteEffects.None : SpriteEffects.FlipVertically);
for (int i = 0; i < 3; i++)
{
Main.EntitySpriteDraw(portal.Value, portalDrawPos, null, Color.LightGreen with { A = 0 } * (1 - fading * 0.3f) * 0.7f, 0, portal.Size() * 0.5f, (0.8f - (i * 0.15f)) * portalFading, SpriteEffects.None);
}
}
//CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
return false;
}
public override bool? CanDamage() => canDamage ? null : false;
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 68, Projectile.ai[1] == 1 ? 60 : 20, targetHitbox);
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.