TAotA start

This commit is contained in:
IbanPlay authored and Cameron Ewell committed 2022-02-03 14:15:48 -05:00
1 parent 235698d1b3
commit 475943b140
10 files changed
+766 -102

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 B

After

Width:  |  Height:  |  Size: 188 B

+18 -3
View File
@@ -9,6 +9,7 @@ using Terraria;
using Terraria.ID;
using static Terraria.ModLoader.ModContent;
using Terraria.ModLoader;
using Microsoft.Xna.Framework.Graphics;
namespace CalamityMod.Items.Weapons.Melee
{
@@ -58,7 +59,7 @@ namespace CalamityMod.Items.Weapons.Melee
{
if (player.altFunctionUse == 2)
{
if (!Main.projectile.Any(n => n.active && n.owner == player.whoAmI && (n.type == ProjectileType<ArkoftheAncientsParryHoldout>())))
if (!Main.projectile.Any(n => n.active && n.owner == player.whoAmI && (n.type == ProjectileType<ArkoftheAncientsParryHoldout>() || n.type == ProjectileType<TrueArkoftheAncientsParryHoldout>())))
Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), ProjectileType<ArkoftheAncientsParryHoldout>(), damage, 0, player.whoAmI, 0, 0);
return false;
}
@@ -79,8 +80,6 @@ namespace CalamityMod.Items.Weapons.Melee
return false;
}
public override ModItem Clone(Item item)
{
var clone = base.Clone(item);
@@ -128,5 +127,21 @@ namespace CalamityMod.Items.Weapons.Melee
recipe.SetResult(this);
recipe.AddRecipe();
}
public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
{
if (Charge <= 0)
return;
var barBG = GetTexture("CalamityMod/ExtraTextures/GenericBarBack");
var barFG = GetTexture("CalamityMod/ExtraTextures/GenericBarFront");
Vector2 drawPos = position + Vector2.UnitY * frame.Height * scale + Vector2.UnitX * (frame.Width - barBG.Width) * scale * 0.5f;
Rectangle frameCrop = new Rectangle(0, 0, (int)(Charge / 10f * barFG.Width), barFG.Height);
Color color = Main.hslToRgb((Main.GlobalTime * 0.6f) % 1, 1, 0.85f + (float)Math.Sin(Main.GlobalTime * 3f) * 0.1f);
spriteBatch.Draw(barBG, drawPos, null, color , 0f, origin, scale, 0f, 0f);
spriteBatch.Draw(barFG, drawPos, frameCrop, color * 0.8f, 0f, origin, scale, 0f, 0f);
}
}
}
+92 -96
View File
@@ -2,160 +2,156 @@ using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Melee;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.IO;
using System.Linq;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
namespace CalamityMod.Items.Weapons.Melee
{
public class TrueArkoftheAncients : ModItem
{
public float Combo = 1f;
public float Charge = 0f;
public override bool CloneNewInstances => true;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("True Ark of the Ancients");
Tooltip.SetDefault("A heavenly blade forged to vanquish all evil");
Tooltip.SetDefault("Using RMB will extend the Ark out in front of you. Hitting an enemy with it will parry them, granting you a small window of invulnerability\n" +
"You can also parry projectiles and temporarily make them deal 160 less damage\n" +
"Parrying will empower the next 10 swings of the sword, boosting their damage and letting them throw stronger projectiles\n" +
"Using RMB after parrying will let you consume all the charge at once into a strong burst of energy\n" +
"A heavenly blade forged to vanquish all evil");
}
public override void SetDefaults()
{
item.width = item.height = 72;
item.damage = 98;
item.damage = 148;
item.melee = true;
item.noUseGraphic = true;
item.noMelee = true;
item.useAnimation = 25;
item.useTime = 25;
item.useTurn = true;
item.useStyle = ItemUseStyleID.SwingThrow;
item.useStyle = ItemUseStyleID.HoldingOut;
item.knockBack = 6.5f;
item.UseSound = SoundID.Item1;
item.UseSound = null;
item.autoReuse = true;
item.value = Item.buyPrice(0, 80, 0, 0);
item.rare = ItemRarityID.Yellow;
item.shoot = ModContent.ProjectileType<EonBeam>();
item.shoot = ProjectileID.PurificationPowder;
item.shootSpeed = 12f;
}
public override bool AltFunctionUse(Player player) => true;
public override bool CanUseItem(Player player)
{
return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI && n.type == ProjectileType<TrueArkoftheAncientsSwungBlade>());
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
type = Utils.SelectRandom(Main.rand, new int[]
{
ModContent.ProjectileType<EonBeam>(),
ModContent.ProjectileType<EonBeamV2>()
});
int beam = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, (int)(damage * 0.75), knockBack, Main.myPlayer);
Main.projectile[beam].localNPCHitCooldown = 14;
Main.projectile[beam].penetrate = 2;
int i = Main.myPlayer;
float num72 = Main.rand.Next(18, 27);
float num74 = knockBack;
num74 = player.GetWeaponKnockback(item, num74);
player.itemTime = item.useTime;
Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true);
Vector2 value = Vector2.UnitX.RotatedBy((double)player.fullRotation, default);
Vector2 vector3 = Main.MouseWorld - vector2;
float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X;
float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y;
if (player.gravDir == -1f)
if (player.altFunctionUse == 2)
{
num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y;
}
float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79));
if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f))
{
num78 = (float)player.direction;
num79 = 0f;
num80 = num72;
}
else
{
num80 = num72 / num80;
}
if (!Main.projectile.Any(n => n.active && n.owner == player.whoAmI && (n.type == ProjectileType<ArkoftheAncientsParryHoldout>() || n.type == ProjectileType<TrueArkoftheAncientsParryHoldout>())))
Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), ProjectileType<TrueArkoftheAncientsParryHoldout>(), damage, 0, player.whoAmI, 0, 0);
for (int num108 = 0; num108 < Main.rand.Next(1,3); num108++)
{
vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f);
vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201);
vector2.Y -= (float)(100 * num108);
num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X;
num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y;
if (num79 < 0f)
else if (Charge > 0)
{
num79 *= -1f;
}
if (num79 < 20f)
{
num79 = 20f;
}
num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79));
num80 = num72 / num80;
num78 *= num80;
num79 *= num80;
float angle = new Vector2(speedX, speedY).ToRotation();
Projectile.NewProjectile(player.Center, Vector2.Zero, ProjectileType<TrueAncientBlast>(), (int)(damage * Charge * 1.8f), 0, player.whoAmI, angle, 600);
float speedX2 = num78 + (float)Main.rand.Next(-160, 161) * 0.02f;
float speedY2 = num79 + (float)Main.rand.Next(-160, 161) * 0.02f;
int proj = Projectile.NewProjectile(vector2.X, vector2.Y, speedX2, speedY2, ProjectileID.HallowStar, damage / 3, num74, i, 0f, (float)Main.rand.Next(10));
if (proj.WithinBounds(Main.maxProjectiles))
Main.projectile[proj].Calamity().forceMelee = true;
Charge = 0;
}
speedX2 = num78 + (float)Main.rand.Next(-80, 81) * 0.02f;
speedY2 = num79 + (float)Main.rand.Next(-80, 81) * 0.02f;
Projectile.NewProjectile(vector2.X, vector2.Y, speedX2, speedY2, ModContent.ProjectileType<TerraBall>(), damage / 3, num74, i, 0f, (float)Main.rand.Next(5));
return false;
}
//Failsafe
if (Combo != -1 && Combo != 1)
Combo = 1;
if (Charge > 0)
damage *= 2;
Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), ProjectileType<TrueArkoftheAncientsSwungBlade>(), damage, knockBack, player.whoAmI, Combo, Charge);
Combo *= -1f;
Charge--;
if (Charge < 0)
Charge = 0;
return false;
}
public override ModItem Clone(Item item)
{
var clone = base.Clone(item);
(clone as TrueArkoftheAncients).Charge = (item.modItem as TrueArkoftheAncients).Charge;
return clone;
}
public override ModItem Clone()
{
var clone = base.Clone();
(clone as TrueArkoftheAncients).Charge = Charge;
return clone;
}
public override void NetSend(BinaryWriter writer)
{
writer.Write(Charge);
}
public override void NetRecieve(BinaryReader reader)
{
Charge = reader.ReadInt32();
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<ArkoftheAncients>());
recipe.AddIngredient(ItemType<ArkoftheAncients>());
recipe.AddIngredient(ItemID.BrokenHeroSword);
recipe.AddIngredient(ItemID.Excalibur);
recipe.AddIngredient(ModContent.ItemType<CoreofCalamity>());
recipe.AddIngredient(ModContent.ItemType<LivingShard>(), 3);
recipe.AddIngredient(ItemType<CoreofCalamity>());
recipe.AddIngredient(ItemType<LivingShard>(), 3);
recipe.AddTile(TileID.MythrilAnvil);
recipe.SetResult(this);
recipe.AddRecipe();
recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<ArkoftheAncients>());
recipe.AddIngredient(ItemType<ArkoftheAncients>());
recipe.AddIngredient(ItemID.TrueExcalibur);
recipe.AddIngredient(ModContent.ItemType<CoreofCalamity>());
recipe.AddIngredient(ModContent.ItemType<LivingShard>(), 3);
recipe.AddIngredient(ItemType<CoreofCalamity>());
recipe.AddIngredient(ItemType<LivingShard>(), 3);
recipe.AddTile(TileID.MythrilAnvil);
recipe.SetResult(this);
recipe.AddRecipe();
}
public override void MeleeEffects(Player player, Rectangle hitbox)
public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
{
if (Main.rand.NextBool(5))
{
int num249 = Main.rand.Next(3);
if (num249 == 0)
{
num249 = 15;
}
else if (num249 == 1)
{
num249 = 57;
}
else
{
num249 = 58;
}
int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, num249, (float)(player.direction * 2), 0f, 150, default, 1.3f);
Main.dust[num250].velocity *= 0.2f;
}
}
if (Charge <= 0)
return;
public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(ModContent.BuffType<HolyFlames>(), 300);
}
var barBG = GetTexture("CalamityMod/ExtraTextures/GenericBarBack");
var barFG = GetTexture("CalamityMod/ExtraTextures/GenericBarFront");
public override void OnHitPvp(Player player, Player target, int damage, bool crit)
{
target.AddBuff(ModContent.BuffType<HolyFlames>(), 300);
Vector2 drawPos = position + Vector2.UnitY * frame.Height * scale + Vector2.UnitX * (frame.Width - barBG.Width) * scale * 0.5f;
Rectangle frameCrop = new Rectangle(0, 0, (int)(Charge / 10f * barFG.Width), barFG.Height);
Color color = Main.hslToRgb((Main.GlobalTime * 0.6f) % 1, 1, 0.85f + (float)Math.Sin(Main.GlobalTime * 3f) * 0.1f);
spriteBatch.Draw(barBG, drawPos, null, color, 0f, origin, scale, 0f, 0f);
spriteBatch.Draw(barFG, drawPos, frameCrop, color * 0.8f, 0f, origin, scale, 0f, 0f);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 971 B

@@ -135,7 +135,7 @@ namespace CalamityMod.Projectiles.Melee
//Bounce off the player if they are in the air
if (Owner.velocity.Y != 0)
Owner.velocity += Vector2.Normalize(Owner.Center - proj.Center) * 5;
Owner.velocity += Vector2.Normalize(Owner.Center - proj.Center) * 2;
Main.PlaySound(SoundID.DD2_WitherBeastCrystalImpact);
Main.PlaySound(SoundID.Item67);
@@ -176,8 +176,8 @@ namespace CalamityMod.Projectiles.Melee
{
if (Main.myPlayer == Owner.whoAmI)
{
var barBG = GetTexture("CalamityMod/ExtraTextures/GenericBarFront");
var barFG = GetTexture("CalamityMod/ExtraTextures/GenericBarBack");
var barBG = GetTexture("CalamityMod/ExtraTextures/GenericBarBack");
var barFG = GetTexture("CalamityMod/ExtraTextures/GenericBarFront");
Vector2 drawPos = Owner.Center - Main.screenPosition + new Vector2(0, -36) - barBG.Size() / 2;
Rectangle frame = new Rectangle(0, 0, (int)((Timer - ParryTime) / (MaxTime - ParryTime) * barFG.Width), barFG.Height);
+132
View File
@@ -0,0 +1,132 @@
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.CalPlayer;
using CalamityMod.DataStructures;
using CalamityMod.Particles;
using CalamityMod.Items.Weapons.Melee;
using Terraria.Graphics.Shaders;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
using static CalamityMod.CalamityUtils;
namespace CalamityMod.Projectiles.Melee
{
public class TrueAncientBeam : ModProjectile //The boring plain one
{
public override string Texture => "CalamityMod/Items/Weapons/Melee/TrueArkoftheAncientsGlow";
public override void SetStaticDefaults()
{
DisplayName.SetDefault("True Ancient Beam");
ProjectileID.Sets.TrailCacheLength[projectile.type] = 5;
ProjectileID.Sets.TrailingMode[projectile.type] = 2;
}
const float MaxTime = 40;
public float Timer => MaxTime - projectile.timeLeft;
public override void SetDefaults()
{
projectile.width = projectile.height = 32;
projectile.aiStyle = 27;
aiType = ProjectileID.LightBeam;
projectile.friendly = true;
projectile.penetrate = 1;
projectile.timeLeft = (int)MaxTime;
projectile.melee = true;
projectile.tileCollide = false;
}
public override void AI()
{
if (projectile.timeLeft < MaxTime - 5)
projectile.tileCollide = true;
projectile.scale = 2.4f;
projectile.Opacity = 0.6f;
Lighting.AddLight(projectile.Center, 0.75f, 1f, 0.24f);
projectile.velocity *= (1 - (float)Math.Pow(Timer / MaxTime, 3));
if (Main.rand.NextBool(3))
{
int dustTrail = Dust.NewDust(projectile.Center, 14, 14, 66, projectile.velocity.X * 0.05f, projectile.velocity.Y * 0.05f, 150, new Color(Main.DiscoR, 100, 255), 1.2f);
Main.dust[dustTrail].noGravity = true;
}
if (Main.rand.NextBool(3))
{
int dustType = Main.rand.Next(3);
dustType = dustType == 0 ? 15 : dustType == 1 ? 57 : 58;
Dust.NewDust(projectile.Center, 14, 14, dustType, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f, 150, default, 1.3f);
}
if (projectile.velocity.Length() < 1.0f)
projectile.Kill();
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
if (projectile.timeLeft > 35)
return false;
DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
Texture2D starTexture = GetTexture("CalamityMod/Particles/Sparkle");
Texture2D bloomTexture = GetTexture("CalamityMod/Particles/BloomCircle");
//Ajust the bloom's texture to be the same size as the star's
float properBloomSize = (float)starTexture.Height / (float)bloomTexture.Height;
Color color = Main.hslToRgb((Main.GlobalTime * 0.6f) % 1, 1, 0.85f);
float rotation = Main.GlobalTime * 8f;
Vector2 sparkCenter = projectile.Center - Utils.SafeNormalize(projectile.velocity, Vector2.Zero) * 30.5f - Main.screenPosition;
spriteBatch.Draw(bloomTexture, sparkCenter, null, color* 0.5f, 0, bloomTexture.Size() / 2f, 4 * properBloomSize, SpriteEffects.None, 0);
spriteBatch.Draw(starTexture, sparkCenter, null, color * 0.5f, rotation + MathHelper.PiOver4, starTexture.Size() / 2f, 2 * 0.75f, SpriteEffects.None, 0);
spriteBatch.Draw(starTexture, sparkCenter, null, Color.White, rotation, starTexture.Size() / 2f, 2, SpriteEffects.None, 0);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
return false;
}
public override void Kill(int timeLeft)
{
Main.PlaySound(SoundID.DD2_WitherBeastDeath, projectile.Center);
for (int i = 0; i < 10; i++)
{
Vector2 particleSpeed = Main.rand.NextVector2CircularEdge(1, 1) * Main.rand.NextFloat(1.2f, 2.3f);
Particle energyLeak = new SquishyLightParticle(projectile.Center + Utils.SafeNormalize(projectile.velocity, Vector2.Zero) * 40f, particleSpeed, Main.rand.NextFloat(0.3f, 0.6f), Color.Cyan, 60, 1, 1.5f, hueShift: 0.02f);
GeneralParticleHandler.SpawnParticle(energyLeak);
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
Vector2 particleOrigin = target.Hitbox.Size().Length() < 140 ? target.Center : projectile.Center + projectile.rotation.ToRotationVector2() * 60f;
for (int i = 0; i < 10; i++)
{
Vector2 particleSpeed = Main.rand.NextVector2CircularEdge(1, 1) * Main.rand.NextFloat(2.6f, 4f);
Particle energyLeak = new SquishyLightParticle(particleOrigin, particleSpeed, Main.rand.NextFloat(0.3f, 0.6f), Color.Cyan, 60, 1, 1.5f, hueShift: 0.02f);
GeneralParticleHandler.SpawnParticle(energyLeak);
}
}
}
}
+120
View File
@@ -0,0 +1,120 @@
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.CalPlayer;
using CalamityMod.DataStructures;
using CalamityMod.Particles;
using CalamityMod.Items.Weapons.Melee;
using Terraria.Graphics.Shaders;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
using static CalamityMod.CalamityUtils;
namespace CalamityMod.Projectiles.Melee
{
public class TrueAncientBlast : ModProjectile //The boring plain one
{
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Ancient Energy Blast");
ProjectileID.Sets.TrailCacheLength[projectile.type] = 5;
ProjectileID.Sets.TrailingMode[projectile.type] = 2;
}
const float MaxTime = 20;
public float Timer => MaxTime - projectile.timeLeft;
public ref float angle => ref projectile.ai[0];
public ref float lenght => ref projectile.ai[1];
public Player Owner => Main.player[projectile.owner];
public Vector2 lineVector => angle.ToRotationVector2() * lenght;
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? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
float collisionPoint = 0f;
return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + lineVector, 20f, ref collisionPoint);
}
public override void AI()
{
if (Timer == 0)
{
Particle Star = new GenericSparkle(projectile.Center, Vector2.Zero, Color.White, Color.HotPink, Main.rand.NextFloat(1f, 1.5f), 20, 0.1f, 3f);
GeneralParticleHandler.SpawnParticle(Star);
Star = new GenericSparkle(projectile.Center + lineVector, Vector2.Zero, Color.White, Color.PaleGoldenrod, Main.rand.NextFloat(1f, 1.5f), 20, 0.1f, 3f);
GeneralParticleHandler.SpawnParticle(Star);
Main.PlaySound(SoundID.Item84, projectile.Center);
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D sword = GetTexture("CalamityMod/Items/Weapons/Melee/TrueArkoftheAncients");
Texture2D glowmask = GetTexture("CalamityMod/Items/Weapons/Melee/TrueArkoftheAncientsGlow");
float drawRotation = angle + MathHelper.PiOver4;
Vector2 drawOrigin = new Vector2(0f, sword.Height);
Vector2 drawOffset = Owner.Center + angle.ToRotationVector2() * 30 - Main.screenPosition;
spriteBatch.Draw(sword, drawOffset, null, lightColor, drawRotation, drawOrigin, projectile.scale, 0f, 0f);
spriteBatch.Draw(glowmask, drawOffset, null, Color.Lerp(lightColor, Color.White, 0.75f), drawRotation, drawOrigin, projectile.scale, 0f, 0f);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
Texture2D tex = GetTexture("CalamityMod/Particles/BloomLine");
float rot = angle + MathHelper.PiOver2;
Vector2 origin = new Vector2(tex.Width / 2f, tex.Height);
float size = Timer / MaxTime > 0.5f ? (float)Math.Sin(Timer / MaxTime * MathHelper.Pi) * 0.2f + 0.8f : (float)Math.Sin(Timer / MaxTime * MathHelper.Pi);
size *= 3;
Vector2 scale = new Vector2(size, lenght / tex.Height);
spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, Color.LightPink, rot, origin, scale, SpriteEffects.None, 0);
Texture2D cap = GetTexture("CalamityMod/Particles/BloomLineCap");
scale = new Vector2(size, size);
origin = new Vector2(cap.Width / 2f, cap.Height);
spriteBatch.Draw(cap, projectile.Center - Main.screenPosition, null, Color.LightPink, rot + MathHelper.Pi, origin, scale, SpriteEffects.None, 0);
spriteBatch.Draw(cap, projectile.Center + lineVector - Main.screenPosition, null, Color.LightPink, rot, origin, scale, SpriteEffects.None, 0);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
return false;
}
}
}
@@ -0,0 +1,233 @@
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.CalPlayer;
using CalamityMod.DataStructures;
using CalamityMod.Particles;
using CalamityMod.Items.Weapons.Melee;
using Terraria.Graphics.Shaders;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
using static CalamityMod.CalamityUtils;
namespace CalamityMod.Projectiles.Melee
{
public class TrueArkoftheAncientsParryHoldout : ModProjectile
{
public override string Texture => "CalamityMod/Items/Weapons/Melee/TrueArkoftheAncients";
private bool initialized = false;
const float MaxTime = 160;
static float ParryTime = 15;
public Vector2 DistanceFromPlayer => projectile.velocity * 10 * (1f + ((float)Math.Sin(Timer / ParryTime * MathHelper.Pi) * 0.8f));
public float Timer => MaxTime - projectile.timeLeft;
public ref float AlreadyParried => ref projectile.ai[1];
public Player Owner => Main.player[projectile.owner];
public override void SetStaticDefaults()
{
DisplayName.SetDefault("True Ark of the Ancients");
}
public override void SetDefaults()
{
projectile.melee = true;
projectile.width = projectile.height = 75;
projectile.width = projectile.height = 75;
projectile.tileCollide = false;
projectile.friendly = true;
projectile.penetrate = -1;
}
public override bool CanDamage() => Timer <= ParryTime && AlreadyParried == 0f;
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
//The hitbox is simplified into a line collision.
float collisionPoint = 0f;
float bladeLenght = 100f * projectile.scale;
return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Owner.Center + DistanceFromPlayer, Owner.Center + DistanceFromPlayer + (projectile.velocity * bladeLenght), 24, ref collisionPoint);
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
if (AlreadyParried > 0)
return;
Owner.GiveIFrames(35);
TrueArkoftheAncients sword = (Owner.HeldItem.modItem as TrueArkoftheAncients);
sword.Charge = 10f;
AlreadyParried = 1f;
Main.PlaySound(SoundID.DD2_WitherBeastCrystalImpact);
Main.PlaySound(SoundID.Item67);
CombatText.NewText(projectile.Hitbox, new Color(111, 247, 200), "Parry!", true);
Vector2 particleOrigin = target.Hitbox.Size().Length() < 140 ? target.Center : projectile.Center + projectile.rotation.ToRotationVector2() * 60f;
Particle spark = new GenericSparkle(particleOrigin, Vector2.Zero, Color.White, Color.HotPink, 1.2f, 35, 0.1f, 2);
GeneralParticleHandler.SpawnParticle(spark);
for (int i = 0; i < 10; i++)
{
Vector2 particleSpeed = Main.rand.NextVector2CircularEdge(1, 1) * Main.rand.NextFloat(2.6f, 4f);
Particle energyLeak = new SquishyLightParticle(particleOrigin, particleSpeed, Main.rand.NextFloat(0.3f, 0.6f), Color.Cyan, 60, 1, 1.5f, hueShift: 0.02f);
GeneralParticleHandler.SpawnParticle(energyLeak);
}
}
public override void AI()
{
if (!initialized) //Initialization
{
projectile.timeLeft = (int)MaxTime;
Main.PlaySound(SoundID.DD2_SkyDragonsFuryShot, projectile.Center);
//Take the direction the sword is swung. FUCK not controlling the swing direction more than just left/right :|
//The direction to mouseworld may need to be turned into the custom synced player mouse variables . not on the branch currently tho
projectile.velocity = Owner.DirectionTo(Main.MouseWorld);
projectile.velocity.Normalize();
projectile.rotation = projectile.velocity.ToRotation();
initialized = true;
projectile.netUpdate = true;
projectile.netSpam = 0;
}
//Manage position and rotation
projectile.Center = Owner.Center + DistanceFromPlayer ;
//rotation = projectile.rotation + MathHelper.SmoothStep(SwingWidth / 2 * SwingDirection, -SwingWidth / 2 * SwingDirection, Timer / MaxTime);
projectile.scale = 1.4f + ((float)Math.Sin(Timer / MaxTime * MathHelper.Pi) * 0.6f); //SWAGGER
if (Timer > ParryTime)
return;
if (AlreadyParried == 0)
{
float collisionPoint = 0f;
float bladeLenght = 100f * projectile.scale;
for (int k = 0; k < Main.maxProjectiles; k++)
{
Projectile proj = Main.projectile[k];
if (proj.active && proj.hostile && proj.damage > 1 && proj.velocity.Length() * (proj.extraUpdates + 1) > 1f
&& Collision.CheckAABBvLineCollision(proj.Hitbox.TopLeft(), proj.Hitbox.Size(), Owner.Center + DistanceFromPlayer, Owner.Center + DistanceFromPlayer + (projectile.velocity * bladeLenght), 24, ref collisionPoint))
{
TrueArkoftheAncients sword = (Owner.HeldItem.modItem as TrueArkoftheAncients);
if (sword != null)
sword.Charge = 10;
CombatText.NewText(projectile.Hitbox, new Color(111, 247, 200), "Parry!", true);
//Reduce the projectile's damage by 100 for half a second.
if (proj.Calamity().damageReduction < 160)
proj.Calamity().damageReduction = 160;
if (proj.Calamity().damageReductionTimer < 60)
proj.Calamity().damageReductionTimer = 60;
//Bounce off the player if they are in the air
if (Owner.velocity.Y != 0)
Owner.velocity += Vector2.Normalize(Owner.Center - proj.Center) * 2;
Main.PlaySound(SoundID.DD2_WitherBeastCrystalImpact);
Main.PlaySound(SoundID.Item67);
AlreadyParried = 1f;
break;
}
}
}
//Make the owner look like theyre holding the sword bla bla
Owner.heldProj = projectile.whoAmI;
Owner.direction = Math.Sign(projectile.velocity.X);
Owner.itemRotation = projectile.rotation;
if (Owner.direction != 1)
{
Owner.itemRotation -= 3.14f;
}
Owner.itemRotation = MathHelper.WrapAngle(Owner.itemRotation);
if (AlreadyParried > 0)
{
AlreadyParried++;
}
}
//Animation keys
public CurveSegment anticipation = new CurveSegment(EasingType.SineBump, 0f, 0f, -0.15f);
public CurveSegment thrust = new CurveSegment(EasingType.PolyInOut, 0.2f, 0f, 0.9f, 3);
public CurveSegment hold = new CurveSegment(EasingType.SineBump, 0.35f, 0.9f, 0.1f);
public CurveSegment retract = new CurveSegment(EasingType.PolyInOut, 0.7f, 0.9f, -0.9f, 3);
internal float ThrustDisplaceRatio() => PiecewiseAnimation(Timer / MaxTime, new CurveSegment[] { anticipation, thrust, hold, retract });
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
//Stop drawing the sword. Draw a recharge bar instead
if (Timer > ParryTime)
{
if (Main.myPlayer == Owner.whoAmI)
{
var barBG = GetTexture("CalamityMod/ExtraTextures/GenericBarBack");
var barFG = GetTexture("CalamityMod/ExtraTextures/GenericBarFront");
Vector2 drawPos = Owner.Center - Main.screenPosition + new Vector2(0, -36) - barBG.Size() / 2;
Rectangle frame = new Rectangle(0, 0, (int)((Timer - ParryTime) / (MaxTime - ParryTime) * barFG.Width), barFG.Height);
float opacity = Timer <= ParryTime + 25f ? (Timer - ParryTime) / 25f : (MaxTime - Timer <= 8) ? projectile.timeLeft / 8f : 1f;
Color color = Main.hslToRgb((Main.GlobalTime * 1.2f) % 1, 1, 0.85f + (float)Math.Sin(Main.GlobalTime * 7f) * 0.1f);
spriteBatch.Draw(barBG, drawPos, color * opacity);
spriteBatch.Draw(barFG, drawPos, frame, color * opacity * 0.8f);
}
return false;
}
Texture2D sword = GetTexture("CalamityMod/Items/Weapons/Melee/TrueArkoftheAncients");
Texture2D glowmask = GetTexture("CalamityMod/Items/Weapons/Melee/TrueArkoftheAncientsGlow");
float drawRotation = projectile.rotation + MathHelper.PiOver4;
Vector2 drawOrigin = new Vector2(0f, sword.Height);
Vector2 drawOffset = Owner.Center + projectile.velocity * DistanceFromPlayer.Length() - Main.screenPosition;
spriteBatch.Draw(sword, drawOffset, null, lightColor, drawRotation, drawOrigin, projectile.scale, 0f, 0f);
spriteBatch.Draw(glowmask, drawOffset, null, Color.Lerp(lightColor, Color.White, 0.75f), drawRotation, drawOrigin, projectile.scale, 0f, 0f);
if (AlreadyParried > 0)
{
drawOrigin = new Vector2(0f, 48f);
Rectangle frame = new Rectangle(24, 0, 48, 48);
drawOffset = Owner.Center + projectile.velocity * (DistanceFromPlayer.Length() + 34) - Main.screenPosition;
spriteBatch.Draw(glowmask, drawOffset, frame, Main.hslToRgb(Main.GlobalTime % 1, 1, 0.8f) * (1 - AlreadyParried / ParryTime), drawRotation, drawOrigin, projectile.scale + AlreadyParried / ParryTime, 0f, 0f);
}
return false;
}
public override void Kill(int timeLeft)
{
//Play a blip when it dies, to indicate to the player its ready to get used again
if (Main.myPlayer == Owner.whoAmI)
Main.PlaySound(SoundID.Item35);
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(initialized);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
initialized = reader.ReadBoolean();
}
}
}
@@ -0,0 +1,168 @@
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.CalPlayer;
using CalamityMod.DataStructures;
using CalamityMod.Particles;
using CalamityMod.Items.Weapons.Melee;
using Terraria.Graphics.Shaders;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
using static CalamityMod.CalamityUtils;
namespace CalamityMod.Projectiles.Melee
{
public class TrueArkoftheAncientsSwungBlade : ModProjectile
{
public override string Texture => "CalamityMod/Items/Weapons/Melee/TrueArkoftheAncients";
private bool initialized = false;
Vector2 direction = Vector2.Zero;
public float SwingDirection => projectile.ai[0] * Math.Sign(direction.X);
public ref float Charge => ref projectile.ai[1];
public ref float HasFired => ref projectile.localAI[0];
const float MaxTime = 35;
private float SwingWidth = MathHelper.PiOver2 * 1.5f;
public Vector2 DistanceFromPlayer => direction * 30;
public float Timer => MaxTime - projectile.timeLeft;
public Player Owner => Main.player[projectile.owner];
public override void SetStaticDefaults()
{
DisplayName.SetDefault("True Ark of the Ancients");
ProjectileID.Sets.TrailCacheLength[projectile.type] = 10;
ProjectileID.Sets.TrailingMode[projectile.type] = 2;
}
public override void SetDefaults()
{
projectile.melee = true;
projectile.width = projectile.height = 60;
projectile.width = projectile.height = 60;
projectile.tileCollide = false;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.extraUpdates = 1;
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
//The hitbox is simplified into a line collision.
float collisionPoint = 0f;
float bladeLenght = 82f * projectile.scale;
Vector2 holdPoint = DistanceFromPlayer.Length() * projectile.rotation.ToRotationVector2();
return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Owner.Center + holdPoint, Owner.Center + holdPoint + projectile.rotation.ToRotationVector2() * bladeLenght, 24, ref collisionPoint);
}
//Swing animation keys
public CurveSegment anticipation = new CurveSegment(EasingType.ExpOut, 0f, 0f, 0.15f);
public CurveSegment thrust = new CurveSegment(EasingType.PolyInOut, 0.1f, 0.15f, 0.85f, 3);
public CurveSegment hold = new CurveSegment(EasingType.Linear, 0.5f, 1f, 0.2f);
public CurveSegment retract = new CurveSegment(EasingType.PolyInOut, 0.7f, 0.9f, -0.9f, 3);
internal float SwingRatio() => PiecewiseAnimation(Timer / MaxTime, new CurveSegment[] { anticipation, thrust, hold });
public override void AI()
{
if (!initialized) //Initialization
{
projectile.timeLeft = (int)MaxTime;
var sound = Main.PlaySound(Charge > 0 ? SoundID.DD2_PhantomPhoenixShot : SoundID.DD2_MonkStaffSwing, projectile.Center);
if (Charge > 0)
sound.Volume *= 2.5f;
direction = Owner.DirectionTo(Main.MouseWorld);
direction.Normalize();
projectile.rotation = direction.ToRotation();
initialized = true;
projectile.netUpdate = true;
projectile.netSpam = 0;
}
//Manage position and rotation
projectile.Center = Owner.Center + DistanceFromPlayer;
projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Lerp(SwingWidth / 2 * SwingDirection, -SwingWidth / 2 * SwingDirection, SwingRatio());
projectile.scale = 1.4f + ((float)Math.Sin(SwingRatio() * MathHelper.Pi) * 0.6f) + (Charge / 10f) * 0.6f;
if (Owner.whoAmI == Main.myPlayer && SwingRatio() > 0.5f && HasFired == 0f && Charge > 0)
{
Projectile.NewProjectile(Owner.Center + direction * 30f, projectile.velocity * 2f, ProjectileType<TrueAncientBeam>(), projectile.damage, 2f, Owner.whoAmI) ;
HasFired = 1f;
}
//Make the owner look like theyre holding the sword bla bla
Owner.heldProj = projectile.whoAmI;
Owner.direction = Math.Sign(projectile.velocity.X);
Owner.itemRotation = projectile.rotation;
if (Owner.direction != 1)
{
Owner.itemRotation -= 3.14f;
}
Owner.itemRotation = MathHelper.WrapAngle(Owner.itemRotation);
if (Charge > 0 && Main.rand.Next(2) == 0)
{
Vector2 particleOrigin = projectile.Center + projectile.rotation.ToRotationVector2() * 75 * projectile.scale;
Vector2 particleSpeed = projectile.rotation.ToRotationVector2().RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(1.2f, 2f);
Particle energyLeak = new CritSpark(particleOrigin, particleSpeed + Owner.velocity, Color.White, Color.Cyan, Main.rand.NextFloat(0.6f, 1.6f), 20 + Main.rand.Next(10), 0.1f, 1.5f, hueShift: 0.02f);
GeneralParticleHandler.SpawnParticle(energyLeak);
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D sword = GetTexture("CalamityMod/Items/Weapons/Melee/TrueArkoftheAncients");
Texture2D glowmask = GetTexture("CalamityMod/Items/Weapons/Melee/TrueArkoftheAncientsGlow");
SpriteEffects flip = Owner.direction < 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
float extraAngle = Owner.direction < 0 ? MathHelper.PiOver2 : 0f;
float drawAngle = projectile.rotation;
float drawRotation = projectile.rotation + MathHelper.PiOver4 + extraAngle;
Vector2 drawOrigin = new Vector2(Owner.direction < 0 ? sword.Width : 0f , sword.Height);
Vector2 drawOffset = Owner.Center + drawAngle.ToRotationVector2() * 10f - Main.screenPosition;
if (CalamityConfig.Instance.Afterimages && Timer > ProjectileID.Sets.TrailCacheLength[projectile.type])
{
for (int i = 0; i < projectile.oldRot.Length; ++i)
{
//Color color = projectile.GetAlpha(lightColor) * (1f - (i / (float)projectile.oldRot.Length));
Color color = Main.hslToRgb((i / (float)projectile.oldRot.Length) * 0.7f, 1, 0.6f + (Charge > 0 ? 0.3f : 0f));
float afterimageRotation = projectile.oldRot[i] + MathHelper.PiOver4;
Main.spriteBatch.Draw(glowmask, drawOffset, null, color * 0.15f, afterimageRotation + extraAngle, drawOrigin, projectile.scale - 0.2f * ((i / (float)projectile.oldRot.Length)), flip, 0f);
}
}
spriteBatch.Draw(sword, drawOffset, null, lightColor, drawRotation, drawOrigin, projectile.scale, flip, 0f);
spriteBatch.Draw(glowmask, drawOffset, null, Color.Lerp(lightColor, Color.White, 0.75f), drawRotation, drawOrigin, projectile.scale, flip, 0f);
return false;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(initialized);
writer.WriteVector2(direction);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
initialized = reader.ReadBoolean();
direction = reader.ReadVector2();
}
}
}