Drainnn ganggg & sounds

This commit is contained in:
IbanPlay authored and Cameron Ewell committed 2022-07-11 19:05:37 -04:00
1 parent 1dccffd387
commit 0bc7a82d44
15 files changed
+568 -51

No files matched your search

+65 -11
View File
@@ -18,6 +18,7 @@ using Terraria.ModLoader;
using Terraria.ModLoader.IO;
using Terraria.GameContent;
using ReLogic.Content;
using System.Linq;
namespace CalamityMod.Items.Weapons.Magic
{
@@ -27,11 +28,14 @@ namespace CalamityMod.Items.Weapons.Magic
public static readonly SoundStyle ShootSound = new("CalamityMod/Sounds/Item/WulfrumProthesisShoot") { PitchVariance = 0.1f, Volume = 0.55f };
public static readonly SoundStyle HitSound = new("CalamityMod/Sounds/Item/WulfrumProthesisHit") { PitchVariance = 0.1f, Volume = 0.75f , MaxInstances = 3};
public static readonly SoundStyle SuckSound = new("CalamityMod/Sounds/Item/WulfrumProthesisSucc") { Volume = 0.5f };
public static readonly SoundStyle SuckStopSound = new("CalamityMod/Sounds/Item/WulfrumProthesisSuccStop") { Volume = 0.5f };
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Wulfrum Prothesis");
Tooltip.SetDefault("Casts a wulfrum bolt");
Tooltip.SetDefault("Casts a wulfrum bolt\n" +
"Right click to drain mana from creatures in front of you");
//Lore about how magic is not always a given for everyone, and how some unlucky people sometimes resort to voluntarily cutting their limbs to use magic augmented prothesis
//1 : Informs about magic as a narrative thing, 2 : Informs about wulfrum energy being partly magical.
SacrificeTotal = 1;
@@ -43,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Magic
public override void SetDefaults()
{
Item.damage = 13;
Item.damage = 15;
Item.DamageType = DamageClass.Magic;
Item.mana = 2;
Item.width = 34;
@@ -58,13 +62,37 @@ namespace CalamityMod.Items.Weapons.Magic
Item.UseSound = ShootSound;
Item.autoReuse = true;
Item.shoot = ModContent.ProjectileType<WulfrumBolt>();
Item.shootSpeed = 17f;
Item.shootSpeed = 18f;
Item.holdStyle = 16; //Custom hold style
}
public override void HoldItem(Player player)
{
player.Calamity().mouseWorldListener = true;
player.Calamity().rightClickListener = true;
}
public override bool CanUseItem(Player player) => !Main.projectile.Any(n => n.active && n.owner == player.whoAmI && n.type == ModContent.ProjectileType<WulfrumManaDrain>());
public override bool AltFunctionUse(Player player) => true;
public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback)
{
if (player.altFunctionUse == 2)
type = ModContent.ProjectileType<WulfrumManaDrain>();
}
public override void ModifyManaCost(Player player, ref float reduce, ref float mult)
{
if (player.altFunctionUse == 2)
mult = 0f;
}
public override void UseAnimation(Player player)
{
Item.UseSound = ShootSound;
if (player.altFunctionUse == 2)
Item.UseSound = null;
}
public void SetItemInHand(Player player, Rectangle heldItemFrame)
@@ -93,20 +121,20 @@ namespace CalamityMod.Items.Weapons.Magic
if (animProgress < 0.4f)
itemRotation += -0.45f * (float)Math.Pow((0.4f - animProgress) / 0.4f, 2) * player.direction * player.gravDir;
//Shakezzz
if (player.itemTime == 1 && Main.projectile.Any(n => n.active && n.owner == player.whoAmI && n.type == ModContent.ProjectileType<WulfrumManaDrain>()))
{
itemPosition += Main.rand.NextVector2Circular(2f, 2f);
}
Vector2 itemSize = new Vector2(28, 14);
Vector2 itemOrigin = new Vector2(-8, 0);
CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin, true);
}
public void SetPlayerArms(Player player)
{
}
public override void HoldStyle(Player player, Rectangle heldItemFrame) => SetItemInHand(player, heldItemFrame);
public override void UseStyle(Player player, Rectangle heldItemFrame) => SetItemInHand(player, heldItemFrame);
public override void HoldItemFrame(Player player) => SetPlayerArms(player);
public override void UseItemFrame(Player player) => SetPlayerArms(player);
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
{
@@ -115,7 +143,7 @@ namespace CalamityMod.Items.Weapons.Magic
Texture2D properSprite = RealSprite.Value;
spriteBatch.DrawNewInventorySprite(properSprite, new Vector2(28f, 14f), position, drawColor, origin, scale);
spriteBatch.DrawNewInventorySprite(properSprite, new Vector2(28f, 14f), position, drawColor, origin, scale, new Vector2(0, -6f));
return false;
}
@@ -140,4 +168,30 @@ namespace CalamityMod.Items.Weapons.Magic
Register();
}
}
public class WulfrumProthesisPlayer : ModPlayer
{
public bool ManaDrainActive = false;
public override void ResetEffects()
{
}
public override void UpdateDead()
{
ManaDrainActive = false;
}
public override void PostUpdateMiscEffects()
{
if (ManaDrainActive)
{
Player.manaRegenBonus = 35;
Player.manaRegenDelay = 0;
Player.manaRegenBuff = true;
}
ManaDrainActive = false;
}
}
}
+16
View File
@@ -1,10 +1,18 @@
using Microsoft.Xna.Framework;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
using System;
using ReLogic.Utilities;
using Terraria;
namespace CalamityMod.NPCs.NormalNPCs
{
public class SuperDummyNPC : ModNPC
{
public static readonly SoundStyle HummSound = new("CalamityMod/Sounds/Item/WulfrumProthesisSucc") { IsLooped = true };
private SlotId IdleSoundSlot;
public override void SetStaticDefaults()
{
this.HideFromBestiary();
@@ -27,6 +35,14 @@ namespace CalamityMod.NPCs.NormalNPCs
NPC.aiStyle = 0;
}
public override void AI()
{
}
public override void OnKill()
{
}
public override void UpdateLifeRegen(ref int damage)
{
NPC.lifeRegen += 2000000;
Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

+62
View File
@@ -0,0 +1,62 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
using System;
namespace CalamityMod.Particles
{
public class ManaDrainBlob : Particle
{
public override bool SetLifetime => false;
public override string Texture => "CalamityMod/Particles/MicroBloom";
public override bool UseAdditiveBlend => true;
public override int FrameVariants => 2;
public Player Owner;
public ManaDrainBlob(Player owner, Vector2 position, Vector2 speed, float scale, Color color)
{
Owner = owner;
Position = position;
Scale = Math.Min(scale, 1f);
Color = color;
Velocity = speed;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Variant = Main.rand.Next(2);
}
public override void Update()
{
Scale -= 0.02f;
if (Scale < 0.1f)
Kill();
Scale += 0.007f;
if (Owner != null && Owner.active)
{
Vector2 speedDirection = Position - Owner.Center;
float distanceToOwner = speedDirection.Length();
distanceToOwner = 100f - distanceToOwner;
if (distanceToOwner > 0f)
Scale -= distanceToOwner * 0.0015f;
speedDirection.Normalize();
float dustAcceleration = (1f - Scale) * -20f;
speedDirection *= dustAcceleration;
Velocity = (Velocity * 4f + speedDirection) / 5f;
if (Main.rand.NextBool(7))
{
Dust chust = Dust.NewDustPerfect(Position, 15, Velocity * Main.rand.NextFloat(0.7f, 1.2f), Alpha: 100, Scale: Main.rand.NextFloat(1.2f, 1.8f));
chust.noGravity = true;
chust.noLight = true;
}
}
Rotation += 0.04f * ((Velocity.X > 0) ? 1f : -1f);
}
}
}
+62
View File
@@ -0,0 +1,62 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
using System;
namespace CalamityMod.Particles
{
public class ManaDrainStreak : Particle
{
public override string Texture => "CalamityMod/Particles/DrainLineBloom";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
public Player Owner;
public float StartDistanceFromPlayer;
public float FinalDistanceFromPlayer;
public Color StartColor;
public Color EndColor;
public ManaDrainStreak(Player owner, float thickness, Vector2 startVector, float finalDistance, Color colorStart, Color colorEnd, int lifetime)
{
Owner = owner;
Scale = thickness;
Velocity = Vector2.Zero;
Rotation = startVector.ToRotation();
StartDistanceFromPlayer = startVector.Length();
FinalDistanceFromPlayer = finalDistance;
StartColor = colorStart;
EndColor = colorEnd;
Color = colorStart;
Lifetime = lifetime;
}
public override void Update()
{
if (Owner == null || !Owner.active || Owner.dead)
return;
Position = Owner.MountedCenter + Rotation.ToRotationVector2() * MathHelper.Lerp(StartDistanceFromPlayer, FinalDistanceFromPlayer, (float)Math.Pow(LifetimeCompletion, 2));
Color = Color.Lerp(StartColor, EndColor, LifetimeCompletion);
Lighting.AddLight(Position, Color.ToVector3());
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D tex = ModContent.Request<Texture2D>(Texture).Value;
float currentDisplace = MathHelper.Lerp(StartDistanceFromPlayer, FinalDistanceFromPlayer, (float)Math.Pow(LifetimeCompletion, 2));
float earlierDisplace = MathHelper.Lerp(StartDistanceFromPlayer, FinalDistanceFromPlayer, (float)Math.Pow(Math.Clamp(LifetimeCompletion - 0.2f, 0f, 1f), 2));
float lenght = (currentDisplace - earlierDisplace) / tex.Height;
Vector2 scale = new Vector2(Scale, lenght);
Vector2 origin = new Vector2(tex.Width / 2f, tex.Height);
spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color, Rotation - MathHelper.PiOver2, origin, scale, SpriteEffects.None, 0);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

+73
View File
@@ -0,0 +1,73 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
using System;
using Microsoft.Xna.Framework.Graphics;
namespace CalamityMod.Particles
{
public class TechyHoloysquareParticle : Particle
{
public override bool SetLifetime => true;
public override string Texture => "CalamityMod/Particles/TechyHolosquare";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
internal Rectangle Frame;
public float Opacity;
public TechyHoloysquareParticle(Vector2 position, Vector2 speed, float scale, Color color, float opacity = 1f)
{
Position = position;
Scale = scale;
Color = color;
Velocity = speed;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Opacity = opacity;
Variant = Main.rand.Next(6);
Lifetime = 25;
switch (Variant)
{
case 0:
Frame = new Rectangle(8, 0, 6, 6);
break;
case 1:
Frame = new Rectangle(6, 8, 10, 6);
break;
case 2:
Frame = new Rectangle(4, 16, 14, 8);
break;
case 3:
Frame = new Rectangle(2, 26, 18, 10);
break;
case 4:
Frame = new Rectangle(2, 38, 18, 8);
break;
case 5:
Frame = new Rectangle(6, 48, 12, 12);
break;
}
}
public override void Update()
{
Opacity = (float)Math.Pow(LifetimeCompletion, 0.5f);
Lighting.AddLight(Position, Color.ToVector3() * Opacity);
Rotation = Velocity.ToRotation();
Velocity *= 0.875f;
Scale *= 0.96f;
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D baseTex = GeneralParticleHandler.GetTexture(Type);
CalamityUtils.DrawChromaticAberration(Vector2.UnitX.RotatedBy(Rotation), 1.5f, delegate (Vector2 offset, Color colorMod)
{
spriteBatch.Draw(baseTex, Position + offset - Main.screenPosition, Frame, Color.MultiplyRGB(colorMod) * Opacity, Rotation, Frame.Size() / 2, Scale / 2f, SpriteEffects.None, 0);
});
}
}
}
+61 -33
View File
@@ -1,31 +1,14 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Magic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
using System;
using System.IO;
using CalamityMod.Items.Materials;
using System;
using CalamityMod.Items.Weapons.Magic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using static CalamityMod.CalamityUtils;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
using Terraria.GameContent;
using ReLogic.Content;
using CalamityMod.Items.Weapons.Magic;
using Terraria.Graphics.Shaders;
using static Terraria.ModLoader.ModContent;
using CalamityMod.Particles;
namespace CalamityMod.Projectiles.Magic
{
@@ -55,6 +38,7 @@ namespace CalamityMod.Projectiles.Magic
public static float HomingAngle = MathHelper.PiOver4 * 1.65f;
internal PrimitiveTrail TrailDrawer;
internal Color PrimColorMult = Color.White;
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
@@ -62,7 +46,7 @@ namespace CalamityMod.Projectiles.Magic
{
DisplayName.SetDefault("Bolt");
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 16;
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 20;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
@@ -76,6 +60,9 @@ namespace CalamityMod.Projectiles.Magic
Projectile.DamageType = DamageClass.Magic;
Projectile.timeLeft = 140;
Projectile.extraUpdates = 2;
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 20;
}
public NPC FindTarget()
@@ -154,9 +141,10 @@ namespace CalamityMod.Projectiles.Magic
*/
}
Projectile.velocity *= 0.98f;
Projectile.velocity *= 0.983f;
Projectile.velocity = Projectile.rotation.ToRotationVector2() * Projectile.velocity.Length();
//Blast off.
if (Projectile.timeLeft == 140)
{
Vector2 dustCenter = Projectile.Center + Projectile.velocity * 1f;
@@ -170,12 +158,30 @@ namespace CalamityMod.Projectiles.Magic
if (Projectile.timeLeft <= 137)
{
for (int num151 = 0; num151 < 3; num151++)
if (Main.rand.NextBool())
{
int num154 = 14;
int num155 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width - num154 * 2, Projectile.height - num154 * 2, 61, 0f, 0f, 100, default, 3f);
Main.dust[num155].noGravity = true;
Main.dust[num155].noLight = true;
Vector2 dustCenter = Projectile.Center + Projectile.velocity.RotatedBy(MathHelper.PiOver2).SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(-3f, 3f);
Dust chust = Dust.NewDustPerfect(dustCenter, 15, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.5f), Scale: Main.rand.NextFloat(1.2f, 1.8f));
chust.noGravity = true;
}
if (Main.rand.NextBool(4))
{
Vector2 dustCenter = Projectile.Center + Projectile.velocity.RotatedBy(MathHelper.PiOver2).SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(-3f, 3f);
Dust largeDust = Dust.NewDustPerfect(dustCenter, 257, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.4f), Scale: Main.rand.NextFloat(0.4f, 1f));
largeDust.noGravity = true;
largeDust.noLight = true;
}
if (Main.rand.NextBool(5))
{
Vector2 center = Projectile.Center + Projectile.velocity.RotatedBy(MathHelper.PiOver2).SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(-3f, 3f);
Vector2 velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(MathHelper.Pi / 6f) * Main.rand.NextFloat(4, 10);
GeneralParticleHandler.SpawnParticle(new TechyHoloysquareParticle(center, velocity, Main.rand.NextFloat(1f, 2f), Main.rand.NextBool() ? new Color(99, 255, 229) : new Color(25, 132, 247), 25));
}
}
}
@@ -183,24 +189,36 @@ namespace CalamityMod.Projectiles.Magic
internal Color ColorFunction(float completionRatio)
{
float fadeOpacity = (float)Math.Sqrt(1 - completionRatio);
return Color.GreenYellow * fadeOpacity;
return Color.DeepSkyBlue.MultiplyRGB(PrimColorMult) * fadeOpacity;
}
internal float WidthFunction(float completionRatio)
{
return 7.4f;
return 9.4f;
}
public override bool PreDraw(ref Color lightColor)
{
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request<Texture2D>("CalamityMod/ExtraTextures/BasicTrail"));
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 30);
Texture2D tex = ModContent.Request<Texture2D>(Texture).Value;
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0);
CalamityUtils.DrawChromaticAberration(Vector2.UnitX, 3.5f, delegate (Vector2 offset, Color colorMod)
{
PrimColorMult = colorMod;
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition + offset, 30);
});
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
return false;
}
@@ -215,5 +233,15 @@ namespace CalamityMod.Projectiles.Magic
return base.OnTileCollide(oldVelocity);
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
int numParticles = Main.rand.Next(4, 7);
for (int i = 0; i < numParticles; i++)
{
Vector2 velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(MathHelper.Pi / 6f) * Main.rand.NextFloat(3, 14);
GeneralParticleHandler.SpawnParticle(new TechyHoloysquareParticle(target.Center, velocity, Main.rand.NextFloat(2.5f, 3f), Main.rand.NextBool() ? new Color(99, 255, 229) : new Color(25, 132, 247), 25));
}
}
}
}
+181
View File
@@ -0,0 +1,181 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Magic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
using System;
using System.IO;
using CalamityMod.Items.Materials;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using static CalamityMod.CalamityUtils;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
using Terraria.GameContent;
using ReLogic.Content;
using CalamityMod.Items.Weapons.Magic;
using Terraria.Graphics.Shaders;
using static Terraria.ModLoader.ModContent;
using CalamityMod.Dusts;
using CalamityMod.Particles;
using ReLogic.Utilities;
namespace CalamityMod.Projectiles.Magic
{
public class WulfrumManaDrain : ModProjectile
{
private SlotId SuccSoundSlot;
public Player Owner => Main.player[Projectile.owner];
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public ref float Timer => ref Projectile.ai[0];
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Mana Drain");
}
public override void SetDefaults()
{
Projectile.width = 8;
Projectile.height = 8;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.penetrate = -1;
Projectile.DamageType = DamageClass.Magic;
Projectile.timeLeft = 2;
}
public override bool ShouldUpdatePosition() => false;
public override bool? CanDamage() => false;
public override void AI()
{
Owner.itemTime = 2;
Owner.itemAnimation = 2;
if (!Owner.Calamity().mouseRight || Owner.dead || Owner.frozen || !Owner.active || Owner.statMana == Owner.statManaMax2)
return;
//Once again the sound volume scaling does NOT work for whatever reason? Help.
if (!SoundEngine.TryGetActiveSound(SuccSoundSlot, out var idleSoundOut) || !idleSoundOut.IsPlaying)
{
SuccSoundSlot = SoundEngine.PlaySound(WulfrumProthesis.SuckSound with { Volume = WulfrumProthesis.SuckSound.Volume * 0.01f ,IsLooped = true }, Owner.Center);
}
else if (idleSoundOut != null)
{
idleSoundOut.Position = Owner.Center;
idleSoundOut.Volume = Math.Clamp((Timer / 30f) + 0.001f, 0f, 1f) * 100f;
}
Projectile.timeLeft = 2;
Projectile.Center = Owner.MountedCenter;
Projectile.velocity = (Owner.Calamity().mouseWorld - Owner.MountedCenter).SafeNormalize(Vector2.One);
if (Main.rand.NextBool(6))
{
Particle streak = new ManaDrainStreak(Owner, Main.rand.NextFloat(0.2f, 0.5f), Projectile.velocity.RotatedByRandom(MathHelper.PiOver2 * 0.6f) * Main.rand.NextFloat(70f, 150f), Main.rand.NextFloat(30f, 44f), Color.GreenYellow, Color.DeepSkyBlue, Main.rand.Next(13, 20));
GeneralParticleHandler.SpawnParticle(streak);
}
NPC target = GetSuccTarget();
if (target != null)
{
Owner.GetModPlayer<WulfrumProthesisPlayer>().ManaDrainActive = true;
if (!Main.rand.NextBool(3))
{
Vector2 center = target.Center;
center.X += (float)Main.rand.Next(-100, 100) * 0.1f;
center.Y += (float)Main.rand.Next(-100, 100) * 0.1f;
center += target.velocity;
//Drain ganggg
Particle bloom = new ManaDrainBlob(Owner, center, Main.rand.NextVector2Circular(4f, 4f), Main.rand.NextFloat(0.7f, 0.9f), Color.DeepSkyBlue);
GeneralParticleHandler.SpawnParticle(bloom);
}
}
Timer++;
}
public NPC GetSuccTarget()
{
float collisionPoint = 0f;
for (int i = 0; i < Main.maxNPCs; i++)
{
NPC struckNPC = Main.npc[i];
if (!struckNPC.active || struckNPC.townNPC || struckNPC.friendly)
continue;
float distance = struckNPC.Distance(Projectile.Center);
float extraDistance = struckNPC.width / 2 + struckNPC.height / 2;
if (distance - extraDistance < 400f)
{
if (!Collision.CheckAABBvLineCollision(struckNPC.Hitbox.TopLeft(), struckNPC.Hitbox.Size(), Owner.MountedCenter, Owner.MountedCenter + Projectile.velocity * 400f, 110f, ref collisionPoint))
continue;
if (!Collision.CanHit(Projectile.Center, 1, 1, struckNPC.Center, 1, 1) && extraDistance < distance)
continue;
return struckNPC;
}
}
return null;
}
public override void Kill(int timeLeft)
{
if (Timer > 2)
{
NPC target = GetSuccTarget();
if (target != null)
{
int particlesCount = Main.rand.Next(5, 10);
for (int i = 0; i < particlesCount; i++)
{
Vector2 center = target.Center;
center.X += (float)Main.rand.Next(-100, 100) * 0.1f;
center.Y += (float)Main.rand.Next(-100, 100) * 0.1f;
center += target.velocity;
//Drain ganggg
Particle bloom = new ManaDrainBlob(Owner, center, Main.rand.NextVector2Circular(4f, 4f), Main.rand.NextFloat(0.76f, 1f), Color.DeepSkyBlue);
GeneralParticleHandler.SpawnParticle(bloom);
}
}
}
if (SoundEngine.TryGetActiveSound(SuccSoundSlot, out var soundOut))
{
soundOut.Stop();
SoundEngine.PlaySound(WulfrumProthesis.SuckStopSound with { Volume = WulfrumProthesis.SuckStopSound.Volume * Timer / 30f}, Projectile.Center);
}
}
}
}
@@ -63,6 +63,7 @@ namespace CalamityMod.Projectiles.Typeless
Projectile.friendly = true;
Projectile.penetrate = -1;
Projectile.timeLeft = Lifetime;
Projectile.netImportant = true;
}
public override bool? CanDamage() => false;
@@ -90,20 +91,20 @@ namespace CalamityMod.Projectiles.Typeless
IdlingSoundSlot = SoundEngine.PlaySound(IdleSound with { Volume = IdleSound.Volume }, Projectile.Center);
else if (idleSoundOut != null)
{
//idleSoundOut.Volume = IdleSound.Volume * (1 - CuttingVolume);
idleSoundOut.Volume = (1 - CuttingVolume);
idleSoundOut.Position = Projectile.Center;
}
/*
//Heavy cutting sound
if ((!SoundEngine.TryGetActiveSound(CuttingSoundSlot, out var cuttingSoundOut) || !cuttingSoundOut.IsPlaying))
CuttingSoundSlot = SoundEngine.PlaySound(CuttingSound with { Volume = CuttingSound.Volume * CuttingVolume }, Projectile.Center);
CuttingSoundSlot = SoundEngine.PlaySound(CuttingSound with { Volume = CuttingSound.Volume }, Projectile.Center);
else if (cuttingSoundOut != null)
{
cuttingSoundOut.Volume = CuttingSound.Volume * CuttingVolume;
cuttingSoundOut.Volume = CuttingVolume;
cuttingSoundOut.Position = Projectile.Center;
}
*/
if (Diggging)
Binary file not shown.
Binary file not shown.
+42 -2
View File
@@ -686,8 +686,14 @@ namespace CalamityMod
/// <param name="drawColor"></param>
/// <param name="origin"></param>
/// <param name="scale"></param>
public static void DrawNewInventorySprite(this SpriteBatch spriteBatch, Texture2D newTexture, Vector2 originalSize, Vector2 position, Color drawColor, Vector2 origin, float scale)
public static void DrawNewInventorySprite(this SpriteBatch spriteBatch, Texture2D newTexture, Vector2 originalSize, Vector2 position, Color drawColor, Vector2 origin, float scale, Vector2? offset = null)
{
Vector2 extraOffset;
if (offset == null)
extraOffset = Vector2.Zero;
else
extraOffset = offset.GetValueOrDefault();
float largestDimensionOriginal = Math.Max(originalSize.X, originalSize.Y);
float largestDimensionNew = Math.Max(newTexture.Width, newTexture.Height);
@@ -702,7 +708,41 @@ namespace CalamityMod
positionOffset *= scale;
spriteBatch.Draw(newTexture, position + positionOffset, null, drawColor, 0f, origin, scale * scaleRatio, 0, 0);
spriteBatch.Draw(newTexture, position + positionOffset + extraOffset, null, drawColor, 0f, origin, scale * scaleRatio, 0, 0);
}
public delegate void ChromaAbberationDelegate(Vector2 offset, Color colorMult);
//Thanks spirit <3
/// <summary>
/// Draws a chromatic abberation effect.
/// </summary>
/// <param name="direction">The direction of the abberation</param>
/// <param name="strength">The strenght of the abberation</param>
/// <param name="action">The draw call itself.</param>
public static void DrawChromaticAberration(Vector2 direction, float strength, ChromaAbberationDelegate drawCall)
{
for (int i = -1; i <= 1; i++)
{
Color aberrationColor = Color.White;
switch (i)
{
case -1:
aberrationColor = new Color(255, 0, 0, 0);
break;
case 0:
aberrationColor = new Color(0, 255, 0, 0);
break;
case 1:
aberrationColor = new Color(0, 0, 255, 0);
break;
}
Vector2 offset = direction.RotatedBy(MathHelper.PiOver2) * i;
offset *= strength;
drawCall.Invoke(offset, aberrationColor);
}
}
}
}