Ontological Despoiler P1

no full charges yet
This commit is contained in:
Xyk committed 2024-08-26 15:59:11 -07:00
1 parent 7453cf6f2f
commit c30fc6406b
23 files changed
+1259 -175

No files matched your search

+1
View File
@@ -195,6 +195,7 @@ namespace CalamityMod.CalPlayer
public int PHAThammer = 0;
public int StellarHammer = 0;
public int GalaxyHammer = 0;
public bool despoilerNerf = false;
public int NorfleetCounter = 0;
public int hideOfDeusMeleeBoostTimer = 0;
public int alcoholPoisonLevel = 0;
@@ -1,61 +0,0 @@
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Ranged;
using CalamityMod.Rarities;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Ranged
{
public class MolecularManipulator : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.Ranged";
public override void SetStaticDefaults()
{
ItemID.Sets.IsRangedSpecialistWeapon[Item.type] = true;
}
public override void SetDefaults()
{
Item.width = 56;
Item.height = 34;
Item.damage = 580;
Item.DamageType = DamageClass.Ranged;
Item.useTime = 20;
Item.useAnimation = 20;
Item.useStyle = ItemUseStyleID.Shoot;
Item.noMelee = true;
Item.knockBack = 8f;
Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice;
Item.rare = ModContent.RarityType<Turquoise>();
Item.UseSound = SoundID.Item33;
Item.autoReuse = true;
Item.shootSpeed = 25f;
Item.shoot = ModContent.ProjectileType<NullShot2>();
Item.Calamity().canFirePointBlankShots = true;
}
public override Vector2? HoldoutOffset()
{
return new Vector2(-5, 0);
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType<NullShot2>(), damage, knockback, player.whoAmI);
return false;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<NullificationPistol>().
AddIngredient<DarkPlasma>(2).
AddIngredient<CoreofCalamity>().
AddTile(TileID.LunarCraftingStation).
Register();
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 837 B

+8 -8
View File
@@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Ranged
public class NullificationPistol : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.Ranged";
public bool ShotType = true;
public bool shotType = true; // true = positive shot, false = negative shot
public float mult = 0;
public override void SetStaticDefaults()
@@ -45,7 +45,7 @@ namespace CalamityMod.Items.Weapons.Ranged
if (player.altFunctionUse == 2)
return 1.3f;
if (!ShotType)
if (!shotType)
return 1.5f - mult;
return 1f - mult;
@@ -55,18 +55,18 @@ namespace CalamityMod.Items.Weapons.Ranged
if (player.altFunctionUse == 2)
{
SoundStyle fire = new("CalamityMod/Sounds/Item/DudFire");
SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = -0.5f + (ShotType ? 0.5f : 0) }, position);
SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = -0.5f + (shotType ? 0.5f : 0) }, position);
for (int i = 0; i < 18; i++)
{
Dust dust = Dust.NewDustPerfect(position, ShotType ? ModContent.DustType<VoidDust>() : ModContent.DustType<LightDust>(), (velocity).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f));
Dust dust = Dust.NewDustPerfect(position, shotType ? ModContent.DustType<VoidDust>() : ModContent.DustType<LightDust>(), (velocity).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(0.9f, 1.25f);
dust.color = ShotType ? Color.White : (Main.rand.NextBool() ? Color.Orchid : Color.Turquoise);
dust.color = shotType ? Color.White : (Main.rand.NextBool() ? Color.Orchid : Color.Turquoise);
}
ShotType = !ShotType;
shotType = !shotType;
mult = 0;
}
else if (ShotType)
else if (shotType)
{
for (int i = 0; i < 3; i++)
Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType<NullShot>(), damage / 3, 0, player.whoAmI, 0, 0, i);
@@ -85,7 +85,7 @@ namespace CalamityMod.Items.Weapons.Ranged
if (player.altFunctionUse != 2)
{
SoundStyle fire = new("CalamityMod/Sounds/Item/NullShot");
SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = Main.rand.NextFloat(0f, 0.2f) + (!ShotType ? 0.3f : 0) }, position);
SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = Main.rand.NextFloat(0f, 0.2f) + (!shotType ? 0.3f : 0) }, position);
}
return false;
}
@@ -0,0 +1,104 @@
using System.Linq;
using CalamityMod.Dusts;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Ranged;
using CalamityMod.Rarities;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Ranged
{
[LegacyName("MolecularManipulator")]
public class OntologicalDespoiler : ModItem, ILocalizedModType
{
public static readonly SoundStyle ChargeLV1 = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeLV1") { Volume = 0.6f };
public static readonly SoundStyle ChargeLV2 = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeLV2") { Volume = 0.6f };
public static readonly SoundStyle ChargeStart = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeStart") { Volume = 0.6f };
public static readonly SoundStyle ChargeLoop = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeLoop") { Volume = 0.6f };
internal static readonly int ChargeLoopSoundFrames = 151;
public static readonly SoundStyle SmallShot = new("CalamityMod/Sounds/Item/ArcNovaDiffuserSmallShot") { PitchVariance = 0.3f };
public static readonly SoundStyle BigShot = new("CalamityMod/Sounds/Item/ArcNovaDiffuserBigShot") { PitchVariance = 0.3f };
public bool shotType = true; // true = positive shot, false = negative shot
public new string LocalizationCategory => "Items.Weapons.Ranged";
public override void SetStaticDefaults()
{
ItemID.Sets.IsRangedSpecialistWeapon[Type] = true;
}
public override void SetDefaults()
{
Item.width = 88;
Item.height = 34;
Item.damage = 772;
Item.DamageType = DamageClass.Ranged;
Item.useAnimation = Item.useTime = 8;
Item.noMelee = true;
Item.noUseGraphic = true;
Item.channel = true;
Item.useStyle = ItemUseStyleID.Shoot;
Item.knockBack = 6f;
Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice;
Item.rare = ModContent.RarityType<Turquoise>();
Item.UseSound = null;
Item.autoReuse = false;
Item.shoot = ModContent.ProjectileType<OntologicalDespoilerHoldout>();
Item.shootSpeed = 12f;
Item.Calamity().canFirePointBlankShots = true;
}
public override bool AltFunctionUse(Player player) => true;
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0;
public override void HoldItem(Player player)
{
if (player.whoAmI != Main.myPlayer)
return;
// Right-click channeling
player.Calamity().rightClickListener = true;
if (player.Calamity().mouseRight && CanUseItem(player) && !Main.mapFullscreen && !Main.blockMouse)
{
// Only one out at a time
if (Main.projectile.Any(n => n.active && n.type == Item.shoot && n.owner == player.whoAmI))
return;
var source = player.GetSource_ItemUse(player.ActiveItem());
Projectile holdout = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, Item.shoot, player.ActiveItem().damage, 0f, player.whoAmI, 0, 0, 10 + (shotType ? 5 : 0));
holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero);
SoundStyle fire = new("CalamityMod/Sounds/Item/DudFire");
SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = -0.5f + (shotType ? 0.5f : 0) }, player.Center);
shotType = !shotType;
}
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
// Only one out at a time
if (Main.projectile.Any(n => n.active && n.type == Item.shoot && n.owner == player.whoAmI))
return false;
Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, shotType ? 0 : 5);
holdout.velocity = player.Calamity().mouseWorld - player.RotatedRelativePoint(player.MountedCenter);
return false;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<ArcNovaDiffuser>().
AddIngredient<NullificationPistol>().
AddIngredient<DarkPlasma>(2).
AddIngredient<CoreofCalamity>().
AddTile(TileID.LunarCraftingStation).
Register();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

