Cragmaw is less of a meme
This commit is contained in:
1 parent
67f761ee9f
commit
006fa56785
6 files changed
+581
-272
No files matched your search
+350
-179
@@ -12,18 +12,34 @@ using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using CalamityMod.Buffs.StatDebuffs;
|
||||
using CalamityMod.Items.Weapons.Rogue;
|
||||
using Terraria.Utilities;
|
||||
using CalamityMod.Projectiles.Rogue;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace CalamityMod.NPCs.AcidRain
|
||||
{
|
||||
public class CragmawMire : ModNPC
|
||||
{
|
||||
public enum CragmawAttackState
|
||||
{
|
||||
ReleaseBurstsOfSpikes,
|
||||
AcidExplosionSlam,
|
||||
DigAndReleaseLaser,
|
||||
CreateVibeCheckTether
|
||||
}
|
||||
|
||||
public Player Target => Main.player[npc.target];
|
||||
public ref float Time => ref npc.ai[0];
|
||||
public CragmawAttackState CurrentAttack
|
||||
{
|
||||
get => (CragmawAttackState)(int)npc.ai[0];
|
||||
set => npc.ai[0] = (int)value;
|
||||
}
|
||||
public ref float AttackTimer => ref npc.ai[1];
|
||||
public bool HasMadeShellBreakGore
|
||||
{
|
||||
{
|
||||
get => npc.localAI[0] == 1f;
|
||||
set => npc.localAI[0] = value.ToInt();
|
||||
}
|
||||
}
|
||||
public bool InPhase2
|
||||
{
|
||||
get
|
||||
@@ -32,6 +48,7 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
return npc.life / (float)npc.lifeMax < phase2CeilingRatio && CalamityWorld.downedPolterghast;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Cragmaw Mire");
|
||||
@@ -40,9 +57,9 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
npc.Calamity().canBreakPlayerDefense = true;
|
||||
npc.Calamity().canBreakPlayerDefense = true;
|
||||
|
||||
npc.width = 68;
|
||||
npc.width = 68;
|
||||
npc.height = 54;
|
||||
npc.aiStyle = aiType = -1;
|
||||
|
||||
@@ -57,6 +74,7 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
npc.defense = 80;
|
||||
}
|
||||
|
||||
npc.behindTiles = true;
|
||||
npc.knockBackResist = 0f;
|
||||
npc.value = Item.buyPrice(0, 3, 60, 0);
|
||||
npc.lavaImmune = false;
|
||||
@@ -72,205 +90,358 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
Time++;
|
||||
npc.TargetClosest(false);
|
||||
|
||||
// Summons a spinning spiral of dust and a dust telegraph
|
||||
if (Time % 420f > 240f && Time % 420f < 300f)
|
||||
{
|
||||
float vectorRotationAngle = (Time % 420f - 240f) / 60f * MathHelper.Pi * 4f;
|
||||
for (int i = 0; i < 25; i++)
|
||||
{
|
||||
float angle = MathHelper.TwoPi * i / 25f;
|
||||
float y = (float)Math.Sin(angle) * (float)Math.Log(Math.Abs(Math.Cos(angle)));
|
||||
if (!float.IsNaN(y))
|
||||
{
|
||||
Vector2 velocity = new Vector2((float)Math.Cos(angle), y) * MathHelper.Lerp(2.4f, 4.2f, (Time - 240f) / 60f);
|
||||
Dust dust = Dust.NewDustPerfect(npc.Center, (int)CalamityDusts.SulfurousSeaAcid);
|
||||
dust.velocity = velocity.RotatedBy(vectorRotationAngle);
|
||||
dust.noGravity = true;
|
||||
dust.scale = MathHelper.Lerp(1.2f, 2.5f, (Time - 240f) / 60f);
|
||||
}
|
||||
}
|
||||
// Reset things every frame. They may be changed in the attack states below.
|
||||
npc.noGravity = false;
|
||||
npc.noTileCollide = false;
|
||||
npc.dontTakeDamage = false;
|
||||
|
||||
float length = MathHelper.Lerp(20f, 1200f, (Time % 420f - 240f) / 60f);
|
||||
float outwardness = 1f - (Time % 420f - 240f) / 60f;
|
||||
for (float i = npc.Top.Y + 4f; i >= npc.Top.Y + 4f - length; i -= 6f)
|
||||
{
|
||||
float angle = i / 32f;
|
||||
vectorRotationAngle = -(i / 20f) % 0.4f - 0.2f;
|
||||
Vector2 spawnPosition = new Vector2(npc.Center.X, i);
|
||||
Dust dust = Dust.NewDustPerfect(spawnPosition, (int)CalamityDusts.SulfurousSeaAcid);
|
||||
dust.scale = 1.5f;
|
||||
dust.velocity = (Vector2.UnitX * (float)Math.Cos(angle) * 4f * outwardness).RotatedBy(vectorRotationAngle);
|
||||
dust.noGravity = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Release a laser beam upward and create an explosion.
|
||||
if (Time % 420f == 300f)
|
||||
{
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
Main.PlaySound(SoundID.Zombie, (int)npc.position.X, (int)npc.position.Y, 104);
|
||||
int damage = CalamityWorld.downedPolterghast ? 120 : 40;
|
||||
Projectile.NewProjectile(npc.Center, -Vector2.UnitY, ModContent.ProjectileType<CragmawBeam>(), damage, 4f, Main.myPlayer, 0f, npc.whoAmI);
|
||||
}
|
||||
|
||||
Vector2 circlePointVector = -Vector2.UnitY;
|
||||
float lerpStart = Main.rand.Next(12, 16);
|
||||
float lerpEnd = Main.rand.Next(3, 6);
|
||||
for (int h = 0; h < 4; h++)
|
||||
{
|
||||
for (float i = 0; i < 9f; ++i)
|
||||
{
|
||||
for (int j = 0; j < 2; ++j)
|
||||
{
|
||||
Vector2 randomCirclePointRotated = circlePointVector.RotatedBy((j == 0 ? 1 : -1) * MathHelper.TwoPi / 18f).RotatedBy(h / 4f * MathHelper.Pi);
|
||||
for (float k = 0f; k < 20f; ++k)
|
||||
{
|
||||
Vector2 randomCirclePointLerped = Vector2.Lerp(circlePointVector, randomCirclePointRotated, k / 20f);
|
||||
float lerpMultiplier = MathHelper.Lerp(lerpStart, lerpEnd, k / 20f) * 0.9f;
|
||||
int dustIndex = Dust.NewDust(npc.Top + 6f * Vector2.UnitY, 0, 0,
|
||||
(int)CalamityDusts.SulfurousSeaAcid,
|
||||
0f, 0f, 100, default, 1.3f);
|
||||
Main.dust[dustIndex].noGravity = true;
|
||||
Main.dust[dustIndex].scale = 2f;
|
||||
Main.dust[dustIndex].velocity = randomCirclePointLerped * lerpMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
circlePointVector = circlePointVector.RotatedBy(MathHelper.TwoPi / 9f);
|
||||
}
|
||||
}
|
||||
npc.netUpdate = true;
|
||||
}
|
||||
|
||||
// Release acid into the air.
|
||||
else if (Time % 420f > 300f && Time % 7f == 6f && CalamityWorld.downedPolterghast)
|
||||
{
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
Projectile.NewProjectile(npc.Center, -Vector2.UnitY.RotatedByRandom(0.6f) * Main.rand.NextFloat(10f, 15f), ModContent.ProjectileType<AcidDrop>(), 69, 4f, Main.myPlayer, 0f, npc.whoAmI);
|
||||
}
|
||||
|
||||
if (InPhase2)
|
||||
DoPhase2AI();
|
||||
else
|
||||
DoPhase1AI();
|
||||
}
|
||||
|
||||
public void DoPhase1AI()
|
||||
{
|
||||
// Become harder to damage to if the target is not in water.
|
||||
npc.Calamity().DR = Target.wet ? 0.3f : 0.5f;
|
||||
|
||||
// Use a rock-like hit sound.
|
||||
npc.HitSound = SoundID.NPCHit42;
|
||||
|
||||
if (Time % 420f < 240f)
|
||||
{
|
||||
float bubbleShootRate = CalamityWorld.downedPolterghast ? 24f : 50f;
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient && Time % bubbleShootRate == bubbleShootRate - 1f)
|
||||
{
|
||||
int damage = CalamityWorld.downedPolterghast ? 47 : 30;
|
||||
Vector2 bubbleSpawnPosition = npc.Top + Vector2.UnitY * 5f;
|
||||
Vector2 bubbleShootVelocity = -Vector2.UnitY.RotatedByRandom(0.25f) * 4f;
|
||||
int bubble = Projectile.NewProjectile(bubbleSpawnPosition, bubbleShootVelocity, ModContent.ProjectileType<CragmawBubble>(), damage, 1f);
|
||||
|
||||
if (Main.projectile.IndexInRange(bubble))
|
||||
{
|
||||
Main.projectile[bubble].timeLeft = Main.rand.Next(120, 180);
|
||||
Main.projectile[bubble].netUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Summon enemies from time to time.
|
||||
if (Time % 50f == 49f && Main.rand.NextBool(4))
|
||||
{
|
||||
List<int> possibleEnemies = new List<int>();
|
||||
if (CalamityWorld.downedPolterghast)
|
||||
{
|
||||
possibleEnemies.Add(ModContent.NPCType<GammaSlime>());
|
||||
possibleEnemies.Add(ModContent.NPCType<NuclearToad>());
|
||||
possibleEnemies.Add(ModContent.NPCType<Orthocera>());
|
||||
}
|
||||
else
|
||||
{
|
||||
possibleEnemies.Add(ModContent.NPCType<WaterLeech>());
|
||||
possibleEnemies.Add(ModContent.NPCType<Trilobite>());
|
||||
}
|
||||
|
||||
SummonEnemyNearSelf(possibleEnemies);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DoPhase2AI()
|
||||
{
|
||||
// Release shell gore the first frame this enemy is in the second phase.
|
||||
if (!HasMadeShellBreakGore)
|
||||
// Handle the phase 2 transition.
|
||||
if (InPhase2 && !HasMadeShellBreakGore)
|
||||
{
|
||||
Main.PlaySound(SoundID.DD2_ExplosiveTrapExplode, npc.Center);
|
||||
Gore.NewGore(npc.position, -Vector2.UnitY.RotatedByRandom(0.4f) * 4f, mod.GetGoreSlot("Gores/AcidRain/CragmawMireP1Gore"), npc.scale);
|
||||
Gore.NewGore(npc.position, -Vector2.UnitY.RotatedByRandom(0.4f) * 4f, mod.GetGoreSlot("Gores/AcidRain/CragmawMireP1Gore2"), npc.scale);
|
||||
Gore.NewGore(npc.position, -Vector2.UnitY.RotatedByRandom(0.4f) * 4f, mod.GetGoreSlot("Gores/AcidRain/CragmawMireP1Gore3"), npc.scale);
|
||||
HasMadeShellBreakGore = true;
|
||||
}
|
||||
|
||||
// Have DR depend on the current mode.
|
||||
npc.Calamity().DR = CalamityWorld.revenge ? 0.125f : 0f;
|
||||
|
||||
// And use the squishy slime hit sound.
|
||||
npc.HitSound = SoundID.NPCHit1;
|
||||
|
||||
// Release a tether that attempts to grab the target and then release spikes upward a bit afterwards.
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
switch (CurrentAttack)
|
||||
{
|
||||
if (Time % 600f == 20f)
|
||||
Projectile.NewProjectile(npc.Center, Vector2.UnitY, ModContent.ProjectileType<CragmawVibeCheckChain>(), 0, 0f, Main.myPlayer, npc.whoAmI, npc.target);
|
||||
if (Time % 600f == 240f)
|
||||
case CragmawAttackState.ReleaseBurstsOfSpikes:
|
||||
DoBehavior_ReleaseBurstsOfSpikes();
|
||||
break;
|
||||
case CragmawAttackState.AcidExplosionSlam:
|
||||
DoBehavior_AcidExplosionSlam();
|
||||
break;
|
||||
case CragmawAttackState.DigAndReleaseLaser:
|
||||
DoBehavior_DigAndReleaseLaser();
|
||||
break;
|
||||
case CragmawAttackState.CreateVibeCheckTether:
|
||||
DoBehavior_CreateVibeCheckTether();
|
||||
break;
|
||||
}
|
||||
|
||||
AttackTimer++;
|
||||
}
|
||||
|
||||
public void DoBehavior_ReleaseBurstsOfSpikes()
|
||||
{
|
||||
int spikesPerBurst = 5;
|
||||
float burstSpeed = 8f;
|
||||
int burstShootRate = 92;
|
||||
if (CalamityWorld.downedPolterghast)
|
||||
{
|
||||
spikesPerBurst += 3;
|
||||
burstSpeed += 3.25f;
|
||||
burstShootRate -= 20;
|
||||
}
|
||||
if (InPhase2)
|
||||
{
|
||||
spikesPerBurst++;
|
||||
burstShootRate -= 10;
|
||||
}
|
||||
|
||||
if (Collision.SolidCollision(npc.position, npc.width, npc.height - 6))
|
||||
npc.position.Y -= 4f;
|
||||
|
||||
// Release bursts of spikes and play a fire sound.
|
||||
float wrappedAttackTimer = AttackTimer % burstShootRate;
|
||||
|
||||
// Create some charge-up dust before firing.
|
||||
if (wrappedAttackTimer > burstShootRate * 0.65f)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Dust rock = Dust.NewDustPerfect(npc.Center + Main.rand.NextVector2Circular(75f, 75f), 1);
|
||||
rock.color = Color.Yellow;
|
||||
rock.velocity = (npc.Center - rock.position) * Main.rand.NextFloat(0.06f, 0.09f);
|
||||
rock.scale = Main.rand.NextFloat(1f, 1.3f);
|
||||
rock.noGravity = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (wrappedAttackTimer == burstShootRate - 1f)
|
||||
{
|
||||
// Play the sound.
|
||||
Main.PlaySound(SoundID.Item92, npc.Center);
|
||||
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
int damage = CalamityWorld.downedPolterghast ? 52 : 33;
|
||||
for (int i = 0; i < 16; i++)
|
||||
float shootOffsetAngle = Main.rand.NextFloat(MathHelper.TwoPi);
|
||||
for (int i = 0; i < spikesPerBurst; i++)
|
||||
{
|
||||
float shootDirectionAngle = MathHelper.TwoPi / 16f * i;
|
||||
float offsetAngle = Main.rand.NextFloatDirection() * MathHelper.TwoPi / 27f;
|
||||
shootDirectionAngle += offsetAngle;
|
||||
Projectile.NewProjectile(npc.Center, shootDirectionAngle.ToRotationVector2() * 6f, ModContent.ProjectileType<CragmawSpike>(), damage, 4f);
|
||||
Vector2 spikeShootVelocity = (MathHelper.TwoPi * i / spikesPerBurst + shootOffsetAngle).ToRotationVector2() * burstSpeed;
|
||||
Projectile.NewProjectile(npc.Center + spikeShootVelocity * 1.6f, spikeShootVelocity, ModContent.ProjectileType<CragmawSpike>(), damage, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (AttackTimer > 240f)
|
||||
SelectNextAttack();
|
||||
}
|
||||
|
||||
public void SummonEnemyNearSelf(IList<int> possibleEnemies)
|
||||
public void DoBehavior_AcidExplosionSlam()
|
||||
{
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient)
|
||||
return;
|
||||
|
||||
int attempts = 0;
|
||||
Vector2 spawnPosition = npc.Center + Utils.RandomVector2(Main.rand, -360f, 360f);
|
||||
|
||||
// Ensure that the potential spawn position is actually in the world.
|
||||
while (!WorldGen.InWorld((int)spawnPosition.X / 16, (int)spawnPosition.Y / 16))
|
||||
float opacityFadeoutIncrement = 0.03f;
|
||||
float verticalTeleportOffset = 415f;
|
||||
float slamAcceleration = 0.375f;
|
||||
float maxSlamSpeed = 19f;
|
||||
int slamCount = 2;
|
||||
if (CalamityWorld.downedPolterghast)
|
||||
{
|
||||
spawnPosition = npc.Center + Utils.RandomVector2(Main.rand, -460f, 460f);
|
||||
attempts++;
|
||||
if (attempts > 200)
|
||||
return;
|
||||
opacityFadeoutIncrement += 0.03f;
|
||||
slamAcceleration += 0.07f;
|
||||
maxSlamSpeed += 5f;
|
||||
}
|
||||
if (InPhase2)
|
||||
{
|
||||
opacityFadeoutIncrement += 0.01f;
|
||||
slamAcceleration += 0.03f;
|
||||
maxSlamSpeed += 1.15f;
|
||||
}
|
||||
|
||||
attempts = 0;
|
||||
ref float attackSubstate = ref npc.ai[2];
|
||||
ref float slamCounter = ref npc.ai[3];
|
||||
|
||||
// As well as an open tile wiht water.
|
||||
while (CalamityUtils.TileSelectionSolidSquare((int)spawnPosition.X / 16, (int)spawnPosition.Y / 16, 8, 8) ||
|
||||
CalamityUtils.ParanoidTileRetrieval((int)spawnPosition.X / 16, (int)spawnPosition.Y / 16).liquid != 255)
|
||||
switch ((int)attackSubstate)
|
||||
{
|
||||
spawnPosition = npc.Center + Utils.RandomVector2(Main.rand, -620f, 620f);
|
||||
attempts++;
|
||||
if (attempts > 300)
|
||||
return;
|
||||
// Dig in anticipation of the slam teleport.
|
||||
case 0:
|
||||
// Disable tile collision and normal gravity, as the cragmaw will dig into the ground.
|
||||
npc.noTileCollide = true;
|
||||
npc.noGravity = true;
|
||||
|
||||
// Dig into the ground.
|
||||
npc.position.Y += 3f;
|
||||
|
||||
// Fade out.
|
||||
npc.Opacity = MathHelper.Clamp(npc.Opacity - opacityFadeoutIncrement * 0.6f, 0f, 1f);
|
||||
|
||||
// Stop taking damage.
|
||||
npc.dontTakeDamage = true;
|
||||
|
||||
// Teleport once completely transparent.
|
||||
if (npc.Opacity <= 0f)
|
||||
{
|
||||
attackSubstate = 1f;
|
||||
npc.Center = Target.Center - Vector2.UnitY * verticalTeleportOffset;
|
||||
npc.velocity = Vector2.Zero;
|
||||
npc.netUpdate = true;
|
||||
}
|
||||
break;
|
||||
|
||||
// Fade in again.
|
||||
case 1:
|
||||
// Disable default gravity and tile collision, as it is expected that the cragmaw is in the air at the moment.
|
||||
npc.noGravity = true;
|
||||
npc.noTileCollide = true;
|
||||
|
||||
// Disable contact damage. This is done to prevent cheap hits from the teleport, either in multiplayer or due to fast upward movement.
|
||||
npc.damage = 0;
|
||||
|
||||
// Fade in.
|
||||
npc.Opacity = MathHelper.Clamp(npc.Opacity + opacityFadeoutIncrement, 0f, 1f);
|
||||
|
||||
// Do the slam once completely faded in.
|
||||
if (npc.Opacity >= 1f)
|
||||
{
|
||||
attackSubstate = 2f;
|
||||
AttackTimer = 0f;
|
||||
npc.velocity = Vector2.UnitY * maxSlamSpeed * 0.251f;
|
||||
npc.netUpdate = true;
|
||||
}
|
||||
break;
|
||||
|
||||
// Do the slam.
|
||||
case 2:
|
||||
// Disable default gravity and tile collision. Both of them will be calculated manually.
|
||||
npc.noGravity = true;
|
||||
npc.noTileCollide = true;
|
||||
|
||||
// Slam downward.
|
||||
npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y + slamAcceleration, 0f, maxSlamSpeed);
|
||||
|
||||
// Register ground collision from the slam.
|
||||
// Once it has been hit a nuke explosion projectile is created on the ground, along with homing nuclear drops.
|
||||
if ((npc.Bottom.Y > Target.Bottom.Y && Collision.SolidCollision(npc.Bottom, 1, 1)) || AttackTimer > 180f)
|
||||
{
|
||||
npc.velocity = Vector2.Zero;
|
||||
|
||||
if (AttackTimer == 1f)
|
||||
{
|
||||
Main.PlaySound(SoundID.DD2_ExplosiveTrapExplode, npc.Center);
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
int nukeDamage = CalamityWorld.downedPolterghast ? 72 : 38;
|
||||
int dropletDamage = (int)(nukeDamage * 0.6f);
|
||||
int explosion = Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType<CragmawExplosion>(), nukeDamage, 0f);
|
||||
if (Main.projectile.IndexInRange(explosion))
|
||||
Main.projectile[explosion].Bottom = npc.Bottom + Vector2.UnitY * 4f;
|
||||
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
Vector2 dropletVelocity = -Vector2.UnitY.RotatedByRandom(0.71f) * Main.rand.NextFloat(8f, 12f);
|
||||
Projectile.NewProjectile(npc.Center, dropletVelocity, ModContent.ProjectileType<CragmawAcidDrop>(), dropletDamage, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
AttackTimer++;
|
||||
}
|
||||
else
|
||||
AttackTimer = 0f;
|
||||
|
||||
// Sit in place for a moment after hitting the ground.
|
||||
if (AttackTimer > 35f)
|
||||
{
|
||||
slamCounter++;
|
||||
if (slamCounter >= slamCount)
|
||||
SelectNextAttack();
|
||||
else
|
||||
{
|
||||
attackSubstate = 0f;
|
||||
npc.netUpdate = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void DoBehavior_DigAndReleaseLaser()
|
||||
{
|
||||
int digReapperTime = 30;
|
||||
float digReapperSpeed = 4f;
|
||||
int chargeupTelegraphTime = 60;
|
||||
float opacityFadeoutIncrement = 0.025f;
|
||||
if (CalamityWorld.downedPolterghast)
|
||||
{
|
||||
opacityFadeoutIncrement += 0.025f;
|
||||
chargeupTelegraphTime -= 15;
|
||||
}
|
||||
if (InPhase2)
|
||||
{
|
||||
opacityFadeoutIncrement += 0.01f;
|
||||
}
|
||||
|
||||
NPC.NewNPC((int)spawnPosition.X, (int)spawnPosition.Y, Main.rand.Next(possibleEnemies));
|
||||
ref float attackSubstate = ref npc.ai[2];
|
||||
|
||||
switch ((int)attackSubstate)
|
||||
{
|
||||
// Dig to reposition.
|
||||
case 0:
|
||||
// Disable tile collision and normal gravity, as the cragmaw will dig into the ground.
|
||||
npc.noTileCollide = true;
|
||||
npc.noGravity = true;
|
||||
|
||||
// Dig into the ground.
|
||||
npc.position.Y += 3f;
|
||||
|
||||
// Fade out.
|
||||
npc.Opacity = MathHelper.Clamp(npc.Opacity - opacityFadeoutIncrement * 0.6f, 0f, 1f);
|
||||
|
||||
// Stop taking damage.
|
||||
npc.dontTakeDamage = true;
|
||||
|
||||
// Teleport once completely transparent.
|
||||
if (npc.Opacity <= 0f)
|
||||
{
|
||||
attackSubstate = 1f;
|
||||
if (WorldUtils.Find(Target.Center.ToTileCoordinates(), Searches.Chain(new Searches.Down(1000), new CustomConditions.SolidOrPlatform()), out Point teleportPosition))
|
||||
npc.Bottom = teleportPosition.ToWorldCoordinates() + Vector2.UnitY * digReapperTime * digReapperSpeed;
|
||||
else
|
||||
SelectNextAttack();
|
||||
|
||||
AttackTimer = 0f;
|
||||
npc.velocity = Vector2.Zero;
|
||||
npc.netUpdate = true;
|
||||
}
|
||||
break;
|
||||
|
||||
// Prepare and fire the laser.
|
||||
case 1:
|
||||
// Come out of the ground.
|
||||
if (AttackTimer < digReapperTime)
|
||||
{
|
||||
npc.noTileCollide = true;
|
||||
npc.noGravity = true;
|
||||
npc.position.Y -= digReapperSpeed;
|
||||
}
|
||||
if (AttackTimer == digReapperTime)
|
||||
npc.netUpdate = true;
|
||||
|
||||
// Fade in.
|
||||
npc.Opacity = MathHelper.Clamp(npc.Opacity + opacityFadeoutIncrement, 0f, 1f);
|
||||
|
||||
// Create some charge dust.
|
||||
if (AttackTimer > digReapperTime && AttackTimer < digReapperTime + chargeupTelegraphTime)
|
||||
{
|
||||
Dust chargeupDust = Dust.NewDustPerfect(npc.Center, 267);
|
||||
chargeupDust.position -= Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * npc.height * 0.4f;
|
||||
chargeupDust.velocity = -Vector2.UnitY.RotatedByRandom(0.31f) * Main.rand.NextFloat(2f, 6f);
|
||||
chargeupDust.color = Color.Lerp(Color.Green, Color.Yellow, Main.rand.NextFloat());
|
||||
chargeupDust.scale = Main.rand.NextFloat(0.95f, 1.35f);
|
||||
chargeupDust.noGravity = true;
|
||||
}
|
||||
|
||||
// Release the laser.
|
||||
if (AttackTimer == digReapperTime + chargeupTelegraphTime)
|
||||
{
|
||||
// Play a sound and create dust.
|
||||
Main.PlaySound(SoundID.Zombie, npc.Center, 104);
|
||||
for (int i = 0; i < 40; i++)
|
||||
{
|
||||
Dust burstDust = Dust.NewDustPerfect(npc.Center + Main.rand.NextVector2Circular(75f, 75f), 267);
|
||||
burstDust.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(2f, 6f);
|
||||
burstDust.color = Color.Lerp(Color.Green, Color.Yellow, Main.rand.NextFloat());
|
||||
burstDust.scale = Main.rand.NextFloat(1.1f, 1.45f);
|
||||
burstDust.noGravity = true;
|
||||
}
|
||||
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
int laserbeamDamage = CalamityWorld.downedPolterghast ? 120 : 40;
|
||||
Projectile.NewProjectile(npc.Center, -Vector2.UnitY, ModContent.ProjectileType<CragmawBeam>(), laserbeamDamage, 0f, Main.myPlayer, 0f, npc.whoAmI);
|
||||
}
|
||||
}
|
||||
|
||||
if (AttackTimer == digReapperTime + chargeupTelegraphTime + CragmawBeam.Lifetime)
|
||||
SelectNextAttack();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void DoBehavior_CreateVibeCheckTether()
|
||||
{
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient && AttackTimer == 30f)
|
||||
Projectile.NewProjectile(npc.Center, -Vector2.UnitY * 4f, ModContent.ProjectileType<CragmawVibeCheckChain>(), 0, 0f, Main.myPlayer, npc.whoAmI, npc.target);
|
||||
if (AttackTimer > CragmawVibeCheckChain.Lifetime + 30f)
|
||||
SelectNextAttack();
|
||||
}
|
||||
|
||||
public void SelectNextAttack()
|
||||
{
|
||||
// Reset the attack timer and optional attack variables.
|
||||
AttackTimer = 0f;
|
||||
npc.ai[2] = 0f;
|
||||
npc.ai[3] = 0f;
|
||||
|
||||
CragmawAttackState oldAttack = CurrentAttack;
|
||||
WeightedRandom<CragmawAttackState> attackSelector = new WeightedRandom<CragmawAttackState>(Main.rand);
|
||||
attackSelector.Add(CragmawAttackState.ReleaseBurstsOfSpikes);
|
||||
attackSelector.Add(CragmawAttackState.AcidExplosionSlam);
|
||||
attackSelector.Add(CragmawAttackState.DigAndReleaseLaser);
|
||||
if (InPhase2)
|
||||
attackSelector.Add(CragmawAttackState.CreateVibeCheckTether);
|
||||
|
||||
// Select the new attack.
|
||||
// It is random, but will never perform the same attack twice in succession.
|
||||
do
|
||||
CurrentAttack = attackSelector.Get();
|
||||
while (oldAttack == CurrentAttack);
|
||||
|
||||
npc.netUpdate = true;
|
||||
}
|
||||
|
||||
public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
|
||||
@@ -282,7 +453,7 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor)
|
||||
{
|
||||
Texture2D texture = InPhase2 ? ModContent.GetTexture("CalamityMod/NPCs/AcidRain/CragmawMire2") : ModContent.GetTexture("CalamityMod/NPCs/AcidRain/CragmawMire");
|
||||
CalamityMod.DrawTexture(spriteBatch, texture, 0, npc, drawColor, true);
|
||||
CalamityMod.DrawTexture(spriteBatch, texture, 0, npc, npc.GetAlpha(drawColor), true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -311,7 +482,7 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
|
||||
public override void NPCLoot()
|
||||
{
|
||||
DropHelper.DropItemChance(npc, ModContent.ItemType<NuclearRod>(), CalamityWorld.downedPolterghast ? 0.1f : 1f);
|
||||
DropHelper.DropItemChance(npc, ModContent.ItemType<NuclearRod>(), CalamityWorld.downedPolterghast ? 0.1f : 1f);
|
||||
DropHelper.DropItemChance(npc, ModContent.ItemType<SpentFuelContainer>(), CalamityWorld.downedPolterghast ? 0.1f : 1f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
using CalamityMod.Buffs.StatDebuffs;
|
||||
using CalamityMod.World;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Enemy
|
||||
{
|
||||
public class CragmawAcidDrop : ModProjectile
|
||||
{
|
||||
public override string Texture => "CalamityMod/Projectiles/Environment/AcidDrop";
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Acid");
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 16;
|
||||
projectile.height = 16;
|
||||
projectile.penetrate = -1;
|
||||
projectile.hostile = true;
|
||||
projectile.timeLeft = 240;
|
||||
projectile.tileCollide = false;
|
||||
projectile.ignoreWater = false;
|
||||
}
|
||||
public override void AI()
|
||||
{
|
||||
float homingSpeed = CalamityWorld.downedPolterghast ? 16.5f : 10f;
|
||||
Player target = Main.player[Player.FindClosest(projectile.Center, 1, 1)];
|
||||
if (projectile.WithinRange(target.Center, 1200f) && projectile.timeLeft < 210)
|
||||
projectile.velocity = (projectile.velocity * 59f + projectile.SafeDirectionTo(target.Center) * homingSpeed) / 60f;
|
||||
projectile.Opacity = Utils.InverseLerp(0f, 25f, projectile.timeLeft, true);
|
||||
projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2;
|
||||
}
|
||||
|
||||
public override void OnHitPlayer(Player target, int damage, bool crit)
|
||||
{
|
||||
target.AddBuff(ModContent.BuffType<Irradiated>(), 60);
|
||||
}
|
||||
|
||||
public override Color? GetAlpha(Color lightColor)
|
||||
{
|
||||
lightColor = Color.White;
|
||||
lightColor.A = 64;
|
||||
return lightColor * projectile.Opacity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,15 @@ using System;
|
||||
using System.IO;
|
||||
using Terraria;
|
||||
using Terraria.Enums;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Enemy
|
||||
{
|
||||
public class CragmawBeam : ModProjectile
|
||||
{
|
||||
// How long this laser can exist before it is deleted.
|
||||
public const int TrueTimeLeft = 120;
|
||||
public const int Lifetime = 120;
|
||||
|
||||
// Pretty self explanatory
|
||||
private const float maximumLength = 1200f;
|
||||
@@ -30,7 +32,7 @@ namespace CalamityMod.Projectiles.Enemy
|
||||
projectile.alpha = 255;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.timeLeft = TrueTimeLeft;
|
||||
projectile.timeLeft = Lifetime;
|
||||
}
|
||||
|
||||
// Netcode for sending and receiving shit
|
||||
@@ -70,14 +72,14 @@ namespace CalamityMod.Projectiles.Enemy
|
||||
float laserSize = 1.6f;
|
||||
|
||||
projectile.localAI[0] += 1f;
|
||||
if (projectile.localAI[0] >= TrueTimeLeft)
|
||||
if (projectile.localAI[0] >= Lifetime)
|
||||
{
|
||||
projectile.Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
// Causes the effect where the laser appears to expand/contract at the beginning and end of its life
|
||||
projectile.scale = (float)Math.Sin(projectile.localAI[0] * MathHelper.Pi / TrueTimeLeft) * 10f * laserSize;
|
||||
projectile.scale = (float)Math.Sin(projectile.localAI[0] * MathHelper.Pi / Lifetime) * 10f * laserSize;
|
||||
if (projectile.scale > laserSize)
|
||||
{
|
||||
projectile.scale = laserSize;
|
||||
@@ -103,6 +105,14 @@ namespace CalamityMod.Projectiles.Enemy
|
||||
projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], determinedLength, lerpDelta);
|
||||
Vector2 beamEndPosiiton = projectile.Center + projectile.velocity * (projectile.localAI[1] - 6f);
|
||||
|
||||
// Release acid along the beam periodically.
|
||||
if (projectile.timeLeft % 20 == 19 && Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
Vector2 acidSpawnPosition = projectile.Center + projectile.velocity * projectile.localAI[1] * Main.rand.NextFloat(0.1f, 0.8f);
|
||||
if (!Main.player[Player.FindClosest(acidSpawnPosition, 1, 1)].WithinRange(acidSpawnPosition, 300f))
|
||||
Projectile.NewProjectile(acidSpawnPosition, Main.rand.NextVector2CircularEdge(8f, 8f), ModContent.ProjectileType<CragmawAcidDrop>(), projectile.damage / 2, 0f);
|
||||
}
|
||||
|
||||
if (WorldGen.SolidTile((int)(beamEndPosiiton.X / 16), (int)(beamEndPosiiton.Y / 16)))
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
using CalamityMod.Buffs.StatDebuffs;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Enemy
|
||||
{
|
||||
public class CragmawExplosion : ModProjectile
|
||||
{
|
||||
public int FrameX = 0;
|
||||
public int FrameY = 0;
|
||||
public int CurrentFrame => FrameY + FrameX * 14;
|
||||
|
||||
public override string Texture => "CalamityMod/Projectiles/Rogue/SulphuricNukesplosion";
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Nuclear Explosion");
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 140;
|
||||
projectile.height = 290;
|
||||
projectile.hostile = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.timeLeft = 300;
|
||||
projectile.tileCollide = false;
|
||||
projectile.hide = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
projectile.frameCounter++;
|
||||
if (projectile.frameCounter % 6 == 0)
|
||||
{
|
||||
FrameY += 1;
|
||||
if (FrameY >= 7)
|
||||
{
|
||||
FrameX += 1;
|
||||
FrameY = 0;
|
||||
}
|
||||
if (FrameX >= 2)
|
||||
projectile.Kill();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnHitPlayer(Player target, int damage, bool crit)
|
||||
{
|
||||
target.AddBuff(ModContent.BuffType<Irradiated>(), 300);
|
||||
}
|
||||
|
||||
public override void DrawBehind(int index, List<int> drawCacheProjsBehindNPCsAndTiles, List<int> drawCacheProjsBehindNPCs, List<int> drawCacheProjsBehindProjectiles, List<int> drawCacheProjsOverWiresUI)
|
||||
{
|
||||
drawCacheProjsBehindNPCsAndTiles.Add(index);
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
Rectangle frame = new Rectangle(FrameX * projectile.width, FrameY * projectile.height, projectile.width, projectile.height);
|
||||
spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Rogue/SulphuricNukesplosion"), projectile.Center - Main.screenPosition, frame, Color.White, projectile.rotation, projectile.Size / 2f, 1f, SpriteEffects.None, 0f);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
using CalamityMod.Buffs.StatDebuffs;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.World;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Enemy
|
||||
{
|
||||
public class CragmawSpike : ModProjectile
|
||||
@@ -14,26 +16,31 @@ namespace CalamityMod.Projectiles.Enemy
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 14;
|
||||
projectile.height = 28;
|
||||
projectile.width = 16;
|
||||
projectile.height = 16;
|
||||
projectile.penetrate = -1;
|
||||
projectile.hostile = true;
|
||||
projectile.timeLeft = 600;
|
||||
projectile.tileCollide = true;
|
||||
projectile.tileCollide = false;
|
||||
projectile.ignoreWater = false;
|
||||
}
|
||||
public override void AI()
|
||||
{
|
||||
if (projectile.velocity.Y < 6f)
|
||||
projectile.velocity.Y += 0.075f;
|
||||
float maxSpeed = CalamityWorld.downedPolterghast ? 19.5f : 11.5f;
|
||||
if (projectile.velocity.Length() < maxSpeed)
|
||||
projectile.velocity *= 1.024f;
|
||||
|
||||
projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2;
|
||||
}
|
||||
|
||||
public override void OnHitPlayer(Player target, int damage, bool crit)
|
||||
{
|
||||
target.AddBuff(ModContent.BuffType<Irradiated>(), 120);
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i <= 2; i++)
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
int idx = Dust.NewDust(projectile.position, 8, 8, (int)CalamityDusts.SulfurousSeaAcid, 0, 0, 0, default, 0.75f);
|
||||
Main.dust[idx].noGravity = true;
|
||||
|
||||
@@ -7,7 +7,8 @@ namespace CalamityMod.Projectiles.Enemy
|
||||
{
|
||||
public class CragmawVibeCheckChain : ModProjectile
|
||||
{
|
||||
public bool ReelingPlayer = false;
|
||||
public bool ReelingPlayer = false;
|
||||
public const int Lifetime = 360;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("You Think You're Safe");
|
||||
@@ -16,99 +17,103 @@ namespace CalamityMod.Projectiles.Enemy
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = projectile.height = 12;
|
||||
projectile.alpha = 255;
|
||||
projectile.timeLeft = 420;
|
||||
projectile.tileCollide = false;
|
||||
projectile.alpha = 255;
|
||||
projectile.timeLeft = Lifetime;
|
||||
projectile.penetrate = -1;
|
||||
projectile.tileCollide = false;
|
||||
projectile.ignoreWater = true;
|
||||
}
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(projectile.localAI[0]);
|
||||
writer.Write(ReelingPlayer);
|
||||
}
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
projectile.localAI[0] = reader.ReadSingle();
|
||||
ReelingPlayer = reader.ReadBoolean();
|
||||
}
|
||||
public override void AI()
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
Vector2 offsetDrawVector = new Vector2(0f, 30f);
|
||||
projectile.alpha -= 15;
|
||||
if (projectile.alpha < 0)
|
||||
{
|
||||
projectile.alpha = 0;
|
||||
}
|
||||
int toTarget = (int)projectile.ai[1];
|
||||
if (!Main.npc[(int)projectile.ai[0]].active)
|
||||
{
|
||||
projectile.Kill();
|
||||
return;
|
||||
}
|
||||
projectile.rotation = (Main.npc[(int)projectile.ai[0]].Top - projectile.Center + offsetDrawVector).ToRotation() + MathHelper.PiOver2;
|
||||
if (projectile.localAI[0] == 0f)
|
||||
{
|
||||
projectile.velocity = (projectile.velocity * 10f + projectile.SafeDirectionTo(Main.player[toTarget].Center) * 9f) / 11f;
|
||||
if (projectile.timeLeft <= 180f)
|
||||
{
|
||||
projectile.localAI[0] = 1f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (projectile.WithinRange(Main.player[toTarget].Center, 16f))
|
||||
{
|
||||
projectile.localAI[0] = 1f;
|
||||
ReelingPlayer = true;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ReelingPlayer)
|
||||
Main.player[toTarget].Center = projectile.Center;
|
||||
writer.Write(projectile.localAI[0]);
|
||||
writer.Write(ReelingPlayer);
|
||||
}
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
projectile.localAI[0] = reader.ReadSingle();
|
||||
ReelingPlayer = reader.ReadBoolean();
|
||||
}
|
||||
public override void AI()
|
||||
{
|
||||
Vector2 offsetDrawVector = new Vector2(0f, 30f);
|
||||
projectile.alpha -= 15;
|
||||
if (projectile.alpha < 0)
|
||||
{
|
||||
projectile.alpha = 0;
|
||||
}
|
||||
int toTarget = (int)projectile.ai[1];
|
||||
if (!Main.npc[(int)projectile.ai[0]].active)
|
||||
{
|
||||
projectile.Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Main.player[toTarget].dead)
|
||||
ReelingPlayer = false;
|
||||
Vector2 drawPosition = ReelingPlayer ? Main.player[toTarget].Center : projectile.Center;
|
||||
projectile.rotation = (Main.npc[(int)projectile.ai[0]].Top - drawPosition + offsetDrawVector).ToRotation() + MathHelper.PiOver2;
|
||||
if (projectile.localAI[0] == 0f)
|
||||
{
|
||||
projectile.velocity = (projectile.velocity * 10f + projectile.SafeDirectionTo(Main.player[toTarget].Center) * 9f) / 11f;
|
||||
if (projectile.timeLeft <= 180f)
|
||||
{
|
||||
projectile.localAI[0] = 1f;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
if (projectile.WithinRange(Main.player[toTarget].Center, 16f))
|
||||
{
|
||||
projectile.localAI[0] = 1f;
|
||||
ReelingPlayer = true;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ReelingPlayer)
|
||||
Main.player[toTarget].velocity = Vector2.Lerp(Main.player[toTarget].velocity, projectile.velocity, 0.024f);
|
||||
|
||||
if (!projectile.WithinRange(Main.npc[(int)projectile.ai[0]].Center, 6f))
|
||||
projectile.velocity = (projectile.velocity * 16f + projectile.SafeDirectionTo(Main.npc[(int)projectile.ai[0]].Center) * 19f) / 17f;
|
||||
}
|
||||
}
|
||||
if (Main.player[toTarget].dead)
|
||||
ReelingPlayer = false;
|
||||
|
||||
if (!Main.npc[(int)projectile.ai[0]].WithinRange(Main.player[toTarget].Center, 6f))
|
||||
projectile.velocity = (projectile.velocity * 16f + Main.player[toTarget].SafeDirectionTo(Main.npc[(int)projectile.ai[0]].Center) * 19f) / 17f;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
Texture2D endTexture = ModContent.GetTexture(Texture);
|
||||
Texture2D chainTexture = ModContent.GetTexture("CalamityMod/Projectiles/Enemy/CragmawVibeCheckMid");
|
||||
Vector2 distanceVectorToStart = Main.npc[(int)projectile.ai[0]].Top + Vector2.UnitY * 30f - projectile.Center;
|
||||
float distanceToStart = distanceVectorToStart.Length();
|
||||
Vector2 directionToStart = Vector2.Normalize(distanceVectorToStart);
|
||||
Rectangle frameRectangle = endTexture.Frame(1, 1, 0, 0);
|
||||
frameRectangle.Height /= 4;
|
||||
frameRectangle.Y += projectile.frame * frameRectangle.Height;
|
||||
Texture2D chainTexture = ModContent.GetTexture("CalamityMod/Projectiles/Enemy/CragmawVibeCheckMid");
|
||||
Vector2 drawPosition = ReelingPlayer ? Main.player[(int)projectile.ai[1]].Center : projectile.Center;
|
||||
Vector2 distanceVectorToStart = Main.npc[(int)projectile.ai[0]].Top + Vector2.UnitY * 30f - drawPosition;
|
||||
float distanceToStart = distanceVectorToStart.Length();
|
||||
Vector2 directionToStart = Vector2.Normalize(distanceVectorToStart);
|
||||
Rectangle frameRectangle = endTexture.Frame(1, 1, 0, 0);
|
||||
frameRectangle.Height /= 4;
|
||||
frameRectangle.Y += projectile.frame * frameRectangle.Height;
|
||||
|
||||
spriteBatch.Draw(endTexture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(frameRectangle), projectile.GetAlpha(lightColor), projectile.rotation, frameRectangle.Size() / 2f, projectile.scale, SpriteEffects.None, 0f);
|
||||
spriteBatch.Draw(endTexture, drawPosition - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(frameRectangle), projectile.GetAlpha(lightColor), projectile.rotation, frameRectangle.Size() / 2f, projectile.scale, SpriteEffects.None, 0f);
|
||||
|
||||
distanceToStart -= (frameRectangle.Height / 2 + chainTexture.Height) * projectile.scale;
|
||||
Vector2 chainDrawPosition = projectile.Center;
|
||||
chainDrawPosition += directionToStart * projectile.scale * frameRectangle.Height / 2f;
|
||||
if (distanceToStart > 0f)
|
||||
{
|
||||
float distanceMoved = 0f;
|
||||
Rectangle chainTextureFrameRectangle = new Rectangle(0, 0, chainTexture.Width, chainTexture.Height);
|
||||
while (distanceMoved + 1f < distanceToStart)
|
||||
{
|
||||
if (distanceToStart - distanceMoved < chainTextureFrameRectangle.Height)
|
||||
{
|
||||
chainTextureFrameRectangle.Height = (int)(distanceToStart - distanceMoved);
|
||||
}
|
||||
Point chainPositionTileCoords = chainDrawPosition.ToTileCoordinates();
|
||||
Color colorAtChainPosition = Lighting.GetColor(chainPositionTileCoords.X, chainPositionTileCoords.Y);
|
||||
colorAtChainPosition = Color.Lerp(colorAtChainPosition, Color.White, 0.3f);
|
||||
spriteBatch.Draw(chainTexture, chainDrawPosition - Main.screenPosition, new Rectangle?(chainTextureFrameRectangle), projectile.GetAlpha(colorAtChainPosition), projectile.rotation, chainTextureFrameRectangle.Bottom(), projectile.scale, SpriteEffects.None, 0f);
|
||||
distanceMoved += chainTextureFrameRectangle.Height * projectile.scale;
|
||||
chainDrawPosition += directionToStart * chainTextureFrameRectangle.Height * projectile.scale;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
distanceToStart -= (frameRectangle.Height / 2 + chainTexture.Height) * projectile.scale;
|
||||
Vector2 chainDrawPosition = drawPosition;
|
||||
chainDrawPosition += directionToStart * projectile.scale * frameRectangle.Height / 2f;
|
||||
if (distanceToStart > 0f)
|
||||
{
|
||||
float distanceMoved = 0f;
|
||||
Rectangle chainTextureFrameRectangle = new Rectangle(0, 0, chainTexture.Width, chainTexture.Height);
|
||||
while (distanceMoved + 1f < distanceToStart)
|
||||
{
|
||||
if (distanceToStart - distanceMoved < chainTextureFrameRectangle.Height)
|
||||
{
|
||||
chainTextureFrameRectangle.Height = (int)(distanceToStart - distanceMoved);
|
||||
}
|
||||
Point chainPositionTileCoords = chainDrawPosition.ToTileCoordinates();
|
||||
Color colorAtChainPosition = Lighting.GetColor(chainPositionTileCoords.X, chainPositionTileCoords.Y);
|
||||
colorAtChainPosition = Color.Lerp(colorAtChainPosition, Color.White, 0.3f);
|
||||
spriteBatch.Draw(chainTexture, chainDrawPosition - Main.screenPosition, new Rectangle?(chainTextureFrameRectangle), projectile.GetAlpha(colorAtChainPosition), projectile.rotation, chainTextureFrameRectangle.Bottom(), projectile.scale, SpriteEffects.None, 0f);
|
||||
distanceMoved += chainTextureFrameRectangle.Height * projectile.scale;
|
||||
chainDrawPosition += directionToStart * chainTextureFrameRectangle.Height * projectile.scale;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user