Passive (freezing)

This commit is contained in:
IbanPlay committed 2022-01-20 22:42:57 +01:00
1 parent f0a84548bc
commit aaa36c515c
2 files changed
+213 -21

No files matched your search

+29 -9
View File
@@ -24,6 +24,7 @@ namespace CalamityMod.Items.Weapons.Melee
public Attunement? mainAttunement = null;
public Attunement? secondaryAttunement = null;
public int Combo = 0;
public Projectile MeatHook;
//Used for passive effects
public int UseTimer = 0;
@@ -76,7 +77,7 @@ namespace CalamityMod.Items.Weapons.Melee
public static float WhirlwindAttunement_SwordThrowProc = 1f;
public static float WhirlwindAttunement_SwordBeamProc = 0.05f;
public static float SuperPogoAttunement_ShredderProc = 0.25f;
public static float SuperPogoAttunement_ShredderProc = 0.1f;
public static float SuperPogoAttunement_WheelProc = 0.4f;
public static float SuperPogoAttunement_DashProc = 1f;
@@ -84,8 +85,8 @@ namespace CalamityMod.Items.Weapons.Melee
public static float ShockwaveAttunement_MonolithProc = 1f;
public static float ShockwaveAttunement_BlastProc = 0.5f;
public static float FlailBladeAttunement_BladeProc = 0.2f;
public static float FlailBladeAttunement_ChainProc = 0.1f;
public static float FlailBladeAttunement_BladeProc = 0.1f;
public static float FlailBladeAttunement_ChainProc = 0.05f;
public static float FlailBladeAttunement_GhostChainProc = 0.1f;
#endregion
@@ -209,7 +210,6 @@ namespace CalamityMod.Items.Weapons.Melee
#endregion
public override void SetDefaults()
{
item.width = item.height = 92;
@@ -376,6 +376,10 @@ namespace CalamityMod.Items.Weapons.Melee
if (player.whoAmI != Main.myPlayer)
return;
//PAssive effetcsts
if (secondaryAttunement != Attunement.FlailBlade || MeatHook == null || !MeatHook.active)
MeatHook = null;
switch (secondaryAttunement)
{
@@ -388,17 +392,17 @@ namespace CalamityMod.Items.Weapons.Melee
UseTimer++;
}
break;
case Attunement.SuperPogo:
if (OnHitProc)
{
if (Main.rand.Next() <= SuperPogoAttunement_PassiveLifeStealChance)
{
player.statLife += SuperPogoAttunement_PassiveLifeSteal;
player.HealEffect(SuperPogoAttunement_PassiveLifeSteal);
}
player.statLife += SuperPogoAttunement_PassiveLifeSteal;
player.HealEffect(SuperPogoAttunement_PassiveLifeSteal);
OnHitProc = false;
}
break;
case Attunement.Shockwave:
if (UseTimer % 120 == 119)
{
@@ -406,7 +410,23 @@ namespace CalamityMod.Items.Weapons.Melee
UseTimer++;
}
break;
case Attunement.FlailBlade:
if (MeatHook == null)
{
MeatHook = Projectile.NewProjectileDirect(player.Center, Vector2.Zero, ProjectileType<ChainedMeatHook>(), (int)(FlailBladeAttunement_PassiveBaseDamage * player.MeleeDamage()), 0f, player.whoAmI);
}
if (OnHitProc)
{
if (MeatHook.modProjectile is ChainedMeatHook hook && hook.Twirling == 0f)
{
hook.Twirling = 1f;
hook.projectile.timeLeft = (int)ChainedMeatHook.MaxTwirlTime;
}
OnHitProc = false;
}
break;
default:
break;
+184 -12
View File
@@ -265,12 +265,12 @@ namespace CalamityMod.Projectiles.Melee
if (CurrentState != 1)
{
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.Next() <= OmegaBiomeBlade.WhirlwindAttunement_WhirlwindProc)
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.NextFloat() <= OmegaBiomeBlade.WhirlwindAttunement_WhirlwindProc)
sword.OnHitProc = true;
return;
}
if (Owner.HeldItem.modItem is OmegaBiomeBlade blade && Main.rand.Next() <= OmegaBiomeBlade.WhirlwindAttunement_SwordThrowProc)
if (Owner.HeldItem.modItem is OmegaBiomeBlade blade && Main.rand.NextFloat() <= OmegaBiomeBlade.WhirlwindAttunement_SwordThrowProc)
blade.OnHitProc = true;
lastTarget = target;
@@ -502,7 +502,7 @@ namespace CalamityMod.Projectiles.Melee
}
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
{
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.Next() <= OmegaBiomeBlade.WhirlwindAttunement_SwordBeamProc)
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.NextFloat() <= OmegaBiomeBlade.WhirlwindAttunement_SwordBeamProc)
sword.OnHitProc = true;
}
@@ -727,7 +727,7 @@ namespace CalamityMod.Projectiles.Melee
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
{
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.Next() <= OmegaBiomeBlade.SuperPogoAttunement_ShredderProc)
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.NextFloat() <= OmegaBiomeBlade.SuperPogoAttunement_ShredderProc)
sword.OnHitProc = true;
}
@@ -868,7 +868,7 @@ namespace CalamityMod.Projectiles.Melee
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
{
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.Next() <= OmegaBiomeBlade.SuperPogoAttunement_WheelProc)
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.NextFloat() <= OmegaBiomeBlade.SuperPogoAttunement_WheelProc)
sword.OnHitProc = true;
}
@@ -958,7 +958,7 @@ namespace CalamityMod.Projectiles.Melee
{
crit = true;
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.Next() <= OmegaBiomeBlade.SuperPogoAttunement_DashProc)
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.NextFloat() <= OmegaBiomeBlade.SuperPogoAttunement_DashProc)
sword.OnHitProc = true;
Particle bloom = new StrongBloom(target.Center, target.velocity, Color.Crimson * 0.5f, 1f, 30);
@@ -1247,7 +1247,7 @@ namespace CalamityMod.Projectiles.Melee
{
damage = (int)(damage * (1f + OmegaBiomeBlade.ShockwaveAttunement_FullChargeBoost * Charge / MaxCharge));
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.Next() <= OmegaBiomeBlade.ShockwaveAttunement_SwordProc)
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.NextFloat() <= OmegaBiomeBlade.ShockwaveAttunement_SwordProc)
sword.OnHitProc = true;
}
@@ -1479,7 +1479,7 @@ namespace CalamityMod.Projectiles.Melee
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
{
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.Next() <= OmegaBiomeBlade.ShockwaveAttunement_MonolithProc)
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.NextFloat() <= OmegaBiomeBlade.ShockwaveAttunement_MonolithProc)
sword.OnHitProc = true;
}
@@ -1616,7 +1616,7 @@ namespace CalamityMod.Projectiles.Melee
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
{
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.Next() <= OmegaBiomeBlade.ShockwaveAttunement_BlastProc)
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.NextFloat() <= OmegaBiomeBlade.ShockwaveAttunement_BlastProc)
sword.OnHitProc = true;
}
@@ -1714,7 +1714,7 @@ namespace CalamityMod.Projectiles.Melee
)
{
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.Next() <= OmegaBiomeBlade.FlailBladeAttunement_BladeProc)
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.NextFloat() <= OmegaBiomeBlade.FlailBladeAttunement_BladeProc)
sword.OnHitProc = true;
@@ -1736,7 +1736,7 @@ namespace CalamityMod.Projectiles.Melee
else
{
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.Next() <= OmegaBiomeBlade.FlailBladeAttunement_ChainProc)
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.NextFloat() <= OmegaBiomeBlade.FlailBladeAttunement_ChainProc)
sword.OnHitProc = true;
damage = (int)(damage * OmegaBiomeBlade.FlailBladeAttunement_ChainDamageReduction); //If the enemy is hit with the chain of the whip, the damage gets reduced
@@ -2108,7 +2108,7 @@ namespace CalamityMod.Projectiles.Melee
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
{
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.Next() <= OmegaBiomeBlade.FlailBladeAttunement_GhostChainProc)
if (Owner.HeldItem.modItem is OmegaBiomeBlade sword && Main.rand.NextFloat() <= OmegaBiomeBlade.FlailBladeAttunement_GhostChainProc)
sword.OnHitProc = true;
}
@@ -2149,6 +2149,178 @@ namespace CalamityMod.Projectiles.Melee
}
public class ChainedMeatHook : ModProjectile
{
public override string Texture => "CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedHook";
public Player Owner => Main.player[projectile.owner];
public float Timer => MaxTwirlTime - projectile.timeLeft;
public static float MaxTwirlTime = 30;
public ref float Twirling => ref projectile.ai[0];
public bool MayIExist => Owner.active && (Owner.HeldItem.modItem is OmegaBiomeBlade blade) && blade.secondaryAttunement == OmegaBiomeBlade.Attunement.FlailBlade;
Particle smear;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Enchanted Meat Hook");
}
public override void SetDefaults()
{
projectile.melee = true;
projectile.width = projectile.height = 66;
projectile.tileCollide = false;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 40;
projectile.timeLeft = 1;
}
public override bool? CanHitNPC(NPC target) => Twirling == 1f;
public override void AI()
{
if (!MayIExist)
{
projectile.Kill();
return;
}
if (Twirling == 0)
{
projectile.velocity = Vector2.Zero;
projectile.timeLeft = 2;
Vector2 idealPosition = Owner.Center - Owner.direction * Vector2.UnitX * 40f + Vector2.One.RotatedBy(Main.GlobalTime) * 10f;
if ((idealPosition - projectile.Center).Length() > 1500f)
projectile.Center = idealPosition;
projectile.Center = Vector2.Lerp(projectile.Center, idealPosition, 0.05f);
projectile.Center = projectile.Center.MoveTowards(idealPosition, 4f);
}
if (Twirling == 1f)
{
if (projectile.timeLeft == MaxTwirlTime)
{
projectile.velocity = Owner.DirectionTo(Main.MouseWorld);
Main.PlaySound(SoundID.Item71, projectile.Center);
for (int i = 0; i < 4; i++)
{
Particle Sparkle = new CritSpark(projectile.Center, Main.rand.NextVector2Circular(1f, 1f) * Main.rand.NextFloat(17.5f, 25f) * projectile.scale, Color.White, Main.rand.NextBool() ? Color.Cyan : Color.MediumTurquoise, 0.4f + Main.rand.NextFloat(0f, 0.5f), 20 + Main.rand.Next(30), 1, 3f);
GeneralParticleHandler.SpawnParticle(Sparkle);
}
if (smear == null)
{
smear = new CircularSmearVFX(Owner.Center, Color.HotPink, projectile.velocity.ToRotation(), projectile.scale * 1.5f);
GeneralParticleHandler.SpawnParticle(smear);
}
}
projectile.velocity = projectile.velocity.RotatedBy(MathHelper.TwoPi * 2f * (1 / MaxTwirlTime));
projectile.velocity.Normalize();
projectile.rotation = projectile.velocity.ToRotation();
projectile.Center = Owner.Center + (projectile.velocity * 140 * (1 + 0.3f * (float)Math.Sin(projectile.timeLeft / MaxTwirlTime * MathHelper.Pi)));
//Update the variables of the smear
if (smear != null)
{
smear.Rotation = projectile.rotation + MathHelper.PiOver2;
smear.Time = 0;
smear.Position = Owner.Center;
smear.Scale = 3.4f;
smear.Color = Color.MediumTurquoise * 0.9f * (float)Math.Sin(projectile.timeLeft / MaxTwirlTime * MathHelper.Pi);
}
if (projectile.timeLeft == 1)
{
Main.PlaySound(SoundID.Item101, projectile.Center);
for (int i = 0; i < 4; i++)
{
Particle Sparkle = new CritSpark(projectile.Center, Main.rand.NextVector2Circular(1f, 1f) * Main.rand.NextFloat(17.5f, 25f) * projectile.scale, Color.White, Main.rand.NextBool() ? Color.Cyan : Color.MediumTurquoise, 0.4f + Main.rand.NextFloat(0f, 0.5f), 20 + Main.rand.Next(30), 1, 3f);
GeneralParticleHandler.SpawnParticle(Sparkle);
}
Twirling = 0f;
}
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
int debuffTime = 100;
target.AddBuff(BuffType<GlacialState>(), debuffTime);
}
public override void Kill(int timeLeft)
{
Main.PlaySound(SoundID.Item105, projectile.Center);
for (int i = 0; i < 10; i++)
{
Particle Sparkle = new CritSpark(projectile.Center, Main.rand.NextVector2Circular(1f, 1f) * Main.rand.NextFloat(17.5f, 25f) * projectile.scale, Color.White, Main.rand.NextBool() ? Color.Cyan : Color.MediumTurquoise, 0.4f + Main.rand.NextFloat(0f, 1.5f), 20 + Main.rand.Next(30), 1, 3f);
GeneralParticleHandler.SpawnParticle(Sparkle);
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D handle = GetTexture("CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedHookBody");
Texture2D blade = GetTexture("CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedHook");
float drawAngle = (projectile.Center - Owner.Center).ToRotation();
float drawRotation = drawAngle + MathHelper.PiOver4;
Vector2 drawOrigin = new Vector2(0f, handle.Height);
Vector2 drawOffset = projectile.Center - Main.screenPosition;
spriteBatch.Draw(handle, drawOffset, null, lightColor, drawRotation, drawOrigin, projectile.scale, 0f, 0f);
//Turn on additive blending
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
//Update the parameters
drawOrigin = new Vector2(0f, blade.Height);
spriteBatch.Draw(blade, drawOffset, null, Color.Lerp(Color.White, lightColor, 0.5f) * 0.9f, drawRotation, drawOrigin, projectile.scale, 0f, 0f);
drawChain(spriteBatch);
//Back to normal
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
return false;
}
public void drawChain(SpriteBatch spriteBatch)
{
Texture2D chainTex = GetTexture("CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedChain");
int dist = (int)Vector2.Distance(Owner.Center, projectile.Center) / 16;
Vector2[] Nodes = new Vector2[dist + 1];
Nodes[0] = Owner.Center;
Nodes[dist] = projectile.Center;
for (int i = 1; i < dist + 1; i++)
{
Rectangle frame = new Rectangle(0, 0 + 18 * (i % 2), 12, 18);
Vector2 positionAlongLine = Vector2.Lerp(Owner.Center, projectile.Center, i / (float)dist); //Get the position of the segment along the line, as if it were a flat line
Nodes[i] = positionAlongLine;
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]) / frame.Height; //Calculate how much to squash/stretch for smooth chain based on distance between points
Vector2 scale = new Vector2(1, yScale);
Vector2 origin = new Vector2(frame.Width / 2, frame.Height); //Draw from center bottom of texture
spriteBatch.Draw(chainTex, Nodes[i] - Main.screenPosition, frame, Color.White * 0.5f, rotation, origin, scale, SpriteEffects.None, 0);
}
}
}
}