@@ -784,15 +784,6 @@ MineralMortar: {
'''
}
MolecularManipulator: {
DisplayName: Molecular Manipulator
Tooltip:
'''
Fires a fast null bullet that distorts NPC stats
'Is it nullable or not? Let's find out!'
'''
}
MonolithBow: {
DisplayName: Monolith Bow
Tooltip: ""
@@ -1448,3 +1439,8 @@ WulfrumBlunderbuss: {
[c/83B87E:In fact, it is quite common for a robot to be turned into ammo right after it stops functioning.']
'''
}
OntologicalDespoiler: {
DisplayName: Ontological Despoiler
Tooltip: ""
}
@@ -140,7 +140,6 @@ NovaChargedShot.DisplayName: Charged Nova Blast
NovaShot.DisplayName: Nova Bolt
Nuke.DisplayName: Nuke
NullShot.DisplayName: Null
NullShot2.DisplayName: Null
OpalChargedStrike.DisplayName: Charged Plasma Bolt
OpalStrike.DisplayName: Heated Bolt
PiercingBullet.DisplayName: Piercing Blow
@@ -248,3 +247,6 @@ HellbornProj.DisplayName: Hell-born Gunblast
HellbornShell.DisplayName: Hell's Shell
NullBurst.DisplayName: Null Burst
NullFlash.DisplayName: Null Flash
OntologicalDespoilerBeam.DisplayName: Ontological Despoiler Beam
OntologicalDespoilerGrenade.DisplayName: Ontological Despoiler Grenade
OntologicalDespoilerShot.DisplayName: Ontological Despoiler Shot
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

