Merge: ENNWAY's brick reworks and backend code

This commit is contained in:
Cameron Ewell authored and GitHub committed 2024-06-22 00:02:41 +02:00
commit e3624e59a9
20 files changed
+417 -58

No files matched your search

+4 -6
View File
@@ -184,8 +184,7 @@ namespace CalamityMod.Effects
#region Aqua's Shaders
internal static Effect CircularGradientWithEdge;
internal static Effect WavyOpacity;
internal static Effect HellBall;
internal static Effect GaleforceArrowTrailShader;
#endregion
//
@@ -408,10 +407,9 @@ namespace CalamityMod.Effects
#region Loading Aqua's Shaders
CircularGradientWithEdge = LoadShader("CircularGradientWithEdge");
RegisterMiscShader(CircularGradientWithEdge, "CircularGradientWithEdgePass", "CircularGradientWithEdge");
WavyOpacity = LoadShader("WavyOpacity");
RegisterMiscShader(WavyOpacity, "WavyOpacityPass", "WavyOpacity");
HellBall = LoadShader("HellBall");
RegisterScreenShader(HellBall, "HellBallPass", "HellBall");
GaleforceArrowTrailShader = LoadShader("GaleforceArrowTrail");
RegisterMiscShader(ArtAttackTrailShader, "TrailPass", "GaleforceArrowTrail");
#endregion
#region Loading Amber's Shaders
+69
View File
@@ -0,0 +1,69 @@
sampler uImage0 : register(s0);
sampler uImage1 : register(s1);
float3 uColor;
float3 uSecondaryColor;
float uOpacity;
float uSaturation;
float uRotation;
float uTime;
float4 uSourceRect;
float2 uWorldPosition;
float uDirection;
float3 uLightSource;
float2 uImageSize0;
float2 uImageSize1;
matrix uWorldViewProjection;
float shouldFlip;
float4 uShaderSpecificData;
struct VertexShaderInput
{
float4 Position : POSITION0;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};
struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
{
VertexShaderOutput output = (VertexShaderOutput)0;
float4 pos = mul(input.Position, uWorldViewProjection);
output.Position = pos;
output.Color = input.Color;
output.TextureCoordinates = input.TextureCoordinates;
return output;
}
float InverseLerp(float a, float b, float x)
{
return saturate((x - a) / (b - a));
}
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
float4 color = input.Color;
float2 coords = input.TextureCoordinates;
// Read the fade map as a streak.
float4 fadeMapColor = tex2D(uImage1, coords - float2(uTime * 0.6, 0));
float opacity = fadeMapColor.r;
float bloomOpacity = sin(coords.y * 3.141) * 1.4;
return lerp(color * bloomOpacity, color * opacity, InverseLerp(0, 0.26, coords.x));
}
technique Technique1
{
pass TrailPass
{
VertexShader = compile vs_2_0 VertexShaderFunction();
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}
Binary file not shown.
+5
View File
@@ -1,6 +1,7 @@
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables;
using CalamityMod.Projectiles.Rogue;
using CalamityMod.Utilities;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -36,6 +37,10 @@ namespace CalamityMod.Items.Weapons.Rogue
public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 20;
public override float StealthDamageMultiplier => 1.3f;
public override void UseStyle(Player player, Rectangle heldItemFrame)
{
ExtraArmAnimations.ThrowArmAnimationFast(player, Item);
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
+9 -3
View File
@@ -1,4 +1,5 @@
using CalamityMod.Projectiles.Rogue;
using CalamityMod.Utilities;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
@@ -17,10 +18,10 @@ namespace CalamityMod.Items.Weapons.Rogue
{
Item.width = 28;
Item.height = 20;
Item.damage = 17;
Item.shootSpeed = 12f;
Item.damage = 14;
Item.shootSpeed = 15f;
Item.shoot = ModContent.ProjectileType<Brick>();
Item.useTime = Item.useAnimation = 35;
Item.useTime = Item.useAnimation = 25;
Item.useStyle = ItemUseStyleID.Swing;
Item.knockBack = 5f;
Item.value = Item.buyPrice(0, 0, 0, 50);
@@ -36,6 +37,11 @@ namespace CalamityMod.Items.Weapons.Rogue
// Terraria seems to really dislike high crit values in SetDefaults
public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 20;
public override void UseStyle(Player player, Rectangle heldItemFrame)
{
ExtraArmAnimations.ThrowArmAnimationFast(player, Item);
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
//Check if stealth is full
@@ -270,3 +270,6 @@ PrimordialEarthExplosion.DisplayName: Primordial Earth
PrimordialEarthProjectile.DisplayName: Primordial Earth
PrimordialAncientProjectile.DisplayName: Primordial Ancient
PrimordialAncientExplosion.DisplayName: Primordial Ancient
GaleforceHoldout.DisplayName: Galeforce
SongOfParadiseNote.DisplayName: Song Of Paradise Note
SongOfParadiseDragon.DisplayName: Song Of Paradise Dragon
@@ -75,7 +75,6 @@ CosmicSpiritBomb3.DisplayName: Cosmic Bomb
CrescentMoonFlail.DisplayName: Crescent Moon
CrescentMoonProj.DisplayName: Crescent Moon
CrystylCrusherRay.DisplayName: Crystyl Crusher Ray
Cyclone.DisplayName: Cyclone
DarkBall.DisplayName: Dark Ball
DarkBeam.DisplayName: Dark Beam
DarkIceZero.DisplayName: Dark Ice
@@ -310,8 +309,10 @@ Waterfall.DisplayName: Waterfall Beam
WhiteBoltAura.DisplayName: White Aura
WhiteOrb.DisplayName: White Orb
Whiterain.DisplayName: White Rain
WindBolt.DisplayName: Wind Bolt
WulfrumScrew.DisplayName: Wulfrum Screw
WulfrumScrewdriverProj.DisplayName: Wulfrum Screwdriver
YateveoBloomProj.DisplayName: Yateveo Bloom
YinYoDark.DisplayName: Dark Shard
YinYoLight.DisplayName: Light Shard
Cyclone.DisplayName: Cyclone
@@ -252,4 +252,7 @@ WildfireBloomFire.DisplayName: Wildfire Fire
WildfireBloomFlare.DisplayName: Wildfire Flare
WulfrumScrapBullet.DisplayName: High Speed Scrap
NitroShot.DisplayName: Nitro Shot
GaleforceHoldout.DisplayName: Galeforce Holdout
GaleforceArrow.DisplayName: Galeforce Arrow
GaleforceWind.DisplayName: Galeforce Wind
ChargedBlastSplit.DisplayName: Charged Blast Split
+1 -1
View File
@@ -41,7 +41,7 @@ namespace CalamityMod.Particles
if (QuickShrink)
{
Squash.X *= 0.8f;
Squash.Y *= 1.25f;
Squash.Y *= 1.2f;
}
if (Velocity.Length() < 12f && AffectedByGravity)
{
+9 -3
View File
@@ -24,7 +24,7 @@ namespace CalamityMod.Particles
private float HueShift;
static int FrameAmount = 6;
public HeavySmokeParticle(Vector2 position, Vector2 velocity, Color color, int lifetime, float scale, float opacity, float rotationSpeed = 0f, bool glowing = false, float hueshift = 0f, bool required = false)
public HeavySmokeParticle(Vector2 position, Vector2 velocity, Color color, int lifetime, float scale, float opacity, float rotationSpeed = 0f, bool glowing = false, float hueshift = 0f, bool required = false, bool affectedByLight = false)
{
Position = position;
Velocity = velocity;
@@ -37,7 +37,7 @@ namespace CalamityMod.Particles
StrongVisual = required;
Glowing = glowing;
HueShift = hueshift;
AffectedByLight = affectedByLight;
}
public override void Update()
@@ -62,8 +62,14 @@ namespace CalamityMod.Particles
int animationFrame = (int)Math.Floor(Time / ((float)(Lifetime / (float)FrameAmount)));
Rectangle frame = new Rectangle(80 * Variant, 80 * animationFrame, 80, 80);
Color col = Color * Opacity;
spriteBatch.Draw(tex, Position - Main.screenPosition, frame, Color * Opacity, Rotation, frame.Size() / 2f, Scale, SpriteEffects.None, 0);
if (AffectedByLight)
{
col = Lighting.GetColor((Position / 16).ToPoint()).MultiplyRGBA(col);
}
spriteBatch.Draw(tex, Position - Main.screenPosition, frame, col, Rotation, frame.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
+3 -3
View File
@@ -32,9 +32,9 @@ namespace CalamityMod.Particles
Vector2 scale = new Vector2(0.3f, 1f) * scaleFactor;
Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, 0f, texture.Size() * 0.5f, scale, 0, 0f);
spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale, 0, 0f);
spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, -Rotation, texture.Size() * 0.5f, scale, 0, 0f);
spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, 0f, texture.Size() * 0.5f, scale * Scale, 0, 0f);
spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale * Scale, 0, 0f);
spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, -Rotation, texture.Size() * 0.5f, scale * Scale, 0, 0f);
}
}
}
+6
View File
@@ -49,6 +49,11 @@ namespace CalamityMod.Particles
public float Rotation;
public float Scale;
/// <summary>
/// Whether your particle is affected by light levels.
/// </summary>
public bool AffectedByLight = false;
public virtual int FrameVariants => 1;
public int Variant = 0;
public virtual string Texture => "";
@@ -78,6 +83,7 @@ namespace CalamityMod.Particles
/// </summary>
public virtual bool UseHalfTransparency => false;
/// <summary>
/// Removes the particle from the handler
/// </summary>
+6 -1
View File
@@ -17,7 +17,7 @@ namespace CalamityMod.Particles
public override string Texture => "CalamityMod/Particles/PointParticle";
public PointParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color, bool AddativeBlend = true)
public PointParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color, bool AddativeBlend = true, bool affectedByLight = false)
{
Position = relativePosition;
Velocity = velocity;
@@ -26,12 +26,17 @@ namespace CalamityMod.Particles
Lifetime = lifetime;
Color = InitialColor = color;
UseAltVisual = AddativeBlend;
AffectedByLight = affectedByLight;
}
public override void Update()
{
Scale *= 0.95f;
Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D));
if (AffectedByLight)
{
Color = Lighting.GetColor((Position / 16).ToPoint()).MultiplyRGBA(Color);
}
Velocity *= 0.95f;
if (Velocity.Length() < 12f && AffectedByGravity)
{
+3 -2
View File
@@ -13,7 +13,7 @@ namespace CalamityMod.Particles
private Color ColorFade;
private float Spin;
public SmallSmokeParticle(Vector2 position, Vector2 velocity, Color colorFire, Color colorFade, float scale, float opacity, float rotationSpeed = 0f)
public SmallSmokeParticle(Vector2 position, Vector2 velocity, Color colorFire, Color colorFade, float scale, float opacity, float rotationSpeed = 0f, bool affectedByLight = false)
{
Position = position;
Velocity = velocity;
@@ -23,11 +23,11 @@ namespace CalamityMod.Particles
Opacity = opacity;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
AffectedByLight = affectedByLight;
}
public override void Update()
{
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
Velocity *= 0.85f;
@@ -47,6 +47,7 @@ namespace CalamityMod.Particles
Color = Color.Lerp(ColorFire, ColorFade, MathHelper.Clamp((float)((255 - Opacity) - 100) / 80, 0f, 1f)) * (Opacity / 255f);
if (AffectedByLight) Color = Lighting.GetColor((Position / 16).ToPoint()).MultiplyRGBA(Color);
}
}
}
+34 -5
View File
@@ -10,26 +10,48 @@ namespace CalamityMod.Particles
{
public Color InitialColor;
public bool AffectedByGravity;
public bool FadeIn = false;
public float FadeInScale = 0f;
public override bool SetLifetime => true;
public override bool UseCustomDraw => true;
public override bool UseAdditiveBlend => true;
public override string Texture => "CalamityMod/Projectiles/StarProj";
public SparkParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color)
public SparkParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color, bool fadeIn = false, bool affectedByLight = false)
{
Position = relativePosition;
Velocity = velocity;
AffectedByGravity = affectedByGravity;
AffectedByLight = affectedByLight;
Scale = scale;
FadeInScale = scale;
Lifetime = lifetime;
Color = InitialColor = color;
FadeIn = fadeIn;
if (FadeIn)
Scale = 0f;
}
public override void Update()
{
Scale *= 0.95f;
Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D));
if (!FadeIn)
{
Scale *= 0.95f;
Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D));
}
else
{
if ((float)Time / (float)Lifetime < 0.5f)
{
Scale = MathHelper.Lerp(Scale, FadeInScale, 0.2f);
}
else
{
Scale = MathHelper.Lerp(Scale, FadeInScale, -0.21f);
}
}
Velocity *= 0.95f;
if (Velocity.Length() < 12f && AffectedByGravity)
{
@@ -44,8 +66,15 @@ namespace CalamityMod.Particles
Vector2 scale = new Vector2(0.5f, 1.6f) * Scale;
Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale, 0, 0f);
spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale * new Vector2(0.45f, 1f), 0, 0f);
Color col = Color;
if (AffectedByLight)
{
col = Lighting.GetColor((Position / 16).ToPoint()).MultiplyRGB(Color);
}
spriteBatch.Draw(texture, Position - Main.screenPosition, null, col, Rotation, texture.Size() * 0.5f, scale, 0, 0f);
spriteBatch.Draw(texture, Position - Main.screenPosition, null, col, Rotation, texture.Size() * 0.5f, scale * new Vector2(0.45f, 1f), 0, 0f);
}
}
}
+115 -8
View File
@@ -1,20 +1,42 @@
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.CalPlayer;
using CalamityMod.MainMenu;
using CalamityMod.Particles;
using CalamityMod.Systems;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using rail;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
using CalamityMod.Projectiles.Typeless;
using CalamityMod.NPCs.SunkenSea;
using CalamityMod.Tiles.Abyss;
namespace CalamityMod.Projectiles.Rogue
{
public class ApoctolithProj : ModProjectile, ILocalizedModType
{
public static Color LowBlueColor => Color.Blue;
public static Color HighBlueColor => Color.DodgerBlue;
public int ShardDamage => (int)(Projectile.damage * 0.12f);
public int ExplosionDamage => (int)(Projectile.damage * 0.5f);
public int ExplosionRadius => 150;
public new string LocalizationCategory => "Projectiles.Rogue";
public override string Texture => "CalamityMod/Items/Weapons/Rogue/Apoctolith";
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 5;
ProjectileID.Sets.TrailingMode[Projectile.type] = 2;
}
public override void SetDefaults()
{
Projectile.width = 30;
@@ -26,9 +48,17 @@ namespace CalamityMod.Projectiles.Rogue
public override void AI()
{
Lighting.AddLight(Projectile.Center, new Vector3(0.2f, 0.2f, 0.5f));
Projectile.ai[0] = Projectile.Calamity().stealthStrike ? 1 : 0;
if (Main.rand.NextBool(3)) GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center, new Vector2(Main.rand.NextFloat(12), 0).RotatedBy(Vector2.Zero.AngleTo(Projectile.velocity) + MathHelper.ToRadians(Main.rand.NextFloat(-20, 20))), false, 10, 1f, Main.rand.NextBool(3) ? LowBlueColor : Color.Black, true));
Projectile.ai[1]++;
//Constant rotation and gravity
Projectile.rotation += 0.4f * Projectile.direction;
Projectile.velocity.Y += 0.3f;
Projectile.velocity.X *= 0.98f;
Projectile.velocity.Y = Projectile.velocity.Y + MathHelper.Clamp(Projectile.ai[1] / 40, 0, 0.6f);
if (Projectile.velocity.Y > 16f)
{
Projectile.velocity.Y = 16f;
@@ -60,19 +90,93 @@ namespace CalamityMod.Projectiles.Rogue
}
}
public override bool PreDrawExtras()
{
CalamityUtils.DrawAfterimagesCentered(Projectile, 2, Color.Lerp(HighBlueColor, Color.Transparent, 0.8f), texture: ModContent.Request<Texture2D>(Texture).Value);
return base.PreDrawExtras();
}
public override void OnKill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Tink, Projectile.position);
//Dust on impact
int dust_splash = 0;
while (dust_splash < 9)
#region Long convoluted particle code
if (Projectile.Calamity().stealthStrike)
{
Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.DungeonSpirit, -Projectile.velocity.X * 0.15f, -Projectile.velocity.Y * 0.15f, 120, default, 1.5f);
dust_splash += 1;
float screenShakePower = 7 * Utils.GetLerpValue(1300f, 0f, Projectile.Distance(Main.LocalPlayer.Center), true);
if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenShakePower)
Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenShakePower;
Particle blastRing = new CustomPulse(
Projectile.Center,
Vector2.Zero,
Projectile.Calamity().stealthStrike ? Color.Black : LowBlueColor,
"CalamityMod/Particles/FlameExplosion",
Vector2.One,
Main.rand.NextFloat(-10, 10),
0.05f,
Projectile.Calamity().stealthStrike ? 0.5f : 0.2f,
15);
GeneralParticleHandler.SpawnParticle(blastRing);
Particle blastRing1 = new CustomPulse(
Projectile.Center,
Vector2.Zero,
LowBlueColor,
"CalamityMod/Particles/FlameExplosion",
Vector2.One,
Main.rand.NextFloat(-10, 10),
0.05f,
0.35f,
15);
GeneralParticleHandler.SpawnParticle(blastRing1);
Particle blastRing2 = new CustomPulse(
Projectile.Center,
Vector2.Zero,
LowBlueColor,
"CalamityMod/Particles/FlameExplosion",
new(1f, 0.5f),
0,
0.05f,
0.35f,
20);
GeneralParticleHandler.SpawnParticle(blastRing2);
}
GeneralParticleHandler.SpawnParticle(new CustomPulse(Projectile.Center, Vector2.Zero, LowBlueColor, "CalamityMod/Particles/LargeBloom", Vector2.One, 0f, 1f, 0f, 25));
GeneralParticleHandler.SpawnParticle(new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/LargeBloom", Vector2.One, 0f, 0.5f, 0f, 15));
for (int i = 0; i < 5; i++) GeneralParticleHandler.SpawnParticle(new BloodParticle2(Projectile.Center, new Vector2(Main.rand.NextFloat(6, 12), 0).RotatedBy(Main.rand.NextFloat(MathHelper.TwoPi)), 12, Main.rand.NextFloat(0.2f, 0.8f), HighBlueColor));
GlowSparkParticle gs = new GlowSparkParticle(Projectile.Center, Vector2.Zero, false, 20, Projectile.Calamity().stealthStrike ? 0.06f : 0.03f, HighBlueColor, Vector2.One, true);
gs.Rotation = Main.rand.NextFloat(-10, 10);
GeneralParticleHandler.SpawnParticle(gs);
#endregion
// Sounds
SoundEngine.PlaySound(AbyssGravel.MineSound, Projectile.position);
SoundEngine.PlaySound(GiantClam.SlamSound, Projectile.position);
SoundEngine.PlaySound(SoundID.DD2_ExplosiveTrapExplode.WithPitchOffset(0.5f), Projectile.position);
if (Projectile.Calamity().stealthStrike) SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/MineralMortarExplode"), Projectile.position);
// This only triggers if stealth is full
if (Projectile.Calamity().stealthStrike)
{
// Explosion damage
foreach (NPC npc in Main.npc)
{
if (npc.active && npc.Distance(Projectile.Center) < ExplosionRadius && !npc.justHit)
{
npc.AddBuff(ModContent.BuffType<CrushDepth>(), 240);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType<DirectStrike>(), ExplosionDamage, 0, Projectile.owner, npc.whoAmI);
}
}
int split = 0;
while (split < 5)
{
@@ -89,8 +193,11 @@ namespace CalamityMod.Projectiles.Rogue
shardspeedY += -Projectile.velocity.Y;
}
shardspeedX *= 2f;
shardspeedY *= 2f;
//Spawn the projectile
int shard = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X + shardspeedX, Projectile.position.Y + shardspeedY, shardspeedX, shardspeedY, ModContent.ProjectileType<ApoctolithShard>(), (int)(Projectile.damage * 0.5), Projectile.knockBack / 2f, Projectile.owner);
int shard = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X + shardspeedX, Projectile.position.Y + shardspeedY, shardspeedX, shardspeedY, ModContent.ProjectileType<ApoctolithShard>(), ShardDamage, Projectile.knockBack / 2f, Projectile.owner);
Main.projectile[shard].frame = Main.rand.Next(3);
split += 1;
}
+44 -6
View File
@@ -1,4 +1,10 @@
using CalamityMod.Buffs.DamageOverTime;
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Particles;
using CalamityMod.Tiles.Abyss;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
@@ -8,35 +14,62 @@ namespace CalamityMod.Projectiles.Rogue
{
public class ApoctolithShard : ModProjectile, ILocalizedModType
{
public int TimeBeforeHoming = 30;
public new string LocalizationCategory => "Projectiles.Rogue";
public override string Texture => "CalamityMod/Projectiles/Rogue/AbyssalMirrorProjectile";
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 5;
ProjectileID.Sets.TrailingMode[Projectile.type] = 2;
Main.projFrames[Projectile.type] = 3;
}
public override void SetDefaults()
{
TimeBeforeHoming = Main.rand.Next(30, 60);
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.width = 13;
Projectile.scale = Main.rand.NextFloat(0.7f, 1.2f);
Projectile.height = 13;
Projectile.DamageType = RogueDamageClass.Instance;
}
public override bool? CanDamage()
{
if (Projectile.ai[1] < TimeBeforeHoming) return false;
return base.CanDamage();
}
public override void AI()
{
Projectile.ai[1]++;
//Rotation and gravity
Projectile.rotation += 0.6f * Projectile.direction;
Projectile.velocity.Y += 0.27f;
if (Projectile.velocity.Y > 16f)
if (Projectile.ai[1] < TimeBeforeHoming)
{
Projectile.velocity.Y = 16f;
Projectile.velocity *= 0.94f;
}
else
{
Projectile.ai[2] = MathHelper.Lerp(Projectile.ai[2], 10, 0.05f);
CalamityUtils.HomeInOnNPC(Projectile, false, 400, Projectile.ai[2], 0.2f);
Projectile.velocity.Y += 0.4f;
}
}
public override bool PreDraw(ref Color lightColor)
{
Asset<Texture2D> tex = ModContent.Request<Texture2D>(Texture);
Rectangle fr = tex.Frame(1, 3, 0, Projectile.frame, 0, 0);
CalamityUtils.DrawAfterimagesCentered(Projectile, 2, Color.Lerp(ApoctolithProj.HighBlueColor, Color.Transparent, 0.8f), texture: tex.Value);
float a = Math.Clamp(MathHelper.Lerp(255f, 0f, Projectile.ai[1] / (float)TimeBeforeHoming), 0, 1);
Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, fr, ApoctolithProj.HighBlueColor.MultiplyRGBA(new Color(a, a, a, 0)), Projectile.rotation, new(fr.Width / 2, fr.Height / 2), 1.35f, SpriteEffects.None);
return base.PreDraw(ref lightColor);
}
public override void OnKill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Dig, Projectile.position);
SoundEngine.PlaySound(AbyssGravel.MineSound, Projectile.position);
//Dust effect
int splash = 0;
while (splash < 4)
@@ -44,6 +77,11 @@ namespace CalamityMod.Projectiles.Rogue
Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.IceRod, -Projectile.velocity.X * 0.15f, -Projectile.velocity.Y * 0.10f, 150, default, 0.9f);
splash += 1;
}
GeneralParticleHandler.SpawnParticle(new CustomPulse(Projectile.Center, Vector2.Zero, ApoctolithProj.LowBlueColor, "CalamityMod/Particles/LargeBloom", Vector2.One, 0f, 0.3f, 0f, 25));
GeneralParticleHandler.SpawnParticle(new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/LargeBloom", Vector2.One, 0f, 0.15f, 0f, 15));
for (int i = 0; i < 5; i++) GeneralParticleHandler.SpawnParticle(new BloodParticle2(Projectile.Center, new Vector2(Main.rand.NextFloat(6, 12), 0).RotatedBy(Main.rand.NextFloat(MathHelper.TwoPi)), 12, Main.rand.NextFloat(0.02f, 0.1f), ApoctolithProj.HighBlueColor));
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
+28 -15
View File
@@ -1,4 +1,7 @@
using CalamityMod.Items.Weapons.Rogue;
using System.Diagnostics;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
@@ -14,6 +17,7 @@ namespace CalamityMod.Projectiles.Rogue
public override void SetDefaults()
{
Projectile.width = 19;
Projectile.aiStyle = -1;
Projectile.height = 19;
Projectile.friendly = true;
Projectile.DamageType = RogueDamageClass.Instance;
@@ -21,9 +25,14 @@ namespace CalamityMod.Projectiles.Rogue
public override void AI()
{
Projectile.ai[0] = Projectile.Calamity().stealthStrike ? 1 : 0;
if (Main.rand.NextBool(3)) GeneralParticleHandler.SpawnParticle(new PointParticle(Projectile.Center, new Vector2(Main.rand.NextFloat(12), 0).RotatedBy(Vector2.Zero.AngleTo(Projectile.velocity) + MathHelper.ToRadians(Main.rand.NextFloat(-20, 20))), false, 10, Projectile.ai[0] == 1 ? 0.4f : 0.3f, Projectile.ai[0] == 1 ? Color.OrangeRed : Color.SaddleBrown, false, true));
Projectile.ai[1]++;
//Constant rotation and gravity
Projectile.rotation += 0.4f * Projectile.direction;
Projectile.velocity.Y = Projectile.velocity.Y + 0.3f;
Projectile.velocity.X *= 0.98f;
Projectile.velocity.Y = Projectile.velocity.Y + MathHelper.Clamp(Projectile.ai[1] / 40, 0, 0.6f);
if (Projectile.velocity.Y > 16f)
{
Projectile.velocity.Y = 16f;
@@ -37,35 +46,39 @@ namespace CalamityMod.Projectiles.Rogue
public override void OnKill(int timeLeft)
{
Projectile.ai[0] = Projectile.Calamity().stealthStrike ? 1 : 0;
SoundEngine.PlaySound(SoundID.Item50, Projectile.position);
SoundEngine.PlaySound(SoundID.Dig.WithPitchOffset(Main.rand.NextFloat(0.5f, 1f)), Projectile.position);
SoundEngine.PlaySound(SoundID.Dig.WithPitchOffset(Main.rand.NextFloat(-1f, -0.5f)), Projectile.position);
//Dust on impact
int dust_splash = 0;
while (dust_splash < 9)
{
Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Copper, -Projectile.velocity.X * 0.15f, -Projectile.velocity.Y * 0.15f, 120, default, 1.5f);
GeneralParticleHandler.SpawnParticle(new PointParticle(Projectile.Center, new Vector2(Main.rand.NextFloat(15), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Projectile.ai[0] == 1 ? 1.2f : 0.6f, Projectile.ai[0] == 1 ? Color.OrangeRed : Color.SaddleBrown, false, true));
Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Copper, 0f, 0f, 0, default, 0.5f);
dust_splash += 1;
}
// This only triggers if stealth is full
if (Projectile.ai[0] == 1)
{
dust_splash = 0;
while (dust_splash < 9)
{
GeneralParticleHandler.SpawnParticle(new PointParticle(Projectile.Center, new Vector2(Main.rand.NextFloat(24), 0).RotatedByRandom(MathHelper.TwoPi), false, 6, 0.6f, Color.SaddleBrown, false, true));
GeneralParticleHandler.SpawnParticle(new SmallSmokeParticle(Projectile.Center, new Vector2(Main.rand.NextFloat(10), 0).RotatedByRandom(MathHelper.TwoPi), Color.SaddleBrown, Color.SaddleBrown, Main.rand.NextFloat(1f, 1.5f), 150, affectedByLight: true));
dust_splash += 1;
}
int split = 0;
while (split < 5)
{
//Calculate the velocity of the projectile
float shardspeedX = -Projectile.velocity.X * Main.rand.NextFloat(.1f, .15f) + Main.rand.NextFloat(-3f, 3f);
float shardspeedY = -Projectile.velocity.Y * Main.rand.NextFloat(.5f, .9f) + Main.rand.NextFloat(-6f, -3f);
//Prevents the projectile speed from being too low
if (shardspeedX < 1f && shardspeedX > -1f)
{
shardspeedX += -Projectile.velocity.X;
}
if (shardspeedY > -3f)
{
shardspeedY += -Projectile.velocity.Y;
}
Vector2 shardspeed = new Vector2(Main.rand.Next(3, 8), 0).RotatedBy(Main.rand.NextFloat(MathHelper.TwoPi));
Vector2 speedAdd = -Projectile.velocity;
speedAdd.Normalize();
shardspeed += speedAdd * 9;
//Spawn the projectile
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X + shardspeedX, Projectile.position.Y + shardspeedY, shardspeedX, shardspeedY, ModContent.ProjectileType<BrickFragment>(), Projectile.damage / 2, Projectile.knockBack / 2f, Projectile.owner);
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position + shardspeed, shardspeed, ModContent.ProjectileType<BrickFragment>(), Projectile.damage / 2, Projectile.knockBack / 2f, Projectile.owner);
split += 1;
}
}
+16 -4
View File
@@ -1,4 +1,6 @@
using Terraria;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
@@ -15,14 +17,17 @@ namespace CalamityMod.Projectiles.Rogue
{
Projectile.friendly = true;
Projectile.width = 16;
Projectile.scale = Main.rand.NextFloat(0.4f, 0.8f);
Projectile.height = 16;
Projectile.DamageType = RogueDamageClass.Instance;
}
public override void AI()
{
Projectile.ai[0]++;
//Rotation and gravity
Projectile.rotation += 0.6f * Projectile.direction;
Projectile.velocity.Y = Projectile.velocity.Y + 0.27f;
Projectile.rotation += MathHelper.ToRadians(3f) * Projectile.direction;
Projectile.velocity.Y = Projectile.velocity.Y + 0.27f + MathHelper.Clamp(Projectile.ai[0] / 40, 0, 0.5f);
Projectile.velocity.X *= 0.97f;
if (Projectile.velocity.Y > 16f)
{
Projectile.velocity.Y = 16f;
@@ -31,7 +36,7 @@ namespace CalamityMod.Projectiles.Rogue
}
public override void OnKill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Dig, Projectile.position);
SoundEngine.PlaySound(SoundID.Dig.WithPitchOffset(Main.rand.NextFloat(0.5f)).WithVolumeScale(0.6f), Projectile.position);
//Dust effect
int splash = 0;
while (splash < 4)
@@ -39,6 +44,13 @@ namespace CalamityMod.Projectiles.Rogue
Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Copper, -Projectile.velocity.X * 0.15f, -Projectile.velocity.Y * 0.10f, 150, default, 0.9f);
splash += 1;
}
int dust_splash = 0;
while (dust_splash < 9)
{
GeneralParticleHandler.SpawnParticle(new PointParticle(Projectile.Center, new Vector2(Main.rand.NextFloat(8), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, 0.4f, Color.SaddleBrown, false, true));
Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Copper, 0f, 0f, 0, default, 0.5f);
dust_splash += 1;
}
}
}
}
+57
View File
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Terraria;
namespace CalamityMod.Utilities
{
public class ExtraArmAnimations
{
public static void ThrowArmAnimationSlow(Player player, Item item)
{
player.Calamity().mouseWorldListener = true;
Vector2 mW = player.Calamity().mouseWorld;
float value1 = player.direction * -90;
float value2 = player.direction * 180;
float value3 = player.direction * -240;
float g1 = (float)item.useAnimation;
float g2 = (float)player.itemAnimation;
float gg = g2 / g1;
player.direction = Math.Sign(mW.X - player.Center.X);
if (player.direction == 0) player.direction = 1;
player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, player.AngleTo(mW) + (player.direction == 1 ? MathHelper.ToRadians(180) : 0) + MathHelper.ToRadians(MathHelper.Lerp(value2, value1, CalamityUtils.SineInOutEasing(gg, 1))));
player.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, player.AngleTo(mW) + (player.direction == 1 ? MathHelper.ToRadians(180) : 0) + MathHelper.ToRadians(MathHelper.Lerp(value1, value3, CalamityUtils.SineInOutEasing(gg, 1))));
}
public static void ThrowArmAnimationFast(Player player, Item item)
{
player.Calamity().mouseWorldListener = true;
Vector2 mW = player.Calamity().mouseWorld;
float value1 = player.direction * -90;
float value2 = player.direction * 180;
float value3 = player.direction * -240;
float g1 = (float)item.useAnimation;
float g2 = (float)player.itemAnimation;
float gg = g2 / g1;
player.direction = Math.Sign(mW.X - player.Center.X);
if (player.direction == 0) player.direction = 1;
player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, player.AngleTo(mW) + (player.direction == 1 ? MathHelper.ToRadians(180) : 0) + MathHelper.ToRadians(MathHelper.Lerp(value2, value1, CalamityUtils.CircInEasing(gg, 1))));
player.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, player.AngleTo(mW) + (player.direction == 1 ? MathHelper.ToRadians(180) : 0) + MathHelper.ToRadians(MathHelper.Lerp(value1, value3, CalamityUtils.CircInEasing(gg, 1))));
}
}
}