Transformer part 1

This commit is contained in:
Xyk authored and Cameron Ewell committed 2025-02-02 14:42:51 -05:00
1 parent 6f631b2272
commit bc308bf2f4
23 files changed
+515 -44

No files matched your search

+30
View File
@@ -742,6 +742,9 @@ namespace CalamityMod.CalPlayer
public bool aquaticHeartIce = false;
public bool aSpark = false;
public bool transformer = false;
public bool transformerVisual = false;
public int transformerCooldown = 0;
public int transformerDelay = 0;
public bool hideOfDeus = false;
public bool dAmulet = false;
public bool rampartOfDeities = false;
@@ -2080,6 +2083,7 @@ namespace CalamityMod.CalPlayer
warbannerGlow = false;
aSpark = false;
transformer = false;
transformerVisual = false;
hideOfDeus = false;
dAmulet = false;
rampartOfDeities = false;
@@ -2748,6 +2752,8 @@ namespace CalamityMod.CalPlayer
ursaSergeantCooldown = 0;
AlchFlaskCooldown = 0;
ascendantInsigniaCooldown = 0;
transformerCooldown = 0;
transformerDelay = 0;
silvaMageCooldown = 0;
bloodflareMageCooldown = 0;
tarraRangedCooldown = 0;
@@ -3162,6 +3168,30 @@ namespace CalamityMod.CalPlayer
ascendantInsigniaBuffTime = 240; //4 seconds
}
int numOfBlobs = Player.ownedProjectileCounts[ModContent.ProjectileType<TransformerBlob>()];
if (transformer && numOfBlobs > 0 && Main.myPlayer == Player.whoAmI && CalamityKeybinds.TransformerHotKey.JustPressed && transformerCooldown <= 0 && true) // Add check if projectiles are active
{
// Go fire all the blobs
int cooldownTime = 300;
transformerCooldown = cooldownTime;
Player.AddCooldown(TransformerCooldown.ID, cooldownTime);
for (int x = 0; x < Main.maxProjectiles; x++)
{
Projectile projectile = Main.projectile[x];
if (projectile.active && projectile.type == ModContent.ProjectileType<TransformerBlob>())
{
projectile.localAI[0] = 5;
}
}
SoundStyle activate = new("CalamityMod/Sounds/Item/NullShot");
for (int i = 0; i < 3; i++)
SoundEngine.PlaySound(activate with { Volume = 0.3f, Pitch = 0.2f + i * 0.3f, MaxInstances = -1 }, Player.Center);
Particle orb2 = new CustomPulse(Player.Center, Vector2.Zero, Color.SkyBlue, "CalamityMod/Particles/BloomRingThinLarge", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0, 0.2f, 20);
GeneralParticleHandler.SpawnParticle(orb2);
}
//Only increment hotkey holdtime if not on ground, not mounted, not on rope, not hooked, not tongued, otherwise reset hold time to zero
if (CalamityKeybinds.GravistarSabatonHotkey.Current && gSabaton && Main.myPlayer == Player.whoAmI && (Player.velocity.Y != Player.oldVelocity.Y) && !Player.pulley && !Player.mount.Active && Player.grappling[0] == -1 && !Player.tongued)
{
-5
View File
@@ -2633,11 +2633,6 @@ namespace CalamityMod.CalPlayer
Vector2 dustVel = Main.rand.NextVector2CircularEdge(1f, 1f) * Main.rand.NextFloat(4.5f, 5.25f);
Dust electric = Dust.NewDustPerfect(Player.Center, DustID.Electric, dustVel, Scale: 0.75f);
electric.noGravity = true;
if (transformer)
{
NanoParticle nano = new(Player.Center, dustVel, new Color(0, 186, 242), 1f, 20, true, true);
GeneralParticleHandler.SpawnParticle(nano);
}
}
}
if (rBrain)
+69
View File
@@ -1518,6 +1518,73 @@ namespace CalamityMod.CalPlayer
if (rOfResilienceCooldown > 0)
rOfResilienceCooldown--;
if (transformer && Player.Calamity().transformerCooldown == 0) // The code for this acursed thing took much... MUCH, too long to make
{
float zoneSize = 150;
// This is a visualizer used to easily see the area
/*
for (int i = 0; i < 13; i++)
{
Vector2 vel1 = new Vector2(zoneSize, 0).RotatedByRandom(100);
Vector2 vel2 = new Vector2(zoneSize, 0).RotatedByRandom(100);
Particle spark2 = new CustomSpark(Player.Center + vel1, -vel1 * 0.01f, "CalamityMod/Particles/GlowSquareParticle", false, 8, Main.rand.NextFloat(0.3f, 0.5f), Color.Cyan, new Vector2(2f, 1f), true, false, 0, false, false, -1.5f);
GeneralParticleHandler.SpawnParticle(spark2);
Particle spark = new CustomSpark(Player.Center + vel2, -vel2 * 0.01f, "CalamityMod/Particles/GlowSquareParticle", false, 8, Main.rand.NextFloat(0.3f, 0.5f), Color.Cyan, new Vector2(2f, 1f), true, false, 0, false, false, -1.5f);
GeneralParticleHandler.SpawnParticle(spark);
}
*/
for (int x = 0; x < Main.maxProjectiles; x++)
{
Projectile projectile = Main.projectile[x];
if (Vector2.Distance(Player.Center, projectile.Center) <= zoneSize && projectile.active && projectile.hostile && projectile.Calamity().TransformerTimer == 0 && transformerDelay == 0)
{
transformerDelay = 2; // 2 frame delay between projectile transformation
int numOfBlobs = Player.ownedProjectileCounts[ModContent.ProjectileType<TransformerBlob>()];
if (numOfBlobs < 30)
{
projectile.Calamity().TransformerTimer = 90;
int blobDamage = (int)Player.GetBestClassDamage().ApplyTo(55);
int layer = ((numOfBlobs + 1) > 20 ? 3 : (numOfBlobs + 1) > 10 ? 2 : 1);
Projectile.NewProjectileDirect(Player.GetSource_FromThis(), projectile.Center, projectile.velocity.SafeNormalize(Vector2.UnitX) * 16f, ModContent.ProjectileType<TransformerBlob>(), blobDamage, 0f, Player.whoAmI, layer, numOfBlobs + 1);
Particle orb2 = new CustomPulse(projectile.Center, Vector2.Zero, Color.DodgerBlue, "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0, 0.5f, 11);
GeneralParticleHandler.SpawnParticle(orb2);
SoundStyle transform = new("CalamityMod/Sounds/Item/NullImpact");
SoundEngine.PlaySound(transform with { Volume = 0.1f, Pitch = Main.rand.NextFloat(-0.3f, -0.4f) + numOfBlobs * 0.015f, MaxInstances = -1 }, projectile.Center);
float topAngle = Utils.Remap(Player.ownedProjectileCounts[ModContent.ProjectileType<TransformerBlob>()], 0, 29, 360, 1080, true);
float index = 1f;
foreach (Projectile p in Main.ActiveProjectiles)
{
float angleMax = MathHelper.ToRadians(360 * layer);
if (numOfBlobs == 0)
angleMax = 0f;
if (Player.ownedProjectileCounts[ModContent.ProjectileType<TransformerBlob>()] > 30)
{
angleMax += MathHelper.ToRadians((Player.ownedProjectileCounts[ModContent.ProjectileType<TransformerBlob>()] - 30) * 2.5f);
}
angleMax = angleMax > MathHelper.ToRadians(topAngle) ? MathHelper.ToRadians(topAngle) : angleMax; // More intuative than using a min function
if (p.type == ModContent.ProjectileType<TransformerBlob>() && p.owner == Player.whoAmI)
{
float insanityValue = ((p.ai[1] % 10) + 1);
if (p.ai[0] == layer)
p.ai[2] = insanityValue / CalamityUtils.CountProjectiles(ModContent.ProjectileType<TransformerBlob>()) * (angleMax) - (angleMax) / 2f;
p.netUpdate = true;
index++;
}
}
}
}
}
}
if (transformerDelay > 0)
transformerDelay--;
if (unstableGraniteCore)
{
zapActivity += 1;
@@ -1636,6 +1703,8 @@ namespace CalamityMod.CalPlayer
arsenalCooldown--;
if (ascendantInsigniaCooldown > 0 && ascendantInsigniaBuffTime <= 0)
ascendantInsigniaCooldown--;
if (transformerCooldown > 0)
transformerCooldown--;
if (DragonsBreathAudioCooldown > 0)
DragonsBreathAudioCooldown--;
if (DragonsBreathAudioCooldown2 > 0)
+1 -1
View File
@@ -1178,7 +1178,7 @@ namespace CalamityMod.CalPlayer
target.AddBuff(BuffID.Poisoned, 60);
if (aSpark && Player.IsUnderwater())
{
int duration = transformer ? 120 : 60;
int duration = 60;
target.AddBuff(BuffType<StaticDischarge>(), duration);
}
if (abyssalAmulet)
+3
View File
@@ -18,6 +18,7 @@ namespace CalamityMod
public static ModKeybind RageHotKey { get; private set; }
public static ModKeybind SandCloakHotkey { get; private set; }
public static ModKeybind SpectralVeilHotKey { get; private set; }
public static ModKeybind TransformerHotKey { get; private set; }
public override void Load()
{
@@ -36,6 +37,7 @@ namespace CalamityMod
RageHotKey = KeybindLoader.RegisterKeybind(Mod, "RageMode", "V");
SandCloakHotkey = KeybindLoader.RegisterKeybind(Mod, "SandCloakEffect", "C");
SpectralVeilHotKey = KeybindLoader.RegisterKeybind(Mod, "SpectralVeilTeleport", "Z");
TransformerHotKey = KeybindLoader.RegisterKeybind(Mod, "TransformerHotKey", "K");
}
public override void Unload()
@@ -54,6 +56,7 @@ namespace CalamityMod
RageHotKey = null;
SandCloakHotkey = null;
SpectralVeilHotKey = null;
TransformerHotKey = null;
}
}
}
+16
View File
@@ -0,0 +1,16 @@
using Microsoft.Xna.Framework;
using Terraria.Localization;
namespace CalamityMod.Cooldowns
{
public class TransformerCooldown : CooldownHandler
{
public static new string ID => "TransformerCooldown";
public override bool ShouldDisplay => true;
public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}");
public override string Texture => "CalamityMod/Cooldowns/TransformerCooldown";
public override Color OutlineColor => Color.AliceBlue;
public override Color CooldownStartColor => Color.Lerp(Color.SlateBlue, Color.DodgerBlue, 1 - instance.Completion);
public override Color CooldownEndColor => Color.Lerp(Color.SlateGray, Color.Cyan, 1 - instance.Completion);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

-3
View File
@@ -16,9 +16,6 @@ namespace CalamityMod.Items.Accessories
Item.rare = ItemRarityID.Blue;
Item.accessory = true;
}
public override bool CanEquipAccessory(Player player, int slot, bool modded) => !player.Calamity().transformer;
public override void UpdateAccessory(Player player, bool hideVisual)
{
CalamityPlayer modPlayer = player.Calamity();
+27 -7
View File
@@ -1,4 +1,8 @@
using CalamityMod.CalPlayer;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables.SunkenSea;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -6,6 +10,7 @@ using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
namespace CalamityMod.Items.Accessories
{
@@ -22,21 +27,36 @@ namespace CalamityMod.Items.Accessories
{
Item.width = 42;
Item.height = 56;
Item.value = CalamityGlobalItem.RarityLightRedBuyPrice;
Item.rare = ItemRarityID.LightRed;
Item.value = CalamityGlobalItem.RarityPinkBuyPrice;
Item.rare = ItemRarityID.Pink;
Item.accessory = true;
}
public override bool CanEquipAccessory(Player player, int slot, bool modded) => !player.Calamity().aSpark;
public override void UpdateAccessory(Player player, bool hideVisual)
{
CalamityPlayer modPlayer = player.Calamity();
modPlayer.transformer = true;
modPlayer.aSpark = true;
player.Calamity().eleResist = true;
}
modPlayer.transformerVisual = !hideVisual;
if (player.ownedProjectileCounts[ProjectileType<TransformerAura>()] < 1 && !hideVisual && !player.dead && player.Calamity().transformerCooldown == 0)
{
Projectile light = Projectile.NewProjectileDirect(player.GetSource_FromThis(), player.Center, Vector2.Zero, ProjectileType<TransformerAura>(), 0, 0f, player.whoAmI);
}
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<SeaPrism>(10).
AddRecipeGroup("AnyMythrilBar", 5).
AddIngredient<EssenceofSunlight>(2).
AddIngredient<EssenceofEleum>(2).
AddIngredient<EssenceofHavoc>(2).
AddIngredient(ItemID.SoulofNight, 3).
AddIngredient(ItemID.SoulofLight, 3).
AddTile(TileID.MythrilAnvil).
Register();
}
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
{
CalamityUtils.DrawInventoryCustomScale(
@@ -1868,14 +1868,7 @@ TheSponge: {
TheTransformer: {
DisplayName: The Transformer
Tooltip:
'''
Multiplies all electricity debuff damage by 1.5x
Attacks inflict Static Discharge while underwater
Reduces the damage of all electricity debuffs by 50%
Taking damage causes the enemy to be shocked
Shocked enemies constantly release sparks
'''
Tooltip: Multiplies all electricity debuff damage by 1.5x
}
ToxicHeart: {
@@ -12,3 +12,4 @@ NormalityRelocator.DisplayName: Normality Relocator
RageMode.DisplayName: Rage Mode
SandCloakEffect.DisplayName: Sand Cloak Effect
SpectralVeilTeleport.DisplayName: Spectral Veil Teleport
TransformerHotKey.DisplayName: Transformer Hot Key
@@ -141,3 +141,5 @@ YanmeisKnifeSlash.DisplayName: Yanmei's Knife
YellowLabSeeker.DisplayName: Seeking Mechanism
VoidofExtinctionCrit.DisplayName: Void of Extinction Crit
XykDeathAnim.DisplayName: Xyk Death Animation
TransformerBlob.DisplayName: Transformer Blob
TransformerAura.DisplayName: Transformer Aura
+4 -19
View File
@@ -360,8 +360,6 @@ namespace CalamityMod.NPCs
public int nightwither = 0;
/// <summary> If greater than 0, this NPC has been "shocked" by Amidias' Spark's on hurt effect. </summary>
public int shocked = 0;
/// <summary> If greater than 0, this NPC has been "shocked" by The Transformer's on hurt effect. </summary>
public int transformerShocked = 0;
public int voidfrost = 0;
public int shellfishVore = 0;
public int clamDebuff = 0;
@@ -605,7 +603,6 @@ namespace CalamityMod.NPCs
myClone.wDeath = wDeath;
myClone.nightwither = nightwither;
myClone.shocked = shocked;
myClone.transformerShocked = transformerShocked;
myClone.voidfrost = voidfrost;
myClone.shellfishVore = shellfishVore;
myClone.clamDebuff = clamDebuff;
@@ -5629,8 +5626,6 @@ namespace CalamityMod.NPCs
nightwither--;
if (shocked > 0)
shocked--;
if (transformerShocked > 0)
transformerShocked--;
if (voidfrost > 0)
voidfrost--;
if (shellfishVore > 0)
@@ -5744,27 +5739,20 @@ namespace CalamityMod.NPCs
}
// Amidias' Spark and Transformer spark spawning
if (shocked > 0 || transformerShocked > 0)
if (shocked > 0)
{
var player = Main.LocalPlayer;
bool strongerShock = transformerShocked > 0;
int frequency = strongerShock ? 10 : 12;
int frequency = 12;
// Spawn sparks from the enemy
if (player.miscCounter % frequency == 0)
{
int sDamage = strongerShock ? 50 : 10;
int sDamage = 10;
Vector2 velocity = Vector2.UnitX.RotatedByRandom(MathHelper.Pi) * 5f;
Projectile spark = Projectile.NewProjectileDirect(npc.GetSource_FromThis(), npc.Center, velocity, ProjectileType<GenericElectricSpark>(), sDamage, 0f, player.whoAmI, 0f, 1f);
spark.timeLeft = 120;
spark.penetrate = 3;
if (strongerShock)
{
spark.timeLeft = 240;
spark.extraUpdates = 1;
spark.penetrate = 10;
}
}
}
@@ -5978,10 +5966,7 @@ namespace CalamityMod.NPCs
if (target.Calamity().aSpark)
{
if (target.Calamity().transformer)
transformerShocked = 120;
else
shocked = 120;
shocked = 120;
}
if (target.Calamity().snowman)
-1
View File
@@ -415,7 +415,6 @@ namespace CalamityMod.NPCs.NormalNPCs
{
npcLoot.AddIf(() => NPC.downedGolemBoss, ItemID.MartianConduitPlating, 1, 10, 30);
npcLoot.Add(ModContent.ItemType<EssenceofSunlight>(), 2);
npcLoot.Add(ModContent.ItemType<TheTransformer>(), 10);
npcLoot.Add(ModContent.ItemType<OracleHeadphones>(), (DateTime.Now.Day == 21 && DateTime.Now.Month == 8) ? 9 : 20);
var postML = npcLoot.DefineConditionalDropSet(() => NPC.downedMoonlord);
postML.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType<ExodiumCluster>(), 1, 8, 12, 11, 16));
Binary file not shown.

After

Width:  |  Height:  |  Size: 285 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

+7
View File
@@ -241,6 +241,9 @@ namespace CalamityMod.Projectiles
/// <summary> Tracks whether this projectile has already triggered Scuttler's Jewel's projectile effect. </summary>
public bool JewelSpikeSpawned = false;
/// <summary> A timer for preventing projectiles from being "transformed" by transformer every frame. </summary>
public int TransformerTimer = 0;
// Note: Although this was intended for fishing line colors, I use this as an AI variable a lot because vanilla only has 4 that sometimes are already in use. ~Ben
// TODO -- uses of this variable are undocumented and unstable. Remove it from the API surface.
public int lineColor = 0;
@@ -3982,6 +3985,10 @@ namespace CalamityMod.Projectiles
if (flatDRTimer <= 0)
flatDR = 0;
}
if (projectile.FinalExtraUpdate() && TransformerTimer > 0)
{
TransformerTimer--;
}
// CIT 29JUN2024: Moved from PreAI to PostAI so that it is called every update instead of every frame.
// This makes the distance traveled increment more accurately for projectiles with extra updates, as previously projectiles with extra updates
+111
View File
@@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using CalamityMod.Buffs.Summon;
using CalamityMod.CalPlayer;
using CalamityMod.Dusts;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Typeless
{
public class TransformerAura : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Typeless";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public Player Owner => Main.player[Projectile.owner];
public CalamityPlayer moddedOwner => Owner.Calamity();
public Color bColor = Color.White;
public int time = 0;
public float rotMult = 0.05f;
public int direction = 1;
public float rot2 = 0;
public float fullSine = 1;
public Vector2 squareRandomPos1;
public Vector2 squareRandomPos2;
public override void SetDefaults()
{
Projectile.width = Projectile.height = 1;
Projectile.ignoreWater = true;
Projectile.timeLeft = 10;
Projectile.tileCollide = false;
Projectile.friendly = true;
Projectile.penetrate = -1;
}
public override void AI()
{
float rate = Main.GlobalTimeWrappedHourly * 5;
List<Color> eColors = new List<Color>()
{
Color.DodgerBlue,
Color.DeepSkyBlue
};
int colorIndex = (int)(rate / 2 % eColors.Count);
Color currentColor = eColors[colorIndex];
Color nextColor = eColors[(colorIndex + 1) % eColors.Count];
bColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f);
Projectile.Center = Owner.MountedCenter;
if (moddedOwner.transformerVisual && moddedOwner.transformer)
{
if (moddedOwner.transformerCooldown == 0)
{
Projectile.timeLeft = (int)MathHelper.Clamp(Projectile.timeLeft + 5, 0, 300);
}
else
Projectile.timeLeft = (int)(Projectile.timeLeft * 0.98f);
}
else
Projectile.Kill();
if (Owner.dead)
Projectile.Kill();
// Emit some light
Lighting.AddLight(Projectile.Center, bColor.ToVector3() * 0.9f);
rot2 = Math.Abs((float)Math.Sin(time * 0.15f / MathHelper.Pi) * 0.2f) + 0.8f;
fullSine = (float)Math.Sin(time * 0.15f / MathHelper.Pi);
if (time % 2 == 0)
{
Vector2 dustVel = new Vector2(10, 10).RotatedByRandom(100);
Dust dust = Dust.NewDustPerfect(Owner.Center + dustVel, ModContent.DustType<VoidDustInverted>(), dustVel * Main.rand.NextFloat(0.1f, 0.4f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(0.5f, 0.7f);
dust.color = new Color(30, 30, 30);
dust.noLightEmittence = true;
}
time++;
}
public override bool PreDraw(ref Color lightColor)
{
Texture2D rTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/QuarterCircle").Value;
Texture2D vTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomRingThinLarge").Value;
Texture2D bTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle").Value;
Color drawColor = bColor;
float deathLerp = (float)Math.Pow(Utils.GetLerpValue(10, 300, Projectile.timeLeft), 2);
float bScale2 = 0.75f;
Main.EntitySpriteDraw(bTexture, Owner.Center - Main.screenPosition, null, drawColor with { A = 0 } * deathLerp, 0, bTexture.Size() * 0.5f, bScale2 * rot2 * Projectile.scale * deathLerp, SpriteEffects.None, 0);
for (int i = 0; i < 3; i++)
{
float subsine = rot2;//MathHelper.Lerp(Math.Abs(fullSine), 0.3f, 0.5f);
float rot = (MathHelper.TwoPi * i / 3f) + Main.GlobalTimeWrappedHourly;
Main.EntitySpriteDraw(vTexture, Owner.Center - Main.screenPosition, null, drawColor with { A = 0 } * 0.05f * deathLerp, rot + MathHelper.ToRadians(-105), vTexture.Size() * 0.5f, new Vector2(1f, 0.97f) * 0.16f * deathLerp, SpriteEffects.None, 0);
Main.EntitySpriteDraw(vTexture, Owner.Center - Main.screenPosition, null, drawColor with { A = 0 } * 0.05f * deathLerp, rot * 2 + MathHelper.ToRadians(-105), vTexture.Size() * 0.5f, new Vector2(1f, 0.97f) * 0.157f * deathLerp, SpriteEffects.None, 0);
}
//Main.EntitySpriteDraw(rTexture, Owner.Center - Main.screenPosition, null, drawColor with { A = 0 }, , rTexture.Size() * 0.5f, 0.04f * rot2 * Projectile.scale, SpriteEffects.None, 0);
return false;
}
public override bool? CanDamage() => false;
}
}
+242
View File
@@ -0,0 +1,242 @@
using System;
using CalamityMod.Dusts;
using CalamityMod.Items.Weapons.Magic;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Typeless
{
public class TransformerBlob : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Typeless";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public Player Owner => Main.player[Projectile.owner];
private float radius = 25f;
public bool visuals => Owner.Calamity().transformerVisual;
public ref float layer => ref Projectile.ai[0];
public bool canDamage = false;
public float speed = 250;
public float rotationAngle = 0;
public int time = 0;
public int currentLayer = 0;
public float sine = 1;
public float rotSpeed = 1f;
public int savedFrame = 0;
public bool powered => Projectile.localAI[0] == 5;
public int poweredTimerMax => (int)(140 + 6 * Projectile.ai[1]);
public int poweredTimer = -1;
public float poweredLerp => (float)Math.Pow(Utils.GetLerpValue(poweredTimerMax, 90, poweredTimer, true), 4);
public override void SetStaticDefaults()
{
Main.projFrames[Type] = 16;
}
public override void SetDefaults()
{
Projectile.width = 42;
Projectile.height = 56;
Projectile.friendly = true;
Projectile.DamageType = AverageDamageClass.Instance;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.penetrate = -1;
Projectile.timeLeft = 600;
Projectile.extraUpdates = 1;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 60 * Projectile.MaxUpdates;
Projectile.ArmorPenetration = 25;
}
public override void AI()
{
Player Owner = Main.player[Projectile.owner];
Lighting.AddLight(Projectile.Center, Color.SkyBlue.ToVector3() * 0.5f);
sine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * (Projectile.ai[1] % 2 == 0 ? 10 : 6) / MathHelper.Pi) * 0.4f;
if (time == 0)
{
rotationAngle = Projectile.ai[2];
Projectile.frame = 8;
}
if (poweredTimer == -1 && powered)
{
poweredTimer = poweredTimerMax;
savedFrame = Projectile.frame;
}
if (time >= 40)
{
Projectile.frameCounter++;
if (Projectile.frameCounter > (6) * Projectile.MaxUpdates)
{
if (powered && Projectile.frame == 8)
Projectile.frame = 8;
else
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame >= 16)
Projectile.frame = 0;
}
else
Projectile.frame = (int)MathHelper.Lerp(savedFrame, 8, poweredLerp);
layer = (Projectile.ai[1] > 20 ? 3 : Projectile.ai[1] > 10 ? 2 : 1);
if (time >= 90)
canDamage = true;
if (layer != currentLayer)
{
currentLayer = (int)layer;
if (time > 60)
time = 60;
}
rotationAngle = MathHelper.Lerp(rotationAngle, Projectile.ai[2], 0.025f);
if (time >= 40)
{
if (poweredTimer == 1)
{
Projectile.numHits = 0;
Projectile.velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) * 12;
Projectile.extraUpdates = 8;
for (int i = 0; i < Main.maxNPCs; i++)
Projectile.localNPCImmunity[i] = 0;
for (int i = 0; i <= 9; i++)
{
float variance = Main.rand.NextFloat(-0.6f, 0.6f);
int dustStyle = 278;
Dust dust2 = Dust.NewDustPerfect(Projectile.Center, dustStyle, Projectile.velocity);
dust2.scale = Main.rand.NextFloat(0.9f, 1.2f) - Math.Abs(variance);
dust2.velocity = (Projectile.velocity * 2).RotatedBy(variance) * Main.rand.NextFloat(0.3f, 1f) * (1 - Math.Abs(variance));
dust2.noGravity = true;
dust2.color = Color.Cyan;
}
SoundStyle fire = new("CalamityMod/Sounds/Item/OmicronBeam");
SoundEngine.PlaySound(fire with { Volume = 0.3f, Pitch = Main.rand.NextFloat(0.3f, 0.5f) + Projectile.ai[1] * 0.015f, MaxInstances = -1 }, Projectile.Center);
}
else if (poweredTimer == 0)
{
//trail shit
float sine = (float)Math.Sin(Projectile.timeLeft * 0.575f / MathHelper.Pi);
Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 20f;
Particle spark = new GlowSparkParticle(Projectile.Center - Projectile.velocity, -Projectile.velocity * 0.3f, false, 21, 0.04f, Color.DodgerBlue * 0.65f, new Vector2(0.6f, 0.5f), true, false, 0.7f);
GeneralParticleHandler.SpawnParticle(spark);
if (time % 2 == 0)
{
Vector2 dustVel = (-Projectile.velocity).RotatedByRandom(0.3f);
Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, ModContent.DustType<VoidDustInverted>(), dustVel * Main.rand.NextFloat(0.1f, 0.8f));
dust.noGravity = true;
dust.scale = Main.rand.NextFloat(0.4f, 0.6f);
dust.color = new Color(30, 30, 30);
dust.noLightEmittence = true;
}
Projectile.rotation = (Projectile.velocity.RotatedBy(MathHelper.ToRadians(-90))).ToRotation();
}
else
{
Vector2 centerPoint = (powered ? Vector2.Lerp(Owner.Center, Vector2.Lerp(Owner.Calamity().mouseWorld, Owner.Center, 0.6f), poweredLerp) : Owner.Center);
float positioning = (-60 - (55 * layer) + 30 * sine) * MathHelper.Clamp((powered ? 1.25f - poweredLerp : 1), 0.25f, 1);
Projectile.velocity = ((centerPoint + new Vector2(0, positioning).RotatedBy(rotationAngle * -rotSpeed + Main.GlobalTimeWrappedHourly * 2.5f * (1 - layer * (powered ? 0.33f : 0.15f)) * (layer == 2 ? -1 : 1))) - Projectile.Center) / (speed);
Projectile.rotation = Projectile.rotation.AngleLerp(sine, 0.02f);
}
if (powered && poweredTimer != 0)
{
rotSpeed *= 1.0067f;
Projectile.rotation = Projectile.rotation.AngleLerp(Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).RotatedBy(MathHelper.ToRadians(-90)).ToRotation(), poweredLerp);
}
}
else
{
Projectile.velocity *= 0.965f;
Projectile.rotation = (Projectile.velocity.RotatedBy(MathHelper.ToRadians(-90))).ToRotation();
}
speed = MathHelper.Lerp(speed, 1, (float)Math.Pow(Utils.GetLerpValue(0, 180, time), 2));
if (!powered)
Projectile.timeLeft++;
if (poweredTimer > 0)
poweredTimer--;
time++;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
if (target.life <= 0 && target.realLife == -1)
Projectile.numHits--;
}
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
{
if (poweredTimer == 0)
{
float minMult = 0.25f;
int hitsToMinMult = 5;
float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true) * (Projectile.numHits == 0 ? 1.5f : 1); // +50% damage on first hit
modifiers.SourceDamage *= damageMult;
}
else
modifiers.SourceDamage *= 0.2f;
}
public override void OnKill(int timeLeft)
{
}
public override bool PreDraw(ref Color lightColor)
{
Texture2D orbTexture = ModContent.Request<Texture2D>("CalamityMod/Items/Accessories/TheTransformer").Value;
Texture2D bTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle").Value;
Rectangle frame = orbTexture.Frame(1, 16, 0, Projectile.frame);
Vector2 origin = frame.Size() * 0.5f;
if (powered)
{
Color auraColor = Color.DodgerBlue with { A = 0 } * poweredLerp;
for (int i = 0; i < 2; i++)
{
float bScale2 = 0.25f;
Main.EntitySpriteDraw(bTexture, Projectile.Center - Main.screenPosition, null, Color.DodgerBlue with { A = 0 }, Projectile.rotation, bTexture.Size() * 0.5f, Vector2.Lerp(new Vector2(0.6f, 1.4f), Vector2.One, MathHelper.Min(Utils.GetLerpValue(8, 15, Projectile.frame, true), Utils.GetLerpValue(8, 0, Projectile.frame, true))) * bScale2 * Projectile.scale, SpriteEffects.None, 0);
}
}
Main.EntitySpriteDraw(orbTexture, Projectile.Center - Main.screenPosition, frame, Color.White, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0);
if (!powered)
{
for (int i = 0; i < 10; i++)
{
Color auraColor = Color.DodgerBlue with { A = 0 } * sine * 0.6f;
Vector2 drawOffset = (MathHelper.TwoPi * i / 10f).ToRotationVector2() * 4;
Main.EntitySpriteDraw(orbTexture, Projectile.Center - Main.screenPosition + drawOffset, frame, auraColor, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None);
}
}
/*
Texture2D rTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/ShatteredExplosion").Value;
Texture2D bTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle").Value;
Color drawColor = Color.DodgerBlue;
float rot2 = 0.3f;
for (int i = 0; i < 5; i++)
{
float bScale2 = 0.75f;
Main.EntitySpriteDraw(bTexture, Projectile.Center - Main.screenPosition, null, Color.Lerp(drawColor, Color.White, i * 0.15f) with { A = 0 }, 0, bTexture.Size() * 0.5f, (bScale2 - i * 0.15f) * rot2 * Projectile.scale, SpriteEffects.None, 0);
}
Main.EntitySpriteDraw(rTexture, Projectile.Center - Main.screenPosition, null, drawColor with { A = 0 }, Main.rand.NextFloat(-2, 2), rTexture.Size() * 0.5f, 0.03f * rot2 * Projectile.scale, SpriteEffects.None, 0);
Main.EntitySpriteDraw(rTexture, Projectile.Center - Main.screenPosition, null, drawColor with { A = 0 }, Main.rand.NextFloat(-2, 2), rTexture.Size() * 0.5f, 0.04f * rot2 * Projectile.scale, SpriteEffects.None, 0);
*/
return false;
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, radius, targetHitbox);
public override bool? CanDamage() => canDamage ? null : false;
public override bool? CanCutTiles() => false;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

@@ -90,6 +90,7 @@ namespace CalamityMod.Systems.Collections
ProjectileType<StellarStrikerHoldout>(),
ProjectileType<TaserHook>(),
ProjectileType<Teslabeam>(),
ProjectileType<TransformerBlob>(),
ProjectileType<TyphonsGreedStaff>(),
ProjectileType<UrchinMaceProj>(),
ProjectileType<UrchinStingerProj>(),