-96
View File
@@ -1,96 +0,0 @@
using CalamityMod.CalPlayer;
using CalamityMod.NPCs.NormalNPCs;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class NullShot2 : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Ranged";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetDefaults()
{
Projectile.width = 6;
Projectile.height = 6;
Projectile.friendly = true;
Projectile.penetrate = 1;
Projectile.timeLeft = 120;
Projectile.DamageType = DamageClass.Ranged;
Projectile.extraUpdates = 1;
Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration;
}
public override void AI()
{
Projectile.localAI[0] += 1f;
if (Projectile.localAI[0] > 3f)
{
for (int num134 = 0; num134 < 10; num134++)
{
float x = Projectile.position.X - Projectile.velocity.X / 10f * (float)num134;
float y = Projectile.position.Y - Projectile.velocity.Y / 10f * (float)num134;
int dust = Dust.NewDust(new Vector2(x, y), 1, 1, DustID.RainbowTorch, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f);
Main.dust[dust].alpha = Projectile.alpha;
Main.dust[dust].position.X = x;
Main.dust[dust].position.Y = y;
Main.dust[dust].velocity *= 0f;
Main.dust[dust].noGravity = true;
}
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
if (target.type == NPCID.TargetDummy)
{
return;
}
int randAmt = (CalamityPlayer.areThereAnyDamnBosses || CalamityLists.AquaticScourgeIDs.Contains(target.type)) ? 8 : 10;
int nullBuff = Main.rand.Next(randAmt);
if (!target.boss)
{
switch (nullBuff)
{
case 0:
if (target.type != ModContent.NPCType<SuperDummyNPC>())
target.damage += 20;
break;
case 1:
target.damage -= 20;
break;
case 2:
target.knockBackResist = 0f;
break;
case 3:
target.knockBackResist = 1f;
break;
case 4:
target.defense += 10;
break;
case 5:
target.defense -= 10;
break;
case 6:
target.velocity.Y = Main.rand.NextBool() ? 30f : -30f;
break;
case 7:
target.velocity.X = Main.rand.NextBool() ? 30f : -30f;
break;
case 8:
target.scale *= 5f;
break;
case 9:
target.scale *= 0.1f;
break;
default:
break;
}
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

@@ -0,0 +1,232 @@
using System;
using System.Collections.Generic;
using CalamityMod.CalPlayer;
using CalamityMod.Dusts;
using CalamityMod.NPCs;
using CalamityMod.NPCs.NormalNPCs;
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;
namespace CalamityMod.Projectiles.Ranged
{
public class OntologicalDespoilerBeam : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Ranged";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public ref float time => ref Projectile.ai[0];
public Color baseColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Main.DiscoR);
public int sineDir = 1;
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 25;
ProjectileID.Sets.TrailingMode[Projectile.type] = 2;
}
public override void SetDefaults()
{
Projectile.width = 28;
Projectile.height = 28;
Projectile.friendly = true;
Projectile.penetrate = -1;
Projectile.timeLeft = 400;
Projectile.DamageType = DamageClass.Ranged;
Projectile.extraUpdates = 4;
Projectile.tileCollide = false;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = -1;
}
public override void AI()
{
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
if (time == 0)
{
Projectile.scale = Projectile.ai[1] == 5 ? 2.2f : 1.5f;
sineDir = Main.rand.NextBool() ? 1 : -1;
}
float rate = (Main.GlobalTimeWrappedHourly * 5);
List<Color> eColors = new List<Color>()
{
Color.Turquoise,
Color.Orchid
};
int colorIndex = (int)(rate / 2 % eColors.Count);
Color currentColor = eColors[colorIndex];
Color nextColor = eColors[(colorIndex + 1) % eColors.Count];
if (!Main.zenithWorld)
baseColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f);
if (Projectile.ai[1] == 5 && !Main.zenithWorld)
baseColor = Color.White;
if (time == 5)
{
for (int i = 0; i < 4; i++)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, Projectile.ai[1] == 5 ? ModContent.DustType<VoidDust>() : ModContent.DustType<LightDust>(), (Projectile.velocity * 4).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.2f, 1f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(1.15f, 1.35f);
dust.color = baseColor;
}
}
if (time > 20)
{
if (Projectile.ai[1] == 5)
{
// Spawn in a helix-style pattern
float sine = (float)Math.Sin(Projectile.timeLeft * 0.575f / MathHelper.Pi);
Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 16f;
float scale = Main.rand.NextFloat(0.8f, 1.1f);
if (Main.rand.NextBool(2))
{
Dust dust2 = Dust.NewDustPerfect(Projectile.Center + offset * sineDir, Projectile.ai[1] == 5 ? ModContent.DustType<VoidDust>() : ModContent.DustType<LightDust>(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f));
dust2.noGravity = true;
dust2.scale = scale;
dust2.color = baseColor;
}
if (Main.rand.NextBool(2))
{
Dust dust3 = Dust.NewDustPerfect(Projectile.Center - offset * sineDir, /*Projectile.ai[1] == 5 ? ModContent.DustType<VoidDust>() : */ModContent.DustType<LightDust>(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f));
dust3.noGravity = true;
dust3.scale = scale;
dust3.color = baseColor;
}
}
else if (Main.rand.NextBool(13))
{
Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10), Projectile.ai[1] == 5 ? ModContent.DustType<VoidDust>() : ModContent.DustType<LightDust>(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(1.05f, 1.65f);
dust.color = baseColor;
}
}
if (time > 13 && time < 34 && Projectile.ai[2] > 0)
{
Projectile.Center += Projectile.velocity.RotatedBy((Projectile.ai[2] == 1 ? MathHelper.PiOver2 : -MathHelper.PiOver2)) * 0.2f;
}
if (Projectile.ai[1] == 5)
{
NPC targetedNPC = Projectile.Center.ClosestNPCAt(700);
if (targetedNPC != null && time > 30 && Projectile.numHits < 1 && Vector2.Distance(targetedNPC.Center, Projectile.Center) < 700)
{
Vector2 position = targetedNPC.Center;
Vector2 moveToMouse = (position - Projectile.Center).SafeNormalize(Vector2.UnitX);
if (Projectile.velocity.Length() < 8 - (Utils.GetLerpValue(150, 0, Projectile.timeLeft, true) * 2))
Projectile.velocity += moveToMouse * (0.42f + Utils.GetLerpValue(300, 150, Projectile.timeLeft, true));
else
Projectile.velocity *= 0.9f;
}
}
else
{
if (Projectile.timeLeft < 100)
{
Projectile.velocity *= 0.96f;
Projectile.scale *= 0.98f;
}
Projectile.timeLeft--;
if (Projectile.timeLeft <= 1)
{
for (int i = 0; i < 4; i++)
{
Particle orb2 = new LineParticle(Projectile.Center, (Projectile.velocity * 5).RotatedByRandom(0.05f) * Main.rand.NextFloat(0.1f, 1f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), baseColor);
GeneralParticleHandler.SpawnParticle(orb2);
}
}
}
time++;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
if (Projectile.ai[1] == 5)
{
for (int i = 0; i < 8; i++)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, Projectile.ai[1] == 5 ? ModContent.DustType<VoidDust>() : ModContent.DustType<LightDust>(), (Projectile.velocity * 3).RotatedByRandom(0.7f) * Main.rand.NextFloat(0.2f, 1f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(1.15f, 1.45f);
dust.color = baseColor;
}
Particle orb = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.3f, 0.65f, 13);
GeneralParticleHandler.SpawnParticle(orb);
Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Black, "CalamityMod/Particles/SmallBloomRingLayered", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.4f, 0.75f, 13, false);
GeneralParticleHandler.SpawnParticle(orb2);
Particle orb3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Black, "CalamityMod/Particles/SmallBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.4f, 0.25f, 16, false);
GeneralParticleHandler.SpawnParticle(orb3);
}
else
{
for (int i = 0; i < 3; i++)
{
Particle orb2 = new LineParticle(Projectile.Center, (Projectile.velocity * 2).RotatedByRandom(0.1f) * Main.rand.NextFloat(0.1f, 1f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), baseColor);
GeneralParticleHandler.SpawnParticle(orb2);
}
}
SoundStyle fire = new("CalamityMod/Sounds/Item/NullHit");
SoundEngine.PlaySound(fire with { Volume = (Projectile.ai[1] == 5 ? 1 : 0.7f), Pitch = Main.rand.NextFloat(0, 0.1f) * (Projectile.ai[1] == 5 ? 3 : 1) }, Projectile.Center);
if (Main.zenithWorld)
{
#region NPC Nullification
int nullBuff = Main.rand.Next(8);
switch (nullBuff)
{
case 0:
if (target.type != ModContent.NPCType<SuperDummyNPC>())
target.damage += 10;
break;
case 1:
target.damage -= 10;
break;
case 2:
target.knockBackResist = 0f;
break;
case 3:
target.knockBackResist = 1f;
break;
case 4:
target.defense += 5;
break;
case 5:
target.defense -= 5;
break;
case 6:
target.scale *= 2f;
break;
case 7:
target.scale *= 0.5f;
break;
default:
break;
}
#endregion
}
}
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
{
if (Projectile.numHits > 0)
Projectile.damage = (int)(Projectile.damage * 0.97f);
if (Projectile.damage < 1)
Projectile.damage = 1;
}
public override bool PreDraw(ref Color lightColor)
{
if (time < 18)
return false;
Asset<Texture2D> tex = ModContent.Request<Texture2D>("CalamityMod/Particles/DrainLineBloom");
Asset<Texture2D> tex2 = ModContent.Request<Texture2D>("CalamityMod/Particles/DrainLine");
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], baseColor with { A = 0 } * 0.35f, 1, tex.Value);
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], Projectile.ai[1] == 5 ? Color.Black : Color.Lerp(baseColor, Color.White, 0.5f), 1, tex2.Value, true, true);
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

