Whip work start (dying,,, hh,h,
This commit is contained in:
1 parent
710456f220
commit
e6da0a1e54
4 files changed
+434
-24
No files matched your search
@@ -24,6 +24,8 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
public Attunement? mainAttunement = null;
|
||||
public Attunement? secondaryAttunement = null;
|
||||
public int Combo = 0;
|
||||
|
||||
//Used for passive effects
|
||||
public int UseTimer = 0;
|
||||
public bool OnHitProc = false;
|
||||
|
||||
@@ -37,7 +39,17 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
public static int WhirlwindAttunement_PassiveBaseDamage = 200;
|
||||
|
||||
|
||||
public static int ShockwaveAttunement_BaseDamage = 1500;
|
||||
public static int SuperPogoAttunement_BaseDamage = 500;
|
||||
public static int SuperPogoAttunement_ShredIFrames = 10;
|
||||
public static float SuperPogoAttunement_SlashDamageBoost = 5f; //Keep in mind the slice always crits
|
||||
public static int SuperPogoAttunementSlashLifesteal = 6;
|
||||
public static int SuperPogoAttunement_SlashIFrames = 60;
|
||||
public static float SuperPogoAttunement_ShotDamageBoost = 2f;
|
||||
|
||||
public static int SuperPogoAttunement_PassiveLifeSteal = 10;
|
||||
|
||||
|
||||
public static int ShockwaveAttunement_BaseDamage = 2500;
|
||||
public static int ShockwaveAttunement_DashHitIFrames = 60;
|
||||
public static float ShockwaveAttunement_FullChargeBoost = 1f; //The EXTRA damage boost. So putting 1 here will make it deal double damage. Putting 0.5 here will make it deal 1.5x the damage.
|
||||
public static float ShockwaveAttunement_MonolithDamageBoost = 2f;
|
||||
@@ -46,25 +58,31 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
public static int ShockwaveAttunement_PassiveBaseDamage = 200;
|
||||
|
||||
|
||||
public static int SuperPogoAttunement_BaseDamage = 500;
|
||||
public static int SuperPogoAttunement_ShredIFrames = 10;
|
||||
public static float SuperPogoAttunement_SlashDamageBoost = 10f;
|
||||
public static int SuperPogoAttunementSlashLifesteal = 6;
|
||||
public static int SuperPogoAttunement_SlashIFrames = 60;
|
||||
public static float SuperPogoAttunement_ShotDamageBoost = 2f;
|
||||
public static int FlailBladeAttunement_BaseDamage = 320;
|
||||
public static int FlailBladeAttunement_MaxFlails = 3;
|
||||
public static int FlailBladeAttunement_FlailTime = 150;
|
||||
public static float FlailBladeAttunement_ChainDamageReduction = 0.5f;
|
||||
public static float FlailBladeAttunement_GhostChainDamageReduction = 0.5f;
|
||||
|
||||
public static float SuperPogoAttunement_PassiveLifeSteal = 10;
|
||||
public static int FlailBladeAttunement_PassiveBaseDamage = 500;
|
||||
|
||||
//Proc coefficients. aka the likelihood of any given attack to trigger a on-hit passive.
|
||||
public static float WhirlwindAttunement_WhirlwindProc = 0.1f;
|
||||
public static float WhirlwindAttunement_SwordThrowProc = 1f;
|
||||
public static float WhirlwindAttunement_SwordBeamProc = 0.05f;
|
||||
|
||||
public static int ColdAttunement_BaseDamage = 320;
|
||||
public static float ColdAttunement_SecondSwingBoost = 1.8f;
|
||||
public static float ColdAttunement_ThirdSwingBoost = 3f;
|
||||
public static float ColdAttunement_MistDamageReduction = 0.2f;
|
||||
public static float SuperPogoAttunement_ShredderProc = 0.25f;
|
||||
public static float SuperPogoAttunement_WheelProc = 0.4f;
|
||||
public static float SuperPogoAttunement_DashProc = 1f;
|
||||
|
||||
public static float ShockwaveAttunement_SwordProc = 1f;
|
||||
public static float ShockwaveAttunement_MonolithProc = 1f;
|
||||
public static float ShockwaveAttunement_BlastProc = 0.5f;
|
||||
|
||||
public static int TropicalAttunement_BaseDamage = 160;
|
||||
public static float TropicalAttunement_ChainDamageReduction = 0.5f;
|
||||
public static float TropicalAttunement_VineDamageReduction = 0.5f;
|
||||
public static float FlailBladeAttunement_BladeProc = 0.2f;
|
||||
public static float FlailBladeAttunement_CritProc = 0.5f;
|
||||
public static float FlailBladeAttunement_ChainProc = 0.1f;
|
||||
public static float FlailBladeAttunement_GhostChainProc = 0.1f;
|
||||
#endregion
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
@@ -287,12 +305,17 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
{
|
||||
player.Calamity().rightClickListener = true;
|
||||
|
||||
UseTimer++;
|
||||
//Reset the strong lunge thing just in case it didnt get caught beofre.
|
||||
//||
|
||||
// n.type == ProjectileType<LamentationsOfTheChained>()
|
||||
|
||||
if (CanUseItem(player))
|
||||
{
|
||||
player.Calamity().LungingDown = false;
|
||||
UseTimer = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
UseTimer++;
|
||||
}
|
||||
|
||||
//Change the swords function based on its attunement
|
||||
@@ -329,11 +352,12 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
item.noMelee = true;
|
||||
break;
|
||||
case Attunement.FlailBlade:
|
||||
item.damage = FlailBladeAttunement_BaseDamage;
|
||||
item.channel = false;
|
||||
item.noUseGraphic = true;
|
||||
item.useStyle = ItemUseStyleID.SwingThrow;
|
||||
item.shoot = ProjectileType<TrueGrovetendersTouch>();
|
||||
item.shootSpeed = 30;
|
||||
item.shoot = ProjectileType<LamentationsOfTheChained>();
|
||||
item.shootSpeed = 12f;
|
||||
item.UseSound = null;
|
||||
item.noMelee = true;
|
||||
break;
|
||||
@@ -357,13 +381,23 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
Main.PlaySound(SoundID.Item78);
|
||||
Projectile beamSword = Projectile.NewProjectileDirect(player.Center, player.DirectionTo(Main.MouseWorld) * 15f, ProjectileType<SwordsmithsPrideBeam>(), (int)(WhirlwindAttunement_PassiveBaseDamage * player.MeleeDamage()), 10f, player.whoAmI, 1f);
|
||||
beamSword.timeLeft = 50;
|
||||
UseTimer++;
|
||||
}
|
||||
break;
|
||||
case Attunement.SuperPogo:
|
||||
if (OnHitProc)
|
||||
{
|
||||
player.statLife += SuperPogoAttunement_PassiveLifeSteal;
|
||||
player.HealEffect(SuperPogoAttunement_PassiveLifeSteal);
|
||||
OnHitProc = false;
|
||||
}
|
||||
break;
|
||||
case Attunement.Shockwave:
|
||||
if (UseTimer % 120 == 119)
|
||||
{
|
||||
Projectile.NewProjectile(player.Center, Vector2.Zero, ProjectileType<MercurialTidesBlast>(), (int)(ShockwaveAttunement_PassiveBaseDamage * player.MeleeDamage()), 10f, player.whoAmI, 1f);
|
||||
UseTimer++;
|
||||
}
|
||||
break;
|
||||
case Attunement.FlailBlade:
|
||||
break;
|
||||
@@ -387,8 +421,8 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI &&
|
||||
(n.type == ProjectileType<SwordsmithsPride>() ||
|
||||
n.type == ProjectileType<MercurialTides>() ||
|
||||
n.type == ProjectileType<SanguineFury>() //||
|
||||
// n.type == ProjectileType<LamentationsOfTheChained>()
|
||||
n.type == ProjectileType<SanguineFury>() ||
|
||||
n.type == ProjectileType<LamentationsOfTheChained>()
|
||||
));
|
||||
}
|
||||
|
||||
@@ -396,6 +430,19 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
{
|
||||
if (mainAttunement == null)
|
||||
return false;
|
||||
|
||||
if (mainAttunement == Attunement.FlailBlade)
|
||||
{
|
||||
Projectile whipProj = Projectile.NewProjectileDirect(player.Center, new Vector2(speedX, speedY), ProjectileType<LamentationsOfTheChained>(), damage, knockBack, player.whoAmI, 0, 0);
|
||||
if (whipProj.modProjectile is LamentationsOfTheChained whip)
|
||||
{
|
||||
whip.flipped = Combo % 2 == 0 ? 1 : -1;
|
||||
whip.Size = 1f + Combo % 3 * 0.05f;
|
||||
}
|
||||
Combo++;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -690,6 +690,8 @@ namespace CalamityMod.Projectiles.Melee
|
||||
{
|
||||
if (Main.myPlayer != Owner.whoAmI)
|
||||
return;
|
||||
|
||||
Owner.fallStart = (int)(Owner.position.Y / 16f);
|
||||
// get lifted up
|
||||
if (PogoCooldown <= 0)
|
||||
{
|
||||
@@ -801,7 +803,7 @@ namespace CalamityMod.Projectiles.Melee
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.melee = true;
|
||||
projectile.width = projectile.height = 55;
|
||||
projectile.width = projectile.height = 45;
|
||||
projectile.tileCollide = true;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.friendly = true;
|
||||
@@ -811,7 +813,7 @@ namespace CalamityMod.Projectiles.Melee
|
||||
|
||||
public override bool OnTileCollide(Vector2 oldVelocity)
|
||||
{
|
||||
projectile.velocity *= 0.5f;
|
||||
projectile.velocity *= 0.95f;
|
||||
return false;
|
||||
}
|
||||
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
|
||||
@@ -931,6 +933,8 @@ namespace CalamityMod.Projectiles.Melee
|
||||
|
||||
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
|
||||
{
|
||||
crit = true;
|
||||
|
||||
Particle bloom = new StrongBloom(target.Center, target.velocity, Color.Crimson * 0.5f, 1f, 30);
|
||||
GeneralParticleHandler.SpawnParticle(bloom);
|
||||
|
||||
@@ -980,7 +984,6 @@ namespace CalamityMod.Projectiles.Melee
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Mercurial tides aka Shockwave attunement
|
||||
|
||||
public class MercurialTides : ModProjectile
|
||||
@@ -1590,6 +1593,348 @@ namespace CalamityMod.Projectiles.Melee
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Lamentations of the Chained aka FlailBlade attunement
|
||||
|
||||
public class LamentationsOfTheChained : ModProjectile
|
||||
{
|
||||
private NPC[] excludedTargets = new NPC[4];
|
||||
|
||||
public override string Texture => "CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained";
|
||||
private bool initialized = false;
|
||||
public Player Owner => Main.player[projectile.owner];
|
||||
public float Timer => MaxTime - projectile.timeLeft;
|
||||
public ref float HasSnapped => ref projectile.ai[0];
|
||||
public ref float SnapCoyoteTime => ref projectile.ai[1];
|
||||
|
||||
public float Size;
|
||||
public float flipped;
|
||||
|
||||
public static readonly float MaxTime = (float)OmegaBiomeBlade.FlailBladeAttunement_FlailTime;
|
||||
const int coyoteTimeFrames = 8; //How many frames does the whip stay extended
|
||||
const int MaxReach = 400;
|
||||
const float SnappingPoint = 0.55f; //When does the snap occur.
|
||||
const float ReelBackStrenght = 14f;
|
||||
|
||||
const float MaxTangleReach = 400f; //How long can tangling vines from crits be
|
||||
|
||||
public BezierCurve curve;
|
||||
private Vector2 controlPoint1;
|
||||
private Vector2 controlPoint2;
|
||||
internal bool ReelingBack => Timer / MaxTime > SnappingPoint;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Lamentations of the Chained");
|
||||
}
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.melee = true;
|
||||
projectile.width = projectile.height = 80;
|
||||
projectile.tileCollide = false;
|
||||
projectile.friendly = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.extraUpdates = 2;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 30;
|
||||
}
|
||||
|
||||
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
|
||||
{
|
||||
BezierCurve curve = new BezierCurve(new Vector2[] { Owner.MountedCenter, controlPoint1, controlPoint2, projectile.Center });
|
||||
|
||||
int numPoints = 32;
|
||||
Vector2[] chainPositions = curve.GetPoints(numPoints).ToArray();
|
||||
float collisionPoint = 0;
|
||||
for (int i = 1; i < numPoints; i++)
|
||||
{
|
||||
Vector2 position = chainPositions[i];
|
||||
Vector2 previousPosition = chainPositions[i - 1];
|
||||
if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), position, previousPosition, 6, ref collisionPoint))
|
||||
return true;
|
||||
if (i == numPoints - 1) //Extra lenght collision for the blade itself
|
||||
{
|
||||
Vector2 projectileHalfLenght = 85 * projectile.rotation.ToRotationVector2();
|
||||
return (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center - projectileHalfLenght, projectile.Center + projectileHalfLenght, 32, ref collisionPoint));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return base.Colliding(projHitbox, targetHitbox);
|
||||
}
|
||||
|
||||
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
|
||||
{
|
||||
Vector2 projectileHalfLenght = 85f * projectile.rotation.ToRotationVector2();
|
||||
float collisionPoint = 0;
|
||||
//If you hit the enemy during the coyote time with the blade of the whip, guarantee a crit
|
||||
if (Collision.CheckAABBvLineCollision(target.Hitbox.TopLeft(), target.Hitbox.Size(), projectile.Center - projectileHalfLenght, projectile.Center + projectileHalfLenght, 32, ref collisionPoint))
|
||||
{
|
||||
if (SnapCoyoteTime > 0f)
|
||||
{
|
||||
crit = true;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Vector2 sparkSpeed = Owner.DirectionTo(target.Center).RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver2, MathHelper.PiOver2)) * 9f;
|
||||
Particle Spark = new CritSpark(target.Center, sparkSpeed, Color.White, Color.LimeGreen, 1f + Main.rand.NextFloat(0, 1f), 30, 0.4f, 0.6f);
|
||||
GeneralParticleHandler.SpawnParticle(Spark);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
damage = (int)(damage * OmegaBiomeBlade.FlailBladeAttunement_ChainDamageReduction); //If the enemy is hit with the chain of the whip, the damage gets reduced
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
{
|
||||
if (crit)
|
||||
{
|
||||
Main.PlaySound(mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/Custom/SwiftSlice"), projectile.Center);
|
||||
excludedTargets[0] = target;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
NPC potentialTarget = TargetNext(target.Center, i);
|
||||
if (potentialTarget == null)
|
||||
break;
|
||||
Projectile.NewProjectile(target.Center, Vector2.Zero, ProjectileType<GhastlyChain>(), (int)(damage * OmegaBiomeBlade.FlailBladeAttunement_GhostChainDamageReduction), 0, Owner.whoAmI, target.whoAmI, potentialTarget.whoAmI);
|
||||
}
|
||||
Array.Clear(excludedTargets, 0, 3);
|
||||
}
|
||||
}
|
||||
|
||||
public NPC TargetNext(Vector2 hitFrom, int index)
|
||||
{
|
||||
float longestReach = MaxTangleReach;
|
||||
NPC target = null;
|
||||
for (int i = 0; i < 200; ++i)
|
||||
{
|
||||
NPC npc = Main.npc[i];
|
||||
if (!excludedTargets.Contains(npc) && npc.CanBeChasedBy() && !npc.friendly && !npc.townNPC)
|
||||
{
|
||||
float distance = Vector2.Distance(hitFrom, npc.Center);
|
||||
if (distance < longestReach)
|
||||
{
|
||||
longestReach = distance;
|
||||
target = npc;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (index < 3)
|
||||
excludedTargets[index + 1] = target;
|
||||
return target;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (!initialized) //Initialization. create control points & shit)
|
||||
{
|
||||
projectile.velocity = Owner.DirectionTo(Main.MouseWorld);
|
||||
Main.PlaySound(SoundID.DD2_OgreSpit, projectile.Center);
|
||||
controlPoint1 = projectile.Center;
|
||||
controlPoint2 = projectile.Center;
|
||||
projectile.timeLeft = (int)MaxTime;
|
||||
initialized = true;
|
||||
projectile.netUpdate = true;
|
||||
projectile.netSpam = 0;
|
||||
}
|
||||
|
||||
if (ReelingBack && HasSnapped == 0f) //Snap & also small coyote time for the hook
|
||||
{
|
||||
Main.PlaySound(SoundID.Item71, projectile.Center); //Slash
|
||||
HasSnapped = 1f;
|
||||
SnapCoyoteTime = coyoteTimeFrames;
|
||||
}
|
||||
|
||||
if (SnapCoyoteTime > 0) //keep checking for the tile hook
|
||||
{
|
||||
Lighting.AddLight(projectile.Center, 0.8f, 1f, 0.35f);
|
||||
SnapCoyoteTime--;
|
||||
}
|
||||
|
||||
Owner.direction = Math.Sign(projectile.velocity.X);
|
||||
projectile.rotation = projectile.AngleFrom(Owner.Center); //Point away from playah
|
||||
|
||||
float ratio = GetSwingRatio();
|
||||
projectile.Center = Owner.MountedCenter + SwingPosition(ratio);
|
||||
projectile.direction = projectile.spriteDirection = -Math.Sign(projectile.velocity.X) * (int)flipped;
|
||||
|
||||
//MessWithTiles();
|
||||
|
||||
Owner.itemRotation = MathHelper.WrapAngle(Owner.AngleTo(Main.MouseWorld) - (Owner.direction < 0 ? MathHelper.Pi : 0));
|
||||
}
|
||||
|
||||
|
||||
private float GetSwingRatio() => Timer / MaxTime;
|
||||
|
||||
private Vector2 SwingPosition(float progress)
|
||||
{
|
||||
|
||||
float distance = MaxReach * Size * MathHelper.Lerp((float)Math.Sin(progress * MathHelper.Pi), 1, 0.04f);
|
||||
distance = Math.Max(distance, 65); //Dont be too close to player
|
||||
|
||||
float angleDeviation = MathHelper.Pi / 1.2f;
|
||||
float angleOffset = Owner.direction * flipped * MathHelper.Lerp(-angleDeviation, angleDeviation, progress); //Go from very angled to straight at the zenith of the attack
|
||||
return projectile.velocity.RotatedBy(angleOffset) * distance;
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
if (Timer == 0)
|
||||
return false;
|
||||
Texture2D handle = GetTexture("CalamityMod/Items/Weapons/Melee/OmegaBiomeBlade");
|
||||
Texture2D blade = GetTexture("CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained");
|
||||
|
||||
Vector2 projBottom = projectile.Center + new Vector2(-handle.Width / 2, handle.Height / 2).RotatedBy(projectile.rotation + MathHelper.PiOver4) * 0.75f;
|
||||
DrawChain(spriteBatch, projBottom, out Vector2[] chainPositions);
|
||||
|
||||
float drawRotation = (projBottom - chainPositions[chainPositions.Length - 2]).ToRotation() + MathHelper.PiOver4; //Face away from the last point of the bezier curve
|
||||
drawRotation += projectile.spriteDirection < 0 ? 0f : 0f;
|
||||
|
||||
if (ReelingBack)
|
||||
drawRotation = Utils.AngleLerp(drawRotation, (projectile.Center - Owner.Center).ToRotation(), GetSwingRatio());
|
||||
|
||||
Vector2 drawOrigin = new Vector2(0f, handle.Height);
|
||||
SpriteEffects flip = (projectile.spriteDirection < 0) ? SpriteEffects.None : SpriteEffects.None;
|
||||
lightColor = Lighting.GetColor((int)(projectile.Center.X / 16f), (int)(projectile.Center.Y / 16f));
|
||||
|
||||
spriteBatch.Draw(handle, projBottom - Main.screenPosition, null, lightColor, drawRotation, drawOrigin, projectile.scale * Size, flip, 0f);
|
||||
|
||||
|
||||
//Turn on additive blending
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
|
||||
//Only update the origin for once
|
||||
drawOrigin = new Vector2(0f, blade.Height);
|
||||
spriteBatch.Draw(blade, projBottom - Main.screenPosition, null, Color.Lerp(Color.White, lightColor, 0.5f) * 0.9f, drawRotation, drawOrigin, projectile.scale * Size, flip, 0f);
|
||||
//Back to normal
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void DrawChain(SpriteBatch spriteBatch, Vector2 projBottom, out Vector2[] chainPositions)
|
||||
{
|
||||
Texture2D chainTex = GetTexture("CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedChain");
|
||||
|
||||
float ratio = GetSwingRatio();
|
||||
|
||||
float rotationAngle = MathHelper.PiOver4 * Math.Sign(projectile.velocity.X) * flipped;
|
||||
|
||||
controlPoint2 = Owner.MountedCenter + SwingPosition(ratio).RotatedBy(MathHelper.Lerp(rotationAngle * 0.5f, -rotationAngle * 0.5f, ratio)) * 0.5f;
|
||||
controlPoint1 = Owner.MountedCenter + SwingPosition(ratio).RotatedBy(MathHelper.Lerp(rotationAngle, -rotationAngle, ratio)) * 0.1f;
|
||||
|
||||
|
||||
BezierCurve curve = new BezierCurve(new Vector2[] { Owner.MountedCenter, controlPoint1, controlPoint2, projBottom });
|
||||
int numPoints = 30;
|
||||
chainPositions = curve.GetPoints(numPoints).ToArray();
|
||||
|
||||
//Draw each chain segment bar the very first one
|
||||
for (int i = 1; i < numPoints; i++)
|
||||
{
|
||||
Vector2 position = chainPositions[i];
|
||||
float rotation = (chainPositions[i] - chainPositions[i - 1]).ToRotation() - MathHelper.PiOver2; //Calculate rotation based on direction from last point
|
||||
float yScale = Vector2.Distance(chainPositions[i], chainPositions[i - 1]) / chainTex.Height; //Calculate how much to squash/stretch for smooth chain based on distance between points
|
||||
Vector2 scale = new Vector2(1, yScale);
|
||||
Color chainLightColor = Lighting.GetColor((int)position.X / 16, (int)position.Y / 16); //Lighting of the position of the chain segment
|
||||
Vector2 origin = new Vector2(chainTex.Width / 2, chainTex.Height); //Draw from center bottom of texture
|
||||
spriteBatch.Draw(chainTex, position - Main.screenPosition, null, chainLightColor, rotation, origin, scale, SpriteEffects.None, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(initialized);
|
||||
writer.Write(flipped);
|
||||
writer.Write(Size);
|
||||
}
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
initialized = reader.ReadBoolean();
|
||||
flipped = reader.ReadSingle();
|
||||
Size = reader.ReadSingle();
|
||||
}
|
||||
}
|
||||
|
||||
public class GhastlyChain : ModProjectile
|
||||
{
|
||||
public override string Texture => "CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedChain";
|
||||
public Player Owner => Main.player[projectile.owner];
|
||||
public float Timer => 20 - projectile.timeLeft;
|
||||
public NPC NPCfrom
|
||||
{
|
||||
get => Main.npc[(int)projectile.ai[0]];
|
||||
set => projectile.ai[0] = value.whoAmI;
|
||||
}
|
||||
public NPC Target
|
||||
{
|
||||
get => Main.npc[(int)projectile.ai[1]];
|
||||
set => projectile.ai[1] = value.whoAmI;
|
||||
}
|
||||
|
||||
const float curvature = 16f;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Ghastly Chain");
|
||||
}
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.melee = true;
|
||||
projectile.width = projectile.height = 8;
|
||||
projectile.tileCollide = false;
|
||||
projectile.friendly = true;
|
||||
projectile.penetrate = -1;
|
||||
projectile.usesLocalNPCImmunity = true;
|
||||
projectile.localNPCHitCooldown = 30;
|
||||
projectile.timeLeft = 20;
|
||||
}
|
||||
|
||||
public override bool? CanHitNPC(NPC target) => target == Target;
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
projectile.Center = Target.Center;
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
Texture2D chainTex = GetTexture("CalamityMod/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouchChain");
|
||||
|
||||
float opacity = projectile.timeLeft > 10 ? 1 : projectile.timeLeft / 10f;
|
||||
Vector2 Shake = projectile.timeLeft < 15 ? Vector2.Zero : Vector2.One.RotatedByRandom(MathHelper.TwoPi) * (15 - projectile.timeLeft / 5f) * 0.5f;
|
||||
|
||||
Vector2 lineDirection = Vector2.Normalize(Target.Center - NPCfrom.Center);
|
||||
int dist = (int)Vector2.Distance(Target.Center, NPCfrom.Center) / 16;
|
||||
Vector2[] Nodes = new Vector2[dist + 1];
|
||||
Nodes[0] = NPCfrom.Center;
|
||||
Nodes[dist] = Target.Center;
|
||||
float pointUp = Target.Center.X > NPCfrom.Center.X ? -MathHelper.PiOver2 : MathHelper.PiOver2;
|
||||
|
||||
for (int i = 1; i < dist + 1; i++)
|
||||
{
|
||||
Vector2 positionAlongLine = Vector2.Lerp(NPCfrom.Center, Target.Center, i / (float)dist); //Get the position of the segment along the line, as if it were a flat line
|
||||
float elevation = (float)Math.Sin(i / (float)dist * MathHelper.Pi) * curvature * dist / 10f;
|
||||
Nodes[i] = positionAlongLine + lineDirection.RotatedBy(pointUp) * elevation + Shake * (float)Math.Sin(i / (float)dist * MathHelper.Pi);
|
||||
|
||||
float rotation = (Nodes[i] - Nodes[i - 1]).ToRotation() - MathHelper.PiOver2; //Calculate rotation based on direction from last point
|
||||
float yScale = Vector2.Distance(Nodes[i], Nodes[i - 1]) / chainTex.Height; //Calculate how much to squash/stretch for smooth chain based on distance between points
|
||||
Vector2 scale = new Vector2(1, yScale);
|
||||
|
||||
Color chainLightColor = Lighting.GetColor((int)Nodes[i].X / 16, (int)Nodes[i].Y / 16); //Lighting of the position of the chain segment
|
||||
|
||||
Vector2 origin = new Vector2(chainTex.Width / 2, chainTex.Height); //Draw from center bottom of texture
|
||||
spriteBatch.Draw(chainTex, Nodes[i] - Main.screenPosition, null, chainLightColor * opacity, rotation, origin, scale, SpriteEffects.None, 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using Microsoft.Xna.Framework.Audio;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Sounds.Custom
|
||||
{
|
||||
public class SwiftSlice : ModSound
|
||||
{
|
||||
public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type)
|
||||
{
|
||||
soundInstance = sound.CreateInstance();
|
||||
soundInstance.Volume = volume * 1f;
|
||||
soundInstance.Pan = pan;
|
||||
Main.PlaySoundInstance(soundInstance);
|
||||
return soundInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in new issue
Block a user