Updates to mammoth

This commit is contained in:
Xyk committed 2026-04-12 17:01:57 -07:00
1 parent ec411597a6
commit 8a5dd9dba2
9 files changed
+478 -331

No files matched your search

+4 -2
View File
@@ -1129,7 +1129,9 @@ namespace CalamityMod.CalPlayer
public bool scionsCurioVisuals = false;
public float scionsCurioDebuffDamage = 0;
public bool frozenCube = false;
public float frozenCubePower = 0;
public bool frozenCubeVisuals = false;
public float frozenCubeDebuffBoost = 0;
public float frozenCubeElumphantBoost = 0;
public bool miniOldDuke = false;
public bool miniOldDukeVanity = false;
public bool starbusterCore = false;
@@ -2511,7 +2513,7 @@ namespace CalamityMod.CalPlayer
camper = false;
corrosiveSpine = false;
scionsCurio = false;
frozenCube = false;
frozenCube = false; frozenCubeDebuffBoost = 0; frozenCubeElumphantBoost = 0;
rottenDogTooth = false;
angelicAlliance = false;
ChaosStone = false;
+15 -6
View File
@@ -4,6 +4,7 @@ using CalamityMod.CalPlayer;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
@@ -12,11 +13,17 @@ namespace CalamityMod.Items.Accessories
{
public class FrozenCube : ModItem, ILocalizedModType
{
public static int mistBaseDamage = 3;
public static int slamBaseDamage = 24;
public static int mistBaseDamage = 2;
public static int slamBaseDamage = 38;
public static int baseAttackSpeed = 90;
public static int baseAttackCooldown = 180;
public static int debuff = BuffID.Frostburn; // Wind chilled
public static int debuff = ModContent.BuffType<WindChilled>();
public static readonly SoundStyle noise = new("CalamityMod/Sounds/Item/ElumphantSound") { Volume = 0.6f };
public static readonly SoundStyle cry = new("CalamityMod/Sounds/Item/ElumphantCry") { Volume = 0.6f };
public static readonly SoundStyle hit = new("CalamityMod/Sounds/Item/ElumphantBop") { Volume = 0.6f };
public static readonly SoundStyle jokeBonk = new("CalamityMod/Sounds/Item/Bonk") { Volume = 0.6f };
public new string LocalizationCategory => "Items.Accessories";
public override void SetDefaults()
{
@@ -26,11 +33,11 @@ namespace CalamityMod.Items.Accessories
Item.rare = ItemRarityID.Orange;
Item.accessory = true;
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
CalamityPlayer modPlayer = player.Calamity();
modPlayer.frozenCube = true;
modPlayer.frozenCubeVisuals = !hideVisual;
int projectile = ProjectileType<Elumphant>();
if (player.ownedProjectileCounts[projectile] < 1 && !player.dead)
@@ -41,9 +48,11 @@ namespace CalamityMod.Items.Accessories
}
public override void ModifyTooltips(List<TooltipLine> list)
{
Player player = Main.LocalPlayer;
if (Main.LocalPlayer != null)
list.FindAndReplace("[DAMAGE]", ((int)(player.Calamity().frozenCubePower)).ToString() + "x");
list.FindAndReplace("[DAMAGELINE]", Main.LocalPlayer.Calamity().frozenCube ?
this.GetLocalization("EquippedDebuff").Format((Main.LocalPlayer.Calamity().frozenCubeDebuffBoost.ToPercent("N0")).ToString()) + "\n" +
this.GetLocalization("EquippedElumphant").Format((Main.LocalPlayer.Calamity().frozenCubeElumphantBoost.ToPercent("N1")).ToString())
: this.GetLocalizedValue("Unequipped"));
}
}
}
@@ -2252,6 +2252,10 @@ FrozenCube: {
The Elumphant will cycle between shooting cold air that inflicts [cbuff:CalamityMod/WindChilled], and headbutting enemies
Elumphant's headbutts only target enemies inflicted with [cbuff:CalamityMod/WindChilled]
Reduces your defense by 33%, but uses that defense to boost the Elumphant's power and your cold debuff damage
[DAMAGELINE]
[c/7497ED:What I wanna know is, where's the mammoth?']
'''
EquippedDebuff: Current Cold Debuff boost: +{0}%
EquippedElumphant: Current Elumphant Power: +{0}%
Unequipped: Equip this accessory to view its statistics
}
+433 -317
View File
@@ -1,25 +1,24 @@
using System;
using System.Collections.Generic;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using System.Linq;
using CalamityMod.Dusts;
using CalamityMod.Enums;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Accessories;
using CalamityMod.NPCs.SunkenSea;
using CalamityMod.Particles;
using CalamityMod.Projectiles.Ranged;
using Microsoft.CodeAnalysis;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using ReLogic.Utilities;
using Terraria;
using Terraria.Audio;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
using static System.Net.Mime.MediaTypeNames;
namespace CalamityMod.Projectiles.Typeless
{
public class Elumphant : ModProjectile, ILocalizedModType
public class Elumphant : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer
{
public new string LocalizationCategory => "Projectiles.Typeless";
public Player Owner => Main.player[Projectile.owner];
@@ -27,49 +26,57 @@ namespace CalamityMod.Projectiles.Typeless
public static Color color2 = new Color(103, 188, 214);
public Color usedColor = Color.White;
public ref float time => ref Projectile.ai[0];
public float squashTimerX = 0;
public float squashTimerY = 0;
public float fallTimer = 0;
public float squashTimerX = 0; public float squashTimerY = 0; // Adjusts the X and Y centric squash effects
public float fallTimer = 0; // How long the Elumphant has been falling
public int maxFallTimer = 120;
public int lastHighestFallTimer = 0;
public ref float attackTimer => ref Projectile.ai[1];
public ref float attackTimer => ref Projectile.ai[1]; // Timer for cycling between attack and cooldown phases
public ref float mistShootTimer => ref Projectile.ai[2]; // Timer for the frames that it fires mist
public float fxFade = 0; // The glow visuals multiplier
public float followSpeed = 7; // The speed it follows you, lower is faster
public float lerpDir = 0;
public float actionSpeed = 1;
public float verticalSquash = 0;
public float horizontalSquash = 0;
public float verticalSquash = 0; public float horizontalSquash = 0; // The Elumphant's current X and Y squash
public float trunkRotation = 0;
public bool dashing = false;
public NPC targeted;
public bool hitHead = true;
public int blinkTime = 1;
public int cryTime = 1;
public bool mammothFlip = false;
public bool mammothOops = false;
public float hopSize = 0;
public int hopTimer = 0;
public float trunkRotation = 0; // Rotation for the trunk, and also the direction that it's mist will be fired in
public bool dashing = false; // If the Elumphant is performing its jumping bonk attack
public NPC targeted; // The currently targeted NPC for either of it's attacks
public bool hitHead = true; // If the Elumphant has landed on its back when falling back to the player's head
public int blinkTime = 1; public int cryTime = 1; // Timers for doing its idle animations
public bool mammothFlip = false; // If the Elumphant is spinning as it falls back to the player
public bool mammothOops = false; // If the Elumphant is doing its mistake animation after bonking the player's head
public int hopTimer = 0; // Timer for the little hop after bonking its head
public bool attackedThisFrame = false;
public int attackDirection = 1;
public float mistShootTimer = 0;
public int attacksDone = 0;
public bool recoiling = false;
public float maxTargetingDistance => 500 * GetPower(0.25f);
public bool recoiling = false; // If the Elumphant has finished bonking enemies and is returning to the player
public float maxTargetingDistance = 0;
public float maxTrunkRot => -MathHelper.PiOver2 * 1.1f;
public int attackTime => (int)(FrozenCube.baseAttackSpeed);
public int attackTimeAdjusted => (int)(FrozenCube.baseAttackSpeed / (GetPower(0.5f) + 0.23f * Projectile.numHits));
public int cooldownTime => (int)(FrozenCube.baseAttackCooldown / GetPower(0.5f));
public int attackTimeAdjusted = 0; // Attack speed adjusted for the slam attack
public float damageScaling = 0; // The damage scaling on the mist and slam attacks
public int cooldownTime = 0; // The cooldown between attacks
public List<NPC> hitNPCs = new List<NPC>();
public Vector2 lastHitNPCPos;
public Vector2 lastProjPos;
public bool spawnJumpDusts = true;
public int usedDefenseDivide = 3;
public float frozenCubePower = 0; // The base power boost gained fromd defense before scaling adjustments
public bool vis => Owner.Calamity().frozenCubeVisuals;
Vector2 goalPosition;
public SlotId soundSlot;
public static Asset<Texture2D> TrunkTexture { get; private set; }
public override void Load()
{
if (Main.dedServ)
return;
TrunkTexture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Typeless/ElumphantTrunk");
}
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Type] = 25;
ProjectileID.Sets.TrailingMode[Type] = 2;
Main.projFrames[Type] = 3;
}
public override void SetDefaults()
@@ -85,16 +92,62 @@ namespace CalamityMod.Projectiles.Typeless
Projectile.localNPCHitCooldown = -1;
Projectile.DamageType = DamageClass.Generic;
}
public float WidthFunction(float completion, Vector2 _)
{
float width;
float sine = MathF.Sin(Main.GlobalTimeWrappedHourly * 9 - completion * 6);
float newSine = 0.7f - sine * 0.1f;
float cutPoint = 0.1f;
float baseFade = (MathF.Pow((1 - completion), 2));
float compFade = completion > cutPoint ? baseFade : baseFade * (1 - MathF.Pow((Utils.GetLerpValue(cutPoint, 0, completion)), 3));
width = (completion == 0 ? 0 : 45 * newSine * compFade);
return width;
}
public Color ColorFunction(float completion, Vector2 _)
{
float sine = MathF.Sin(Main.GlobalTimeWrappedHourly * 9 - completion * 6);
Color clr = Color.Lerp(usedColor, Color.DodgerBlue, 0.6f + 0.2f * sine);
Color tipColor = Color.Lerp(clr, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true));
return Color.Lerp(clr, tipColor, completion) * fxFade;
}
public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer)
{
if (vis)
{
// Render the main trail
string shader = "CalamityMod:TrailStreak";
Vector2[] length = Projectile.oldPos.Take((int)(Math.Max(10 - Projectile.numHits, 5))).ToArray();
GameShaders.Misc[shader].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/DoubleTrail"));
PrimitiveRenderer.RenderTrail(length, new(WidthFunction, ColorFunction, (_, _) => Projectile.Size * 0.5f, true, true, GameShaders.Misc[shader]), length.Length * 6);
}
}
public void SetStats()
{
maxTargetingDistance = (float)(500 * GetPower(0.25f));
attackTimeAdjusted = (int)(FrozenCube.baseAttackSpeed / (GetPower(0.5f)));
damageScaling = (float)GetPower(0.014f, 21 * (1 + frozenCubePower));
cooldownTime = (int)(FrozenCube.baseAttackCooldown / GetPower(0.5f));
}
public void SetElumphantPower()
{
int usedDefense = (Owner.statDefense / 3);
if (time == 0)
int usedDefense = (Owner.statDefense / usedDefenseDivide);
if (time == 0) // Show the player how much defense is being used
CombatText.NewText(Projectile.Hitbox, color2, -usedDefense,false, true);
Owner.statDefense -= usedDefense;
Owner.Calamity().frozenCubePower = usedDefense * 0.05f;
Owner.Calamity().ColdDebuffMultiplier += Owner.Calamity().frozenCubePower;
frozenCubePower = usedDefense * 0.05f; // 1 point of defense = 5% effectiveness
float power = (float)(GetPower(0.02f, 14f * (1 + frozenCubePower)) - 1);
Owner.Calamity().frozenCubeDebuffBoost = power;
Owner.Calamity().frozenCubeElumphantBoost = damageScaling - 1;
Owner.Calamity().ColdDebuffMultiplier += power; // Boost cold debuff damage
}
public float GetPower(float efficiency) => 1 + Owner.Calamity().frozenCubePower * efficiency;
public double GetPower(float efficiency, float intenseScaling = 1)
{
double defensePower = frozenCubePower;
return Math.Pow(1 + defensePower * efficiency, intenseScaling);
}
public void GetColor()
{
float rate = Main.GlobalTimeWrappedHourly * 5;
@@ -128,26 +181,21 @@ namespace CalamityMod.Projectiles.Typeless
}
Projectile.spriteDirection = newDirection;
}
public void GetTarget(bool excludeHitNPCs) // Target closest NPC to mouse, unless they're too far, then do closest to Elumphant
public void GetTarget(bool excludeHitNPCs, float distanceMult = 1) // Target closest NPC to mouse, unless they're too far, then do closest to Elumphant
{
if (excludeHitNPCs)
{
float distance = maxTargetingDistance * 5;
NPC chosenTarget = null;
for (int index = 0; index < Main.npc.Length; index++) // look for a target that isnt one it has already hit in the last two hits.
float distance = 0;
for (int index = 0; index < Main.npc.Length; index++) // look for a target that isnt one it has already hit
{
NPC searchedTarget = Main.npc[index];
if (searchedTarget.CanBeChasedBy(null, false))
if (searchedTarget.CanBeChasedBy(null, false) && searchedTarget.HasBuff(FrozenCube.debuff) && !hitNPCs.Contains(searchedTarget) && searchedTarget.active && searchedTarget.life > 0)
{
float extraDistance = (searchedTarget.width / 2) + (searchedTarget.height / 2);
bool canHit = true;
if (extraDistance < distance)
canHit = Collision.CanHit(Projectile.Center, 1, 1, Main.npc[index].Center, 1, 1); // blocked by walls
if (searchedTarget.HasBuff(ModContent.BuffType<WindChilled>()) && Vector2.Distance(Projectile.Center, searchedTarget.Center) < distance && !hitNPCs.Contains(searchedTarget) && searchedTarget.active && searchedTarget.life > 0 && canHit)
float targetDistance = Projectile.Center.Distance(new Vector2(searchedTarget.Center.X, Projectile.Center.Y));
if (targetDistance > distance)
{
distance = Vector2.Distance(Projectile.Center, searchedTarget.Center);
distance = targetDistance;
chosenTarget = searchedTarget;
}
}
@@ -156,27 +204,261 @@ namespace CalamityMod.Projectiles.Typeless
}
else
{
targeted = (Owner.ClampedMouseWorld()).ClosestNPCAt(maxTargetingDistance, true);
if (!ValidDistance())
targeted = (Projectile.Center).ClosestNPCAt(maxTargetingDistance, true);
bool targetFar = (distanceMult != -1);
NPC chosenTarget = null;
float distance = (targetFar ? 0 : maxTargetingDistance);
for (int index = 0; index < Main.npc.Length; index++)
{
NPC searchedTarget = Main.npc[index];
if (searchedTarget.CanBeChasedBy(null, false) && searchedTarget.active && searchedTarget.life > 0)
{
bool canHit = Collision.CanHit(Owner.Center, 1, 1, searchedTarget.Center, 1, 1);
float targetDistance = Owner.Center.Distance(new Vector2(searchedTarget.Center.X, Owner.Center.Y));
// Checks most distant target first, then closest if that fails
bool inRange = (targetFar ? (targetDistance > distance) : (targetDistance < distance));
if (inRange && canHit && targetDistance < maxTargetingDistance)
{
distance = targetDistance;
chosenTarget = searchedTarget;
}
}
}
if (chosenTarget != null)
targeted = chosenTarget;
if (!ValidDistance())
targeted = null;
}
}
public bool ValidDistance() => (targeted != null && targeted.Distance(Projectile.Center) < maxTargetingDistance);
public void ScaleOpacity(float endAt)
{
Projectile.Opacity = MathHelper.Lerp(Projectile.Opacity, endAt, 0.12f);
}
public bool ValidDistance(float distanceCheckMult = 1) => (targeted != null && targeted.Distance(Owner.Center) < (maxTargetingDistance * distanceCheckMult));
public void HopAttack(Vector2 originalPosition)
{
if (!vis)
ScaleOpacity(0.4f);
if (attackTimer == 0 && Projectile.numHits == 0)
{
GetTarget(true);
}
if (attacksDone != 0)
Projectile.frame = 2;
if (recoiling)
{
attackTimeAdjusted = (int)(FrozenCube.baseAttackSpeed / GetPower(0.5f));
if (Projectile.numHits > 1)
attackTimer = attackTimeAdjusted;
Projectile.numHits = 1;
}
float attackLerp = Utils.GetLerpValue((int)(Math.Max(attackTimeAdjusted, 2) / 2), Math.Max(attackTimeAdjusted, 2), attackTimer, true);
int direction = Owner.ItemAnimationActive ? (Math.Sign(Projectile.Center.DirectionTo(Owner.ClampedMouseWorld()).X)) : (Owner.direction);
if (!recoiling)
fxFade = (attackLerp <= 0.2f ? 0 : Math.Max(attackLerp, MathHelper.Lerp(fxFade, 1, 0.15f)));
else
fxFade = MathHelper.Lerp(0f, 1, MathF.Pow(attackLerp, 4));
if (targeted == null || (targeted != null && (targeted.life <= 0 || !targeted.active)))
{
if (attackLerp > 0 && !recoiling)
{
lastHitNPCPos = Projectile.Center;
attackTimer = attackTimeAdjusted;
}
recoiling = true;
targeted = null;
}
Vector2 basePosition = recoiling ? originalPosition : Projectile.numHits == 0 ? originalPosition : (lastHitNPCPos);
Vector2 targetPos = recoiling ? lastHitNPCPos : targeted.Center - (Vector2.UnitY * targeted.height / 2);
float jumpHeight = 250;// Math.Max(250 - Projectile.numHits * 10, recoiling ? 250 : 60);
float jumpLerp = attackLerp > 0.5f ? 1 - (MathF.Pow(Utils.GetLerpValue(0.5f, 1f, attackLerp), 4)) : 1 - (MathF.Pow(Utils.GetLerpValue(0.5f, 0f, attackLerp), 2));
float jumpOffsetY = MathHelper.Lerp(basePosition.Y, targetPos.Y, attackLerp) - jumpHeight * jumpLerp;
float jumpOffsetX = MathHelper.Lerp(basePosition.X, targetPos.X, attackLerp);
goalPosition = new Vector2(jumpOffsetX, jumpOffsetY);
Projectile.Center = goalPosition;
if (attackLerp > 0f && spawnJumpDusts && vis)
{
bool clrChoose = Main.rand.NextBool();
int halfDusts = 14;
for (int i = -halfDusts; i <= halfDusts; i++)
{
Vector2 dustVel = -Vector2.UnitY.RotatedByRandom(0.9f) * Main.rand.NextFloat(0.6f, 1.8f);
Vector2 dustPos = Owner.Center + Vector2.UnitY * -(Owner.height / 2 + Projectile.height / 2.5f * Projectile.scale) + dustVel * 1.5f;
Dust dust2 = Dust.NewDustPerfect(dustPos, ModContent.DustType<SquashDustPixelated>(),
dustVel.RotatedByRandom(0.55f) * (Math.Abs(i) * 0.2f) * (Main.rand.NextBool(5) ? 3 : 1), 0, default, Main.rand.NextFloat(0.2f, 0.45f) * 2.5f);
dust2.noGravity = true;
dust2.color = Main.rand.NextBool() ? color1 : color2;
dust2.customData = new Vector2(0.6f, 1.5f);
dust2.fadeIn = -0.7f;
if (i == -1)
i = 1;
}
spawnJumpDusts = false;
}
float goalAngle = (attackLerp > 0.5f ? basePosition.DirectionTo(Projectile.Center) : Projectile.Center.DirectionTo(targetPos)).ToRotation() + (attackLerp > 0.5f ? MathHelper.PiOver2 : -MathHelper.PiOver2);
if (!recoiling)
Projectile.rotation = MathHelper.WrapAngle(Utils.Remap(attackLerp, 0, 1, -MathHelper.PiOver2 * Projectile.spriteDirection, MathHelper.PiOver2 * Projectile.spriteDirection)) * (1 - MathF.Pow(1 - attackLerp, 3));
else
Projectile.rotation = MathHelper.WrapAngle(Utils.Remap(attackLerp, 0, 1, MathHelper.TwoPi * 2 * Projectile.spriteDirection, 0));
trunkRotation = Utils.AngleLerp(trunkRotation, 0, 0.11f);
int attemptDir = Math.Sign((recoiling ? basePosition.X : targetPos.X) - Projectile.Center.X);
SetDirection(attemptDir);
if (attackTimer <= (int)(Math.Max(attackTimeAdjusted, 2) / 2) && recoiling)
{
Projectile.frame = 0;
hitNPCs.Clear();
Projectile.velocity = Vector2.Zero;
recoiling = false;
dashing = false;
Projectile.numHits = 0;
attackTimer = (int)(cooldownTime / 2);
attacksDone = 0;
spawnJumpDusts = true;
for (int i = 0; i < Main.maxNPCs; i++)
Projectile.localNPCImmunity[i] = 0;
GetTarget(true);
}
}
public void MistAttack(float fallLerp)
{
Projectile.frame = 1;
float angleSweep = MathF.Sin(attackTimer * 0.085f) * attackDirection;
float goalAngle = Projectile.Center.DirectionTo(targeted.Center).ToRotation() - MathHelper.PiOver2;
if (attackTimer == cooldownTime + 1) // Make start attack sound
{
if (vis)
SoundEngine.PlaySound(FrozenCube.noise with { Pitch = Main.rand.NextFloat(-0.2f, 0.2f) }, Projectile.Center);
Projectile.soundDelay = 0;
Projectile.frameCounter = 1;
}
SetDirection(Math.Sign(Projectile.Center.DirectionTo(targeted.Center).X));
horizontalSquash = 0.5f;
Projectile.rotation = Projectile.rotation.AngleLerp((goalAngle + MathHelper.PiOver2 * Projectile.spriteDirection), 0.07f) * MathF.Pow(fallLerp, 0.2f);
float angleMax = MathHelper.PiOver4 * 0.75f * Utils.GetLerpValue(maxTargetingDistance, 30, Projectile.Center.Distance(targeted.Center), true);
if (hopTimer <= 0)
trunkRotation = trunkRotation.AngleLerp(goalAngle - Projectile.rotation - angleMax * angleSweep, 0.23f);
if (attackTimer > (cooldownTime * 1.1f))
{
if (!vis)
ScaleOpacity(0.4f);
if (mistShootTimer == 0 && Main.myPlayer == Projectile.owner)
{
Vector2 shootVel = (trunkRotation + Projectile.rotation + MathHelper.PiOver2).ToRotationVector2();
int damage = (int)Owner.GetTotalDamage<GenericDamageClass>().ApplyTo((float)(FrozenCube.mistBaseDamage * damageScaling));
int projectile = ModContent.ProjectileType<ElumphantMist>();
Vector2 shootPosition = Projectile.Center + shootVel * 5 * Projectile.scale;
Projectile mist = Projectile.NewProjectileDirect(Owner.GetSource_FromThis(), shootPosition, (shootVel * shootPosition.Distance(targeted.Center) / 25) * Main.rand.NextFloat(0.9f, 1.1f), projectile, damage, 0, Owner.whoAmI, 0, Owner.ownedProjectileCounts[projectile] % 3, (float)GetPower(1));
}
mistShootTimer += (float)(0.35f * GetPower(0.25f));
if (mistShootTimer >= 2f)
mistShootTimer = 0;
}
mammothFlip = false;
attackedThisFrame = true;
if (!ValidDistance())
{
GetTarget(false, -1);
if (!ValidDistance())
{
attackTimer = cooldownTime + attackTime;
targeted = null;
}
}
if (attackTimer == cooldownTime + attackTime)
{
attackDirection *= -1;
Projectile.frame = 0;
attacksDone++;
if (attacksDone >= 2) // Every 2 attacks, do a dash slam
{
dashing = true;
attackTimer = -1;
}
}
}
public void Idle()
{
if (!vis)
ScaleOpacity(0);
targeted = null;
if (Owner.StandingStill()) // If standing still, let the player mess with the mammoth squash for fun
{
if (Owner.controlDown)
horizontalSquash = 0.5f;
if (Owner.controlUp)
verticalSquash = 0.5f;
}
if (Math.Abs(Owner.velocity.X) > 4 && fallTimer == 0)
verticalSquash = 0.25f * Utils.GetLerpValue(4, 10, Math.Abs(Owner.velocity.X));
if (targeted == null && attackTimer > cooldownTime) // If can attack but there is no target, wait to decrease the timer until a target is found
attackTimer--;
int cryStart = (int)(cryTime - 65);
if (Projectile.soundDelay >= cryStart)
{
if (Projectile.soundDelay == cryStart) // Sound
{
verticalSquash = 0.3f;
if (vis)
soundSlot = SoundEngine.PlaySound(FrozenCube.cry with { Pitch = Main.rand.NextFloat(-0.2f, 0.2f) }, Projectile.Center);
}
trunkRotation = Utils.AngleLerp(trunkRotation, maxTrunkRot * Projectile.spriteDirection, 0.025f);
}
else if (hopTimer <= 0)
trunkRotation = Utils.AngleLerp(trunkRotation, 0, 0.11f);
if (Projectile.soundDelay >= cryTime)
{
SetRandCry();
}
if (Projectile.frameCounter >= blinkTime)
{
Projectile.frame = 1;
Projectile.frameCounter = -6;
}
if (Projectile.frameCounter == 0)
{
Projectile.frame = 0;
SetRandBlink();
}
if (vis)
{
Projectile.frameCounter++;
Projectile.soundDelay += 2; // Naturally decreases by 1, so to make it count up, increases it by 2
}
}
public override void AI()
{
if (time == 0)
{
lastHitNPCPos = lastProjPos = Owner.MountedCenter;
lastHitNPCPos = lastProjPos = Owner.Center;
Projectile.Opacity = 0;
}
if (vis && Projectile.Opacity < 1)
ScaleOpacity(1);
Projectile.timeLeft++;
SetStats();
GetColor();
SetElumphantPower();
ManageSquash();
if (SoundEngine.TryGetActiveSound(soundSlot, out var sound) && sound.IsPlaying)
sound.Position = Projectile.Center;
if (targeted != null && (targeted.life <= 0 || !targeted.active || !targeted.CanBeChasedBy(Projectile)))
targeted = null;
GetTarget(false);
float sine = MathF.Sin(time * 0.04f);
float sine2 = MathF.Sin(time * 0.08f);
@@ -194,205 +476,31 @@ namespace CalamityMod.Projectiles.Typeless
Vector2 offsetY = -Vector2.UnitY * (Owner.height / 2 + Projectile.height / 2.5f * Projectile.scale) * (1 + 0.4f * sine2 * fallLerp + 5 * CalamityUtils.EaseInOutExp(fallLerp, 2f, 2f)) * hop;
Vector2 offsetX = Vector2.UnitX * ((3 * Projectile.spriteDirection) + 17 * sine3 * fallLerp) * Projectile.scale;
goalPosition = Owner.MountedCenter + offsetX + offsetY;
if (dashing)
goalPosition = Owner.Center + offsetX + offsetY;
if (dashing) // Hop Attack
{
if (attackTimer == 0)
{
GetTarget(true);
}
if (attacksDone != 0)
Projectile.frame = 2;
float attackLerp = Utils.GetLerpValue((int)(attackTimeAdjusted / 2), attackTimeAdjusted, attackTimer, true);
int direction = Owner.ItemAnimationActive ? (Math.Sign(Projectile.Center.DirectionTo(Owner.ClampedMouseWorld()).X)) : (Owner.direction);
fxFade = attackLerp;
if (targeted == null || (targeted != null && (targeted.life <= 0 || !targeted.active)))
{
if (attackLerp > 0 && !recoiling)
{
lastHitNPCPos = Projectile.Center;
attackTimer = attackTimeAdjusted;
}
recoiling = true;
targeted = null;
}
Vector2 ownerPos = (Owner.MountedCenter + new Vector2((3 * Projectile.spriteDirection), -(Owner.height / 2 + Projectile.height / 2.5f * Projectile.scale)));
Vector2 basePosition = recoiling ? ownerPos : Projectile.numHits == 0 ? ownerPos : (lastHitNPCPos);
Vector2 targetPos = recoiling ? lastHitNPCPos : targeted.Center - (Vector2.UnitY * targeted.height / 2);
float jumpHeight = Math.Max(250 - Projectile.numHits * 40, recoiling ? 250 : 60);
float jumpLerp = attackLerp > 0.5f ? 1 - (MathF.Pow(Utils.GetLerpValue(0.5f, 1f, attackLerp), 4)) : 1 - (MathF.Pow(Utils.GetLerpValue(0.5f, 0f, attackLerp), 2));
float jumpOffsetY = MathHelper.Lerp(basePosition.Y, targetPos.Y, attackLerp) - (jumpHeight + Math.Max(targeted != null ? (Owner.Center.Y - targeted.Center.Y) : 0, 0)) * jumpLerp;
float jumpOffsetX = MathHelper.Lerp(basePosition.X, targetPos.X, attackLerp);
goalPosition = new Vector2(jumpOffsetX, jumpOffsetY);
Projectile.Center = goalPosition;
if (attackLerp > 0f && spawnJumpDusts)
{
bool clrChoose = Main.rand.NextBool();
int halfDusts = 14;
for (int i = -halfDusts; i <= halfDusts; i++)
{
Vector2 dustVel = -Vector2.UnitY.RotatedByRandom(0.9f) * Main.rand.NextFloat(0.6f, 1.8f);
Vector2 dustPos = Owner.MountedCenter + Vector2.UnitY * -(Owner.height / 2 + Projectile.height / 2.5f * Projectile.scale) + dustVel * 1.5f;
Dust dust2 = Dust.NewDustPerfect(dustPos, ModContent.DustType<SquashDustPixelated>(),
dustVel.RotatedByRandom(0.55f) * (Math.Abs(i) * 0.2f) * (Main.rand.NextBool(5) ? 3 : 1), 0, default, Main.rand.NextFloat(0.2f, 0.45f) * 2.5f);
dust2.noGravity = true;
dust2.color = Main.rand.NextBool() ? color1 : color2;
dust2.customData = new Vector2(0.6f, 1.5f);
dust2.fadeIn = -0.7f;
if (i == -1)
i = 1;
}
spawnJumpDusts = false;
}
if (attackLerp > 0.6f && !recoiling)
{
Vector2 vel = lastProjPos.DirectionTo(Projectile.Center);
bool clrChoose = Main.rand.NextBool();
float opacity = 0.3f * attackLerp;
Particle smoke = new CustomColorChangeSpark(Projectile.Center - vel * 18, vel * Main.rand.NextFloat(0.3f, 0.45f), "CalamityMod/Particles/BloomCircle", false, Main.rand.Next(12, 17), (Main.rand.NextFloat(0.35f, 0.45f) + 0.35f * attackLerp) * Projectile.scale, (clrChoose ? color1 : color2) with { A = 0 } * opacity, (clrChoose ? color2 : color1) with { A = 0 } * opacity, new Vector2(0.65f, 1f), false, shrinkSpeed: 0.1f);
GeneralParticleHandler.SpawnParticle(smoke, true, Enums.GeneralDrawLayer.BeforeProjectiles);
}
float goalAngle = (attackLerp > 0.5f ? basePosition.DirectionTo(Projectile.Center) : Projectile.Center.DirectionTo(targetPos)).ToRotation() + (attackLerp > 0.5f ? MathHelper.PiOver2 : -MathHelper.PiOver2);
if (!recoiling)
Projectile.rotation = MathHelper.WrapAngle(Utils.Remap(attackLerp, 0, 1, -MathHelper.PiOver2 * Projectile.spriteDirection, MathHelper.PiOver2 * Projectile.spriteDirection)) * (1 - MathF.Pow(1 - attackLerp, 3));
else
Projectile.rotation = MathHelper.WrapAngle(Utils.Remap(attackLerp, 0, 1, MathHelper.TwoPi * 2 * Projectile.spriteDirection, 0));
trunkRotation = trunkRotation.AngleLerp(Projectile.rotation, recoiling ? 1 : 0.15f);
int attemptDir = Math.Sign((recoiling ? basePosition.X : targetPos.X) - Projectile.Center.X);
SetDirection(attemptDir);
if (attackTimer <= (int)(attackTimeAdjusted / 2) && recoiling)
{
Projectile.frame = 0;
hitNPCs.Clear();
Projectile.velocity = Vector2.Zero;
recoiling = false;
dashing = false;
Projectile.numHits = 0;
attackTimer = (int)(cooldownTime / 2);
attacksDone = 0;
spawnJumpDusts = true;
for (int i = 0; i < Main.maxNPCs; i++)
Projectile.localNPCImmunity[i] = 0;
GetTarget(true);
}
HopAttack(goalPosition);
}
else
{
int direction = Owner.ItemAnimationActive ? (Math.Sign(Projectile.Center.DirectionTo(Owner.ClampedMouseWorld()).X)) : Math.Sign(Owner.velocity.X);
if (fallTimer == 0)
SetDirection(direction);
Projectile.Center = goalPosition;
if (targeted == null)
GetTarget(false);
if (attackTimer == cooldownTime && !ValidDistance())
attackTimer--;
if (attackTimer > cooldownTime && ValidDistance()) // Attack!!!
if (attackTimer > cooldownTime && targeted != null) // Mist Attack
{
Projectile.frame = 1;
float angleSweep = MathF.Sin(attackTimer * 0.085f) * attackDirection;
float goalAngle = Projectile.Center.DirectionTo(targeted.Center).ToRotation() - MathHelper.PiOver2;
if (attackTimer == cooldownTime + 1) // Make start attack sound
{
SoundStyle attack = new("CalamityMod/Sounds/Item/ElumphantSound");
SoundEngine.PlaySound(attack with { Pitch = Main.rand.NextFloat(-0.2f, 0.2f) }, Projectile.Center);
Projectile.soundDelay = 0;
Projectile.frameCounter = 1;
}
SetDirection(Math.Sign(Projectile.Center.DirectionTo(targeted.Center).X));
horizontalSquash = 0.5f;
Projectile.rotation = Projectile.rotation.AngleLerp((goalAngle + MathHelper.PiOver2 * Projectile.spriteDirection), 0.07f) * MathF.Pow(fallLerp, 0.2f);
float angleMax = MathHelper.PiOver4 * 0.75f * Utils.GetLerpValue(maxTargetingDistance, 30, Projectile.Center.Distance(targeted.Center), true);
if (hopTimer == 0)
trunkRotation = trunkRotation.AngleLerp(goalAngle - Projectile.rotation - angleMax * angleSweep, 0.23f);
if (attackTimer > (cooldownTime * 1.1f))
{
if (mistShootTimer == 0 && Main.myPlayer == Projectile.owner)
{
Vector2 shootVel = (trunkRotation + Projectile.rotation + MathHelper.PiOver2).ToRotationVector2();
int damage = (int)Owner.GetTotalDamage<GenericDamageClass>().ApplyTo(FrozenCube.mistBaseDamage * GetPower(4));
int projectile = ModContent.ProjectileType<ElumphantMist>();
Vector2 shootPosition = Projectile.Center + shootVel * 5 * Projectile.scale;
Projectile mist = Projectile.NewProjectileDirect(Owner.GetSource_FromThis(), shootPosition, (shootVel * shootPosition.Distance(targeted.Center) / 25) * Main.rand.NextFloat(0.9f, 1.1f), projectile, damage, 0, Owner.whoAmI, 0, Owner.ownedProjectileCounts[projectile] % 3, GetPower(1));
}
mistShootTimer += 0.35f * GetPower(0.25f);
if (mistShootTimer >= 2f)
mistShootTimer = 0;
}
mammothFlip = false;
attackedThisFrame = true;
if (attackTimer == cooldownTime + attackTime)
{
attackDirection *= -1;
Projectile.frame = 0;
attacksDone++;
if (attacksDone >= 2) // Every 2 attacks, do a dash slam
{
dashing = true;
attackTimer = -1;
}
}
MistAttack(fallLerp);
}
else // Idle
{
targeted = null;
if (Owner.StandingStill()) // If standing still, let the player mess with the mammoth squash for fun
{
if (Owner.controlDown)
horizontalSquash = 0.5f;
if (Owner.controlUp)
verticalSquash = 0.5f;
}
if (Math.Abs(Owner.velocity.X) > 4 && fallTimer == 0)
verticalSquash = 0.25f * Utils.GetLerpValue(4, 10, Math.Abs(Owner.velocity.X));
if (targeted == null && attackTimer > cooldownTime) // If can attack but there is no target, wait to decrease the timer until a target is found
attackTimer--;
int cryStart = (int)(cryTime - 65);
if (Projectile.soundDelay >= cryStart)
{
if (Projectile.soundDelay == cryStart) // Sound
{
verticalSquash = 0.3f;
SoundStyle cry = new("CalamityMod/Sounds/Item/ElumphantCry");
SoundEngine.PlaySound(cry with { Pitch = Main.rand.NextFloat(-0.2f, 0.2f) }, Projectile.Center);
}
trunkRotation = Utils.AngleLerp(trunkRotation, maxTrunkRot * Projectile.spriteDirection, 0.025f);
}
else
trunkRotation = Utils.AngleLerp(trunkRotation, 0, 0.11f);
if (Projectile.soundDelay >= cryTime)
{
SetRandCry();
}
if (Projectile.frameCounter >= blinkTime)
{
Projectile.frame = 1;
Projectile.frameCounter = -6;
}
if (Projectile.frameCounter == 0)
{
Projectile.frame = 0;
SetRandBlink();
}
Projectile.frameCounter++;
Projectile.soundDelay += 2; // Naturally decreases by 1, so to make it count up, increases it by 2
int direction = Owner.ItemAnimationActive ? (Math.Sign(Projectile.Center.DirectionTo(Owner.ClampedMouseWorld()).X)) : Owner.direction;
if (fallTimer == 0)
SetDirection(direction);
Idle();
}
if (hopTimer == 0 && !attackedThisFrame)
if (hopTimer <= 0 && !attackedThisFrame)
{
if (mammothFlip)
{
@@ -403,11 +511,10 @@ namespace CalamityMod.Projectiles.Typeless
}
}
if (Owner.velocity.Y > 8)
if (Owner.velocity.Y > 8 && !dashing && vis) // If the player is falling at close to max normal downward velocity
{
if (fallTimer == 0)
mammothFlip = true;//Main.rand.NextBool(3);
mammothFlip = Main.rand.NextBool(3);
hitHead = false;
SetRandCry();
SetRandBlink();
@@ -415,7 +522,7 @@ namespace CalamityMod.Projectiles.Typeless
fallTimer++;
}
else if (fallTimer > 0)
fallTimer -= 7 - Owner.velocity.Y; if (fallTimer < 0) fallTimer = 0;
fallTimer -= 7 - Math.Min(Owner.velocity.Y, 0); if (fallTimer < 0) fallTimer = 0;
if (fallTimer <= 0 && !hitHead)
{
float landPower = (Utils.GetLerpValue(0, maxFallTimer, lastHighestFallTimer, true));
@@ -425,32 +532,31 @@ namespace CalamityMod.Projectiles.Typeless
float rotation = MathHelper.WrapAngle(Projectile.rotation + MathHelper.Pi);
if (mammothFlip && rotation < MathHelper.PiOver2 && rotation > -MathHelper.PiOver2 && landPower > 0.2f)
{
SoundStyle bonk = new("CalamityMod/Sounds/Item/Bonk");
SoundEngine.PlaySound(bonk with { Pitch = Main.rand.NextFloat(0.1f, 0.2f) }, Projectile.Center);
int halfDusts = 7;
Owner.SetScreenshake(3);
Projectile.frame = 1;
SetRandBlink();
for (int i = -halfDusts; i <= halfDusts; i++)
if (vis)
{
Vector2 dustVel = Vector2.UnitX.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.6f, 1.8f);
Vector2 dustPos = Owner.MountedCenter - (Vector2.UnitY * Owner.height / 2) + dustVel * 1.5f;
Dust dust2 = Dust.NewDustPerfect(dustPos, ModContent.DustType<SquashDustPixelated>(),
dustVel * (i * 0.4f), 0, default, Main.rand.NextFloat(0.2f, 0.45f) * 3);
dust2.noGravity = true;
dust2.color = Main.rand.NextBool() ? color1 : color2;
dust2.customData = new Vector2(0.6f, 1.5f);
dust2.fadeIn = -0.4f;
if (i == -1)
i = 1;
Owner.SetScreenshake(2);
SoundEngine.PlaySound(FrozenCube.jokeBonk with { Pitch = Main.rand.NextFloat(0.1f, 0.2f) }, Projectile.Center);
for (int i = -halfDusts; i <= halfDusts; i++)
{
Vector2 dustVel = Vector2.UnitX.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.6f, 1.8f);
Vector2 dustPos = Owner.Center - (Vector2.UnitY * Owner.height / 2) + dustVel * 1.5f;
Dust dust2 = Dust.NewDustPerfect(dustPos, ModContent.DustType<SquashDustPixelated>(),
dustVel * (i * 0.4f), 0, default, Main.rand.NextFloat(0.2f, 0.45f) * 3);
dust2.noGravity = true;
dust2.color = Main.rand.NextBool() ? color1 : color2;
dust2.customData = new Vector2(0.6f, 1.5f);
dust2.fadeIn = -0.4f;
if (i == -1)
i = 1;
}
SoundEngine.PlaySound(FrozenCube.noise with { Pitch = Main.rand.NextFloat(0.4f, 0.6f), volume = 0.6f }, Projectile.Center);
CombatText.NewText(Projectile.Hitbox, usedColor, "!");
}
trunkRotation = maxTrunkRot * Projectile.spriteDirection;
SoundStyle ahh = new("CalamityMod/Sounds/Item/ElumphantSound");
SoundEngine.PlaySound(ahh with { Pitch = Main.rand.NextFloat(0.4f, 0.6f), volume = 0.6f }, Projectile.Center);
CombatText.NewText(Projectile.Hitbox, usedColor, "!");
verticalSquash = 1.5f * landPower;
mammothOops = true;
}
@@ -461,7 +567,7 @@ namespace CalamityMod.Projectiles.Typeless
mammothFlip = false;
}
if (fxFade > 0)
if (fxFade > 0 && vis)
Lighting.AddLight(Projectile.Center, usedColor.ToVector3() * 0.6f * fxFade);
if (fallTimer > lastHighestFallTimer)
@@ -470,7 +576,7 @@ namespace CalamityMod.Projectiles.Typeless
if (attackTimer >= attackTime + cooldownTime)
attackTimer = 0;
attackTimer += recoiling ? -0.75f : 1;
attackTimer += recoiling ? -0.75f : 1 + 0.4f * Projectile.numHits;
time++;
if (mammothOops)
hopTimer++;
@@ -485,7 +591,12 @@ namespace CalamityMod.Projectiles.Typeless
lastProjPos = Projectile.Center;
if (!Owner.Calamity().frozenCube)
{
if (sound.IsPlaying)
sound?.Stop();
Projectile.Kill();
return;
}
}
public void SetRandBlink()
{
@@ -495,15 +606,16 @@ namespace CalamityMod.Projectiles.Typeless
public void SetRandCry()
{
Projectile.soundDelay = 0;
cryTime = Main.rand.Next(420, 600 + 1);
cryTime = Main.rand.Next(800, 1200 + 1);
}
public override bool PreDraw(ref Color lightColor)
{
if (time == 0)
return false;
Asset<Texture2D> tex = ModContent.Request<Texture2D>(Texture);
Texture2D trunk = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Typeless/ElumphantTrunk").Value;
Texture2D bTexture = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle").Value;
Texture2D trunk = TrunkTexture.Value;
Color bodyColor = lightColor;
Color bodyColor = lightColor * Projectile.Opacity;
Rectangle frame = tex.Value.Frame(1, Main.projFrames[Type], 0, Projectile.frame);
float squashSineV = MathF.Sin(squashTimerY * 0.55f) * verticalSquash;
@@ -518,11 +630,14 @@ namespace CalamityMod.Projectiles.Typeless
float trunkPosX = (trunkDistX - trunkDistX * (1 - squashX)) * Projectile.spriteDirection;
Vector2 trunkPos = new Vector2(trunkPosX * Projectile.scale, 0);
for (int i = 0; i < 18; i++) // Backglow
if (vis)
{
Vector2 drawOffset = (MathHelper.TwoPi * i / 18f).ToRotationVector2() * 6 * fxFade;
Main.EntitySpriteDraw(tex.Value, elumphantLocation - Main.screenPosition + drawOffset, frame, usedColor with { A = 0 } * 0.2f * fxFade, Projectile.rotation, frame.Size() * 0.5f, elumphantSquash * Projectile.scale, Projectile.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally);
Main.EntitySpriteDraw(trunk, elumphantLocation - Main.screenPosition + trunkPos.RotatedBy(Projectile.rotation), null, usedColor with { A = 0 } * 0.2f * fxFade, Projectile.rotation + trunkRotation, new Vector2(trunk.Width / 2, 0), elumphantSquash * Projectile.scale, Projectile.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally);
for (int i = 0; i < 18; i++) // Backglow
{
Vector2 drawOffset = (MathHelper.TwoPi * i / 18f).ToRotationVector2() * 4 * fxFade;
Main.EntitySpriteDraw(tex.Value, elumphantLocation - Main.screenPosition + drawOffset, frame, usedColor with { A = 0 } * 0.2f * fxFade, Projectile.rotation, frame.Size() * 0.5f, elumphantSquash * Projectile.scale, Projectile.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally);
Main.EntitySpriteDraw(trunk, elumphantLocation - Main.screenPosition + trunkPos.RotatedBy(Projectile.rotation), null, usedColor with { A = 0 } * 0.2f * fxFade * Projectile.Opacity, Projectile.rotation + trunkRotation, new Vector2(trunk.Width / 2, 0), elumphantSquash * Projectile.scale, Projectile.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally);
}
}
// Main body
@@ -536,11 +651,8 @@ namespace CalamityMod.Projectiles.Typeless
{
if (dashing)
{
float attackMult = 0.7f * GetPower(0.5f);
SoundStyle attack = new("CalamityMod/Sounds/Item/Bonk");
SoundEngine.PlaySound(attack with { Pitch = -0.2f + 0.05f * Projectile.numHits, volume = 0.75f, MaxInstances = -1 }, Projectile.Center);
target.MoveNPC(Projectile.Center.DirectionTo(target.Center), 8, false, Owner);
float attackMult = (float)(0.7f * GetPower(0.5f));
target.MoveNPC(Vector2.UnitY, 8, false, Owner);
hitNPCs.Add(target);
GetTarget(true);
@@ -549,62 +661,65 @@ namespace CalamityMod.Projectiles.Typeless
bool lastHit = false;
if (targeted == null)
{
Projectile.extraUpdates = 0;
attackMult *= 1.25f;
Owner.SetScreenshake(3 * attackMult);
if (vis)
Owner.SetScreenshake(3 * attackMult);
lastHit = true;
recoiling = true;
modifiers.SourceDamage *= 2f * GetPower(5);
modifiers.SourceDamage *= (float)(1.5f * damageScaling);
}
else
{
attackTimer = (int)(attackTimeAdjusted / 2) - 4;
float minMult = 0.1f;
int hitsToMinMult = 3;
attackTimer = (int)(attackTimeAdjusted / 2);
float minMult = 0.25f;
int hitsToMinMult = 4;
float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true);
modifiers.SourceDamage *= damageMult * GetPower(4);
modifiers.SourceDamage *= (float)(damageMult * damageScaling);
}
if (lastHit)
if (lastHit && vis)
{
SoundStyle finalHit = new("CalamityMod/Sounds/Item/ElumphantSound");
SoundEngine.PlaySound(finalHit with { Pitch = -0.5f, volume = 0.8f }, Projectile.Center);
SoundEngine.PlaySound(FrozenCube.noise with { Pitch = -0.5f, volume = 0.8f }, Projectile.Center);
}
verticalSquash = lastHit ? 0.85f : 0.5f;
int halfDusts = (int)((lastHit ? 12 : 8) * attackMult);
for (int i = -halfDusts; i <= halfDusts; i++)
if (vis)
{
Vector2 dustVel = Vector2.UnitX * Main.rand.NextFloat(0.6f, 1.8f) * attackMult;
Vector2 dustPos = Projectile.Center + dustVel * 1.5f;
Dust dust2 = Dust.NewDustPerfect(dustPos, ModContent.DustType<SquashDustPixelated>(),
dustVel.RotatedByRandom(0.35f) * (i * 0.4f), 0, default, Main.rand.NextFloat(0.2f, 0.45f) * (lastHit ? 5 : 3.5f) * attackMult);
dust2.noGravity = true;
dust2.color = Main.rand.NextBool() ? color1 : color2;
dust2.customData = new Vector2(0.6f, 1.5f);
dust2.fadeIn = -0.4f / attackMult;
float opacity = 0.7f;
if (i % 2 == 0)
SoundEngine.PlaySound(FrozenCube.hit with { Pitch = -0.2f + 0.05f * Projectile.numHits, volume = 1f, MaxInstances = -1 }, Projectile.Center);
int halfDusts = (int)((lastHit ? 12 : 8) * attackMult);
for (int i = -halfDusts; i <= halfDusts; i++)
{
bool clrChoose = Main.rand.NextBool();
Particle smoke = new CustomColorChangeSpark(dustPos, dustVel.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 0.45f) * i * (lastHit ? 2 : 1), Main.rand.NextBool(3) ? "CalamityMod/Particles/WaterFoam" : "CalamityMod/Particles/BloomCircle", false, Main.rand.Next(22, 27), Main.rand.NextFloat(0.45f, 0.65f) * Projectile.scale * (lastHit ? 2 : 1) * attackMult, (clrChoose ? color1 : color2) * opacity, (clrChoose ? color2 : color1) * opacity, new Vector2(0.25f, 1.2f));
GeneralParticleHandler.SpawnParticle(smoke, true);
}
Vector2 dustVel = Vector2.UnitX * Main.rand.NextFloat(0.6f, 1.8f) * attackMult;
Vector2 dustPos = Projectile.Center + dustVel * 1.5f;
Dust dust2 = Dust.NewDustPerfect(dustPos, ModContent.DustType<SquashDustPixelated>(),
dustVel.RotatedByRandom(0.35f) * (i * 0.4f), 0, default, Main.rand.NextFloat(0.2f, 0.45f) * (lastHit ? 5 : 3.5f) * attackMult);
dust2.noGravity = true;
dust2.color = Main.rand.NextBool() ? color1 : color2;
dust2.customData = new Vector2(0.6f, 1.5f);
dust2.fadeIn = -0.4f / attackMult;
if (lastHit)
{
bool clrChoose = Main.rand.NextBool();
float velMult = Main.rand.NextFloat(1.2f, 1.35f) * i;
Vector2 velocity = dustVel.RotatedByRandom(0.3f) * velMult;
Particle mist = new CustomPulsingSpark(dustPos, velocity, "CalamityMod/Particles/ThinSparkle", "CalamityMod/Particles/BloomCircle", false, 55, Main.rand.NextFloat(1.05f, 1.45f) * Projectile.scale * attackMult, (clrChoose ? color1 : color2) * opacity, (clrChoose ? color2 : color1) * opacity,
new Vector2(0.6f, 1.2f), true, true, Main.rand.Next(4, 7 + 1), colorFadeSpeed: 0.85f, noShrink: true, extraRotation: 0, shrinkSpeed: 0.1f, turnRate: (Main.rand.NextBool() ? -1 : 1) * Main.rand.NextFloat(0.0028f, 0.0035f) * velMult,
sineRate: Main.rand.NextFloat(0.09f, 0.12f), sineIntensity: (int)(4 + Main.rand.Next(15, 20 + 1)) * Projectile.scale, sineRotation: MathHelper.PiOver2 + velocity.ToRotation());
GeneralParticleHandler.SpawnParticle(mist, true, Main.rand.NextBool() ? Enums.GeneralDrawLayer.AfterNPCs : Enums.GeneralDrawLayer.BeforeNPCs);
}
float opacity = 0.7f;
if (i % 2 == 0)
{
bool clrChoose = Main.rand.NextBool();
Particle smoke = new CustomColorChangeSpark(dustPos, dustVel.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 0.45f) * i * (lastHit ? 2 : 1), Main.rand.NextBool(3) ? "CalamityMod/Particles/WaterFoam" : "CalamityMod/Particles/BloomCircle", false, Main.rand.Next(22, 27), Main.rand.NextFloat(0.45f, 0.65f) * Projectile.scale * (lastHit ? 2 : 1) * attackMult, (clrChoose ? color1 : color2) * opacity, (clrChoose ? color2 : color1) * opacity, new Vector2(0.25f, 1.2f));
GeneralParticleHandler.SpawnParticle(smoke, true);
}
if (i == -1)
i = 1;
if (lastHit)
{
bool clrChoose = Main.rand.NextBool();
float velMult = Main.rand.NextFloat(1.2f, 1.35f) * i;
Vector2 velocity = dustVel.RotatedByRandom(0.3f) * velMult;
Particle mist = new CustomPulsingSpark(dustPos, velocity, "CalamityMod/Particles/ThinSparkle", "CalamityMod/Particles/BloomCircle", false, 55, Main.rand.NextFloat(1.05f, 1.45f) * Projectile.scale * attackMult, (clrChoose ? color1 : color2) * opacity, (clrChoose ? color2 : color1) * opacity,
new Vector2(0.6f, 1.2f), true, true, Main.rand.Next(4, 7 + 1), colorFadeSpeed: 0.85f, noShrink: true, extraRotation: 0, shrinkSpeed: 0.1f, turnRate: (Main.rand.NextBool() ? -1 : 1) * Main.rand.NextFloat(0.0028f, 0.0035f) * velMult,
sineRate: Main.rand.NextFloat(0.09f, 0.12f), sineIntensity: (int)(4 + Main.rand.Next(15, 20 + 1)) * Projectile.scale, sineRotation: MathHelper.PiOver2 + velocity.ToRotation());
GeneralParticleHandler.SpawnParticle(mist, true, Main.rand.NextBool() ? Enums.GeneralDrawLayer.AfterNPCs : Enums.GeneralDrawLayer.BeforeNPCs);
}
if (i == -1)
i = 1;
}
}
}
}
@@ -616,6 +731,7 @@ namespace CalamityMod.Projectiles.Typeless
{
if (targeted == null)
return false;
// These extra frames before the hit allow for a bit of "hitstop" on the jump attack
return (dashing && attackTimer >= attackTimeAdjusted + 3 && target == targeted) ? null : false;
}
}
+22 -6
View File
@@ -28,6 +28,19 @@ namespace CalamityMod.Projectiles.Typeless
public int lifetime = 90;
public float originalScale = 0;
public Color mistColor = Color.White;
public bool vis => Owner.Calamity().frozenCubeVisuals;
public static Asset<Texture2D> SmokeTexture1 { get; private set; }
public static Asset<Texture2D> SmokeTexture2 { get; private set; }
public static Asset<Texture2D> SmokeTexture3 { get; private set; }
public override void Load()
{
if (Main.dedServ)
return;
SmokeTexture1 = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Typeless/SmokePuff1");
SmokeTexture2 = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Typeless/SmokePuff2");
SmokeTexture3 = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Typeless/SmokePuff3");
}
public override void SetDefaults()
{
Projectile.width = 32;
@@ -57,12 +70,12 @@ namespace CalamityMod.Projectiles.Typeless
float inverseFade = Utils.GetLerpValue(lifetime, 0, Projectile.timeLeft, true);
float opacity = 0.4f * fade * (1.2f - inverseFade);
if (Main.rand.NextBool(3)) // Effects
if (Main.rand.NextBool(3) && vis) // Effects
{
Particle trail = new CustomColorChangeSpark(Projectile.Center + Main.rand.NextVector2Circular(40, 40) * Projectile.scale * (1 - fade) - Projectile.velocity.SafeNormalize(Vector2.UnitX) * (-35 + 65 * inverseFade) * Projectile.scale, Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.3f) * Main.rand.NextFloat(3, 4), Main.rand.NextBool(3) ? "CalamityMod/Particles/WaterFoam" : "CalamityMod/Particles/BloomCircle", false, Main.rand.Next(9, 12), Main.rand.NextFloat(0.75f, 1f) * Projectile.scale, (mistColor == Elumphant.color1 ? mistColor : Elumphant.color2) * opacity, (mistColor == Elumphant.color2 ? mistColor : Elumphant.color1) * opacity, new Vector2(0.15f + 0.85f * inverseFade, 1.4f - 0.4f * inverseFade));
GeneralParticleHandler.SpawnParticle(trail, true);
}
if (Main.rand.NextBool(12))
if (Main.rand.NextBool(12) && vis)
{
float rotation = 0;
Vector2 velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.1f) * Main.rand.NextFloat(7f, 14f);
@@ -78,7 +91,11 @@ namespace CalamityMod.Projectiles.Typeless
}
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
{
target.AddBuff(ModContent.BuffType<WindChilled>(), (int)(300 * Projectile.ai[2]));
target.AddBuff(FrozenCube.debuff, (int)(300 * Projectile.ai[2]));
float minMult = 0.25f;
int hitsToMinMult = 3;
float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true);
modifiers.SourceDamage *= damageMult;
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
@@ -88,13 +105,12 @@ namespace CalamityMod.Projectiles.Typeless
{
if (time == 0)
return false;
Asset<Texture2D> tex = ModContent.Request<Texture2D>(Texture);
Texture2D bTexture = (textureChoice == 0 ? ModContent.Request<Texture2D>("CalamityMod/Particles/SmokePuff1").Value : textureChoice == 1 ? ModContent.Request<Texture2D>("CalamityMod/Particles/SmokePuff2").Value : ModContent.Request<Texture2D>("CalamityMod/Particles/SmokePuff3").Value);
Texture2D bTexture = (textureChoice == 0 ? SmokeTexture1.Value : textureChoice == 1 ? SmokeTexture2.Value : SmokeTexture3.Value);
float inverseFade = Utils.GetLerpValue(lifetime, 0, Projectile.timeLeft, true);
PixelationManager.AddPixelatedDrawer((_) =>
{
Main.EntitySpriteDraw(bTexture, Projectile.Center - Main.screenPosition, null, mistColor with { A = 0 } * fade, Projectile.rotation, new Vector2(bTexture.Width / 2, bTexture.Height * (MathHelper.Lerp(0.7f, 0.4f, inverseFade))), new Vector2(0.3f + 0.7f * inverseFade, 1.4f - 0.4f * inverseFade) * Projectile.scale, SpriteEffects.None);
Main.EntitySpriteDraw(bTexture, Projectile.Center - Main.screenPosition, null, mistColor with { A = 0 } * fade * (vis ? 1 : 0.5f), Projectile.rotation, new Vector2(bTexture.Width / 2, bTexture.Height * (MathHelper.Lerp(0.7f, 0.4f, inverseFade))), new Vector2(0.3f + 0.7f * inverseFade, 1.4f - 0.4f * inverseFade) * Projectile.scale, SpriteEffects.None);
}, Enums.GeneralDrawLayer.AfterProjectiles, default);
return false;
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.