@@ -0,0 +1,232 @@
using System;
using System.Collections.Generic;
using CalamityMod.CalPlayer;
using CalamityMod.Dusts;
using CalamityMod.NPCs;
using CalamityMod.NPCs.NormalNPCs;
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;
namespace CalamityMod.Projectiles.Ranged
{
public class OntologicalDespoilerGrenade : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Ranged";
public override string Texture => "CalamityMod/Projectiles/Ranged/OntologicalDespoilerGrenade";
public ref float time => ref Projectile.ai[0];
public Color baseColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Main.DiscoR);
public int sineDir = 1;
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 25;
ProjectileID.Sets.TrailingMode[Projectile.type] = 2;
}
public override void SetDefaults()
{
Projectile.width = 28;
Projectile.height = 28;
Projectile.friendly = true;
Projectile.penetrate = -1;
Projectile.timeLeft = 400;
Projectile.DamageType = DamageClass.Ranged;
Projectile.extraUpdates = 4;
Projectile.tileCollide = false;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = -1;
}
public override void AI()
{
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
if (time == 0)
{
Projectile.scale = Projectile.ai[1] == 5 ? 2.2f : 1.5f;
sineDir = Main.rand.NextBool() ? 1 : -1;
}
float rate = (Main.GlobalTimeWrappedHourly * 5);
List<Color> eColors = new List<Color>()
{
Color.Turquoise,
Color.Orchid
};
int colorIndex = (int)(rate / 2 % eColors.Count);
Color currentColor = eColors[colorIndex];
Color nextColor = eColors[(colorIndex + 1) % eColors.Count];
if (!Main.zenithWorld)
baseColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f);
if (Projectile.ai[1] == 5 && !Main.zenithWorld)
baseColor = Color.White;
if (time == 5)
{
for (int i = 0; i < 4; i++)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, Projectile.ai[1] == 5 ? ModContent.DustType<VoidDust>() : ModContent.DustType<LightDust>(), (Projectile.velocity * 4).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.2f, 1f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(1.15f, 1.35f);
dust.color = baseColor;
}
}
if (time > 20)
{
if (Projectile.ai[1] == 5)
{
// Spawn in a helix-style pattern
float sine = (float)Math.Sin(Projectile.timeLeft * 0.575f / MathHelper.Pi);
Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 16f;
float scale = Main.rand.NextFloat(0.8f, 1.1f);
if (Main.rand.NextBool(2))
{
Dust dust2 = Dust.NewDustPerfect(Projectile.Center + offset * sineDir, Projectile.ai[1] == 5 ? ModContent.DustType<VoidDust>() : ModContent.DustType<LightDust>(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f));
dust2.noGravity = true;
dust2.scale = scale;
dust2.color = baseColor;
}
if (Main.rand.NextBool(2))
{
Dust dust3 = Dust.NewDustPerfect(Projectile.Center - offset * sineDir, /*Projectile.ai[1] == 5 ? ModContent.DustType<VoidDust>() : */ModContent.DustType<LightDust>(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f));
dust3.noGravity = true;
dust3.scale = scale;
dust3.color = baseColor;
}
}
else if (Main.rand.NextBool(13))
{
Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10), Projectile.ai[1] == 5 ? ModContent.DustType<VoidDust>() : ModContent.DustType<LightDust>(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(1.05f, 1.65f);
dust.color = baseColor;
}
}
if (time > 13 && time < 34 && Projectile.ai[2] > 0)
{
Projectile.Center += Projectile.velocity.RotatedBy((Projectile.ai[2] == 1 ? MathHelper.PiOver2 : -MathHelper.PiOver2)) * 0.2f;
}
if (Projectile.ai[1] == 5)
{
NPC targetedNPC = Projectile.Center.ClosestNPCAt(700);
if (targetedNPC != null && time > 30 && Projectile.numHits < 1 && Vector2.Distance(targetedNPC.Center, Projectile.Center) < 700)
{
Vector2 position = targetedNPC.Center;
Vector2 moveToMouse = (position - Projectile.Center).SafeNormalize(Vector2.UnitX);
if (Projectile.velocity.Length() < 8 - (Utils.GetLerpValue(150, 0, Projectile.timeLeft, true) * 2))
Projectile.velocity += moveToMouse * (0.42f + Utils.GetLerpValue(300, 150, Projectile.timeLeft, true));
else
Projectile.velocity *= 0.9f;
}
}
else
{
if (Projectile.timeLeft < 100)
{
Projectile.velocity *= 0.96f;
Projectile.scale *= 0.98f;
}
Projectile.timeLeft--;
if (Projectile.timeLeft <= 1)
{
for (int i = 0; i < 4; i++)
{
Particle orb2 = new LineParticle(Projectile.Center, (Projectile.velocity * 5).RotatedByRandom(0.05f) * Main.rand.NextFloat(0.1f, 1f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), baseColor);
GeneralParticleHandler.SpawnParticle(orb2);
}
}
}
time++;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
if (Projectile.ai[1] == 5)
{
for (int i = 0; i < 8; i++)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, Projectile.ai[1] == 5 ? ModContent.DustType<VoidDust>() : ModContent.DustType<LightDust>(), (Projectile.velocity * 3).RotatedByRandom(0.7f) * Main.rand.NextFloat(0.2f, 1f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(1.15f, 1.45f);
dust.color = baseColor;
}
Particle orb = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.3f, 0.65f, 13);
GeneralParticleHandler.SpawnParticle(orb);
Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Black, "CalamityMod/Particles/SmallBloomRingLayered", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.4f, 0.75f, 13, false);
GeneralParticleHandler.SpawnParticle(orb2);
Particle orb3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Black, "CalamityMod/Particles/SmallBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.4f, 0.25f, 16, false);
GeneralParticleHandler.SpawnParticle(orb3);
}
else
{
for (int i = 0; i < 3; i++)
{
Particle orb2 = new LineParticle(Projectile.Center, (Projectile.velocity * 2).RotatedByRandom(0.1f) * Main.rand.NextFloat(0.1f, 1f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), baseColor);
GeneralParticleHandler.SpawnParticle(orb2);
}
}
SoundStyle fire = new("CalamityMod/Sounds/Item/NullHit");
SoundEngine.PlaySound(fire with { Volume = (Projectile.ai[1] == 5 ? 1 : 0.7f), Pitch = Main.rand.NextFloat(0, 0.1f) * (Projectile.ai[1] == 5 ? 3 : 1) }, Projectile.Center);
if (Main.zenithWorld)
{
#region NPC Nullification
int nullBuff = Main.rand.Next(8);
switch (nullBuff)
{
case 0:
if (target.type != ModContent.NPCType<SuperDummyNPC>())
target.damage += 10;
break;
case 1:
target.damage -= 10;
break;
case 2:
target.knockBackResist = 0f;
break;
case 3:
target.knockBackResist = 1f;
break;
case 4:
target.defense += 5;
break;
case 5:
target.defense -= 5;
break;
case 6:
target.scale *= 2f;
break;
case 7:
target.scale *= 0.5f;
break;
default:
break;
}
#endregion
}
}
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
{
if (Projectile.numHits > 0)
Projectile.damage = (int)(Projectile.damage * 0.97f);
if (Projectile.damage < 1)
Projectile.damage = 1;
}
public override bool PreDraw(ref Color lightColor)
{
if (time < 18)
return false;
Asset<Texture2D> tex = ModContent.Request<Texture2D>("CalamityMod/Particles/DrainLineBloom");
Asset<Texture2D> tex2 = ModContent.Request<Texture2D>("CalamityMod/Particles/DrainLine");
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], baseColor with { A = 0 } * 0.35f, 1, tex.Value);
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], Projectile.ai[1] == 5 ? Color.Black : Color.Lerp(baseColor, Color.White, 0.5f), 1, tex2.Value, true, true);
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

@@ -0,0 +1,451 @@
using System;
using System.Collections.Generic;
using System.Reflection.Metadata;
using CalamityMod.Dusts;
using CalamityMod.Items.Weapons.Magic;
using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.Particles;
using CalamityMod.Projectiles.BaseProjectiles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Utilities;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class OntologicalDespoilerHoldout : BaseGunHoldoutProjectile
{
public override int AssociatedItemID => ModContent.ItemType<OntologicalDespoiler>();
public override float MaxOffsetLengthFromArm => 29f;
public override float OffsetXUpwards => -8f;
public override float BaseOffsetY => -10f;
public override float OffsetYDownwards => 8f;
public override float RecoilResolveSpeed => 0.5f;
public override Vector2 GunTipPosition => Projectile.Center + (Projectile.velocity * 45).RotatedBy(0.18f * Projectile.direction);
public int FramesPerLoad = 9;
public int MaxLoadableShots = 23;
public float BulletSpeed = 6.5f;
public SlotId OntologicalChargeSlot;
public int Time = 0;
public ref float CurrentChargingFrames => ref Projectile.ai[0];
public float ShotsLoaded = 1;
public Color baseColor = Color.White;
public Color color1 = Color.DarkMagenta;
public Color color2 = Color.DarkOrchid;
public Color color3 = Color.Purple;
public Color color4 = Color.BlueViolet;
public bool hasBegunFiring = false;
public bool Positive => Projectile.ai[2] == 0;
public ref float ShootRecoilTimer => ref Projectile.ai[1]; // Dual functions for rapid fire shooting cooldown and recoil
public int AftershotCooldownFrames = 8;
public int Charge1Frames = 156;
public int Charge2Frames = 308;
public int fireFrameCounter = 0;
public int fireFrame = 0;
public int flashFrameCounter = 0;
public int flashFrame = 0;
public bool showFlash = false;
public Vector2 flashPos;
public float flashRot;
public Vector2 voidPlacement;
public bool ChargeLV1 => CurrentChargingFrames >= Charge1Frames;
public bool ChargeLV2 => CurrentChargingFrames >= Charge2Frames;
public override void SetStaticDefaults()
{
Main.projFrames[Type] = 7;
}
public override void KillHoldoutLogic()
{
if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type)
Projectile.Kill();
}
public override void HoldoutAI()
{
if (SoundEngine.TryGetActiveSound(OntologicalChargeSlot, out var ChargeSound) && ChargeSound.IsPlaying)
ChargeSound.Position = Projectile.Center;
float rate = (Main.GlobalTimeWrappedHourly * 15);
List<Color> eColors = new List<Color>()
{
color1,
color2,
color3,
color4
};
int colorIndex = (int)(rate / 2 % eColors.Count);
Color currentColor = eColors[colorIndex];
Color nextColor = eColors[(colorIndex + 1) % eColors.Count];
baseColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f);
if (!Positive)
baseColor = Color.White;
Projectile.frameCounter++;
if (Projectile.frameCounter > 1)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame > 5)
{
Projectile.frame = 0;
}
fireFrameCounter++;
if (fireFrameCounter > 1)
{
fireFrame++;
fireFrameCounter = 0;
}
if (fireFrame > 5)
fireFrame = 0;
if (showFlash)
{
flashFrameCounter++;
if (flashFrameCounter > (flashFrame == 2 ? 7 : 1))
{
flashFrame++;
flashFrameCounter = 0;
}
if (flashFrame > 6)
showFlash = false;
}
if (Time % 2 == 0)
voidPlacement = Main.rand.NextVector2Circular(10.5f, 10.5f);
if (Projectile.ai[2] >= 10) // Changing Mode
{
Owner.Calamity().despoilerNerf = false;
Projectile.frame = 6;
fireFrame = 6;
ShotsLoaded = 0;
if (Time == 0)
{
for (int i = 0; i < 18; i++)
{
Color useColor = Main.rand.Next(4) switch
{
0 => color1,
1 => color2,
2 => color3,
_ => color4,
};
Dust dust = Dust.NewDustPerfect(Owner.Center, Main.rand.NextBool() ? ModContent.DustType<VoidDust>() : ModContent.DustType<LightDust>(), new Vector2(12, 12).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(0.9f, 1.25f);
dust.color = Projectile.ai[2] == 15 ? Color.White : useColor;
}
Projectile.timeLeft = AftershotCooldownFrames * 2;
OffsetLengthFromArm = 25f;
}
}
// Fire if the owner stops channeling or otherwise cannot use the weapon.
if (Owner.CantUseHoldout() || Projectile.ai[2] >= 10)
{
if (Projectile.ai[2] < 10)
Owner.Calamity().despoilerNerf = true;
hasBegunFiring = true;
KeepRefreshingLifetime = false;
// Big Shot mode
if (ChargeLV2)
{
if (ShotsLoaded > 0)
{
// Set lifespan to double of remaining cooldown so that it can finish the recoil animation
Projectile.timeLeft = AftershotCooldownFrames * 2;
ChargeSound?.Stop();
if (Positive)
{
}
else
{
}
SoundEngine.PlaySound(OntologicalDespoiler.BigShot, Projectile.position);
Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed;
int charge2Damage = Projectile.damage * 20;
float charge2KB = Projectile.knockBack * 3f;
//Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType<NovaChargedShot>(), charge2Damage, charge2KB, Projectile.owner);
Owner.Calamity().GeneralScreenShakePower = 9.5f;
flashPos = GunTipPosition + Projectile.velocity * 90;
flashRot = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f);
showFlash = true;
for (int i = 0; i < 20; i++)
{
Color useColor = Main.rand.Next(4) switch
{
0 => color1,
1 => color2,
2 => color3,
_ => color4,
};
float rand = Main.rand.NextFloat(0, 2.5f);
Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, ModContent.DustType<VoidDust>(), shootVelocity.RotatedByRandom(0.12f + rand * 0.2f) * (Main.rand.NextFloat(2.5f, 6.3f) - rand));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(1.55f, 1.85f);
dust.color = Positive ? useColor : baseColor;
}
ShotsLoaded = 0;
ShootRecoilTimer = 34f;
OffsetLengthFromArm -= 35f;
}
// Retracting recoil
else if (ShootRecoilTimer > 0)
ShootRecoilTimer -= 2;
}
// Rapid Fire mode
else if (ShotsLoaded > 0)
{
// While bullets are remaining, refresh the lifespan; it will not refresh again after bullets run out
Projectile.timeLeft = AftershotCooldownFrames;
// Retract recoil & shoot faster if charged
ShootRecoilTimer -= ChargeLV1 ? 2.5f : 2f;
if (ShootRecoilTimer <= 0f)
{
ChargeSound?.Stop();
Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed;
Vector2 fireVec = shootVelocity * Main.rand.NextFloat(0.9f, 1.1f);
if (Positive)
{
for (int i = 0; i < 3; i++)
{
float angle = i == 0 ? -0.25f : i == 2 ? 0.25f : 0;
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, fireVec.RotatedBy(angle) * (1 - Math.Abs(angle * 0.4f)), ModContent.ProjectileType<OntologicalDespoilerShot>(), Projectile.damage / 3, Projectile.knockBack, Projectile.owner, 0, 0, i);
}
}
else
{
for (int i = 0; i < 2; i++)
{
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, fireVec.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.8f, 1f), ModContent.ProjectileType<OntologicalDespoilerShot>(), Projectile.damage / 3, Projectile.knockBack, Projectile.owner, 0, 0, 5);
}
}
SoundEngine.PlaySound(OntologicalDespoiler.SmallShot, Projectile.position);
for (int i = 0; i < 3; i++)
{
Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, !Positive ? ModContent.DustType<VoidDust>() : ModContent.DustType<LightDust>(), shootVelocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.3f, 2.3f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(1.15f, 1.35f);
dust.color = baseColor;
}
ShotsLoaded -= (Positive ? 2 : 1);
ShootRecoilTimer = Positive ? 16 : 12f;
OffsetLengthFromArm -= 3.2f;
}
}
// Retracting any remaining recoil
else if (ShootRecoilTimer > 0)
ShootRecoilTimer -= 2;
}
else
{
// Loads shots until maxed out
if (ShotsLoaded < MaxLoadableShots && CurrentChargingFrames % FramesPerLoad == 0)
ShotsLoaded++;
CurrentChargingFrames += 2 * (Owner.Calamity().despoilerNerf ? 0.5f : 1);
// Sounds
if (ChargeLV1)
{
// Pulse sounds play independently of the loop
if (CurrentChargingFrames == Charge2Frames)
SoundEngine.PlaySound(OntologicalDespoiler.ChargeLV2, Projectile.Center);
else if (CurrentChargingFrames == Charge1Frames)
{
SoundEngine.PlaySound(OntologicalDespoiler.ChargeLV1, Projectile.Center);
ShotsLoaded = MaxLoadableShots;
}
if ((CurrentChargingFrames - Charge1Frames) % (OntologicalDespoiler.ChargeLoopSoundFrames * 2) == 0)
OntologicalChargeSlot = SoundEngine.PlaySound(OntologicalDespoiler.ChargeLoop, Projectile.Center);
}
else if (CurrentChargingFrames == 10)
OntologicalChargeSlot = SoundEngine.PlaySound(OntologicalDespoiler.ChargeStart, Projectile.Center);
// Charge-up visuals
if (CurrentChargingFrames >= 10 && (Positive || (!Positive && !ChargeLV2)))
{
float particleScale = MathHelper.Clamp(CurrentChargingFrames, 0f, Charge2Frames);
for (int i = 0; i < (ChargeLV2 ? 3 : ChargeLV1 ? 2 : 1); i++)
{
//SparkParticle spark2 = new SparkParticle((GunTipPosition - Projectile.velocity * 4) + Main.rand.NextVector2Circular(12, 12), -Projectile.velocity * Main.rand.NextFloat(16.1f, 30.8f), false, Main.rand.Next(2, 7), Main.rand.NextFloat(particleScale / 350f, particleScale / 270f), baseColor);
//GeneralParticleHandler.SpawnParticle(spark2);
Vector2 dustVel = -Projectile.velocity.RotatedByRandom(100) * Main.rand.NextFloat(1.1f, 15.8f);
Vector2 addedPlace = Positive ? Vector2.Zero : dustVel * 3;
Dust dust = Dust.NewDustPerfect(GunTipPosition + (Positive ? Vector2.Zero : (dustVel * 15 * Utils.GetLerpValue(Charge1Frames, Charge2Frames, CurrentChargingFrames, true))), !Positive ? ModContent.DustType<VoidDust>() : ChargeLV1 ? Main.rand.NextBool((int)(50 * Utils.GetLerpValue(Charge1Frames, Charge2Frames, CurrentChargingFrames, true) + 1)) ? ModContent.DustType<LightDust>() : ModContent.DustType<VoidDust>() : ModContent.DustType<LightDust>(), dustVel - addedPlace * Utils.GetLerpValue(Charge1Frames, Charge2Frames, CurrentChargingFrames, true));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(0.5f, 1.25f) * Utils.GetLerpValue(0, Charge1Frames, CurrentChargingFrames, true);
dust.color = baseColor;
}
//Particle orb2 = new GenericBloom(GunTipPosition, Projectile.velocity, Color.Black * 0.5f, (particleScale / 350f) * Main.rand.NextFloat(0.9f, 1.1f), 2, false, false);
//GeneralParticleHandler.SpawnParticle(orb2);
Particle orb = new GenericBloom(GunTipPosition, Projectile.velocity, Positive ? Color.Lerp(Color.White, Color.Black, Utils.GetLerpValue(Charge1Frames, Charge2Frames, CurrentChargingFrames, true)) : Color.Black * Utils.GetLerpValue(0, Charge1Frames, CurrentChargingFrames, true), (particleScale / 400f) * Main.rand.NextFloat(0.9f, 1.1f), 2, false, false);
GeneralParticleHandler.SpawnParticle(orb);
float strength = particleScale / 45f;
Vector3 DustLight = baseColor.ToVector3() * 0.2f;
Lighting.AddLight(GunTipPosition, DustLight * strength);
}
if (ChargeLV2 && !Positive)
{
for (int i = 0; i < 3; i++)
{
Particle orb = new CustomSpark(GunTipPosition, Projectile.velocity.RotatedByRandom(100) * Main.rand.NextFloat(1.1f, 15.8f), "CalamityMod/Particles/PearlParticleGlow", false, 3, Main.rand.NextFloat(1.8f, 1.9f), Color.Black, new Vector2(0.3f, 1.3f), false, false);
GeneralParticleHandler.SpawnParticle(orb);
Vector2 dustVel = -Projectile.velocity.RotatedByRandom(100) * Main.rand.NextFloat(1.1f, 15.8f);
Dust dust = Dust.NewDustPerfect(GunTipPosition, ModContent.DustType<VoidDust>(), dustVel);
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(0.5f, 1.25f) * Utils.GetLerpValue(0, Charge1Frames, CurrentChargingFrames, true);
dust.color = baseColor;
}
}
// Full charge dusts
if (CurrentChargingFrames == Charge1Frames)
{
for (int i = 0; i < 16; i++)
{
Color useColor = Main.rand.Next(4) switch
{
0 => color1,
1 => color2,
2 => color3,
_ => color4,
};
Dust chargefull = Dust.NewDustPerfect(GunTipPosition, ModContent.DustType<LightDust>());
chargefull.velocity = (MathHelper.TwoPi * i / 16f).ToRotationVector2() * 16f * (i % 2 == 0 ? 0.7f : 1);
chargefull.scale = Main.rand.NextFloat(1.1f, 1.3f);
chargefull.noGravity = true;
chargefull.color = Positive ? useColor : baseColor;
}
}
if (CurrentChargingFrames == Charge2Frames)
{
for (int i = 0; i < 25; i++)
{
Color useColor = Main.rand.Next(4) switch
{
0 => color1,
1 => color2,
2 => color3,
_ => color4,
};
Dust chargefull = Dust.NewDustPerfect(GunTipPosition, ModContent.DustType<LightDust>());
chargefull.velocity = (MathHelper.TwoPi * i / 25f).ToRotationVector2() * 22f * (i % 2 == 0 ? 0.7f : 1);
chargefull.scale = Main.rand.NextFloat(1.45f, 1.55f);
chargefull.noGravity = true;
chargefull.color = Positive ? useColor : baseColor;
}
}
}
if (!hasBegunFiring)
{
Projectile.frame = 6;
fireFrame = 6;
}
else
{
Lighting.AddLight(Projectile.Center, baseColor.ToVector3() * 0.75f);
}
Time++;
}
public override void OnKill(int timeLeft)
{
if (SoundEngine.TryGetActiveSound(OntologicalChargeSlot, out var ChargeSound))
ChargeSound?.Stop();
}
public override bool PreDraw(ref Color lightColor)
{
if (Time < 3)
return false;
Texture2D texture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Ranged/OntologicalDespoilerHoldout").Value;
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f);
Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame);
Vector2 rotationPoint = frame.Size() * 0.5f;
SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
Texture2D fireTexture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Ranged/OntologicalDespoilerFlame").Value;
Texture2D fireTexture2 = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Ranged/OntologicalDespoilerFlame2").Value;
Rectangle frame2 = fireTexture.Frame(1, 7, 0, fireFrame);
Vector2 rotationPoint2 = frame2.Size() * 0.5f;
Texture2D flashTexture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Ranged/OntologicalDespoilerFlash").Value;
Rectangle frame3 = fireTexture.Frame(1, 6, 0, flashFrame);
Vector2 rotationPoint3 = frame3.Size() * 0.5f;
Texture2D rechargeTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/FlameExplosion").Value;
Texture2D rechargeTexture2 = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/BasicCircle").Value;
// Glow Orb
float randSize = Main.rand.NextFloat(0.9f, 1.1f);
if (!hasBegunFiring)
{
for (int i = 0; i < 2; i++)
Main.EntitySpriteDraw(rechargeTexture, GunTipPosition - Main.screenPosition, null, baseColor with { A = 0 }, Projectile.rotation + Main.rand.NextFloat(-30, 30), rechargeTexture.Size() * 0.5f, 0.028f * Utils.GetLerpValue(0, Charge2Frames, CurrentChargingFrames, true) * randSize, SpriteEffects.None, 0);
Main.EntitySpriteDraw(rechargeTexture2, GunTipPosition - Main.screenPosition, null, Positive ? Color.Lerp(Color.White, Color.Black, Utils.GetLerpValue(Charge1Frames, Charge2Frames, CurrentChargingFrames, true)) : Color.Black, Projectile.rotation + Main.rand.NextFloat(-30, 30), rechargeTexture2.Size() * 0.5f, 0.58f * Utils.GetLerpValue(0, Charge2Frames, CurrentChargingFrames, true) * randSize, SpriteEffects.None, 0);
}
if (!Owner.CantUseHoldout())
{
float rumble = MathHelper.Clamp(CurrentChargingFrames, 0f, Charge2Frames);
drawPosition += Main.rand.NextVector2Circular(rumble / 120f, rumble / 120f);
}
if (ChargeLV1 && !Positive && !hasBegunFiring)
{
for (int i = 0; i < 2; i++)
{
Vector2 placement = drawPosition + voidPlacement;
Main.EntitySpriteDraw(texture, placement, frame, baseColor with { A = 0 } * 0.3f * Utils.GetLerpValue(Charge1Frames, Charge2Frames, CurrentChargingFrames, true), drawRotation, rotationPoint, new Vector2(Main.rand.NextFloat(0.7f, 1f), Main.rand.NextFloat(0.8f, 1.2f)) * Projectile.scale * Owner.gravDir * 1.1f, flipSprite);
Main.EntitySpriteDraw(texture, placement, frame, Color.Black * Utils.GetLerpValue(Charge1Frames, Charge2Frames, CurrentChargingFrames, true), drawRotation, rotationPoint, new Vector2(Main.rand.NextFloat(0.7f, 1f), Main.rand.NextFloat(0.6f, 1f)) * Projectile.scale * Owner.gravDir, flipSprite);
}
}
Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite);
if (Projectile.frame < 6)
{
if (Positive && false)
Main.EntitySpriteDraw(fireTexture, drawPosition, frame2, baseColor with { A = 0 }, drawRotation, rotationPoint2, Projectile.scale * Owner.gravDir, flipSprite);
else
{
for (int i = 0; i< 4; i++)
Main.EntitySpriteDraw(fireTexture, drawPosition + Main.rand.NextVector2Circular(4.5f, 4.5f), frame2, baseColor with { A = 0 } * 0.3f, drawRotation, rotationPoint2, Projectile.scale * Owner.gravDir, flipSprite);
Main.EntitySpriteDraw(Positive ? fireTexture : fireTexture2, drawPosition, frame2, Positive ? baseColor with { A = 0 } : baseColor, drawRotation, rotationPoint2, Projectile.scale * Owner.gravDir, flipSprite);
}
}
if (showFlash)
{
for (int i = 0; i < 4; i++)
Main.EntitySpriteDraw(flashTexture, flashPos - Main.screenPosition + Main.rand.NextVector2Circular(4.5f, 4.5f), frame3, baseColor with { A = 0 } * 0.3f, flashRot, rotationPoint3, new Vector2(3, 0.8f) * Projectile.scale * Owner.gravDir, flipSprite);
Main.EntitySpriteDraw(flashTexture, flashPos - Main.screenPosition, frame3, Color.Black, flashRot, rotationPoint3, new Vector2(3, 0.8f) * Projectile.scale * Owner.gravDir, flipSprite);
}
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

@@ -0,0 +1,223 @@
using System;
using System.Collections.Generic;
using CalamityMod.CalPlayer;
using CalamityMod.Dusts;
using CalamityMod.NPCs;
using CalamityMod.NPCs.NormalNPCs;
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;
using static CalamityMod.Projectiles.Rogue.FinalDawnFlame;
namespace CalamityMod.Projectiles.Ranged
{
public class OntologicalDespoilerShot : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Ranged";
public override string Texture => "CalamityMod/Projectiles/Ranged/OntologicalDespoilerShot";
public ref float time => ref Projectile.ai[0];
public Color baseColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Main.DiscoR);
public int sineDir = 1;
public int zagRate = 55;
public Color color1 = Color.DarkMagenta;
public Color color2 = Color.DarkOrchid;
public Color color3 = Color.Purple;
public Color color4 = Color.BlueViolet;
public bool Positive => Projectile.ai[2] < 5;
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 25;
ProjectileID.Sets.TrailingMode[Projectile.type] = 2;
}
public override void SetDefaults()
{
Projectile.width = 28;
Projectile.height = 28;
Projectile.friendly = true;
Projectile.penetrate = -1;
Projectile.timeLeft = 600;
Projectile.DamageType = DamageClass.Ranged;
Projectile.extraUpdates = 4;
Projectile.tileCollide = false;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = -1;
}
public override void AI()
{
Projectile.rotation = Projectile.velocity.ToRotation();
Projectile.frameCounter++;
if (Projectile.frameCounter > 1)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame > 5)
{
Projectile.frame = 0;
}
if (time == 0)
{
Projectile.scale = 1f;
sineDir = Main.rand.NextBool() ? 1 : -1;
Projectile.frame = Main.rand.Next(0, 6 + 1);
zagRate = Main.rand.Next(55, 70 + 1);
if (!Positive)
Projectile.penetrate = 1;
}
float rate = (Main.GlobalTimeWrappedHourly * 15);
List<Color> eColors = new List<Color>()
{
color1,
color2,
color3,
color4
};
int colorIndex = (int)(rate / 2 % eColors.Count);
Color currentColor = eColors[colorIndex];
Color nextColor = eColors[(colorIndex + 1) % eColors.Count];
baseColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f);
if (!Positive)
baseColor = Color.White;
if (time > 20)
{
if (!Positive)
{
// Spawn in a helix-style pattern
float sine = (float)Math.Sin(Projectile.timeLeft * 0.575f / MathHelper.Pi);
Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 8f;
float scale = Main.rand.NextFloat(0.3f, 0.4f);
if (true)
{
Dust dust2 = Dust.NewDustPerfect(Projectile.Center + offset * sineDir, ModContent.DustType<VoidDust>(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f));
dust2.noGravity = true;
dust2.scale = scale;
dust2.color = baseColor;
//Dust dust3 = Dust.NewDustPerfect(Projectile.Center - offset * sineDir, ModContent.DustType<VoidDust>(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f));
//dust3.noGravity = true;
//dust3.scale = scale;
//dust3.color = baseColor;
}
}
else
{
if (Main.rand.NextBool(21))
{
Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10), ModContent.DustType<LightDust>(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 1.8f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(0.8f, 1.15f);
dust.color = baseColor;
}
if ((time < 15 || time % 25 <= 15) && Projectile.ai[2] != 1)
{
Projectile.velocity = Projectile.velocity.RotatedBy(0.5f / 15f * (Projectile.ai[2] == 2 ? 1 : -1));
if (time % 25 == 0 || time == 15)
Projectile.ai[2] = (Projectile.ai[2] == 2 ? 0 : 2);
}
}
}
if (!Positive)
{
NPC targetedNPC = Projectile.Center.ClosestNPCAt(700);
if (targetedNPC != null && time > 30 && Projectile.numHits < 1 && Vector2.Distance(targetedNPC.Center, Projectile.Center) < 700)
{
Vector2 position = targetedNPC.Center;
Vector2 moveToMouse = (position - Projectile.Center).SafeNormalize(Vector2.UnitX);
if (Projectile.velocity.Length() < 8 - (Utils.GetLerpValue(350, 0, Projectile.timeLeft, true) * 2))
Projectile.velocity += moveToMouse * (0.42f + Utils.GetLerpValue(500, 350, Projectile.timeLeft, true));
else
Projectile.velocity *= 0.9f;
}
}
else
{
if (Projectile.timeLeft < 100)
{
Projectile.velocity *= 0.96f;
Projectile.scale *= 0.98f;
}
Projectile.timeLeft--;
if (Projectile.timeLeft <= 1)
{
for (int i = 0; i < 2; i++)
{
Particle orb2 = new LineParticle(Projectile.Center, (Projectile.velocity * 5).RotatedByRandom(0.05f) * Main.rand.NextFloat(0.1f, 1f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), baseColor);
GeneralParticleHandler.SpawnParticle(orb2);
}
}
}
time++;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
if (!Positive)
{
for (int i = 0; i < 3; i++)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, !Positive ? ModContent.DustType<VoidDust>() : ModContent.DustType<LightDust>(), (Projectile.velocity * 3).RotatedByRandom(0.7f) * Main.rand.NextFloat(0.2f, 1f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(1.15f, 1.45f);
dust.color = baseColor;
}
Particle orb = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.15f, 0.65f, 8);
GeneralParticleHandler.SpawnParticle(orb);
Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Black, "CalamityMod/Particles/SmallBloomRingLayered", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.2f, 0.75f, 8, false);
GeneralParticleHandler.SpawnParticle(orb2);
Particle orb3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Black, "CalamityMod/Particles/SmallBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.4f, 0.05f, 9, false);
GeneralParticleHandler.SpawnParticle(orb3);
}
else
{
for (int i = 0; i < 3; i++)
{
Particle orb2 = new LineParticle(Projectile.Center, (Projectile.velocity * 4).RotatedByRandom(0.15f) * Main.rand.NextFloat(0.1f, 1f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), baseColor);
GeneralParticleHandler.SpawnParticle(orb2);
}
}
SoundStyle fire = new("CalamityMod/Sounds/Item/NullHit");
SoundEngine.PlaySound(fire with { Volume = (!Positive ? 1 : 0.7f), Pitch = Main.rand.NextFloat(0, 0.1f) * (!Positive ? 3 : 1) }, Projectile.Center);
}
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
{
if (Projectile.numHits > 0)
Projectile.damage = (int)(Projectile.damage * 0.9f);
if (Projectile.damage < 1)
Projectile.damage = 1;
}
public override bool PreDraw(ref Color lightColor)
{
if (time < 2)
return false;
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
float drawRotation = Projectile.rotation;
Asset<Texture2D> tex = ModContent.Request<Texture2D>("CalamityMod/Particles/DrainLineBloom2");
Asset<Texture2D> tex2 = ModContent.Request<Texture2D>("CalamityMod/Particles/DrainLine2");
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], baseColor with { A = 0 } * 0.8f, 1, tex.Value);
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], Positive ? Color.Lerp(Color.White, baseColor, MathHelper.Clamp(Utils.GetLerpValue(50, 175, time, true), 0, 0.5f)) with { A = 0 } : Color.Black, 1, tex2.Value, true, true);
Asset<Texture2D> tex3 = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Ranged/OntologicalDespoilerShot");
Asset<Texture2D> tex4 = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Ranged/OntologicalDespoilerShot2");
Rectangle frame = tex3.Frame(1, 6, 0, Projectile.frame);
Vector2 rotationPoint = frame.Size() * 0.5f;
Main.EntitySpriteDraw(Positive ? tex4.Value : tex3.Value, drawPosition, frame, baseColor with { A = 0 }, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None);
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 B