Biome Blade line full rework + huge amounts of render tech

This commit is contained in:
Cameron Ewell authored and GitHub committed 2022-01-25 12:28:14 -05:00
commit 31bf53a981
130 files changed
+11500 -1299

No files matched your search

+2
View File
@@ -136,6 +136,7 @@ namespace CalamityMod.CalPlayer
public bool GivenBrimstoneLocus = false;
public DoGCartSegment[] DoGCartSegments = new DoGCartSegment[DoGCartMount.SegmentCount];
public float SmoothenedMinecartRotation;
public bool LungingDown = false;
#endregion
#region IL Editing Constants
@@ -2557,6 +2558,7 @@ namespace CalamityMod.CalPlayer
potionTimer = 0;
bloodflareCoreLostDefense = 0;
persecutedEnchantSummonTimer = 0;
LungingDown = false;
if (BossRushEvent.BossRushActive)
{
+12
View File
@@ -129,6 +129,9 @@ namespace CalamityMod.CalPlayer
// This must be done here instead of in the item logic because these sets are not properly instanced
// in the global classes. Attempting to update them there will cause multiple updates to one set for multiple items.
CalamityGlobalItem.UpdateAllParticleSets();
BiomeBlade.UpdateAllParticleSets();
TrueBiomeBlade.UpdateAllParticleSets();
OmegaBiomeBlade.UpdateAllParticleSets();
// Update the gem tech armor set.
GemTechState.Update();
@@ -1062,6 +1065,15 @@ namespace CalamityMod.CalPlayer
if (gSabatonFall > 0 || player.PortalPhysicsEnabled)
player.maxFallSpeed = 20f;
}
if (LungingDown)
{
player.maxFallSpeed = 80f;
player.noFallDmg = true;
}
}
// Omega Blue Armor bonus
-51
View File
@@ -1,51 +0,0 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Dusts {
public class PumplerDust : ModDust //TURN THAT INTO A PARTICLE WHEN I REMEMBER
{
public override bool Autoload(ref string name, ref string texture)
{
texture = "CalamityMod/Particles/SmallSmoke";
return true;
}
public override void OnSpawn(Dust dust)
{
dust.noGravity = true;
dust.frame = new Rectangle(0, 0, 24, 24);
}
public override Color? GetAlpha(Dust dust, Color lightColor)
{
Color gray = new Color(40, 40, 40);
Color ret;
ret = Color.Lerp(Color.Orange, gray, MathHelper.Clamp((float)(dust.alpha - 100) / 80, 0f, 1f));
return ret * ((255 - dust.alpha) / 255f);
}
public override bool Update(Dust dust)
{
dust.velocity *= 0.85f;
if (dust.alpha < 165)
{
Lighting.AddLight(dust.position, dust.color.ToVector3() * 0.1f);
dust.scale += 0.01f;
dust.alpha += 3;
}
else
{
dust.scale *= 0.975f;
dust.alpha += 2;
}
dust.position += dust.velocity;
if (dust.alpha >= 255)
dust.active = false;
return false;
}
}
}
+1 -2
View File
@@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee
public override void SetDefaults()
{
item.width = 50;
item.width = item.height = 60;
item.damage = 80;
item.melee = true;
item.useAnimation = 22;
@@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Melee
item.knockBack = 6.25f;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.height = 50;
item.value = Item.buyPrice(0, 48, 0, 0);
item.rare = ItemRarityID.LightPurple;
item.shoot = ModContent.ProjectileType<EonBeam>();
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

+597 -20
View File
@@ -1,64 +1,641 @@
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.CalPlayer;
using CalamityMod.DataStructures;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables;
using CalamityMod.Particles;
using CalamityMod.Projectiles.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 Terraria.ModLoader.IO;
using static CalamityMod.Items.Weapons.Melee.BiomeBlade;
using static CalamityMod.CalamityUtils;
namespace CalamityMod.Items.Weapons.Melee
{
public class BiomeBlade : ModItem
{
public enum Attunement : byte { Default, Hot, Cold, Tropical, Evil }
public Attunement? mainAttunement = null;
public Attunement? secondaryAttunement = null;
public int Combo = 0;
public int CanLunge = 1;
#region stats
public static int DefaultAttunement_BaseDamage = 55;
public static int EvilAttunement_BaseDamage = 102;
public static int EvilAttunement_Lifesteal = 3;
public static int EvilAttunement_BounceIFrames = 10;
public static int ColdAttunement_BaseDamage = 70;
public static float ColdAttunement_SecondSwingBoost = 1.8f;
public static float ColdAttunement_ThirdSwingBoost = 3f;
public static int HotAttunement_BaseDamage = 70;
public static int HotAttunement_ShredIFrames = 8;
public static int HotAttunement_LocalIFrames = 30; //Be warned its got one extra update so all the iframes should be divided in 2
public static int HotAttunement_LocalIFramesCharged = 16;
public static int TropicalAttunement_BaseDamage = 55;
public static float TropicalAttunement_ChainDamageReduction = 0.5f;
public static int TropicalAttunement_LocalIFrames = 60; //Be warned its got 2 extra updates so all the iframes should be divided in 3
#endregion
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Biome Blade");
Tooltip.SetDefault("Fires different projectiles based on what biome you're in");
DisplayName.SetDefault("Broken Biome Blade"); //Broken Ecoliburn lmfao. Tbh a proper name instead of just "biome blade" may be neat given the importance of the sword
Tooltip.SetDefault("FUNCTION_DESC\n" +
"Use RMB while standing still on the ground to attune the weapon to the powers of the surrounding biome\n" +
"Using RMB otherwise switches between the current attunement and an extra stored one\n" +
"Main attunement : None\n" +
"Secondary attunement: None\n"); //Theres potential for flavor text as well but im not a writer
}
#region tooltip editing
public override void ModifyTooltips(List<TooltipLine> list)
{
Player player = Main.player[Main.myPlayer];
if (player is null)
return;
foreach (TooltipLine l in list)
{
if (l.text.StartsWith("FUNCTION_DESC"))
{
AttunementInfo info = GetAttunementInfo(mainAttunement);
l.overrideColor = info.color;
l.text = info.function_description;
}
if (l.text.StartsWith("Main attunement"))
{
AttunementInfo info = GetAttunementInfo(mainAttunement);
l.overrideColor = info.color;
l.text = "Main Attumenent : ["+ info.name + "]";
}
if (l.text.StartsWith("Secondary attunement"))
{
AttunementInfo info = GetAttunementInfo(secondaryAttunement);
l.overrideColor = Color.Lerp(info.color, Color.Gray, 0.5f);
l.text = "Secondary Attumenent : [" + info.name + "]";
}
}
}
internal struct AttunementInfo
{
public string name;
public string function_description;
public Color color;
}
internal AttunementInfo GetAttunementInfo(Attunement? attunement)
{
AttunementInfo AttunementInfo = new AttunementInfo();
switch (attunement)
{
case Attunement.Default:
AttunementInfo.name = "Pure Clarity";
AttunementInfo.function_description = "Fires a weak projectile that crushes enemy defenses";
AttunementInfo.color = new Color(171, 180, 73);
break;
case Attunement.Hot:
AttunementInfo.name = "Arid Grandeur";
AttunementInfo.function_description = "Conjures searing blades in front of you that get larger and stronger the more you hit enemies. The blades can also be used to bounce off tiles when in the air";
AttunementInfo.color = new Color(238, 156, 73);
break;
case Attunement.Cold:
AttunementInfo.name = "Biting Embrace";
AttunementInfo.function_description = "Perform a 3 strike combo with a glacial blade. The final strike freezes foes for a split second";
AttunementInfo.color = new Color(165, 235, 235);
break;
case Attunement.Tropical:
AttunementInfo.name = "Grovetender's Touch";
AttunementInfo.function_description = "Throw out the blade using a vine whip. Striking enemies with the tip of the whip as it cracks guarantees a critical hit. The whip will also propel you towards struck tiles";
AttunementInfo.color = new Color(162, 200, 85);
break;
case Attunement.Evil:
AttunementInfo.name = "Decay's Retort";
AttunementInfo.function_description = "Lunge forward using a ghostly rapier projection that leeches life off any struck foes. You also get bounced away from hit targets";
AttunementInfo.color = new Color(211, 64, 147);
break;
default:
AttunementInfo.name = "None";
AttunementInfo.function_description = "Does nothing... yet";
AttunementInfo.color = new Color(163, 163, 163);
break;
}
return AttunementInfo;
}
#endregion
public override void SetDefaults()
{
item.width = 42;
item.width = item.height = 36;
item.damage = 55;
item.melee = true;
item.useAnimation = 30;
item.useTime = 30;
item.useTurn = true;
item.useStyle = ItemUseStyleID.SwingThrow;
item.shoot = ProjectileID.PurificationPowder;
item.knockBack = 5f;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.height = 42;
item.value = Item.buyPrice(0, 4, 0, 0);
item.rare = ItemRarityID.Orange;
item.shoot = ModContent.ProjectileType<BiomeOrb>();
item.shootSpeed = 12f;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.WoodenSword);
recipe.AddIngredient(ItemID.DirtBlock, 20);
recipe.AddIngredient(ItemID.SandBlock, 20);
recipe.AddIngredient(ItemID.IceBlock, 20); //intentionally not any ice
recipe.AddRecipeGroup("AnyEvilBlock", 20);
recipe.AddIngredient(ItemID.GlowingMushroom, 20);
recipe.AddIngredient(ItemID.Marble, 20);
recipe.AddIngredient(ItemID.Granite, 20);
recipe.AddIngredient(ItemID.Hellstone, 20);
recipe.AddIngredient(ItemID.Coral, 20);
recipe.AddIngredient(ModContent.ItemType<Navystone>(), 20);
recipe.AddRecipeGroup("AnyWoodenSword");
recipe.AddIngredient(ItemID.DirtBlock, 50);
recipe.AddIngredient(ItemID.StoneBlock, 50);
recipe.AddIngredient(ItemID.HellstoneBar, 5);
recipe.AddIngredient(ItemType<VictoryShard>(), 5);
recipe.AddTile(TileID.Anvils);
recipe.SetResult(this);
recipe.AddRecipe();
}
public override void MeleeEffects(Player player, Rectangle hitbox)
#region Saving and syncing attunements
public override bool CloneNewInstances => true;
public override ModItem Clone(Item item)
{
if (Main.rand.NextBool(5))
var clone = base.Clone(item);
if (Main.mouseItem.type == ItemType<BiomeBlade>())
item.modItem.HoldItem(Main.player[Main.myPlayer]);
(clone as BiomeBlade).mainAttunement = (item.modItem as BiomeBlade).mainAttunement;
(clone as BiomeBlade).secondaryAttunement = (item.modItem as BiomeBlade).secondaryAttunement;
//As funny as a Broken Broken Biome Blade would be, its also quite funny to make it turn into that. This is only done for a new instance of the item since the goblin tinkerer changes prevent it from happening through reforging
if (clone.item.prefix == PrefixID.Broken)
{
int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 0);
clone.item.Prefix(PrefixID.Legendary);
clone.item.prefix = PrefixID.Legendary;
}
return clone;
}
public override ModItem Clone() //ditto
{
var clone = base.Clone();
(clone as BiomeBlade).mainAttunement = mainAttunement;
(clone as BiomeBlade).secondaryAttunement = secondaryAttunement;
if (clone.item.prefix == PrefixID.Broken)
{
clone.item.Prefix(PrefixID.Legendary);
clone.item.prefix = PrefixID.Legendary;
}
return clone;
}
public override TagCompound Save()
{
int attunement1 = mainAttunement == null? -1 : (int)mainAttunement;
int attunement2 = secondaryAttunement == null ? -1 : (int)secondaryAttunement;
TagCompound tag = new TagCompound
{
{ "mainAttunement", attunement1 },
{ "secondaryAttunement", attunement2 }
};
return tag;
}
public override void Load(TagCompound tag)
{
int attunement1 = tag.GetInt("mainAttunement");
int attunement2 = tag.GetInt("secondaryAttunement");
if (attunement1 == -1)
mainAttunement = null;
else
mainAttunement = (Attunement?)attunement1;
if (attunement2 == -1 || (attunement1 == attunement2))
secondaryAttunement = null;
else
secondaryAttunement = (Attunement?)attunement2;
}
public override void NetSend(BinaryWriter writer)
{
writer.Write((byte)mainAttunement);
writer.Write((byte)secondaryAttunement);
}
public override void NetRecieve(BinaryReader reader)
{
mainAttunement = (Attunement?)reader.ReadByte();
secondaryAttunement = (Attunement?)reader.ReadByte();
}
#endregion
public override void HoldItem(Player player)
{
player.Calamity().rightClickListener = true;
if (player.velocity.Y == 0) //Reset the lunge ability on ground contact
CanLunge = 1;
//Change the swords function based on its attunement
switch (mainAttunement)
{
case Attunement.Default:
item.damage = DefaultAttunement_BaseDamage;
item.channel = false;
item.noUseGraphic = false;
item.useStyle = ItemUseStyleID.SwingThrow;
item.shoot = ProjectileType<PurityProjection>();
item.shootSpeed = 12f;
item.UseSound = SoundID.Item1;
item.noMelee = false;
Combo = 0;
break;
case Attunement.Hot:
item.damage = HotAttunement_BaseDamage;
item.channel = true;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.HoldingOut;
item.shoot = ProjectileType<AridGrandeur>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
Combo = 0;
break;
case Attunement.Cold:
item.damage = ColdAttunement_BaseDamage;
item.channel = true;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.HoldingOut;
item.shoot = ProjectileType<BitingEmbrace>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
break;
case Attunement.Tropical:
item.damage = TropicalAttunement_BaseDamage;
item.channel = false;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.SwingThrow;
item.shoot = ProjectileType<GrovetendersTouch>();
item.shootSpeed = 30;
item.UseSound = null;
item.noMelee = true;
Combo = 0;
break;
case Attunement.Evil:
item.damage = EvilAttunement_BaseDamage;
item.channel = false;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.Stabbing;
item.shoot = ProjectileType<DecaysRetort>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
Combo = 0;
break;
default:
item.noUseGraphic = false;
item.useStyle = ItemUseStyleID.SwingThrow;
item.shoot = ProjectileID.PurificationPowder;
item.shootSpeed = 12f;
item.UseSound = SoundID.Item1;
Combo = 0;
break;
}
if (player.Calamity().mouseRight && CanUseItem(player) && player.whoAmI == Main.myPlayer && !Main.mapFullscreen)
{
//Don't shoot out a visual blade if you already have one out
if (Main.projectile.Any(n => n.active && n.type == ProjectileType<BrokenBiomeBladeVisuals>() && n.owner == player.whoAmI))
return;
int x = (int)player.Center.X / 16;
int y = (int)(player.position.Y + (float)player.height - 1f) / 16;
Tile tileStandingOn = Main.tile[x, y + 1];
bool mayAttune = player.StandingStill() && !player.mount.Active && tileStandingOn.IsTileSolidGround();
Vector2 displace = new Vector2(18f, 0f);
Projectile.NewProjectile(player.Top + displace, Vector2.Zero, ProjectileType<BrokenBiomeBladeVisuals>(), 0, 0, player.whoAmI, mayAttune ? 0f : 1f);
}
}
public override bool CanUseItem(Player player)
{
return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI &&
(n.type == ProjectileType<BitingEmbrace>() || n.type == ProjectileType<GrovetendersTouch>() || n.type == ProjectileType<AridGrandeur>()));
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
if (mainAttunement == null)
return false;
switch (mainAttunement)
{
case Attunement.Cold:
switch (Combo)
{
case 0:
Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), ProjectileType<BitingEmbrace>(), damage, knockBack, player.whoAmI, 0, 15);
break;
case 1:
Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), ProjectileType<BitingEmbrace>(), damage, knockBack, player.whoAmI, 1, 20);
break;
case 2:
Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), ProjectileType<BitingEmbrace>(), damage, knockBack, player.whoAmI, 2, 50);
break;
}
Combo++;
if (Combo > 2)
Combo = 0;
return false;
case Attunement.Evil:
Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), ProjectileType<DecaysRetort>(), damage, knockBack, player.whoAmI, 26, (float) CanLunge);
CanLunge = 0;
return false;
default:
return base.Shoot(player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack);
}
}
internal static ChargingEnergyParticleSet BiomeEnergyParticles = new ChargingEnergyParticleSet(-1, 2, Color.DarkViolet, Color.White, 0.04f, 20f);
internal static void UpdateAllParticleSets()
{
BiomeEnergyParticles.Update();
}
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
{
Texture2D itemTexture = Main.itemTexture[item.type];
Rectangle itemFrame = (Main.itemAnimations[item.type] == null) ? itemTexture.Frame() : Main.itemAnimations[item.type].GetFrame(itemTexture);
if (mainAttunement == null)
return true;
// Draw all particles.
Vector2 particleDrawCenter = position + new Vector2(12f, 16f) * Main.inventoryScale;
switch (mainAttunement)
{
case Attunement.Default:
BiomeEnergyParticles.EdgeColor = new Color(117, 126, 72);
BiomeEnergyParticles.CenterColor = new Color(200, 184, 136);
break;
case Attunement.Hot:
BiomeEnergyParticles.EdgeColor = new Color(137, 32, 0);
BiomeEnergyParticles.CenterColor = new Color(209, 154, 0);
break;
case Attunement.Cold:
BiomeEnergyParticles.EdgeColor = new Color(165, 235, 235);
BiomeEnergyParticles.CenterColor = new Color(58, 110, 141);
break;
case Attunement.Tropical:
BiomeEnergyParticles.EdgeColor = new Color(53, 112, 4);
BiomeEnergyParticles.CenterColor = new Color(131, 173, 39);
break;
case Attunement.Evil:
BiomeEnergyParticles.EdgeColor = new Color(112, 4, 35);
BiomeEnergyParticles.CenterColor = new Color(195, 42, 200);
break;
}
BiomeEnergyParticles.InterpolationSpeed = 0.1f;
BiomeEnergyParticles.DrawSet(particleDrawCenter + Main.screenPosition);
Vector2 displacement = Vector2.UnitX.RotatedBy(Main.GlobalTime * 3f) * 2f * (float)Math.Sin(Main.GlobalTime);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive);
spriteBatch.Draw(itemTexture, position + displacement, itemFrame, BiomeEnergyParticles.CenterColor, 0f, origin, scale, SpriteEffects.None, 0f);
spriteBatch.Draw(itemTexture, position - displacement, itemFrame, BiomeEnergyParticles.CenterColor, 0f, origin, scale, SpriteEffects.None, 0f);
spriteBatch.End();
spriteBatch.Begin(default, default);
return true;
}
}
public class BrokenBiomeBladeVisuals : ModProjectile //Visuals
{
private Player Owner => Main.player[projectile.owner];
public bool OwnerOnGround => Main.tile[(int)Owner.Center.X / 16, (int)(Owner.position.Y + (float)Owner.height - 1f) / 16 + 1].IsTileSolidGround() && Main.tile[(int)Owner.Center.X / 16 + Owner.direction, (int)(Owner.position.Y + (float)Owner.height - 1f) / 16 + 1].IsTileSolidGround();
public bool OwnerCanUseItem => Owner.HeldItem == associatedItem ? (Owner.HeldItem.modItem as BiomeBlade).CanUseItem(Owner) : false;
public bool OwnerMayChannel => OwnerCanUseItem && Owner.Calamity().mouseRight && Owner.active && !Owner.dead && Owner.StandingStill() && !Owner.mount.Active && OwnerOnGround;
public ref float ChanneledState => ref projectile.ai[0];
public ref float ChannelTimer => ref projectile.ai[1];
public ref float Initialized => ref projectile.localAI[0];
private Item associatedItem;
const int ChannelTime = 120;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Broken Biome Blade");
}
public override string Texture => "CalamityMod/Items/Weapons/Melee/BiomeBlade";
public bool drawIndrawHeldProjInFrontOfHeldItemAndArms = true;
public override void SetDefaults()
{
projectile.width = projectile.height = 36;
projectile.aiStyle = -1;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.timeLeft = 60;
projectile.tileCollide = false;
projectile.damage = 0;
}
public CurveSegment anticipation = new CurveSegment(EasingType.SineOut, 0f, 1f, 0.35f);
public CurveSegment thrust = new CurveSegment(EasingType.ExpIn, 0.85f, 1.35f, -1.45f);
public CurveSegment bounceback = new CurveSegment(EasingType.SineOut, 0.95f, -0.1f, 0.1f);
internal float SwordHeight() => PiecewiseAnimation(ChannelTimer / (float)ChannelTime, new CurveSegment[] { anticipation, thrust, bounceback });
public override void AI()
{
if (Initialized == 0f)
{
//If dropped, kill it instantly
if (Owner.HeldItem.type != ItemType<BiomeBlade>())
{
projectile.Kill();
return;
}
if (Owner.whoAmI == Main.myPlayer)
Main.PlaySound(SoundID.DD2_DarkMageHealImpact);
associatedItem = Owner.HeldItem;
//Switch up the attunements
Attunement? temporaryAttunementStorage = (associatedItem.modItem as BiomeBlade).mainAttunement;
(associatedItem.modItem as BiomeBlade).mainAttunement = (associatedItem.modItem as BiomeBlade).secondaryAttunement;
(associatedItem.modItem as BiomeBlade).secondaryAttunement = temporaryAttunementStorage;
Initialized = 1f;
}
if (!OwnerMayChannel && ChanneledState == 0f) //IF the channeling gets interrupted for any reason
{
projectile.Center = Owner.Top + new Vector2(18f, 0f);
ChanneledState = 1f;
projectile.timeLeft = 60;
return;
}
if (ChanneledState == 0f)
{
Owner.heldProj = projectile.whoAmI;
projectile.Center = Owner.Center + new Vector2(16f * Owner.direction, -30 * SwordHeight() + 10f) ;
projectile.rotation = Utils.AngleLerp(-MathHelper.PiOver4, MathHelper.PiOver4 + MathHelper.PiOver2, MathHelper.Clamp(((ChannelTimer - 20f) / 50f), 0f, 1f));
ChannelTimer++;
projectile.timeLeft = 60;
if (ChannelTimer >= ChannelTime)
{
Attune((BiomeBlade)associatedItem.modItem);
projectile.timeLeft = 120;
ChanneledState = 2f; //State where it stays invisible doing nothing. Acts as a cooldown
Color particleColor = (associatedItem.modItem as BiomeBlade).GetAttunementInfo((associatedItem.modItem as BiomeBlade).mainAttunement).color;
for (int i = 0; i <= 5; i++)
{
Vector2 displace = Vector2.UnitX * 20 * Main.rand.NextFloat(-1f, 1f);
Particle Glow = new GenericBloom(Owner.Bottom + displace, -Vector2.UnitY * Main.rand.NextFloat(1f, 5f), particleColor, 0.02f + Main.rand.NextFloat(0f, 0.2f), 20 + Main.rand.Next(30));
GeneralParticleHandler.SpawnParticle(Glow);
}
for (int i = 0; i <= 10; i++)
{
Vector2 displace = Vector2.UnitX * 16 * Main.rand.NextFloat(-1f, 1f);
Particle Sparkle = new GenericSparkle(Owner.Bottom + displace, -Vector2.UnitY * Main.rand.NextFloat(1f, 5f), particleColor, particleColor, 0.5f + Main.rand.NextFloat(-0.2f, 0.2f), 20 + Main.rand.Next(30), 1, 2f);
GeneralParticleHandler.SpawnParticle(Sparkle);
}
}
}
if (ChanneledState == 1f)
projectile.position += Vector2.UnitY * -0.3f * (1f + projectile.timeLeft/60f);
}
public void Attune(BiomeBlade item)
{
bool jungle = Owner.ZoneJungle;
bool snow = Owner.ZoneSnow;
bool evil = Owner.ZoneCorrupt || Owner.ZoneCrimson;
bool desert = Owner.ZoneDesert;
bool hell = Owner.ZoneUnderworldHeight;
bool ocean = Owner.ZoneBeach;
Attunement attunement = Attunement.Default;
if (desert || hell)
{
attunement = Attunement.Hot;
}
if (snow)
{
attunement = Attunement.Cold;
}
if (jungle || ocean)
{
attunement = Attunement.Tropical;
}
if (evil)
{
attunement = Attunement.Evil;
}
//If the owner already had the attunement , break out of it (And unswap)
if (item.secondaryAttunement == attunement)
{
Main.PlaySound(SoundID.DD2_LightningBugZap, projectile.Center);
item.secondaryAttunement = item.mainAttunement;
item.mainAttunement = attunement;
return;
}
Main.PlaySound(SoundID.DD2_MonkStaffGroundImpact, projectile.Center);
item.mainAttunement = attunement;
//Lots of particles!!! yay!! visuals!!
}
public override void Kill(int timeLeft)
{
if (associatedItem == null)
{
return;
}
//If we swapped out the main attunement for the second one despite the second attunement being empty at the time, unswap them.
if ((associatedItem.modItem as BiomeBlade).mainAttunement == null && (associatedItem.modItem as BiomeBlade).secondaryAttunement != null)
{
(associatedItem.modItem as BiomeBlade).mainAttunement = (associatedItem.modItem as BiomeBlade).secondaryAttunement;
(associatedItem.modItem as BiomeBlade).secondaryAttunement = null;
}
//Cool particles
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
if (ChanneledState == 0f && ChannelTimer > 6f)
return base.PreDraw(spriteBatch, lightColor);
else if (ChanneledState == 1f)
{
Texture2D tex = GetTexture(Texture);
Vector2 squishyScale = new Vector2(Math.Abs((float)Math.Sin(MathHelper.Pi + MathHelper.TwoPi * projectile.timeLeft / 30f)), 1f);
SpriteEffects flip = (float)Math.Sin(MathHelper.Pi + MathHelper.TwoPi * projectile.timeLeft / 30f) > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
spriteBatch.Draw(tex, projectile.position - Main.screenPosition, null, lightColor * (projectile.timeLeft / 60f), 0, tex.Size() / 2, squishyScale * (2f - (projectile.timeLeft / 60f)), flip, 0);
return false;
}
else
return false;
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 688 B

After

Width:  |  Height:  |  Size: 975 B

+555 -206
View File
@@ -7,22 +7,211 @@ using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using CalamityMod.Items.Placeables;
using CalamityMod.Particles;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Terraria.ModLoader.IO;
using static CalamityMod.CalamityUtils;
using static CalamityMod.Items.Weapons.Melee.FourSeasonsGalaxia;
using static Terraria.ModLoader.ModContent;
namespace CalamityMod.Items.Weapons.Melee
{
public class FourSeasonsGalaxia : ModItem
{
public enum Attunement : byte { SuperPogo, Whirlwind, Shockwave, FlailBlade }
public Attunement? mainAttunement = null;
//Used for passive effects? Unless we make em different idk lol
public int UseTimer = 0;
public bool OnHitProc = false;
#region stats
public static int WhirlwindAttunement_BaseDamage = 800;
public static int WhirlwindAttunement_LocalIFrames = 20; //Remember its got one extra update
public static float WhirlwindAttunement_BoltDamageReduction = 0.5f;
public static float WhirlwindAttunement_BoltThrowDamageMultiplier = 1.5f;
public static float WhirlwindAttunement_BaseDamageReduction = 0.2f;
public static float WhirlwindAttunement_FullChargeDamageBoost = 2f;
public static int SuperPogoAttunement_BaseDamage = 1200;
public static int SuperPogoAttunement_ShredIFrames = 10;
public static int SuperPogoAttunement_LocalIFrames = 30; //Be warned its got one extra update so all the iframes should be divided in 2
public static int SuperPogoAttunement_LocalIFramesCharged = 16;
public static float SuperPogoAttunement_SlashDamageBoost = 5f; //Keep in mind the slice always crits
public static int SuperPogoAttunement_SlashBoltsDamage = 1300;
public static int SuperPogoAttunement_SlashIFrames = 60;
public static float SuperPogoAttunement_ShotDamageBoost = 2f; //The shots fired if the dash connects
public static int ShockwaveAttunement_BaseDamage = 3500;
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;
public static float ShockwaveAttunement_BoltsDamageReduction = 0.2f; //The shots fired as it charges
public static int FlailBladeAttunement_BaseDamage = 1420;
public static int FlailBladeAttunement_LocalIFrames = 10;
public static int FlailBladeAttunement_Reach = 600;
public static float FlailBladeAttunement_ChainDamageReduction = 0.5f;
public static float FlailBladeAttunement_OnHitBoltDamageReduction = 0.5f;
public static int CancerPassiveDamage = 3000;
public static int CancerPassiveLifeSteal = 3;
public static float CancerPassiveLifeStealProc = 0.4f;
public static int CapricornPassiveDebuffTime = 200;
#endregion
public override string Texture => "CalamityMod/Items/Weapons/Melee/GalaxiaExtra"; //Just in case the player SOMEHOW gets to swing galaxia itself. Sprite also used as the base for other attacks
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Galaxia");
Tooltip.SetDefault("Fires a spread of homing projectiles that inflict different debuffs depending on what biome you're in\n" +
"Upon hitting an enemy you are granted a buff based on what biome you're in\n" +
"Projectiles also change based on moon events");
Tooltip.SetDefault("FUNCTION_DESC\n" +
"FUNCTION_EXTRA\n" +
"FUNCTION_PASSIVE\n" +
"Upgrading the sword let it break free from its earthly boundaries. You now have access to every single attunement at all times!\n" +
"Use RMB to cycle the sword's attunement forward or backwards depending on the position of your cursor\n" +
"Active attunement : None\n" +
"Passive blessing: None\n"); ;
}
#region tooltip editing
public override void ModifyTooltips(List<TooltipLine> list)
{
Player player = Main.player[Main.myPlayer];
if (player is null)
return;
foreach (TooltipLine l in list)
{
if (l.text.StartsWith("FUNCTION_DESC"))
{
AttunementInfo info = GetAttunementInfo(mainAttunement);
l.overrideColor = info.color;
l.text = info.function_description;
}
if (l.text.StartsWith("FUNCTION_EXTRA"))
{
AttunementInfo info = GetAttunementInfo(mainAttunement);
l.overrideColor = info.color;
l.text = info.function_extra;
}
if (l.text.StartsWith("FUNCTION_PASSIVE"))
{
AttunementInfo info = GetAttunementInfo(mainAttunement);
l.overrideColor = info.passive_color;
l.text = info.passive_desc;
}
if (l.text.StartsWith("Active attunement"))
{
AttunementInfo info = GetAttunementInfo(mainAttunement);
l.overrideColor = Color.Lerp(info.color, info.color2, 0.5f + (float)Math.Sin(Main.GlobalTime) * 0.5f);
l.text = "Active Attumenent : [" + info.name + "]";
}
if (l.text.StartsWith("Passive blessing"))
{
AttunementInfo info = GetAttunementInfo(mainAttunement);
l.overrideColor = info.passive_color;
l.text = "Passive blessing : [" + info.passive_name + "]";
}
}
}
internal struct AttunementInfo
{
public string name;
public string function_description;
public string function_extra;
public string passive_name;
public string passive_desc;
public Color color;
public Color color2;
public Color passive_color;
}
internal AttunementInfo GetAttunementInfo(Attunement? attunement)
{
AttunementInfo AttunementInfo = new AttunementInfo();
switch (attunement)
{
case Attunement.Whirlwind:
AttunementInfo.name = "Phoenix's Pride";
AttunementInfo.function_description = "Hold LMB to swing Galaxia around you, powering up as it spins. Homing cosmic bolts get released around you as you spin";
AttunementInfo.function_extra = "Releasing LMB during a spin will throw the sword out alongside a blast of 6 stronger cosmic bolts";
AttunementInfo.color = new Color(255, 87, 0);
AttunementInfo.color2 = new Color(255, 143, 0);
break;
case Attunement.SuperPogo:
AttunementInfo.name = "Polaris's Gaze"; //It carries the mark of the Northern Star
AttunementInfo.function_description = "Channels the mark of the Northern Star into a short ranged shredding blade, surrounded by spinning stars. The blade powers up over time and when hitting enemies";
AttunementInfo.function_extra = "Releasing LMB sends the charged star flying. Using LMB right after it makes the player perform a dash towards the star, releasing cosmic bolts at the end of the lunge";
AttunementInfo.color = new Color(128, 189, 255);
AttunementInfo.color2 = new Color(255, 128, 140);
break;
case Attunement.Shockwave:
AttunementInfo.name = "Andromeda's Stride"; //EHEEHEHEHE GOD ERASING BECAUSE THE ANDROMEDA BOSS WAS SCRAPPED (ALSO KNOWN AS A "GOD" BEING "ERASED") EHEHEHE
AttunementInfo.function_description = "Hold LMB to charge up a god-erasing sword thrust, and release to unleash the devastating blow. Small cosmic bolts are released as you charge the sword";
AttunementInfo.function_extra = "Striking the ground with the charge will create an impact so powerful large homing cosmic energies will rise from the ground";
AttunementInfo.color = new Color(132, 128, 255);
AttunementInfo.color2 = new Color(194, 166, 255);
break;
case Attunement.FlailBlade:
AttunementInfo.name = "Aries's Wrath";
AttunementInfo.function_description = "Send out Galaxia flying, circling at your cursor's position, connected to you by constellations";
AttunementInfo.function_extra = "Enemy hits explode into extra homing cosmic bolts";
AttunementInfo.color = new Color(196, 89, 201);
AttunementInfo.color2 = new Color(255, 0, 0);
break;
default:
AttunementInfo.name = "None";
AttunementInfo.function_description = "";
AttunementInfo.function_extra = "";
AttunementInfo.color = new Color(163, 163, 163);
AttunementInfo.color2 = new Color(163, 163, 163);
break;
}
switch (attunement)
{
case Attunement.Whirlwind:
case Attunement.FlailBlade:
AttunementInfo.passive_name = "Capricorn's Blessing";
AttunementInfo.passive_desc = "Periodically releases a ring of weakening stars around your cursor when attacking\nThe ring is repelled away from you at first, before slowing down over time";
AttunementInfo.passive_color = new Color(76, 137, 237);
break;
case Attunement.SuperPogo:
case Attunement.Shockwave:
AttunementInfo.passive_name = "Cancer's Blessing";
AttunementInfo.passive_desc = "Periodically releases a ring of lifestealing stars around yourself when attacking\nThe ring is attracted towards you at first, before slowing down over time";
AttunementInfo.passive_color = new Color(203, 25, 119);
break;
default:
AttunementInfo.passive_name = "None";
AttunementInfo.passive_desc = "Based on your current attunement, you are granted a passive blessing";
AttunementInfo.passive_color = new Color(163, 163, 163);
break;
}
return AttunementInfo;
}
#endregion
public override void SetDefaults()
{
item.width = 70;
item.width = item.height = 108;
item.damage = 99;
item.melee = true;
item.useAnimation = 18;
@@ -32,234 +221,394 @@ namespace CalamityMod.Items.Weapons.Melee
item.knockBack = 9f;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.height = 70;
item.value = Item.buyPrice(1, 80, 0, 0);
item.rare = ItemRarityID.Red;
item.shoot = ModContent.ProjectileType<Galaxia>();
item.shoot = ProjectileID.PurificationPowder;
item.shootSpeed = 24f;
item.Calamity().customRarity = CalamityRarity.DarkBlue;
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
for (int projectiles = 0; projectiles < 3; projectiles++)
{
float SpeedX = speedX + Main.rand.Next(-40, 41) * 0.05f;
float SpeedY = speedY + Main.rand.Next(-40, 41) * 0.05f;
Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI);
}
return false;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<OmegaBiomeBlade>());
recipe.AddIngredient(ModContent.ItemType<CosmiliteBar>(), 8);
recipe.AddIngredient(ModContent.ItemType<DarksunFragment>(), 8);
recipe.AddTile(ModContent.TileType<CosmicAnvil>());
recipe.AddIngredient(ItemType<OmegaBiomeBlade>());
recipe.AddIngredient(ItemType<CosmiliteBar>(), 8);
recipe.AddIngredient(ItemType<DarksunFragment>(), 8);
recipe.AddTile(TileType<CosmicAnvil>());
recipe.SetResult(this);
recipe.AddRecipe();
}
public override void MeleeEffects(Player player, Rectangle hitbox)
#region saving and syncing attunements
public override bool CloneNewInstances => true;
public override ModItem Clone(Item item)
{
if (Main.rand.NextBool(5))
{
int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 0);
}
var clone = base.Clone(item);
if (Main.mouseItem.type == ItemType<FourSeasonsGalaxia>())
item.modItem.HoldItem(Main.player[Main.myPlayer]);
(clone as FourSeasonsGalaxia).mainAttunement = (item.modItem as FourSeasonsGalaxia).mainAttunement;
return clone;
}
public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
public override ModItem Clone() //ditto
{
CalamityPlayer modPlayer = player.Calamity();
bool astral = modPlayer.ZoneAstral;
bool jungle = player.ZoneJungle;
bool snow = player.ZoneSnow;
bool beach = player.ZoneBeach;
bool corrupt = player.ZoneCorrupt;
bool crimson = player.ZoneCrimson;
bool dungeon = player.ZoneDungeon;
bool desert = player.ZoneDesert;
bool glow = player.ZoneGlowshroom;
bool hell = player.ZoneUnderworldHeight;
bool holy = player.ZoneHoly;
bool nebula = player.ZoneTowerNebula;
bool stardust = player.ZoneTowerStardust;
bool solar = player.ZoneTowerSolar;
bool vortex = player.ZoneTowerVortex;
bool bloodMoon = Main.bloodMoon;
bool snowMoon = Main.snowMoon;
bool pumpkinMoon = Main.pumpkinMoon;
if (bloodMoon)
var clone = base.Clone();
(clone as FourSeasonsGalaxia).mainAttunement = mainAttunement;
return clone;
}
public override TagCompound Save()
{
int attunement1 = mainAttunement == null ? 1 : (int)mainAttunement;
TagCompound tag = new TagCompound
{
player.AddBuff(BuffID.Battle, 600);
}
if (snowMoon)
{ "mainAttunement", attunement1 }
};
return tag;
}
public override void Load(TagCompound tag)
{
int attunement1 = tag.GetInt("mainAttunement");
if (attunement1 == -1)
mainAttunement = Attunement.Whirlwind;
else
mainAttunement = (Attunement?)attunement1;
}
public override void NetSend(BinaryWriter writer)
{
writer.Write((byte)mainAttunement);
}
public override void NetRecieve(BinaryReader reader)
{
mainAttunement = (Attunement?)reader.ReadByte();
}
#endregion
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
if (mainAttunement == null)
return false;
return true;
}
public override void HoldItem(Player player)
{
player.Calamity().rightClickListener = true;
if (CanUseItem(player))
{
player.AddBuff(BuffID.RapidHealing, 600);
}
if (pumpkinMoon)
{
player.AddBuff(BuffID.WellFed, 600);
}
if (astral)
{
player.AddBuff(ModContent.BuffType<GravityNormalizerBuff>(), 600);
}
else if (jungle)
{
player.AddBuff(BuffID.Thorns, 600);
}
else if (snow)
{
player.AddBuff(BuffID.Warmth, 600);
}
else if (beach)
{
player.AddBuff(BuffID.Wet, 600);
}
else if (corrupt)
{
player.AddBuff(BuffID.Wrath, 600);
}
else if (crimson)
{
player.AddBuff(BuffID.Rage, 600);
}
else if (dungeon)
{
player.AddBuff(BuffID.Dangersense, 600);
}
else if (desert)
{
player.AddBuff(BuffID.Endurance, 600);
}
else if (glow)
{
player.AddBuff(BuffID.Spelunker, 600);
}
else if (hell)
{
player.AddBuff(BuffID.Inferno, 600);
}
else if (holy)
{
player.AddBuff(BuffID.Heartreach, 600);
}
else if (nebula)
{
player.AddBuff(BuffID.MagicPower, 600);
}
else if (stardust)
{
player.AddBuff(BuffID.Summoning, 600);
}
else if (solar)
{
player.AddBuff(BuffID.Titan, 600);
}
else if (vortex)
{
player.AddBuff(BuffID.AmmoReservation, 600);
player.Calamity().LungingDown = false;
}
else
{
player.AddBuff(BuffID.DryadsWard, 600);
UseTimer++;
}
//Change the swords function based on its attunement
switch (mainAttunement)
{
case Attunement.Whirlwind:
item.damage = WhirlwindAttunement_BaseDamage;
item.channel = true;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.HoldingOut;
item.shoot = ProjectileType<PhoenixsPride>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
break;
case Attunement.SuperPogo:
item.damage = SuperPogoAttunement_BaseDamage;
item.channel = true;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.HoldingOut;
item.shoot = ProjectileType<PolarissGaze>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
break;
case Attunement.Shockwave:
item.damage = ShockwaveAttunement_BaseDamage;
item.channel = true;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.HoldingOut;
item.shoot = ProjectileType<AndromedasStride>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
break;
case Attunement.FlailBlade:
item.damage = FlailBladeAttunement_BaseDamage;
item.channel = true;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.HoldingOut;
item.shoot = ProjectileType<AriessWrath>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
break;
default:
mainAttunement = Attunement.Whirlwind;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.SwingThrow;
item.shoot = ProjectileID.PurificationPowder;
item.shootSpeed = 12f;
item.UseSound = SoundID.Item1;
break;
}
//Passive effects only jappen player side haha
if (player.whoAmI != Main.myPlayer)
return;
switch (mainAttunement)
{
case Attunement.SuperPogo:
case Attunement.Shockwave:
if (UseTimer % 500 == 449)
{
Main.PlaySound(SoundID.Item78);
Projectile.NewProjectile(player.Center, Vector2.Zero, ProjectileType<GalaxiaTropicRing>(), CancerPassiveDamage, 0f, player.whoAmI, 0f);
UseTimer++;
}
break;
case Attunement.FlailBlade:
case Attunement.Whirlwind:
if (UseTimer % 500 == 449)
{
Main.PlaySound(SoundID.Item78);
Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, ProjectileType<GalaxiaTropicRing>(), 0, 0f, player.whoAmI, 1f);
UseTimer++;
}
break;
default:
break;
}
if (player.Calamity().mouseRight && CanUseItem(player) && player.whoAmI == Main.myPlayer && !Main.mapFullscreen)
{
//Don't shoot out a visual blade if you already have one out
if (Main.projectile.Any(n => n.active && n.type == ProjectileType<GalaxiaVisuals>() && n.owner == player.whoAmI))
return;
Projectile.NewProjectile(player.Top, Vector2.Zero, ProjectileType<GalaxiaVisuals>(), 0, 0, player.whoAmI, 0, Math.Sign(player.position.X - Main.MouseWorld.X));
}
}
public override void OnHitPvp(Player player, Player target, int damage, bool crit)
public override bool CanUseItem(Player player)
{
bool jungle = player.ZoneJungle;
bool snow = player.ZoneSnow;
bool beach = player.ZoneBeach;
bool corrupt = player.ZoneCorrupt;
bool crimson = player.ZoneCrimson;
bool dungeon = player.ZoneDungeon;
bool desert = player.ZoneDesert;
bool glow = player.ZoneGlowshroom;
bool hell = player.ZoneUnderworldHeight;
bool holy = player.ZoneHoly;
bool nebula = player.ZoneTowerNebula;
bool stardust = player.ZoneTowerStardust;
bool solar = player.ZoneTowerSolar;
bool vortex = player.ZoneTowerVortex;
bool bloodMoon = Main.bloodMoon;
bool snowMoon = Main.snowMoon;
bool pumpkinMoon = Main.pumpkinMoon;
if (bloodMoon)
{
player.AddBuff(BuffID.Battle, 600);
}
if (snowMoon)
{
player.AddBuff(BuffID.RapidHealing, 600);
}
if (pumpkinMoon)
{
player.AddBuff(BuffID.WellFed, 600);
}
if (jungle)
{
player.AddBuff(BuffID.Thorns, 600);
}
else if (snow)
{
player.AddBuff(BuffID.Warmth, 600);
}
else if (beach)
{
player.AddBuff(BuffID.Wet, 600);
}
else if (corrupt)
{
player.AddBuff(BuffID.Wrath, 600);
}
else if (crimson)
{
player.AddBuff(BuffID.Rage, 600);
}
else if (dungeon)
{
player.AddBuff(BuffID.Dangersense, 600);
}
else if (desert)
{
player.AddBuff(BuffID.Endurance, 600);
}
else if (glow)
{
player.AddBuff(BuffID.Spelunker, 600);
}
else if (hell)
{
player.AddBuff(BuffID.Inferno, 600);
}
else if (holy)
{
player.AddBuff(BuffID.Heartreach, 600);
}
else if (nebula)
{
player.AddBuff(BuffID.MagicPower, 600);
}
else if (stardust)
{
player.AddBuff(BuffID.Summoning, 600);
}
else if (solar)
{
player.AddBuff(BuffID.Titan, 600);
}
else if (vortex)
{
player.AddBuff(BuffID.AmmoReservation, 600);
}
else
{
player.AddBuff(BuffID.DryadsWard, 600);
}
return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI &&
(n.type == ProjectileType<PhoenixsPride>() ||
n.type == ProjectileType<AndromedasStride>() ||
n.type == ProjectileType<PolarissGaze>() ||
n.type == ProjectileType<AriessWrath>()
));
}
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
{
if (mainAttunement == null)
mainAttunement = Attunement.Whirlwind;
Texture2D itemTexture = GetTexture((mainAttunement == Attunement.SuperPogo || mainAttunement == Attunement.Shockwave) ? "CalamityMod/Items/Weapons/Melee/GalaxiaRed" : "CalamityMod/Items/Weapons/Melee/GalaxiaBlue");
spriteBatch.Draw(itemTexture, position, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f);
return false;
}
public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
{
Texture2D itemTexture = GetTexture((mainAttunement == Attunement.SuperPogo || mainAttunement == Attunement.Shockwave) ? "CalamityMod/Items/Weapons/Melee/GalaxiaRed" : "CalamityMod/Items/Weapons/Melee/GalaxiaBlue");
spriteBatch.Draw(itemTexture, item.Center - Main.screenPosition, null, lightColor, rotation, item.Size * 0.5f, scale, SpriteEffects.None, 0f);
return false;
}
}
public class GalaxiaVisuals : ModProjectile //Visuals. Now much simpler than before!
{
private Player Owner => Main.player[projectile.owner];
public bool OwnerCanUseItem => Owner.HeldItem == associatedItem ? (Owner.HeldItem.modItem as FourSeasonsGalaxia).CanUseItem(Owner) : false;
public ref float Initialized => ref projectile.ai[0];
public ref float CycleDirection => ref projectile.ai[1];
private Item associatedItem;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Galactic Formation");
}
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetDefaults()
{
projectile.width = projectile.height = 2;
projectile.aiStyle = -1;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.timeLeft = 40;
projectile.tileCollide = false;
projectile.damage = 0;
}
public override void AI()
{
if (Initialized == 0f)
{
//If dropped, kill it instantly
if (Owner.HeldItem.type != ItemType<FourSeasonsGalaxia>())
{
projectile.Kill();
return;
}
projectile.Center = Owner.Center;
associatedItem = Owner.HeldItem;
//Switch up the attunements
Reattune((FourSeasonsGalaxia)associatedItem.modItem);
//Do particles around the player
Color particleColor = (associatedItem.modItem as FourSeasonsGalaxia).GetAttunementInfo((associatedItem.modItem as FourSeasonsGalaxia).mainAttunement).color;
for (int i = 0; i <= 5; i++)
{
Vector2 displace = Vector2.UnitX * 20 * Main.rand.NextFloat(-1f, 1f);
Particle Glow = new GenericBloom(Owner.Bottom + displace, -Vector2.UnitY * Main.rand.NextFloat(1f, 5f), particleColor, 0.02f + Main.rand.NextFloat(0f, 0.2f), 20 + Main.rand.Next(30));
GeneralParticleHandler.SpawnParticle(Glow);
}
for (int i = 0; i <= 10; i++)
{
Vector2 displace = Vector2.UnitX * 16 * Main.rand.NextFloat(-1f, 1f);
Particle Sparkle = new GenericSparkle(Owner.Bottom + displace, -Vector2.UnitY * Main.rand.NextFloat(1f, 5f), particleColor, particleColor, 0.5f + Main.rand.NextFloat(-0.2f, 0.2f), 20 + Main.rand.Next(30), 1, 2f);
GeneralParticleHandler.SpawnParticle(Sparkle);
}
Initialized = 1f;
}
}
public void Reattune(FourSeasonsGalaxia item)
{
Attunement attunement;
Vector2[] StarPositions;
Vector2[] ExtraLines; //Extra lines vector give us an indication of the index between the 2 stars we need to connect
List<int> IgnoredLines = new List<int>();
Particle Star;
Particle Line;
Color StarColor;
if (CycleDirection == -1) //Cycles goes Whirlwind => Flailblade => Superpogo => Shockwave
{
switch (item.mainAttunement)
{
case Attunement.Whirlwind: //Switching to the flailblade attunement.
attunement = Attunement.FlailBlade;
break;
case Attunement.FlailBlade: //Switching to the superpogo attunement.
attunement = Attunement.SuperPogo;
break;
case Attunement.SuperPogo: //Switching to the shockwave attunement.
attunement = Attunement.Shockwave;
break;
case Attunement.Shockwave: //Switching to the whirlwind attunement.
default:
attunement = Attunement.Whirlwind;
break;
}
}
else //Cycles goes Whirlwind <= Flailblade <= Superpogo <= Shockwave
{
switch (item.mainAttunement)
{
case Attunement.Whirlwind: //Switching to the shockwave attunement.
attunement = Attunement.Shockwave;
break;
case Attunement.Shockwave: //Switching to the superpogo attunement.
attunement = Attunement.SuperPogo;
break;
case Attunement.SuperPogo: //Switching to the flailblade attunement.
attunement = Attunement.FlailBlade;
break;
case Attunement.FlailBlade: //Switching to the whirlwind attunement.
default:
attunement = Attunement.Whirlwind;
break;
}
}
switch (attunement)
{
case Attunement.FlailBlade: // Drawing Aries
StarPositions = new Vector2[] { new Vector2(-160, -150), new Vector2(45, -170), new Vector2(137, 40), new Vector2(146, 126), new Vector2(129, 151) };
ExtraLines = new Vector2[] { };
StarColor = Color.Orchid;
break;
case Attunement.SuperPogo: //Drawing Ursa Minor
StarPositions = new Vector2[] { new Vector2(69, -188), new Vector2(18, -122), new Vector2(-23, -39), new Vector2(-13, 63), new Vector2(42, 147), new Vector2(-8, 184), new Vector2(-61, 83) };
ExtraLines = new Vector2[] { new Vector2(3, 6) };
StarColor = Color.CornflowerBlue;
break;
case Attunement.Shockwave: //Drawing Andromeda
//https://media.discordapp.net/attachments/802291445360623686/934200685254291546/unknown.png
StarPositions = new Vector2[] {
new Vector2(-210, -46), new Vector2(-150, -35), new Vector2(-69, 18), new Vector2(33, 61), new Vector2(127, 72), //The horizontal line
new Vector2(-41, -27), new Vector2(-41, -67), new Vector2(-100, -124), new Vector2(-160, -130), //The first branch from the left
new Vector2(15, 147), new Vector2(35, 126), new Vector2(37, 23), new Vector2(67, -47), new Vector2(126, -109), new Vector2(146, -136), //The second branch from the left
new Vector2(95, -117)
};
ExtraLines = new Vector2[] { new Vector2(2, 5) , new Vector2(13, 15) };
IgnoredLines.Add(5);
IgnoredLines.Add(9);
IgnoredLines.Add(15);
StarColor = Color.MediumSlateBlue;
break;
case Attunement.Whirlwind: //Drawing Phoenix
default:
StarPositions = new Vector2[] { new Vector2(-206, -99), new Vector2(-150, -43), new Vector2(-120, -146), new Vector2(-60, -71), new Vector2(-106, 71), new Vector2(-59, 138), new Vector2(116, -22),//The main line
new Vector2(246, -26), new Vector2(192, 36), new Vector2(138, 81), //The side bit
new Vector2(88, -107), new Vector2(84, -75) }; //Complete the loop
ExtraLines = new Vector2[] { new Vector2(3, 10), new Vector2(11, 6) };
IgnoredLines.Add(10);
StarColor = Color.OrangeRed;
break;
}
//Only draw the cool effect if you have enough particle slots left. Itd look really ugly to have a half complete constellation
if (GeneralParticleHandler.FreeSpacesAvailable() > StarPositions.Length * 2)
{
for (int i = 0; i < StarPositions.Length; i++)
{
//The polar star gets bigger than the others. Also since andromeda has so many stars, make em smaller
Star = new GenericSparkle(Owner.Center + StarPositions[i], Vector2.Zero, Color.White, StarColor, (attunement == Attunement.SuperPogo && i == 0) ? 3f : Main.rand.NextFloat(1f, 1.5f) * (attunement == Attunement.Shockwave ? 0.8f : 1f), 20, 0f, 3f);
GeneralParticleHandler.SpawnParticle(Star);
if (i > 0 && !IgnoredLines.Contains(i))
{
Line = new BloomLineVFX(Owner.Center + StarPositions[i - 1], StarPositions[i] - StarPositions[i - 1], 0.5f, StarColor, 20, true);
GeneralParticleHandler.SpawnParticle(Line);
}
}
for (int i = 0; i < ExtraLines.Length; i++)
{
Line = new BloomLineVFX(Owner.Center + StarPositions[(int)ExtraLines[i].Y], StarPositions[(int)ExtraLines[i].X] - StarPositions[(int)ExtraLines[i].Y], 0.5f, StarColor, 20, true);
GeneralParticleHandler.SpawnParticle(Line);
}
}
//Chunger
Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThunderStrike"), projectile.Center);
if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 5)
Main.LocalPlayer.Calamity().GeneralScreenShakePower = 5;
item.mainAttunement = attunement;
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

+658 -25
View File
@@ -1,26 +1,217 @@
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables;
using CalamityMod.Particles;
using CalamityMod.Projectiles.Melee;
using CalamityMod.Items.Placeables.Ores;
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 Terraria.ModLoader.IO;
using static CalamityMod.CalamityUtils;
using static CalamityMod.Items.Weapons.Melee.OmegaBiomeBlade;
using static Terraria.ModLoader.ModContent;
namespace CalamityMod.Items.Weapons.Melee
{
public class OmegaBiomeBlade : ModItem
{
public enum Attunement : byte { SuperPogo, Whirlwind, Shockwave, FlailBlade }
public Attunement? mainAttunement = null;
public Attunement? secondaryAttunement = null;
public Projectile MeatHook;
//Used for passive effects
public int UseTimer = 0;
public bool OnHitProc = false;
#region stats
public static int WhirlwindAttunement_BaseDamage = 400;
public static int WhirlwindAttunement_LocalIFrames = 20; //Remember its got one extra update
public static int WhirlwindAttunement_SigilTime = 1200;
public static float WhirlwindAttunement_BeamDamageReduction = 0.5f;
public static float WhirlwindAttunement_BaseDamageReduction = 0.2f;
public static float WhirlwindAttunement_FullChargeDamageBoost = 2f;
public static int WhirlwindAttunement_PassiveBaseDamage = 200;
public static int SuperPogoAttunement_BaseDamage = 500;
public static int SuperPogoAttunement_ShredIFrames = 10;
public static int SuperPogoAttunement_LocalIFrames = 30; //Be warned its got one extra update so all the iframes should be divided in 2
public static int SuperPogoAttunement_LocalIFramesCharged = 16;
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;
public static float ShockwaveAttunement_BlastDamageReduction = 0.6f;
public static int ShockwaveAttunement_PassiveBaseDamage = 200;
public static int FlailBladeAttunement_BaseDamage = 320;
public static int FlailBladeAttunement_LocalIFrames = 30;
public static int FlailBladeAttunement_FlailTime = 10;
public static int FlailBladeAttunement_Reach = 400;
public static float FlailBladeAttunement_ChainDamageReduction = 0.5f;
public static float FlailBladeAttunement_GhostChainDamageReduction = 0.5f;
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.24f;
public static float WhirlwindAttunement_SwordThrowProc = 1f;
public static float WhirlwindAttunement_SwordBeamProc = 0.05f;
public static float SuperPogoAttunement_ShredderProc = 0.1f;
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 float FlailBladeAttunement_BladeProc = 0.1f;
public static float FlailBladeAttunement_ChainProc = 0.05f;
public static float FlailBladeAttunement_GhostChainProc = 0.1f;
#endregion
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Omega Biome Blade");
Tooltip.SetDefault("Fires different homing projectiles based on what biome you're in\n" +
"Projectiles also change based on moon events");
DisplayName.SetDefault("True Biome Blade");
Tooltip.SetDefault("FUNCTION_DESC\n" +
"FUNCTION_EXTRA\n" +
"FUNCTION_PASSIVE\n" +
"Holding down RMB for 2 seconds attunes the weapon to the powers of the surrounding biome\n" +
"Using RMB for a shorter period of time switches your active and passive attunements around\n" +
"Active attunement : None\n" +
"Passive attunement: None\n");
}
#region tooltip editing
public override void ModifyTooltips(List<TooltipLine> list)
{
Player player = Main.player[Main.myPlayer];
if (player is null)
return;
foreach (TooltipLine l in list)
{
if (l.text.StartsWith("FUNCTION_DESC"))
{
AttunementInfo info = GetAttunementInfo(mainAttunement);
l.overrideColor = info.color;
l.text = info.function_description;
}
if (l.text.StartsWith("FUNCTION_EXTRA"))
{
AttunementInfo info = GetAttunementInfo(mainAttunement);
l.overrideColor = info.color;
l.text = info.function_extra;
}
if (l.text.StartsWith("FUNCTION_PASSIVE"))
{
AttunementInfo info = GetAttunementInfo(secondaryAttunement);
l.overrideColor = info.color;
l.text = info.function_passive;
}
if (l.text.StartsWith("Active attunement"))
{
AttunementInfo info = GetAttunementInfo(mainAttunement);
l.overrideColor = Color.Lerp(info.color, info.color2, 0.5f + (float)Math.Sin(Main.GlobalTime) * 0.5f);
l.text = "Active Attumenent : [" + info.name + "]";
}
if (l.text.StartsWith("Passive attunement"))
{
AttunementInfo info = GetAttunementInfo(secondaryAttunement);
l.overrideColor = Color.Lerp(Color.Lerp(info.color, info.color2, 0.5f + (float)Math.Sin(Main.GlobalTime) * 0.5f), Color.Gray, 0.5f);
l.text = "Passive Attumenent : [" + info.name + "]";
}
}
}
internal struct AttunementInfo
{
public string name;
public string function_description;
public string function_extra;
public string function_passive;
public Color color;
public Color color2;
}
internal AttunementInfo GetAttunementInfo(Attunement? attunement)
{
AttunementInfo AttunementInfo = new AttunementInfo();
switch (attunement)
{
case Attunement.Whirlwind:
AttunementInfo.name = "Swordsmith's Pride";
AttunementInfo.function_description = "Hold LMB to swing the sword around you, powering up as it spins. Extra ghostly swords are summoned during the spin";
AttunementInfo.function_extra = "Releasing LMB during a spin will throw the sword out. Ghostly swords will home onto enemies hit by the sword throw";
AttunementInfo.function_passive = "While attacking, extra ghost swords have a chance to be shot out";
AttunementInfo.color = new Color(220, 105, 197);
AttunementInfo.color2 = new Color(171, 239, 113);
break;
case Attunement.SuperPogo:
AttunementInfo.name = "Sanguine Fury";
AttunementInfo.function_description = "Conjures molten blades in front of you that get larger and stronger the more you hit enemies. The blades can also be used to bounce off tiles when in the air";
AttunementInfo.function_extra = "Releasing LMB sends the charged blades flying in a wheel. Using LMB right after the throw makes the player perform dash towards the blade wheel, shredding anything inbetween";
AttunementInfo.function_passive = "Successful strikes rarely grant lifesteal";
AttunementInfo.color = new Color(216, 55, 22);
AttunementInfo.color2 = new Color(216, 131, 22);
break;
case Attunement.Shockwave:
AttunementInfo.name = "Mercurial Tides";
AttunementInfo.function_description = "Hold LMB to charge up a heaven-shattering sword thrust, and release to unleash the devastating blow. Small shockwaves are released as you charge the sword";
AttunementInfo.function_extra = "Striking the ground after a jump will create an impact so powerful a shockwave of ancient monoliths will rise up and propagate through the ground";
AttunementInfo.function_passive = "While attacking, release small shockwaves around you";
AttunementInfo.color = new Color(132, 109, 233);
AttunementInfo.color2 = new Color(122, 213, 233);
break;
case Attunement.FlailBlade:
AttunementInfo.name = "Lamentations of the Chained";
AttunementInfo.function_description = "Throw out a flurry of chained blades in front of you. Striking enemies with the tip of the blades guarantees a critical hit.";
AttunementInfo.function_extra = "Critical strikes create extra ghostly chains to latch onto extra targets";
AttunementInfo.function_passive = "Gain a magical chain hook. On enemy hits the hook quickly spins around you, freezing any struck foe"; //No way sentient meat hook
AttunementInfo.color = new Color(113, 239, 177);
AttunementInfo.color2 = new Color(169, 207, 255);
break;
default:
AttunementInfo.name = "None";
AttunementInfo.function_description = "Does nothing... yet";
AttunementInfo.function_extra = "It seems upgrading the blade expanded the scope of the previous attunements";
AttunementInfo.function_passive = "Your secondary attunement can now provide passive bonuses";
AttunementInfo.color = new Color(163, 163, 163);
AttunementInfo.color2 = new Color(163, 163, 163);
break;
}
return AttunementInfo;
}
#endregion
public override void SetDefaults()
{
item.width = 62;
item.width = item.height = 92;
item.damage = 130;
item.melee = true;
item.useAnimation = 18;
@@ -30,43 +221,485 @@ namespace CalamityMod.Items.Weapons.Melee
item.knockBack = 8;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.height = 62;
item.value = CalamityGlobalItem.Rarity11BuyPrice;
item.rare = ItemRarityID.Purple;
item.shoot = ModContent.ProjectileType<OmegaBiomeOrb>();
item.shoot = ProjectileID.PurificationPowder;
item.shootSpeed = 15f;
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
for (int projectiles = 0; projectiles < 3; projectiles++)
{
float SpeedX = speedX + Main.rand.Next(-40, 41) * 0.05f;
float SpeedY = speedY + Main.rand.Next(-40, 41) * 0.05f;
Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI);
}
return false;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<TrueBiomeBlade>());
recipe.AddIngredient(ModContent.ItemType<CoreofCalamity>());
recipe.AddIngredient(ModContent.ItemType<AstralBar>(), 3);
recipe.AddIngredient(ModContent.ItemType<BarofLife>(), 3);
recipe.AddIngredient(ModContent.ItemType<ExodiumClusterOre>(), 5);
recipe.AddIngredient(ItemType<TrueBiomeBlade>());
recipe.AddIngredient(ItemType<CoreofCalamity>());
recipe.AddIngredient(ItemType<AstralBar>(), 3);
recipe.AddIngredient(ItemType<BarofLife>(), 3);
recipe.AddIngredient(ItemType<ExodiumClusterOre>(), 5);
recipe.AddTile(TileID.LunarCraftingStation);
recipe.SetResult(this);
recipe.AddRecipe();
}
public override void MeleeEffects(Player player, Rectangle hitbox)
#region Saving and syncing attunements
public override bool CloneNewInstances => true;
public override ModItem Clone(Item item)
{
if (Main.rand.NextBool(5))
var clone = base.Clone(item);
if (Main.mouseItem.type == ItemType<OmegaBiomeBlade>())
item.modItem.HoldItem(Main.player[Main.myPlayer]);
(clone as OmegaBiomeBlade).mainAttunement = (item.modItem as OmegaBiomeBlade).mainAttunement;
(clone as OmegaBiomeBlade).secondaryAttunement = (item.modItem as OmegaBiomeBlade).secondaryAttunement;
return clone;
}
public override ModItem Clone() //ditto
{
var clone = base.Clone();
(clone as OmegaBiomeBlade).mainAttunement = mainAttunement;
(clone as OmegaBiomeBlade).secondaryAttunement = secondaryAttunement;
return clone;
}
public override TagCompound Save()
{
int attunement1 = mainAttunement == null ? -1 : (int)mainAttunement;
int attunement2 = secondaryAttunement == null ? -1 : (int)secondaryAttunement;
TagCompound tag = new TagCompound
{
int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 0);
{ "mainAttunement", attunement1 },
{ "secondaryAttunement", attunement2 }
};
return tag;
}
public override void Load(TagCompound tag)
{
int attunement1 = tag.GetInt("mainAttunement");
int attunement2 = tag.GetInt("secondaryAttunement");
if (attunement1 == -1)
mainAttunement = null;
else
mainAttunement = (Attunement?)attunement1;
if (attunement2 == -1 || (attunement1 == attunement2))
secondaryAttunement = null;
else
secondaryAttunement = (Attunement?)attunement2;
}
public override void NetSend(BinaryWriter writer)
{
writer.Write((byte)mainAttunement);
writer.Write((byte)secondaryAttunement);
}
public override void NetRecieve(BinaryReader reader)
{
mainAttunement = (Attunement?)reader.ReadByte();
secondaryAttunement = (Attunement?)reader.ReadByte();
}
#endregion
public override void HoldItem(Player player)
{
player.Calamity().rightClickListener = true;
//Reset the strong lunge thing just in case it didnt get caught beofre.
if (CanUseItem(player))
{
player.Calamity().LungingDown = false;
}
else
{
UseTimer++;
}
//Change the swords function based on its attunement
switch (mainAttunement)
{
case Attunement.Whirlwind:
item.damage = WhirlwindAttunement_BaseDamage;
item.channel = true;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.HoldingOut;
item.shoot = ProjectileType<SwordsmithsPride>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
break;
case Attunement.SuperPogo:
item.damage = SuperPogoAttunement_BaseDamage;
item.channel = true;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.HoldingOut;
item.shoot = ProjectileType<SanguineFury>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
break;
case Attunement.Shockwave:
item.damage = ShockwaveAttunement_BaseDamage;
item.channel = true;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.HoldingOut;
item.shoot = ProjectileType<MercurialTides>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
break;
case Attunement.FlailBlade:
item.damage = FlailBladeAttunement_BaseDamage;
item.channel = true;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.HoldingOut;
item.shoot = ProjectileType<LamentationsOfTheChained>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
break;
default:
item.noUseGraphic = false;
item.useStyle = ItemUseStyleID.SwingThrow;
item.shoot = ProjectileID.PurificationPowder;
item.shootSpeed = 12f;
item.UseSound = SoundID.Item1;
break;
}
if (player.whoAmI != Main.myPlayer)
return;
//PAssive effetcsts only happen on the side of the owner
if (secondaryAttunement != Attunement.FlailBlade || MeatHook == null || !MeatHook.active)
MeatHook = null;
switch (secondaryAttunement)
{
case Attunement.Whirlwind:
if (UseTimer % 30 == 29 && Main.rand.Next(2) == 0)
{
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:
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;
}
if (player.Calamity().mouseRight && CanUseItem(player) && player.whoAmI == Main.myPlayer && !Main.mapFullscreen)
{
//Don't shoot out a visual blade if you already have one out
if (Main.projectile.Any(n => n.active && n.type == ProjectileType<TrueBiomeBladeVisuals>() && n.owner == player.whoAmI))
return;
Projectile.NewProjectile(player.Top, Vector2.Zero, ProjectileType<TrueBiomeBladeVisuals>(), 0, 0, player.whoAmI);
}
}
public override bool CanUseItem(Player player)
{
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>()
));
}
//No need for any wacky zany hijinx in the shoot method for once??? damn
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) => mainAttunement == null ? false : true;
internal static ChargingEnergyParticleSet BiomeEnergyParticles = new ChargingEnergyParticleSet(-1, 2, Color.White, Color.White, 0.04f, 20f);
internal static void UpdateAllParticleSets()
{
BiomeEnergyParticles.Update();
}
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
{
if (mainAttunement == null)
return true;
position.Y -= 6f * scale;
Texture2D itemTexture = GetTexture("CalamityMod/Items/Weapons/Melee/OmegaBiomeBladeExtra");
Rectangle itemFrame = (Main.itemAnimations[item.type] == null) ? itemTexture.Frame() : Main.itemAnimations[item.type].GetFrame(itemTexture);
// Draw all particles.
Vector2 particleDrawCenter = position + new Vector2(12f, 16f) * Main.inventoryScale;
AttunementInfo info = GetAttunementInfo(mainAttunement);
BiomeEnergyParticles.EdgeColor = info.color2;
BiomeEnergyParticles.CenterColor = info.color;
BiomeEnergyParticles.InterpolationSpeed = 0.1f;
BiomeEnergyParticles.DrawSet(particleDrawCenter + Main.screenPosition);
Vector2 displacement = Vector2.UnitX.RotatedBy(Main.GlobalTime * 3f) * 2f * (float)Math.Sin(Main.GlobalTime);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive);
spriteBatch.Draw(itemTexture, position + displacement, itemFrame, BiomeEnergyParticles.CenterColor, 0f, origin, scale, SpriteEffects.None, 0f);
spriteBatch.Draw(itemTexture, position - displacement, itemFrame, BiomeEnergyParticles.CenterColor, 0f, origin, scale, SpriteEffects.None, 0f);
spriteBatch.End();
spriteBatch.Begin(default, default);
spriteBatch.Draw(itemTexture, position, itemFrame, Color.White, 0f, origin, scale, SpriteEffects.None, 0f);
return false;
}
public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
{
if (mainAttunement == null)
return true;
//Draw the charged version if you can
Texture2D itemTexture = GetTexture("CalamityMod/Items/Weapons/Melee/OmegaBiomeBladeExtra");
spriteBatch.Draw(itemTexture, item.Center - Main.screenPosition, null, lightColor, rotation, item.Size * 0.5f, scale, SpriteEffects.None, 0f);
return false;
}
}
public class TrueBiomeBladeVisuals : ModProjectile //Visuals
{
private Player Owner => Main.player[projectile.owner];
public bool OwnerCanUseItem => Owner.HeldItem == associatedItem ? (Owner.HeldItem.modItem as OmegaBiomeBlade).CanUseItem(Owner) : false;
public bool OwnerMayChannel => OwnerCanUseItem && Owner.Calamity().mouseRight && Owner.active && !Owner.dead;
public ref float ChanneledState => ref projectile.ai[0];
public ref float ChannelTimer => ref projectile.ai[1];
public ref float Initialized => ref projectile.localAI[0];
private Item associatedItem;
const int ChannelTime = 120;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("True Biome Blade");
}
public override string Texture => "CalamityMod/Items/Weapons/Melee/OmegaBiomeBlade";
public bool drawIndrawHeldProjInFrontOfHeldItemAndArms = true;
public override void SetDefaults()
{
projectile.width = projectile.height = 36;
projectile.aiStyle = -1;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.timeLeft = 60;
projectile.tileCollide = false;
projectile.damage = 0;
}
public CurveSegment anticipation = new CurveSegment(EasingType.SineBump, 0f, 0f, -0.3f);
public CurveSegment rise = new CurveSegment(EasingType.ExpIn, 0f, 0f, 1f);
public CurveSegment overshoot = new CurveSegment(EasingType.SineBump, 0.80f, 1f, 0.1f);
internal float SwordHeight() => PiecewiseAnimation(ChannelTimer / (float)ChannelTime, new CurveSegment[] {rise, overshoot });
public override void AI()
{
if (Initialized == 0f)
{
//If dropped, kill it instantly
if (Owner.HeldItem.type != ItemType<OmegaBiomeBlade>())
{
projectile.Kill();
return;
}
if (Owner.whoAmI == Main.myPlayer)
Main.PlaySound(SoundID.DD2_DarkMageHealImpact);
associatedItem = Owner.HeldItem;
//Switch up the attunements
Attunement? temporaryAttunementStorage = (associatedItem.modItem as OmegaBiomeBlade).mainAttunement;
(associatedItem.modItem as OmegaBiomeBlade).mainAttunement = (associatedItem.modItem as OmegaBiomeBlade).secondaryAttunement;
(associatedItem.modItem as OmegaBiomeBlade).secondaryAttunement = temporaryAttunementStorage;
Initialized = 1f;
}
if (!OwnerMayChannel && ChanneledState == 0f) //IF the channeling gets interrupted for any reason
{
projectile.Center = Owner.Top + new Vector2(18f, 0f);
ChanneledState = 1f;
projectile.timeLeft = 60;
return;
}
if (ChanneledState == 0f)
{
Owner.heldProj = projectile.whoAmI;
Owner.itemRotation = (-Vector2.UnitY).ToRotation();
projectile.Center = Owner.Top + new Vector2(0f, -20f * SwordHeight() - 50f);
projectile.rotation = -MathHelper.PiOver4; // No more silly turnaround with the repaired one?
ChannelTimer++;
projectile.timeLeft = 60;
if (ChannelTimer == ChannelTime - 15)
{
Attune((OmegaBiomeBlade)associatedItem.modItem);
Color particleColor = (associatedItem.modItem as OmegaBiomeBlade).GetAttunementInfo((associatedItem.modItem as OmegaBiomeBlade).mainAttunement).color;
for (int i = 0; i <= 5; i++)
{
Vector2 displace = Vector2.UnitX * 20 * Main.rand.NextFloat(-1f, 1f);
Particle Glow = new GenericBloom(Owner.Bottom + displace, -Vector2.UnitY * Main.rand.NextFloat(1f, 5f), particleColor, 0.02f + Main.rand.NextFloat(0f, 0.2f), 20 + Main.rand.Next(30));
GeneralParticleHandler.SpawnParticle(Glow);
}
for (int i = 0; i <= 10; i++)
{
Vector2 displace = Vector2.UnitX * 16 * Main.rand.NextFloat(-1f, 1f);
Particle Sparkle = new GenericSparkle(Owner.Bottom + displace, -Vector2.UnitY * Main.rand.NextFloat(1f, 5f), particleColor, particleColor, 0.5f + Main.rand.NextFloat(-0.2f, 0.2f), 20 + Main.rand.Next(30), 1, 2f);
GeneralParticleHandler.SpawnParticle(Sparkle);
}
}
if (ChannelTimer >= ChannelTime - 15)
{
Vector2 Shake = Main.rand.NextVector2Circular(6f, 6f);
projectile.Center += Shake;
Vector2 Bottom = projectile.Center + Vector2.UnitY * 20f;
Particle Sparkle = new ElectricSpark(Bottom, -Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(10f, 20f), Color.White, Main.rand.NextBool() ? Main.rand.NextBool() ? Color.Goldenrod : Color.GreenYellow : Main.rand.NextBool() ? Color.Cyan : Color.Magenta, 1f + Main.rand.NextFloat(0f, 1f), 34, rotationSpeed : 0.1f, bloomScale : 4f);
GeneralParticleHandler.SpawnParticle(Sparkle);
}
if (ChannelTimer >= ChannelTime)
{
projectile.timeLeft = 60;
ChanneledState = 2f; //State where it stays invisible doing nothing. Acts as a cooldown
}
}
if (ChanneledState == 1f)
projectile.position += Vector2.UnitY * -0.3f * (1f + projectile.timeLeft / 60f);
}
public void Attune(OmegaBiomeBlade item)
{
bool jungle = Owner.ZoneJungle;
bool snow = Owner.ZoneSnow;
bool evil = Owner.ZoneCorrupt || Owner.ZoneCrimson;
bool desert = Owner.ZoneDesert;
bool hell = Owner.ZoneUnderworldHeight;
bool ocean = Owner.ZoneBeach;
bool holy = Owner.ZoneHoly;
bool astral = Owner.Calamity().ZoneAstral;
bool marine = Owner.Calamity().ZoneAbyss || Owner.Calamity().ZoneSunkenSea;
Attunement attunement = Attunement.Whirlwind;
if (desert || hell)
attunement = Attunement.SuperPogo;
if (jungle || ocean || snow) //Check put after the desert check so ocean doesnt get overriden as desert
attunement = Attunement.FlailBlade;
if (evil) //Evil check separated so that it overrides corrupted beach & snow biomes
attunement = Attunement.SuperPogo;
if (astral || marine)
attunement = Attunement.Shockwave;
if (holy)
attunement = Attunement.Whirlwind; //Putting holy attunement at the end so it may override hallowed variants of biomes
//If the owner already had the attunement , break out of it (And unswap)
if (item.secondaryAttunement == attunement)
{
Main.PlaySound(SoundID.DD2_LightningBugZap, projectile.Center);
item.secondaryAttunement = item.mainAttunement;
item.mainAttunement = attunement;
return;
}
//Chunger
Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThunderStrike"), projectile.Center);
Particle thunder = new ThunderBoltVFX(projectile.Center + Vector2.UnitY * 20f, Main.rand.NextBool() ? Main.rand.NextBool() ? Color.Goldenrod : Color.GreenYellow : Main.rand.NextBool() ? Color.Cyan : Color.Magenta, 0f, 1.5f, Vector2.One, 1f, 15f, projectile, 20f);
GeneralParticleHandler.SpawnParticle(thunder);
if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 5)
Main.LocalPlayer.Calamity().GeneralScreenShakePower = 5;
item.mainAttunement = attunement;
}
public override void Kill(int timeLeft)
{
if (associatedItem == null)
{
return;
}
//If we swapped out the main attunement for the second one despite the second attunement being empty at the time, unswap them.
if ((associatedItem.modItem as OmegaBiomeBlade).mainAttunement == null && (associatedItem.modItem as OmegaBiomeBlade).secondaryAttunement != null)
{
(associatedItem.modItem as OmegaBiomeBlade).mainAttunement = (associatedItem.modItem as OmegaBiomeBlade).secondaryAttunement;
(associatedItem.modItem as OmegaBiomeBlade).secondaryAttunement = null;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
if (ChanneledState == 0f && ChannelTimer > 10f)
{
Texture2D tex = GetTexture(Texture);
spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, lightColor, projectile.rotation, tex.Size() / 2, 1, 0, 0);
return false;
}
else if (ChanneledState == 1f)
{
Texture2D tex = GetTexture(Texture);
Vector2 squishyScale = new Vector2(Math.Abs((float)Math.Sin(MathHelper.Pi + MathHelper.TwoPi * projectile.timeLeft / 30f)), 1f);
SpriteEffects flip = (float)Math.Sin(MathHelper.Pi + MathHelper.TwoPi * projectile.timeLeft / 30f) > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
spriteBatch.Draw(tex, projectile.position - Main.screenPosition, null, lightColor * (projectile.timeLeft / 60f), 0, tex.Size() / 2, squishyScale * (2f - (projectile.timeLeft / 60f)), flip, 0);
return false;
}
else
return false;
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

+1 -2
View File
@@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee
public override void SetDefaults()
{
item.width = 60;
item.width = item.height = 72;
item.damage = 98;
item.melee = true;
item.useAnimation = 25;
@@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Melee
item.knockBack = 6.5f;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.height = 60;
item.value = Item.buyPrice(0, 80, 0, 0);
item.rare = ItemRarityID.Yellow;
item.shoot = ModContent.ProjectileType<EonBeam>();
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

+735 -14
View File
@@ -1,24 +1,201 @@
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables;
using CalamityMod.Particles;
using CalamityMod.Projectiles.Melee;
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 Terraria.ModLoader.IO;
using static CalamityMod.CalamityUtils;
using static CalamityMod.Items.Weapons.Melee.TrueBiomeBlade;
using static Terraria.ModLoader.ModContent;
namespace CalamityMod.Items.Weapons.Melee
{
public class TrueBiomeBlade : ModItem
{
public enum Attunement : byte { Default, Hot, Cold, Tropical, Evil, Holy, Astral, Marine }
public Attunement? mainAttunement = null;
public Attunement? secondaryAttunement = null;
public int Combo = 0;
public int StoredLunges = 2;
public int PowerLungeCounter = 0;
#region stats
public static int DefaultAttunement_BaseDamage = 160;
public static int DefaultAttunement_SigilTime = 600;
public static int EvilAttunement_BaseDamage = 320;
public static int EvilAttunement_Lifesteal = 4;
public static int EvilAttunement_BounceIFrames = 10;
public static float EvilAttunement_SlashDamageBoost = 3f;
public static int EvilAttunement_SlashIFrames = 60;
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 int HotAttunement_BaseDamage = 320;
public static int HotAttunement_ShredIFrames = 8;
public static float HotAttunement_ShotDamageBoost = 2;
public static int HotAttunement_LocalIFrames = 30; //Be warned its got one extra update so all the iframes should be divided in 2
public static int HotAttunement_LocalIFramesCharged = 16;
public static int TropicalAttunement_BaseDamage = 160;
public static float TropicalAttunement_ChainDamageReduction = 0.5f;
public static float TropicalAttunement_VineDamageReduction = 0.5f;
public static int TropicalAttunement_LocalIFrames = 60; //Be warned its got 2 extra updates so all the iframes should be divided in 3
public static int HolyAttunement_BaseDamage = 160;
public static float HolyAttunement_BaseDamageReduction = 0.2f;
public static float HolyAttunement_FullChargeDamageBoost = 2f;
public static int HolyAttunement_LocalIFrames = 16; //Be warned its got 1 extra update yadda yadda
public static int AstralAttunement_BaseDamage = 500;
public static int AstralAttunement_DashHitIFrames = 30;
public static float AstralAttunement_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 AstralAttunement_MonolithDamageBoost = 2f;
public static int MarineAttunement_BaseDamage = 160;
#endregion
public override void SetStaticDefaults()
{
DisplayName.SetDefault("True Biome Blade");
Tooltip.SetDefault("Fires different projectiles based on what biome you're in");
DisplayName.SetDefault("Biome Blade");
Tooltip.SetDefault("FUNCTION_DESC\n" +
"FUNCTION_EXTRA\n" +
"Use RMB while standing still on the ground to attune the weapon to the powers of the surrounding biome\n" +
"Using RMB otherwise switches between the current attunement and an extra stored one\n" +
"Main attunement : None\n" +
"Secondary attunement: None\n"); //Theres potential for flavor text as well but im not a writer
}
#region tooltip editing
public override void ModifyTooltips(List<TooltipLine> list)
{
Player player = Main.player[Main.myPlayer];
if (player is null)
return;
foreach (TooltipLine l in list)
{
if (l.text.StartsWith("FUNCTION_DESC"))
{
AttunementInfo info = GetAttunementInfo(mainAttunement);
l.overrideColor = info.color;
l.text = info.function_description;
}
if (l.text.StartsWith("FUNCTION_EXTRA"))
{
AttunementInfo info = GetAttunementInfo(mainAttunement);
l.overrideColor = info.color;
l.text = info.function_extra;
}
if (l.text.StartsWith("Main attunement"))
{
AttunementInfo info = GetAttunementInfo(mainAttunement);
l.overrideColor = info.color;
l.text = "Main Attumenent : [" + info.name + "]";
}
if (l.text.StartsWith("Secondary attunement"))
{
AttunementInfo info = GetAttunementInfo(secondaryAttunement);
l.overrideColor = Color.Lerp(info.color, Color.Gray, 0.5f);
l.text = "Secondary Attumenent : [" + info.name + "]";
}
}
}
internal struct AttunementInfo
{
public string name;
public string function_description;
public string function_extra;
public Color color;
}
internal AttunementInfo GetAttunementInfo(Attunement? attunement)
{
AttunementInfo AttunementInfo = new AttunementInfo();
switch (attunement)
{
case Attunement.Default:
AttunementInfo.name = "Pure Clarity";
AttunementInfo.function_description = "Fires a weak projectile that crushes enemy defenses";
AttunementInfo.function_extra = "Landing true melee hits places a sigil of purity over the enemy. Your projectiles home onto the marked foes";
AttunementInfo.color = new Color(171, 180, 73);
break;
case Attunement.Hot:
AttunementInfo.name = "Arid Grandeur";
AttunementInfo.function_description = "Conjures searing blades in front of you that get larger and stronger the more you hit enemies. The blades can also be used to bounce off tiles when in the air";
AttunementInfo.function_extra = "Releasing LMB after charging up the blades sends them out flying to shred your foes";
AttunementInfo.color = new Color(238, 156, 73);
break;
case Attunement.Cold:
AttunementInfo.name = "Biting Embrace";
AttunementInfo.function_description = "Perform a 3 strike combo with a glacial blade. The final strike freezes foes for a split second";
AttunementInfo.function_extra = "Lingering glacial mist is released on each swing, dealing damage to enemies wandering into it";
AttunementInfo.color = new Color(165, 235, 235);
break;
case Attunement.Tropical:
AttunementInfo.name = "Grovetender's Touch";
AttunementInfo.function_description = "Throw out the blade using a vine whip. Striking enemies with the tip of the whip as it cracks guarantees a critical hit. The whip will also propel you towards struck tiles";
AttunementInfo.function_extra = "Critical strikes sprout up extra vines that can hit up to three targets";
AttunementInfo.color = new Color(162, 200, 85);
break;
case Attunement.Evil:
AttunementInfo.name = "Decay's Retort";
AttunementInfo.function_description = "Lunge forward using a ghostly rapier projection that leeches life off any struck foes. You also get bounced away from hit targets";
AttunementInfo.function_extra = "Lining up three strikes without touching the ground empowers the next strike into a powerful dash thrust ";
AttunementInfo.color = new Color(211, 64, 147);
break;
case Attunement.Holy:
AttunementInfo.name = "Heaven's Might";
AttunementInfo.function_description = "Hold LMB to swing the sword around you, powering up as it spins";
AttunementInfo.function_extra = "Releasing LMB will throw the sword in front of you, flying a short distance away before coming back";
AttunementInfo.color = new Color(220, 143, 255);
break;
case Attunement.Astral:
AttunementInfo.name = "Their Abhorrence";
AttunementInfo.function_description = "Hold LMB to charge up a star-piercing sword thrust, and release to unleash the devastating blow";
AttunementInfo.function_extra = "Striking the ground after a jump will create an impact so powerful massive otherwordly monoliths will rise up from the earth";
AttunementInfo.color = new Color(91, 73, 196);
break;
case Attunement.Marine:
AttunementInfo.name = "Gesture for the Drowned";
AttunementInfo.function_description = "Shoot out two water balls at your sides. On ground contact the water balls will turn into small waves that ride along the ground";
AttunementInfo.function_extra = "If used while submerged, or if the waves contact water, the waves will turn into bigger and faster ones";
AttunementInfo.color = new Color(98, 225, 255);
break;
default:
AttunementInfo.name = "None";
AttunementInfo.function_description = "Does nothing... yet";
AttunementInfo.function_extra = "Repairing the blade did increase its attuning capacities";
AttunementInfo.color = new Color(163, 163, 163);
break;
}
return AttunementInfo;
}
#endregion
public override void SetDefaults()
{
item.width = 54;
item.width = item.height = 68;
item.damage = 160;
item.melee = true;
item.useAnimation = 21;
@@ -28,33 +205,577 @@ namespace CalamityMod.Items.Weapons.Melee
item.knockBack = 7.5f;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.height = 54;
item.value = Item.buyPrice(0, 80, 0, 0);
item.rare = ItemRarityID.Yellow;
item.shoot = ModContent.ProjectileType<TrueBiomeOrb>();
item.shoot = ProjectileID.PurificationPowder;
item.shootSpeed = 12f;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<BiomeBlade>());
recipe.AddIngredient(ModContent.ItemType<LivingShard>(), 5);
recipe.AddIngredient(ItemID.Ectoplasm, 5);
recipe.AddIngredient(ModContent.ItemType<DepthCells>(), 10);
recipe.AddIngredient(ModContent.ItemType<Lumenite>(), 10);
recipe.AddIngredient(ModContent.ItemType<Tenebris>(), 5);
recipe.AddIngredient(ItemType<BiomeBlade>());
recipe.AddIngredient(ItemType<LivingShard>(), 5);
recipe.AddIngredient(ItemID.PixieDust, 2);
recipe.AddIngredient(ItemType<Stardust>(), 10);
recipe.AddIngredient(ItemType<EssenceofChaos>(), 5);
recipe.AddIngredient(ItemType<EssenceofCinder>(), 5);
recipe.AddIngredient(ItemType<EssenceofEleum>(), 5);
recipe.AddTile(TileID.MythrilAnvil);
recipe.SetResult(this);
recipe.AddRecipe();
}
public override void MeleeEffects(Player player, Rectangle hitbox)
#region Saving and syncing attunements
public override bool CloneNewInstances => true;
public override ModItem Clone(Item item)
{
if (Main.rand.NextBool(5))
var clone = base.Clone(item);
if (Main.mouseItem.type == ItemType<TrueBiomeBlade>())
item.modItem.HoldItem(Main.player[Main.myPlayer]);
(clone as TrueBiomeBlade).mainAttunement = (item.modItem as TrueBiomeBlade).mainAttunement;
(clone as TrueBiomeBlade).secondaryAttunement = (item.modItem as TrueBiomeBlade).secondaryAttunement;
return clone;
}
public override ModItem Clone() //ditto
{
var clone = base.Clone();
(clone as TrueBiomeBlade).mainAttunement = mainAttunement;
(clone as TrueBiomeBlade).secondaryAttunement = secondaryAttunement;
return clone;
}
public override TagCompound Save()
{
int attunement1 = mainAttunement == null ? -1 : (int)mainAttunement;
int attunement2 = secondaryAttunement == null ? -1 : (int)secondaryAttunement;
TagCompound tag = new TagCompound
{
int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 0);
{ "mainAttunement", attunement1 },
{ "secondaryAttunement", attunement2 }
};
return tag;
}
public override void Load(TagCompound tag)
{
int attunement1 = tag.GetInt("mainAttunement");
int attunement2 = tag.GetInt("secondaryAttunement");
if (attunement1 == -1)
mainAttunement = null;
else
mainAttunement = (Attunement?)attunement1;
if (attunement2 == -1 || (attunement1 == attunement2))
secondaryAttunement = null;
else
secondaryAttunement = (Attunement?)attunement2;
}
public override void NetSend(BinaryWriter writer)
{
writer.Write((byte)mainAttunement);
writer.Write((byte)secondaryAttunement);
}
public override void NetRecieve(BinaryReader reader)
{
mainAttunement = (Attunement?)reader.ReadByte();
secondaryAttunement = (Attunement?)reader.ReadByte();
}
#endregion
public override void HoldItem(Player player)
{
player.Calamity().rightClickListener = true;
if (player.velocity.Y == 0) //reset the amount of lunges on ground contact
{
StoredLunges = 2;
if (PowerLungeCounter != 3)
PowerLungeCounter = 0;
}
//Change the swords function based on its attunement
switch (mainAttunement)
{
case Attunement.Default:
item.damage = DefaultAttunement_BaseDamage;
item.channel = false;
item.noUseGraphic = false;
item.useStyle = ItemUseStyleID.SwingThrow;
item.shoot = ProjectileType<TruePurityProjection>();
item.shootSpeed = 12f;
item.UseSound = SoundID.Item1;
item.noMelee = false;
Combo = 0;
PowerLungeCounter = 0;
break;
case Attunement.Hot:
item.damage = HotAttunement_BaseDamage;
item.channel = true;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.HoldingOut;
item.shoot = ProjectileType<TrueAridGrandeur>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
Combo = 0;
PowerLungeCounter = 0;
break;
case Attunement.Cold:
item.damage = ColdAttunement_BaseDamage;
item.channel = true;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.HoldingOut;
item.shoot = ProjectileType<TrueBitingEmbrace>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
PowerLungeCounter = 0;
break;
case Attunement.Tropical:
item.damage = TropicalAttunement_BaseDamage;
item.channel = false;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.SwingThrow;
item.shoot = ProjectileType<TrueGrovetendersTouch>();
item.shootSpeed = 30;
item.UseSound = null;
item.noMelee = true;
PowerLungeCounter = 0;
break;
case Attunement.Evil:
item.damage = EvilAttunement_BaseDamage;
item.channel = false;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.Stabbing;
item.shoot = ProjectileType<TrueDecaysRetort>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
Combo = 0;
break;
case Attunement.Holy:
item.damage = HolyAttunement_BaseDamage;
item.channel = true;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.HoldingOut;
item.shoot = ProjectileType<HeavensMight>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
Combo = 0;
PowerLungeCounter = 0;
break;
case Attunement.Astral:
item.damage = AstralAttunement_BaseDamage;
item.channel = true;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.Stabbing;
item.shoot = ProjectileType<TheirAbhorrence>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
Combo = 0;
PowerLungeCounter = 0;
break;
case Attunement.Marine:
item.damage = MarineAttunement_BaseDamage;
item.channel = false;
item.noUseGraphic = true;
item.useStyle = ItemUseStyleID.Stabbing;
item.shoot = ProjectileType<GestureForTheDrowned>();
item.shootSpeed = 12f;
item.UseSound = null;
item.noMelee = true;
Combo = 0;
PowerLungeCounter = 0;
break;
default:
item.noUseGraphic = false;
item.useStyle = ItemUseStyleID.SwingThrow;
item.shoot = ProjectileID.PurificationPowder;
item.shootSpeed = 12f;
item.UseSound = SoundID.Item1;
Combo = 0;
PowerLungeCounter = 0;
break;
}
if (player.Calamity().mouseRight && CanUseItem(player) && player.whoAmI == Main.myPlayer && !Main.mapFullscreen)
{
//Don't shoot out a visual blade if you already have one out
if (Main.projectile.Any(n => n.active && n.type == ProjectileType<MendedBiomeBladeVisuals>() && n.owner == player.whoAmI))
return;
int x = (int)player.Center.X / 16;
int y = (int)(player.position.Y + (float)player.height - 1f) / 16;
Tile tileStandingOn = Main.tile[x, y + 1];
bool mayAttune = player.StandingStill() && !player.mount.Active && tileStandingOn.IsTileSolidGround();
Vector2 displace = new Vector2(18f, 0f);
Projectile.NewProjectile(player.Top + displace, Vector2.Zero, ProjectileType<MendedBiomeBladeVisuals>(), 0, 0, player.whoAmI, mayAttune ? 0f : 1f);
}
}
public override bool CanUseItem(Player player)
{
return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI &&
(n.type == ProjectileType<TrueBitingEmbrace>() ||
n.type == ProjectileType<TrueGrovetendersTouch>() ||
n.type == ProjectileType<TrueAridGrandeur>() ||
n.type == ProjectileType<HeavensMight>() ||
n.type == ProjectileType<TheirAbhorrence>() ||
n.type == ProjectileType<GestureForTheDrowned>()));
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
if (mainAttunement == null)
return false;
switch (mainAttunement)
{
case Attunement.Cold:
switch (Combo)
{
case 0:
Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), ProjectileType<TrueBitingEmbrace>(), damage, knockBack, player.whoAmI, 0, 15);
break;
case 1:
Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), ProjectileType<TrueBitingEmbrace>(), damage, knockBack, player.whoAmI, 1, 20);
break;
case 2:
Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), ProjectileType<TrueBitingEmbrace>(), damage, knockBack, player.whoAmI, 2, 50);
break;
}
Combo++;
if (Combo > 2)
Combo = 0;
return false;
case Attunement.Tropical:
Projectile whipProj = Projectile.NewProjectileDirect(player.Center, new Vector2(speedX, speedY), ProjectileType<TrueGrovetendersTouch>(), damage, knockBack, player.whoAmI, 0, 0);
if (whipProj.modProjectile is TrueGrovetendersTouch whip)
whip.flipped = Combo == 0 ? 1 : -1;
Combo++;
if (Combo > 1)
Combo = 0;
return false;
case Attunement.Evil:
bool powerLungeAvailable = false;
if (PowerLungeCounter == 3)
{
powerLungeAvailable = true;
PowerLungeCounter = 0;
}
Projectile proj = Projectile.NewProjectileDirect(player.Center, new Vector2(speedX, speedY), ProjectileType<TrueDecaysRetort>(), damage, knockBack, player.whoAmI, 26f, StoredLunges > 0 ? 1f : 0f);
if (proj.modProjectile is TrueDecaysRetort rapier)
rapier.ChargedUp = powerLungeAvailable;
StoredLunges --;
if (StoredLunges < 0)
StoredLunges = 0;
return false;
default:
return base.Shoot(player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack);
}
}
//This is only used for the purity sigil effect of the default attunement
public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
{
if (mainAttunement != Attunement.Default || player.whoAmI != Main.myPlayer)
return;
foreach (Projectile proj in Main.projectile)
{
if (proj.active && proj.type == ProjectileType<PurityProjectionSigil>() && proj.owner == player.whoAmI)
{
//Reset the timeleft on the sigil & give it its new target (or the same, it doesnt matter really.
proj.ai[0] = target.whoAmI;
proj.timeLeft = DefaultAttunement_SigilTime;
return;
}
}
Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType<PurityProjectionSigil>(), 0, 0, player.whoAmI, target.whoAmI);
}
internal static ChargingEnergyParticleSet BiomeEnergyParticles = new ChargingEnergyParticleSet(-1, 2, Color.White, Color.White, 0.04f, 20f);
internal static void UpdateAllParticleSets()
{
BiomeEnergyParticles.Update();
}
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
{
Texture2D itemTexture = GetTexture("CalamityMod/Projectiles/Melee/MendedBiomeBlade");
if (mainAttunement == null)
{
spriteBatch.Draw(itemTexture, position, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f);
return true;
}
// Draw all particles.
Vector2 particleDrawCenter = position + new Vector2(12f, 16f) * Main.inventoryScale;
switch (mainAttunement)
{
case Attunement.Default:
BiomeEnergyParticles.EdgeColor = new Color(117, 126, 72);
BiomeEnergyParticles.CenterColor = new Color(200, 184, 136);
break;
case Attunement.Hot:
BiomeEnergyParticles.EdgeColor = new Color(137, 32, 0);
BiomeEnergyParticles.CenterColor = new Color(209, 154, 0);
break;
case Attunement.Cold:
BiomeEnergyParticles.EdgeColor = new Color(165, 235, 235);
BiomeEnergyParticles.CenterColor = new Color(58, 110, 141);
break;
case Attunement.Tropical:
BiomeEnergyParticles.EdgeColor = new Color(53, 112, 4);
BiomeEnergyParticles.CenterColor = new Color(131, 173, 39);
break;
case Attunement.Evil:
BiomeEnergyParticles.EdgeColor = new Color(112, 4, 35);
BiomeEnergyParticles.CenterColor = new Color(195, 42, 200);
break;
case Attunement.Holy:
case Attunement.Astral:
BiomeEnergyParticles.EdgeColor = new Color(62, 55, 110);
BiomeEnergyParticles.CenterColor = new Color(255, 143, 255);
break;
case Attunement.Marine:
BiomeEnergyParticles.EdgeColor = new Color(27, 59, 101);
BiomeEnergyParticles.CenterColor = new Color(27, 112643, 255);
break;
}
BiomeEnergyParticles.InterpolationSpeed = 0.1f;
BiomeEnergyParticles.DrawSet(particleDrawCenter + Main.screenPosition);
Vector2 displacement = Vector2.UnitX.RotatedBy(Main.GlobalTime * 3f) * 2f * (float)Math.Sin(Main.GlobalTime);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive);
spriteBatch.Draw(itemTexture, position + displacement, null, BiomeEnergyParticles.CenterColor, 0f, origin, scale, SpriteEffects.None, 0f);
spriteBatch.Draw(itemTexture, position - displacement, null, BiomeEnergyParticles.CenterColor, 0f, origin, scale, SpriteEffects.None, 0f);
spriteBatch.End();
spriteBatch.Begin(default, default);
spriteBatch.Draw(itemTexture, position, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f);
return false;
}
public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
{
Texture2D itemTexture = GetTexture("CalamityMod/Projectiles/Melee/MendedBiomeBlade"); //Use the "projectile" sprite which is flipped so its consistent in lighting with the rest of the line, since its actual sprite is flipped so the swings may look normal
spriteBatch.Draw(itemTexture, item.Center - Main.screenPosition, null, lightColor, rotation, item.Size * 0.5f, scale, SpriteEffects.None, 0f);
return false;
}
}
public class MendedBiomeBladeVisuals : ModProjectile //Visuals
{
private Player Owner => Main.player[projectile.owner];
public bool OwnerOnGround => Main.tile[(int)Owner.Center.X / 16, (int)(Owner.position.Y + (float)Owner.height - 1f) / 16 + 1].IsTileSolidGround() && Main.tile[(int)Owner.Center.X / 16 + Owner.direction, (int)(Owner.position.Y + (float)Owner.height - 1f) / 16 + 1].IsTileSolidGround();
public bool OwnerCanUseItem => Owner.HeldItem == associatedItem ? (Owner.HeldItem.modItem as TrueBiomeBlade).CanUseItem(Owner) : false;
public bool OwnerMayChannel => OwnerCanUseItem && Owner.Calamity().mouseRight && Owner.active && !Owner.dead && Owner.StandingStill() && !Owner.mount.Active && OwnerOnGround;
public ref float ChanneledState => ref projectile.ai[0];
public ref float ChannelTimer => ref projectile.ai[1];
public ref float Initialized => ref projectile.localAI[0];
private Item associatedItem;
const int ChannelTime = 120;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Mended Biome Blade");
}
public override string Texture => "CalamityMod/Items/Weapons/Melee/TrueBiomeBlade";
public bool drawIndrawHeldProjInFrontOfHeldItemAndArms = true;
public override void SetDefaults()
{
projectile.width = projectile.height = 36;
projectile.aiStyle = -1;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.timeLeft = 60;
projectile.tileCollide = false;
projectile.damage = 0;
}
public CurveSegment anticipation = new CurveSegment(EasingType.SineOut, 0f, 1f, 0.35f);
public CurveSegment thrust = new CurveSegment(EasingType.ExpIn, 0.85f, 1.35f, -1.45f);
public CurveSegment bounceback = new CurveSegment(EasingType.SineOut, 0.95f, -0.1f, 0.1f);
internal float SwordHeight() => PiecewiseAnimation(ChannelTimer / (float)ChannelTime, new CurveSegment[] { anticipation, thrust, bounceback });
public override void AI()
{
if (Initialized == 0f)
{
//If dropped, kill it instantly
if (Owner.HeldItem.type != ItemType<TrueBiomeBlade>())
{
projectile.Kill();
return;
}
if (Owner.whoAmI == Main.myPlayer)
Main.PlaySound(SoundID.DD2_DarkMageHealImpact);
associatedItem = Owner.HeldItem;
//Switch up the attunements
Attunement? temporaryAttunementStorage = (associatedItem.modItem as TrueBiomeBlade).mainAttunement;
(associatedItem.modItem as TrueBiomeBlade).mainAttunement = (associatedItem.modItem as TrueBiomeBlade).secondaryAttunement;
(associatedItem.modItem as TrueBiomeBlade).secondaryAttunement = temporaryAttunementStorage;
Initialized = 1f;
}
if (!OwnerMayChannel && ChanneledState == 0f) //IF the channeling gets interrupted for any reason
{
projectile.Center = Owner.Top + new Vector2(18f, 0f);
ChanneledState = 1f;
projectile.timeLeft = 60;
return;
}
if (ChanneledState == 0f)
{
Owner.heldProj = projectile.whoAmI;
projectile.Center = Owner.Center + new Vector2(16f * Owner.direction + Owner.direction < 0 ? -26f : 16f, -30 * SwordHeight() + 10f);
projectile.rotation = MathHelper.PiOver4 + MathHelper.PiOver2; // No more silly turnaround with the repaired one?
ChannelTimer++;
projectile.timeLeft = 60;
if (ChannelTimer >= ChannelTime)
{
Attune((TrueBiomeBlade)associatedItem.modItem);
projectile.timeLeft = 120;
ChanneledState = 2f; //State where it stays invisible doing nothing. Acts as a cooldown
Color particleColor = (associatedItem.modItem as TrueBiomeBlade).GetAttunementInfo((associatedItem.modItem as TrueBiomeBlade).mainAttunement).color;
for (int i = 0; i <= 5; i++)
{
Vector2 displace = Vector2.UnitX * 20 * Main.rand.NextFloat(-1f, 1f);
Particle Glow = new GenericBloom(Owner.Bottom + displace, -Vector2.UnitY * Main.rand.NextFloat(1f, 5f), particleColor, 0.02f + Main.rand.NextFloat(0f, 0.2f), 20 + Main.rand.Next(30));
GeneralParticleHandler.SpawnParticle(Glow);
}
for (int i = 0; i <= 10; i++)
{
Vector2 displace = Vector2.UnitX * 16 * Main.rand.NextFloat(-1f, 1f);
Particle Sparkle = new GenericSparkle(Owner.Bottom + displace, -Vector2.UnitY * Main.rand.NextFloat(1f, 5f), particleColor, particleColor, 0.5f + Main.rand.NextFloat(-0.2f, 0.2f), 20 + Main.rand.Next(30), 1, 2f);
GeneralParticleHandler.SpawnParticle(Sparkle);
}
}
}
if (ChanneledState == 1f)
projectile.position += Vector2.UnitY * -0.3f * (1f + projectile.timeLeft / 60f);
}
public void Attune(TrueBiomeBlade item)
{
bool jungle = Owner.ZoneJungle;
bool snow = Owner.ZoneSnow;
bool evil = Owner.ZoneCorrupt || Owner.ZoneCrimson;
bool desert = Owner.ZoneDesert;
bool hell = Owner.ZoneUnderworldHeight;
bool ocean = Owner.ZoneBeach;
bool holy = Owner.ZoneHoly;
bool astral = Owner.Calamity().ZoneAstral;
bool marine = Owner.Calamity().ZoneAbyss || Owner.Calamity().ZoneSunkenSea;
Attunement attunement = Attunement.Default;
if (desert || hell)
attunement = Attunement.Hot;
if (snow)
attunement = Attunement.Cold;
if (jungle || ocean)
attunement = Attunement.Tropical;
if (evil)
attunement = Attunement.Evil;
if (holy)
attunement = Attunement.Holy;
if (astral)
attunement = Attunement.Astral;
if (marine)
attunement = Attunement.Marine;
//If the owner already had the attunement , break out of it (And unswap)
if (item.secondaryAttunement == attunement)
{
Main.PlaySound(SoundID.DD2_LightningBugZap, projectile.Center);
item.secondaryAttunement = item.mainAttunement;
item.mainAttunement = attunement;
return;
}
Main.PlaySound(SoundID.DD2_MonkStaffGroundImpact, projectile.Center);
item.mainAttunement = attunement;
}
public override void Kill(int timeLeft)
{
if (associatedItem == null)
{
return;
}
//If we swapped out the main attunement for the second one despite the second attunement being empty at the time, unswap them.
if ((associatedItem.modItem as TrueBiomeBlade).mainAttunement == null && (associatedItem.modItem as TrueBiomeBlade).secondaryAttunement != null)
{
(associatedItem.modItem as TrueBiomeBlade).mainAttunement = (associatedItem.modItem as TrueBiomeBlade).secondaryAttunement;
(associatedItem.modItem as TrueBiomeBlade).secondaryAttunement = null;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
if (ChanneledState == 0f && ChannelTimer > 6f)
return base.PreDraw(spriteBatch, lightColor);
else if (ChanneledState == 1f)
{
Texture2D tex = GetTexture(Texture);
Vector2 squishyScale = new Vector2(Math.Abs((float)Math.Sin(MathHelper.Pi + MathHelper.TwoPi * projectile.timeLeft / 30f)), 1f);
SpriteEffects flip = (float)Math.Sin(MathHelper.Pi + MathHelper.TwoPi * projectile.timeLeft / 30f) > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
spriteBatch.Draw(tex, projectile.position - Main.screenPosition, null, lightColor * (projectile.timeLeft / 60f), 0, tex.Size() / 2, squishyScale * (2f - (projectile.timeLeft / 60f)), flip, 0);
return false;
}
else
return false;
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

+56
View File
@@ -0,0 +1,56 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class BloomLineVFX : Particle
{
public override string Texture => "CalamityMod/Particles/BloomLine";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
public override bool Important => Telegraph;
public bool Capped;
public float opacity;
public Vector2 LineVector;
public bool Telegraph; //Denotes if the line is used as an enemy telegraph. In that case, it'll be marked as important
public BloomLineVFX(Vector2 startPoint, Vector2 lineVector, float thickness, Color color, int lifetime, bool capped = false, bool telegraph = false)
{
Position = startPoint;
LineVector = lineVector;
Scale = thickness;
Color = color;
Lifetime = lifetime;
Capped = capped;
Telegraph = telegraph;
Velocity = Vector2.Zero;
Rotation = 0;
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D tex = GeneralParticleHandler.GetTexture(Type);
float rot = LineVector.ToRotation() + MathHelper.PiOver2;
Vector2 origin = new Vector2(tex.Width/2f, tex.Height);
Vector2 scale = new Vector2(Scale, LineVector.Length() / tex.Height);
spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color, rot, origin, scale, SpriteEffects.None, 0);
if (Capped)
{
Texture2D cap = ModContent.GetTexture("CalamityMod/Particles/BloomLineCap"); ;
scale = new Vector2(Scale, Scale);
origin = new Vector2(cap.Width / 2f, cap.Height);
spriteBatch.Draw(cap, Position - Main.screenPosition, null, Color, rot + MathHelper.Pi, origin, scale, SpriteEffects.None, 0);
spriteBatch.Draw(cap, Position + LineVector - Main.screenPosition, null, Color, rot, origin, scale, SpriteEffects.None, 0);
}
}
}
}
+43
View File
@@ -0,0 +1,43 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class BloomRing : Particle
{
public override string Texture => "CalamityMod/Particles/BloomRing";
public override bool UseAdditiveBlend => true;
public override bool SetLifetime => true;
private float opacity;
private Color BaseColor;
public BloomRing(Vector2 position, Vector2 velocity, Color color, float scale, int lifeTime)
{
Position = position;
Velocity = velocity;
BaseColor = color;
Scale = scale;
Lifetime = lifeTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
}
public override void Update()
{
opacity = (float)Math.Sin(MathHelper.PiOver2 + LifetimeCompletion * MathHelper.PiOver2);
Color = BaseColor * opacity;
Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f);
Velocity *= 0.95f;
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D tex = GeneralParticleHandler.GetTexture(Type);
spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * opacity, Rotation, tex.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

+27
View File
@@ -0,0 +1,27 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class CircularSmearSmokeyVFX : Particle //Also check out random noise generation!
{
public override string Texture => "CalamityMod/Particles/CircularSmearSmokey";
public override bool UseAdditiveBlend => true;
public override bool SetLifetime => true;
public float opacity;
public CircularSmearSmokeyVFX(Vector2 position, Color color, float rotation, float scale)
{
Position = position;
Velocity = Vector2.Zero;
Color = color;
Scale = scale;
Rotation = rotation;
Lifetime = 2;
}
}
}
+27
View File
@@ -0,0 +1,27 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class CircularSmearVFX : Particle //Also check out Split mod!
{
public override string Texture => "CalamityMod/Particles/CircularSmear";
public override bool UseAdditiveBlend => true;
public override bool SetLifetime => true;
public float opacity;
public CircularSmearVFX(Vector2 position, Color color, float rotation, float scale)
{
Position = position;
Velocity = Vector2.Zero;
Color = color;
Scale = scale;
Rotation = rotation;
Lifetime = 2;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

+68
View File
@@ -0,0 +1,68 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class ConstellationRingVFX : Particle //Also check out Split mod!
{
public override string Texture => "CalamityMod/Particles/HollowCircleSoftEdge";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
public override bool Important => NeededVisual;
public Vector2 Squish;
public int StarAmount;
public float StarScale;
public float SpinSpeed;
public bool NeededVisual;
public float Offset;
public float Opacity;
public ConstellationRingVFX(Vector2 position, Color color, float rotation, float scale, Vector2 squish, float opacity = 1f, int starAmount = 3, float starScale = 2f, float spinSpeed = 0.05f, bool important = false)
{
Position = position;
Velocity = Vector2.Zero;
Rotation = rotation;
Color = color;
Scale = scale;
Squish = squish;
Opacity = opacity;
StarAmount = starAmount;
StarScale = starScale;
SpinSpeed = spinSpeed;
NeededVisual = important;
Lifetime = 2;
Offset = Main.rand.NextFloat(0f, MathHelper.TwoPi);
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D ringTexture = GeneralParticleHandler.GetTexture(Type);
Texture2D starTexture = ModContent.GetTexture("CalamityMod/Particles/Sparkle");
Texture2D bloomTexture = ModContent.GetTexture("CalamityMod/Particles/BloomCircle");
spriteBatch.Draw(ringTexture, Position - Main.screenPosition, null, Color * Opacity, Rotation, ringTexture.Size() / 2f, Squish * Scale, SpriteEffects.None, 0);
for (int i = 0; i < StarAmount; i++)
{
float starHeight = (float)Math.Sin(Offset + Main.GlobalTime * SpinSpeed + i * MathHelper.TwoPi / (float)StarAmount);
float starWidth = (float)Math.Cos(Offset + Main.GlobalTime * SpinSpeed + i * MathHelper.TwoPi / (float)StarAmount);
Vector2 starPos = Position + Rotation.ToRotationVector2() * starWidth * (Squish.X * Scale * ringTexture.Width * 0.45f) + (Rotation + MathHelper.PiOver2).ToRotationVector2() * starHeight * (Squish.Y * Scale * ringTexture.Height * 0.45f);
//Ajust the bloom's texture to be the same size as the star's
float properBloomSize = (float)starTexture.Height / (float)bloomTexture.Height;
spriteBatch.Draw(bloomTexture, starPos - Main.screenPosition, null, Color * Opacity * 0.5f, 0, bloomTexture.Size() / 2f, Scale * properBloomSize, SpriteEffects.None, 0);
spriteBatch.Draw(starTexture, starPos - Main.screenPosition, null, Color * Opacity * 0.5f, Rotation + MathHelper.PiOver4 + MathHelper.PiOver4 * i, starTexture.Size() / 2f, Scale * 0.75f, SpriteEffects.None, 0);
spriteBatch.Draw(starTexture, starPos - Main.screenPosition, null, Color.White * Opacity, Rotation + MathHelper.PiOver4 * i, starTexture.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}
}
+54
View File
@@ -0,0 +1,54 @@
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles {
public class CosmicSmokeParticle : Particle
{
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
public override string Texture => "CalamityMod/Particles/SmallSmoke";
private float Opacity;
private Color BackColor;
private float ColorHueShift;
private float Spin;
public CosmicSmokeParticle(Vector2 position, Vector2 velocity, Color color, Color backColor, float scale, float opacity, int lifetime, float rotationSpeed = 0f)
{
Position = position;
Velocity = velocity;
Color = color;
BackColor = backColor;
Scale = scale;
Opacity = opacity;
Lifetime = lifetime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
}
public override void Update()
{
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
Velocity *= 0.85f;
if (Opacity > 90)
{
Lighting.AddLight(Position, Color.ToVector3() * 0.1f);
Scale += 0.01f;
Opacity -= 3;
}
else
{
Scale *= 0.975f;
Opacity -= 2;
}
if (Opacity < 0)
Kill();
}
}
}
+55
View File
@@ -0,0 +1,55 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class CritSpark : Particle
{
public override string Texture => "CalamityMod/Particles/ThinSparkle";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
private float Spin;
private float opacity;
private Color Bloom;
private Color LightColor => Bloom * opacity;
private float BloomScale;
public CritSpark(Vector2 position, Vector2 velocity, Color color, Color bloom, float scale, int lifeTime, float rotationSpeed = 1f, float bloomScale = 1f)
{
Position = position;
Velocity = velocity;
Color = color;
Bloom = bloom;
Scale = scale;
Lifetime = lifeTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
BloomScale = bloomScale;
}
public override void Update()
{
opacity = (float)Math.Sin(MathHelper.PiOver2 + LifetimeCompletion * MathHelper.PiOver2);
Velocity *= 0.80f;
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f) * (LifetimeCompletion > 0.5 ? 1f : 0.5f);
Lighting.AddLight(Position, LightColor.R / 255f, LightColor.G / 255f, LightColor.B / 255f);
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D sparkTexture = GeneralParticleHandler.GetTexture(Type);
Texture2D bloomTexture = ModContent.GetTexture("CalamityMod/Particles/BloomCircle");
//Ajust the bloom's texture to be the same size as the star's
float properBloomSize = (float)sparkTexture.Height / (float)bloomTexture.Height;
spriteBatch.Draw(bloomTexture, Position - Main.screenPosition, null, Bloom * opacity * 0.5f, 0, bloomTexture.Size() / 2f, Scale * BloomScale * properBloomSize, SpriteEffects.None, 0);
spriteBatch.Draw(sparkTexture, Position - Main.screenPosition, null, Color * opacity, Rotation, sparkTexture.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B

+69
View File
@@ -0,0 +1,69 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class ElectricSpark : Particle
{
public override string Texture => "CalamityMod/Particles/ElectricSpark";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
public override int FrameVariants => 2;
private float Spin;
private float opacity;
private Color Bloom;
private Color LightColor => Bloom * opacity;
private float BloomScale;
private float MaxJumpRotation; //Max rotation that the particle can change velocity per "jump"
private float JumpTime; //Time between jumps
private Vector2 OriginalSpeed;
public ElectricSpark(Vector2 position, Vector2 velocity, Color color, Color bloom, float scale, int lifeTime, float maxJumpRotation = MathHelper.PiOver4, float jumpTime = 10, float rotationSpeed = 1f, float bloomScale = 1f)
{
Position = position;
Velocity = velocity;
OriginalSpeed = velocity;
Color = color;
Bloom = bloom;
Scale = scale;
Lifetime = lifeTime;
MaxJumpRotation = maxJumpRotation;
JumpTime = jumpTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
BloomScale = bloomScale;
Variant = Main.rand.Next(2);
}
public override void Update()
{
opacity -= JumpTime * 0.25f / Lifetime;
if (Time % JumpTime == 0)
{
opacity = 1f;
Velocity = OriginalSpeed.RotatedByRandom(MaxJumpRotation);
}
Velocity *= 0.6f;
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f) * (LifetimeCompletion > 0.5 ? 1f : 0.5f);
Lighting.AddLight(Position, LightColor.R / 255f, LightColor.G / 255f, LightColor.B / 255f);
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D sparkTexture = GeneralParticleHandler.GetTexture(Type);
Rectangle frame = new Rectangle(0, 6 * Variant, 6, 6);
Texture2D bloomTexture = ModContent.GetTexture("CalamityMod/Particles/BloomCircle");
//Ajust the bloom's texture to be the same size as the star's
float properBloomSize = (float)frame.Height / (float)bloomTexture.Height;
spriteBatch.Draw(bloomTexture, Position - Main.screenPosition, null, Bloom * opacity * 0.5f, 0, bloomTexture.Size() / 2f, Scale * BloomScale * properBloomSize, SpriteEffects.None, 0);
spriteBatch.Draw(sparkTexture, Position - Main.screenPosition, frame, Color * opacity, Rotation, frame.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

+57
View File
@@ -0,0 +1,57 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class FakeGlowDust : Particle
{
public override string Texture => "CalamityMod/Particles/FakeDust";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
private float Spin;
private float opacity;
private bool Big;
private bool EmitsLight;
private Vector2 Gravity;
public FakeGlowDust(Vector2 position, Vector2 velocity, Color color, float scale, int lifeTime, float rotationSpeed = 1f, bool bigSize = false, bool emitsLight = false, Vector2? gravity = null)
{
Position = position;
Velocity = velocity;
Color = color;
Scale = scale;
Lifetime = lifeTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
Big = bigSize;
EmitsLight = emitsLight;
Gravity = (Vector2)(gravity == null ? Vector2.Zero : gravity);
Variant = Main.rand.Next(3);
}
public override void Update()
{
Velocity += Gravity;
opacity = (float)Math.Sin(LifetimeCompletion * MathHelper.Pi);
if (EmitsLight)
Lighting.AddLight(Position, opacity * Color.R / 255f, opacity * Color.G / 255f, opacity * Color.B / 255f);
Velocity *= 0.95f;
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
Scale *= 0.98f;
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D dustTexture = Big ? ModContent.GetTexture("CalamityMod/Particles/FakeDustBig") : GeneralParticleHandler.GetTexture(Type);
Rectangle frame = new Rectangle(0, (Big ? 8 : 6) * Variant, (Big ? 8 : 6), (Big ? 8 : 6));
spriteBatch.Draw(dustTexture, Position - Main.screenPosition, frame, Color * opacity, Rotation, frame.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}
+56 -14
View File
@@ -14,23 +14,28 @@ namespace CalamityMod.Particles
public static class GeneralParticleHandler
{
private static List<Particle> particles;
private static int nextVacantIndex;
//List containing the particles to delete
private static List<Particle> particlesToKill;
//Static list for details concerning every particle type
private static Dictionary<Type, int> particleTypes;
private static Dictionary<int, Texture2D> particleTextures;
private static List<Particle> particleInstances;
//Lists used when drawing particles batched
private static List<Particle> batchedAlphaBlendParticles;
private static List<Particle> batchedNonPremultipliedParticles;
private static List<Particle> batchedAdditiveBlendParticles;
internal static void Load()
{
particles = new List<Particle>();
particlesToKill = new List<Particle>();
particleTypes = new Dictionary<Type, int>();
particleTextures = new Dictionary<int, Texture2D>();
particleInstances = new List<Particle>();
batchedAlphaBlendParticles = new List<Particle>();
batchedNonPremultipliedParticles = new List<Particle>();
batchedAdditiveBlendParticles = new List<Particle>();
Type baseParticleType = typeof(Particle);
@@ -57,10 +62,12 @@ namespace CalamityMod.Particles
internal static void Unload()
{
particles = null;
particlesToKill = null;
particleTypes = null;
particleTextures = null;
particleInstances = null;
batchedAlphaBlendParticles = null;
batchedNonPremultipliedParticles = null;
batchedAdditiveBlendParticles = null;
}
@@ -87,12 +94,13 @@ namespace CalamityMod.Particles
particle.Update();
}
//Clear out particles whose time is up
particles.RemoveAll(particle => particle.Time >= particle.Lifetime && particle.SetLifetime);
particles.RemoveAll(particle => (particle.Time >= particle.Lifetime && particle.SetLifetime) || particlesToKill.Contains(particle));
particlesToKill.Clear();
}
public static void RemoveParticle(Particle particle)
{
particles.Remove(particle);
particlesToKill.Add(particle);
}
public static void DrawAllParticles(SpriteBatch sb)
@@ -105,6 +113,8 @@ namespace CalamityMod.Particles
if (particle.UseAdditiveBlend)
batchedAdditiveBlendParticles.Add(particle);
else if (particle.UseHalfTransparency)
batchedNonPremultipliedParticles.Add(particle);
else
batchedAlphaBlendParticles.Add(particle);
}
@@ -120,26 +130,58 @@ namespace CalamityMod.Particles
}
}
sb.End();
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, null, null, Main.GameViewMatrix.ZoomMatrix);
foreach (Particle particle in batchedAdditiveBlendParticles)
if (batchedNonPremultipliedParticles.Count > 0)
{
if (particle.UseCustomDraw)
particle.CustomDraw(sb);
else
sb.End();
sb.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.Default, null, null, Main.GameViewMatrix.ZoomMatrix);
foreach (Particle particle in batchedNonPremultipliedParticles)
{
Rectangle frame = particleTextures[particle.Type].Frame(1, particle.FrameVariants, 0, particle.Variant);
sb.Draw(particleTextures[particle.Type], particle.Position - Main.screenPosition, frame, particle.Color, particle.Rotation, frame.Size() * 0.5f, particle.Scale, SpriteEffects.None, 0f);
if (particle.UseCustomDraw)
particle.CustomDraw(sb);
else
{
Rectangle frame = particleTextures[particle.Type].Frame(1, particle.FrameVariants, 0, particle.Variant);
sb.Draw(particleTextures[particle.Type], particle.Position - Main.screenPosition, frame, particle.Color, particle.Rotation, frame.Size() * 0.5f, particle.Scale, SpriteEffects.None, 0f);
}
}
}
sb.End();
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
if (batchedAdditiveBlendParticles.Count > 0)
{
sb.End();
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, null, null, Main.GameViewMatrix.ZoomMatrix);
foreach (Particle particle in batchedAdditiveBlendParticles)
{
if (particle.UseCustomDraw)
particle.CustomDraw(sb);
else
{
Rectangle frame = particleTextures[particle.Type].Frame(1, particle.FrameVariants, 0, particle.Variant);
sb.Draw(particleTextures[particle.Type], particle.Position - Main.screenPosition, frame, particle.Color, particle.Rotation, frame.Size() * 0.5f, particle.Scale, SpriteEffects.None, 0f);
}
}
}
//Return to normal if we swapped the blend state before
if (batchedAdditiveBlendParticles.Count > 0 || batchedNonPremultipliedParticles.Count > 0)
{
sb.End();
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
}
batchedAlphaBlendParticles.Clear();
batchedNonPremultipliedParticles.Clear();
batchedAdditiveBlendParticles.Clear();
}
/// <summary>
/// Gives you the amount of particle slots that are available. Useful when you need multiple particles at once to make an effect and dont want it to be only halfway drawn due to a lack of particle slots
/// </summary>
/// <returns></returns>
public static int FreeSpacesAvailable() => CalamityConfig.Instance.ParticleLimit - particles.Count();
/// <summary>
/// Gives you the texture of the particle type. Useful for custom drawing
/// </summary>
+43
View File
@@ -0,0 +1,43 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class GenericBloom : Particle
{
public override string Texture => "CalamityMod/Particles/Light";
public override bool UseAdditiveBlend => true;
public override bool SetLifetime => true;
private float opacity;
private Color BaseColor;
public GenericBloom(Vector2 position, Vector2 velocity, Color color, float scale, int lifeTime)
{
Position = position;
Velocity = velocity;
BaseColor = color;
Scale = scale;
Lifetime = lifeTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
}
public override void Update()
{
opacity = (float)Math.Sin(LifetimeCompletion * MathHelper.Pi);
Color = BaseColor * opacity;
Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f);
Velocity *= 0.95f;
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D tex = GeneralParticleHandler.GetTexture(Type);
spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * opacity, Rotation, tex.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

+74
View File
@@ -0,0 +1,74 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class HeavySmokeParticle : Particle
{
public override bool SetLifetime => true;
public override int FrameVariants => 7;
public override bool UseCustomDraw => true;
public override bool Important => StrongVisual;
public override bool UseAdditiveBlend => Glowing;
public override bool UseHalfTransparency => !Glowing;
public override string Texture => "CalamityMod/Particles/HeavySmoke";
private float Opacity;
private float Spin;
private bool StrongVisual;
private bool Glowing;
private float HueShift;
static int FrameAmount = 6;
public HeavySmokeParticle(Vector2 position, Vector2 velocity, Color color, int lifetime, float scale, float opacity, float rotationSpeed = 0f, bool glowing = false, float hueshift = 0f, bool required = false)
{
Position = position;
Velocity = velocity;
Color = color;
Scale = scale;
Variant = Main.rand.Next(7);
Lifetime = lifetime;
Opacity = opacity;
Spin = rotationSpeed;
StrongVisual = required;
Glowing = glowing;
HueShift = hueshift;
}
public override void Update()
{
if (Time / (float)Lifetime < 0.2f)
Scale += 0.01f;
else
Scale *= 0.975f;
Color = Main.hslToRgb(Main.rgbToHsl(Color).X + HueShift, Main.rgbToHsl(Color).Y, Main.rgbToHsl(Color).Z);
Opacity *= 0.98f;
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
Velocity *= 0.85f;
float opacity = Utils.InverseLerp(1f, 0.85f, LifetimeCompletion, true);
Color *= opacity;
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D tex = GeneralParticleHandler.GetTexture(Type);
int animationFrame = (int)Math.Floor(Time / ((float)(Lifetime / (float)FrameAmount)));
Rectangle frame = new Rectangle(80 * Variant, 80 * animationFrame, 80, 80);
spriteBatch.Draw(tex, Position - Main.screenPosition, frame, Color * Opacity, Rotation, frame.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

+50
View File
@@ -0,0 +1,50 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class LineVFX : Particle
{
public override string Texture => "CalamityMod/Particles/ThinEndedLine";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
public override bool Important => Telegraph;
public float opacity;
public Vector2 LineVector;
public bool Concave;
public bool Telegraph; //Denotes if the line is used as an enemy telegraph. In that case, it'll be marked as important
public LineVFX(Vector2 startPoint, Vector2 lineVector, float thickness, Color color, bool concave = false, bool telegraph = false)
{
Position = startPoint;
LineVector = lineVector;
Scale = thickness;
Color = color;
Concave = concave;
Telegraph = telegraph;
Velocity = Vector2.Zero;
Rotation = 0;
Lifetime = 2;
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D tex;
if (Concave)
tex = ModContent.GetTexture("CalamityMod/Particles/ThickEndedLine"); //THICC :wearty: weary: :weary : oogogg;... ooog... that line be lookin' mighty fine... :hot:
else
tex = GeneralParticleHandler.GetTexture(Type);
float rot = LineVector.ToRotation() + MathHelper.PiOver2;
Vector2 origin = new Vector2(tex.Width/2f, tex.Height);
Vector2 scale = new Vector2(Scale, LineVector.Length() / tex.Height);
spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color, rot, origin, scale, SpriteEffects.None, 0);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

+57
View File
@@ -0,0 +1,57 @@
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles {
public class MediumMistParticle : Particle
{
public override string Texture => "CalamityMod/Particles/MediumMist";
public override int FrameVariants => 3;
public override bool UseAdditiveBlend => true;
private float Opacity;
private Color ColorFire;
private Color ColorFade;
private float Spin;
public MediumMistParticle(Vector2 position, Vector2 velocity, Color colorFire, Color colorFade, float scale, float opacity, float rotationSpeed = 0f)
{
Position = position;
Velocity = velocity;
ColorFire = colorFire;
ColorFade = colorFade;
Scale = scale;
Opacity = opacity;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
Variant = Main.rand.Next(3);
}
public override void Update()
{
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
Velocity *= 0.85f;
if (Opacity > 90)
{
Lighting.AddLight(Position, Color.ToVector3() * 0.1f);
Scale += 0.01f;
Opacity -= 3;
}
else
{
Scale *= 0.975f;
Opacity -= 2;
}
if (Opacity < 0)
Kill();
Color = Color.Lerp(ColorFire, ColorFade, MathHelper.Clamp((float)((255 -Opacity) - 100) / 80, 0f, 1f)) * (Opacity / 255f);
}
}
}
+5
View File
@@ -71,6 +71,11 @@ namespace CalamityMod.Particles
/// </summary>
public virtual bool UseAdditiveBlend => false;
/// <summary>
/// Set this to true to make your particles work with semi transparent pixels. Is overriden if UseAdditiveBlend is set to true.
/// </summary>
public virtual bool UseHalfTransparency => false;
/// <summary>
/// Removes the particle from the handler
/// </summary>
Binary file not shown.

After

Width:  |  Height:  |  Size: 830 B

+45
View File
@@ -0,0 +1,45 @@
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles {
public class SeaFoamParticle : Particle
{
public override string Texture => "CalamityMod/Particles/SeaFoam";
public override int FrameVariants => 3;
public override bool UseAdditiveBlend => true;
public float Opacity;
private Color ColorStart;
private Color ColorFade;
private float Spin;
private float BaseScale;
public SeaFoamParticle(Vector2 position, Vector2 velocity, Color colorStart, Color colorFade, float scale, float opacity, float rotationSpeed = 1f)
{
Position = position;
Velocity = velocity;
ColorStart = colorStart;
ColorFade = colorFade;
BaseScale = scale;
Opacity = opacity;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
Variant = Main.rand.Next(3);
}
public override void Update()
{
Velocity *= 0.85f;
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
Opacity -= 10;
Scale = BaseScale + Opacity / 255f;
if (Opacity <= 0)
Kill();
Color = Color.Lerp(ColorStart, ColorFade, MathHelper.Clamp((float)((255 -Opacity) - 100) / 80, 0f, 1f)) * (Opacity / 255f);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

+35
View File
@@ -0,0 +1,35 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class SemiCircularSmearVFX : Particle //Also check out Split mod!
{
public override string Texture => "CalamityMod/Particles/SemiCircularSmear";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
public Vector2 Squish;
public SemiCircularSmearVFX(Vector2 position, Color color, float rotation, float scale, Vector2 squish)
{
Position = position;
Velocity = Vector2.Zero;
Color = color;
Scale = scale;
Squish = squish;
Rotation = rotation;
Lifetime = 2;
}
//Use custom draw for the squish
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D tex = GeneralParticleHandler.GetTexture(Type);
spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color, Rotation, tex.Size() / 2f, Squish * Scale, SpriteEffects.None, 0);
}
}
}
+53
View File
@@ -0,0 +1,53 @@
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles {
public class SmallSmokeParticle : Particle
{
public override string Texture => "CalamityMod/Particles/SmallSmoke";
private float Opacity;
private Color ColorFire;
private Color ColorFade;
private float Spin;
public SmallSmokeParticle(Vector2 position, Vector2 velocity, Color colorFire, Color colorFade, float scale, float opacity, float rotationSpeed = 0f)
{
Position = position;
Velocity = velocity;
ColorFire = colorFire;
ColorFade = colorFade;
Scale = scale;
Opacity = opacity;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
}
public override void Update()
{
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
Velocity *= 0.85f;
if (Opacity > 90)
{
Lighting.AddLight(Position, Color.ToVector3() * 0.1f);
Scale += 0.01f;
Opacity -= 3;
}
else
{
Scale *= 0.975f;
Opacity -= 2;
}
if (Opacity < 0)
Kill();
Color = Color.Lerp(ColorFire, ColorFade, MathHelper.Clamp((float)((255 -Opacity) - 100) / 80, 0f, 1f)) * (Opacity / 255f);
}
}
}
+61
View File
@@ -0,0 +1,61 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class SnowflakeSparkle : Particle
{
public override string Texture => "CalamityMod/Particles/HalfIceStar";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
private float Spin;
private float opacity;
private Color Bloom;
private Color LightColor => Bloom * opacity;
private float BloomScale;
private int Spokes;
public SnowflakeSparkle(Vector2 position, Vector2 velocity, Color color, Color bloom, float scale, int lifeTime, float rotationSpeed = 1f, float bloomScale = 1f, int spokes = 3)
{
Position = position;
Velocity = velocity;
Color = color;
Bloom = bloom;
Scale = scale;
Lifetime = lifeTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
BloomScale = bloomScale;
Spokes = spokes;
}
public override void Update()
{
opacity = (float)Math.Sin(LifetimeCompletion * MathHelper.Pi);
Lighting.AddLight(Position, LightColor.R / 255f, LightColor.G / 255f, LightColor.B / 255f);
Velocity *= 0.95f;
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D spokesTexture = GeneralParticleHandler.GetTexture(Type);
Texture2D bloomTexture = ModContent.GetTexture("CalamityMod/Particles/BloomCircle");
//Ajust the bloom's texture to be the same size as the star's
float properBloomSize = (float)spokesTexture.Height / (float)bloomTexture.Height;
spriteBatch.Draw(bloomTexture, Position - Main.screenPosition, null, Bloom * opacity * 0.5f, 0, bloomTexture.Size()/2f, Scale * BloomScale * properBloomSize, SpriteEffects.None, 0);
for (int i = 0; i < Spokes; i++)
{
float rotation = Rotation + MathHelper.Lerp(0f, MathHelper.Pi, i/(float)Spokes);
spriteBatch.Draw(spokesTexture, Position - Main.screenPosition, null, Color * opacity * 0.5f, Rotation + rotation, spokesTexture.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

+40
View File
@@ -0,0 +1,40 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class StoneDebrisParticle : Particle
{
public override string Texture => "CalamityMod/Particles/StoneDebris";
public override bool SetLifetime => true;
public override int FrameVariants => 5;
private float Spin;
private float opacity;
Color originalColor;
public StoneDebrisParticle(Vector2 position, Vector2 velocity, Color color, float scale, int lifeTime, float rotationSpeed = 1f)
{
Position = position;
Velocity = velocity;
Color = color;
originalColor = color;
Scale = scale;
Lifetime = lifeTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
Variant = Main.rand.Next(3);
}
public override void Update()
{
opacity = LifetimeCompletion < 0.5f ? 1f : (float)Math.Sin(LifetimeCompletion * MathHelper.Pi);
Color = originalColor * opacity;
Velocity = Velocity * 0.95f + Vector2.UnitY * 0.1f;
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
}
}
}
+43
View File
@@ -0,0 +1,43 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class StrongBloom : Particle
{
public override string Texture => "CalamityMod/Particles/BloomCircle";
public override bool UseAdditiveBlend => true;
public override bool SetLifetime => true;
private float opacity;
private Color BaseColor;
public StrongBloom(Vector2 position, Vector2 velocity, Color color, float scale, int lifeTime)
{
Position = position;
Velocity = velocity;
BaseColor = color;
Scale = scale;
Lifetime = lifeTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
}
public override void Update()
{
opacity = (float)Math.Sin(LifetimeCompletion * MathHelper.Pi);
Color = BaseColor * opacity;
Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f);
Velocity *= 0.95f;
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D tex = GeneralParticleHandler.GetTexture(Type);
spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * opacity, Rotation, tex.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

+66
View File
@@ -0,0 +1,66 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class ThunderBoltVFX : Particle //Also check out Split mod!
{
public override string Texture => "CalamityMod/Particles/ThunderBolt";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
public Vector2 Squish;
public float ShakePower;
public float Opacity;
public Projectile AttachedProjectile;
public float DisplacementFromProjectile;
public ThunderBoltVFX(Vector2 position, Color color, float rotation, float scale, Vector2 squish, float opacity = 1f, float shakePower = 20f, Projectile projectileToFollow = null, float displacementFromProjectile = 0f)
{
Position = position;
Velocity = Vector2.Zero;
Color = color;
Scale = scale;
Squish = squish;
Rotation = rotation;
Opacity = opacity;
ShakePower = shakePower;
if (projectileToFollow != null)
AttachedProjectile = projectileToFollow;
DisplacementFromProjectile = displacementFromProjectile;
Lifetime = 30;
}
public override void Update()
{
Lighting.AddLight(Position, Color.ToVector3() * 3f);
float fadeFactor = 1f - 0.05f * MathHelper.Clamp((Time - 10) / 10f, 0f, 1f);
Opacity *= fadeFactor;
Squish.X *= fadeFactor;
if (AttachedProjectile != null && AttachedProjectile.active)
Position = AttachedProjectile.Center + Vector2.UnitY * DisplacementFromProjectile;
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D tex = GeneralParticleHandler.GetTexture(Type);
Vector2 Shake = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * (1 - (Time / (float)Lifetime)) * ShakePower;
//The draw happens at the base of the texture
Vector2 Origin = new Vector2(tex.Width / 2f, tex.Height);
Color drawColor = Color.Lerp(Color.White, Color, (Time / (float)Lifetime));
SpriteEffects flip = (Main.GlobalTime % 30 < 15) ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
spriteBatch.Draw(tex, Position + Shake - Main.screenPosition, null, Color * Opacity * 0.6f, Rotation, Origin, Squish * Scale, flip, 0);
spriteBatch.Draw(tex, Position - Main.screenPosition, null, drawColor * Opacity, Rotation, Origin, Squish * Scale, flip, 0);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

+39
View File
@@ -0,0 +1,39 @@
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles {
public class WaterGlobParticle : Particle
{
public override string Texture => "CalamityMod/Particles/WaterGlob";
public override bool SetLifetime => true;
public override bool Important => true;
private float Spin;
public WaterGlobParticle(Vector2 position, Vector2 velocity, float scale, float rotationSpeed = 0f, int lifeTime = 50)
{
Position = position;
Velocity = velocity;
Color = Color.White * 0.5f;
Scale = scale;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
Lifetime = lifeTime;
}
public override void Update()
{
Color *= 0.985f;
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
Velocity *= 0.85f;
Scale *= 0.975f;
}
}
}
-211
View File
@@ -1,211 +0,0 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.CalPlayer;
using CalamityMod.Dusts;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Melee
{
public class BiomeOrb : ModProjectile
{
private int dustType = 3;
Color color = default;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Biome Orb");
ProjectileID.Sets.TrailCacheLength[projectile.type] = 2;
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
}
public override void SetDefaults()
{
projectile.width = 20;
projectile.height = 20;
projectile.aiStyle = 27;
aiType = ProjectileID.LightBeam;
projectile.friendly = true;
projectile.penetrate = 1;
projectile.timeLeft = 300;
projectile.melee = true;
}
public override void AI()
{
Player player = Main.player[projectile.owner];
CalamityPlayer modPlayer = player.Calamity();
bool astral = modPlayer.ZoneAstral;
bool jungle = player.ZoneJungle;
bool snow = player.ZoneSnow;
bool beach = player.ZoneBeach;
bool corrupt = player.ZoneCorrupt;
bool crimson = player.ZoneCrimson;
bool dungeon = player.ZoneDungeon;
bool desert = player.ZoneDesert;
bool glow = player.ZoneGlowshroom;
bool hell = player.ZoneUnderworldHeight;
bool sky = player.ZoneSkyHeight;
bool holy = player.ZoneHoly;
if (astral)
{
dustType = ModContent.DustType<AstralOrange>();
color = new Color(255, 127, 80, projectile.alpha);
}
else if (jungle)
{
dustType = 39;
color = new Color(128, 255, 128, projectile.alpha);
}
else if (snow)
{
dustType = 51;
color = new Color(128, 255, 255, projectile.alpha);
}
else if (beach)
{
dustType = 33;
color = new Color(0, 0, 128, projectile.alpha);
}
else if (corrupt)
{
dustType = 14;
color = new Color(128, 64, 255, projectile.alpha);
}
else if (crimson)
{
dustType = 5;
color = new Color(128, 0, 0, projectile.alpha);
}
else if (dungeon)
{
dustType = 29;
color = new Color(64, 0, 128, projectile.alpha);
}
else if (desert)
{
dustType = 32;
color = new Color(255, 255, 128, projectile.alpha);
}
else if (glow)
{
dustType = 56;
color = new Color(0, 255, 255, projectile.alpha);
}
else if (hell)
{
dustType = 6;
color = new Color(255, 128, 0, projectile.alpha);
}
else if (sky)
{
dustType = 213;
color = new Color(255, 255, 255, projectile.alpha);
}
else if (holy)
{
dustType = 57;
color = new Color(255, 255, 0, projectile.alpha);
}
else
{
color = new Color(0, 128, 0, projectile.alpha);
}
int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 0.9f);
Main.dust[num458].noGravity = true;
Main.dust[num458].velocity *= 0.5f;
Main.dust[num458].velocity += projectile.velocity * 0.1f;
}
public override Color? GetAlpha(Color lightColor)
{
return color;
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
if (projectile.timeLeft > 295)
return false;
CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1);
return false;
}
public override void Kill(int timeLeft)
{
int num3;
for (int num795 = 4; num795 < 31; num795 = num3 + 1)
{
float num796 = projectile.oldVelocity.X * (30f / (float)num795);
float num797 = projectile.oldVelocity.Y * (30f / (float)num795);
int num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, dustType, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.8f);
Main.dust[num798].noGravity = true;
Dust dust = Main.dust[num798];
dust.velocity *= 0.5f;
num798 = Dust.NewDust(new Vector2(projectile.oldPosition.X - num796, projectile.oldPosition.Y - num797), 8, 8, dustType, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default, 1.4f);
dust = Main.dust[num798];
dust.velocity *= 0.05f;
num3 = num795;
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
Player player = Main.player[projectile.owner];
CalamityPlayer modPlayer = player.Calamity();
bool astral = modPlayer.ZoneAstral;
bool jungle = player.ZoneJungle;
bool snow = player.ZoneSnow;
bool beach = player.ZoneBeach;
bool dungeon = player.ZoneDungeon;
bool desert = player.ZoneDesert;
bool glow = player.ZoneGlowshroom;
bool hell = player.ZoneUnderworldHeight;
bool holy = player.ZoneHoly;
int debuffTime = 90;
if (astral)
{
target.AddBuff(ModContent.BuffType<AstralInfectionDebuff>(), debuffTime);
}
else if (jungle)
{
target.AddBuff(BuffID.Venom, debuffTime);
}
else if (snow)
{
target.AddBuff(ModContent.BuffType<GlacialState>(), debuffTime / 3);
}
else if (beach)
{
target.AddBuff(ModContent.BuffType<CrushDepth>(), debuffTime);
}
else if (dungeon)
{
target.AddBuff(BuffID.Frostburn, debuffTime);
}
else if (desert)
{
target.AddBuff(ModContent.BuffType<HolyFlames>(), debuffTime);
}
else if (glow)
{
target.AddBuff(ModContent.BuffType<TemporalSadness>(), debuffTime / 3);
}
else if (hell)
{
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), debuffTime);
}
else if (holy)
{
target.AddBuff(ModContent.BuffType<HolyFlames>(), debuffTime);
}
else
{
target.AddBuff(ModContent.BuffType<ArmorCrunch>(), debuffTime);
}
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 705 B

@@ -0,0 +1,937 @@
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 PurityProjection : ModProjectile //The boring plain one
{
public override string Texture => "CalamityMod/Projectiles/Melee/BrokenBiomeBlade_PurityProjection";
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Purity Projection");
ProjectileID.Sets.TrailCacheLength[projectile.type] = 5;
ProjectileID.Sets.TrailingMode[projectile.type] = 2;
}
public override void SetDefaults()
{
projectile.width = projectile.height = 32;
projectile.aiStyle = 27;
aiType = ProjectileID.LightBeam;
projectile.friendly = true;
projectile.penetrate = 1;
projectile.timeLeft = 40;
projectile.melee = true;
projectile.tileCollide = false;
}
public override void AI()
{
if (projectile.timeLeft < 35)
projectile.tileCollide = true;
Lighting.AddLight(projectile.Center, 0.75f, 1f, 0.24f);
int dustParticle = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.CursedTorch, 0f, 0f, 100, default, 0.9f);
Main.dust[dustParticle].noGravity = true;
Main.dust[dustParticle].velocity *= 0.5f;
Main.dust[dustParticle].velocity += projectile.velocity * 0.1f;
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
if (projectile.timeLeft > 35)
return false;
DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1);
return false;
}
public override void Kill(int timeLeft)
{
Main.PlaySound(SoundID.Item43, projectile.Center);
for (int i = 0; i <= 15; i++)
{
Vector2 displace = (projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * (-0.5f + (i / 15f)) * 88f;
int dustParticle = Dust.NewDust(projectile.Center + displace, projectile.width, projectile.height, DustID.CursedTorch, 0f, 0f, 100, default, 2f);
Main.dust[dustParticle].noGravity = true;
Main.dust[dustParticle].velocity = projectile.oldVelocity;
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
int debuffTime = 90;
target.AddBuff(BuffType<ArmorCrunch>(), debuffTime);
}
}
public class DecaysRetort : ModProjectile
{
public override string Texture => "CalamityMod/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort";
private bool initialized = false;
Vector2 direction = Vector2.Zero;
public ref float MaxTime => ref projectile.ai[0];
public ref float CanLunge => ref projectile.ai[1];
public float Timer => MaxTime - projectile.timeLeft;
public Player Owner => Main.player[projectile.owner];
public const float LungeSpeed = 16;
public ref float CanBounce => ref projectile.localAI[0];
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Decay's retort");
}
public override void SetDefaults()
{
projectile.melee = true;
projectile.width = projectile.height = 84;
projectile.width = projectile.height = 84;
projectile.tileCollide = false;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.extraUpdates = 1;
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
float collisionPoint = 0f;
float bladeLenght = 120f * projectile.scale;
Vector2 displace = direction * ((float)Math.Sin(Timer / MaxTime * 3.14f) * 60);
return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Owner.Center + displace, Owner.Center + displace + (direction * bladeLenght), 24, ref collisionPoint);
}
public override void AI()
{
if (!initialized) //Initialization
{
CanBounce = 1f;
projectile.timeLeft = (int)MaxTime;
direction = Owner.DirectionTo(Main.MouseWorld);
direction.Normalize();
projectile.rotation = direction.ToRotation();
if (CanLunge == 1f)
Lunge();
Main.PlaySound(SoundID.Item103, projectile.Center);
initialized = true;
projectile.netUpdate = true;
projectile.netSpam = 0;
}
//Manage position and rotation
projectile.scale = 1f + ((float)Math.Sin(Timer / MaxTime * MathHelper.Pi) * 0.6f); //SWAGGER
projectile.Center = Owner.Center + (direction * ((float)Math.Sin(Timer / MaxTime * MathHelper.Pi) * 60));
Lighting.AddLight(projectile.Center, new Vector3(0.9f, 0f, 0.35f) * (float)Math.Sin(Timer / MaxTime * MathHelper.Pi));
//Make the owner look like theyre holding the sword bla bla
Owner.heldProj = projectile.whoAmI;
Owner.direction = Math.Sign(direction.X);
Owner.itemRotation = direction.ToRotation();
if (Owner.direction != 1)
{
Owner.itemRotation -= 3.14f;
}
Owner.itemRotation = MathHelper.WrapAngle(Owner.itemRotation);
}
public void Lunge()
{
if (Main.myPlayer != projectile.owner)
return;
Owner.velocity = direction.SafeNormalize(Vector2.UnitX * Owner.direction) * LungeSpeed;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => OnHitEffects(!target.canGhostHeal || Main.player[projectile.owner].moonLeech);
public override void OnHitPvp(Player target, int damage, bool crit) => OnHitEffects(Main.player[projectile.owner].moonLeech);
private void OnHitEffects(bool cannotLifesteal)
{
projectile.netUpdate = true;
projectile.netSpam = 0;
if (!cannotLifesteal) //trolled
{
Owner.statLife += BiomeBlade.EvilAttunement_Lifesteal;
Owner.HealEffect(BiomeBlade.EvilAttunement_Lifesteal); //Idk if its too much or what but at the same time its close range as fuck
}
if (Main.myPlayer != Owner.whoAmI || CanBounce == 0f)
return;
// Bounce off
float bounceStrength = Math.Max((LungeSpeed / 2f), Owner.velocity.Length());
bounceStrength *= Owner.velocity.Y == 0 ? 0.2f : 1f; //Reduce the bounce if the player is on the ground
Owner.velocity = -direction.SafeNormalize(Vector2.Zero) * MathHelper.Clamp(bounceStrength, 0f, 22f);
CanBounce = 0f;
Owner.GiveIFrames(BiomeBlade.EvilAttunement_BounceIFrames); // i frames for free!
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D handle = GetTexture("CalamityMod/Items/Weapons/Melee/BiomeBlade");
Texture2D tex = GetTexture("CalamityMod/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort");
float drawAngle = direction.ToRotation();
float drawRotation = drawAngle + MathHelper.PiOver4;
Vector2 displace = direction * ((float)Math.Sin(Timer / MaxTime * 3.14f) * 60);
Vector2 drawOrigin = new Vector2(0f, handle.Height);
Vector2 drawOffset = Owner.Center + direction * 10f - Main.screenPosition;
spriteBatch.Draw(handle, drawOffset + displace, 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, tex.Height);
drawOffset = Owner.Center + (drawAngle.ToRotationVector2() * 24f * projectile.scale) - Main.screenPosition;
spriteBatch.Draw(tex, drawOffset + displace, null, Color.Lerp(Color.White, lightColor, 0.5f) * 0.9f, drawRotation, drawOrigin, projectile.scale, 0f, 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;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(initialized);
writer.WriteVector2(direction);
writer.Write(CanBounce);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
initialized = reader.ReadBoolean();
direction = reader.ReadVector2();
CanBounce = reader.ReadSingle();
}
}
public class BitingEmbrace : ModProjectile
{
public override string Texture => "CalamityMod/Projectiles/Melee/BrokenBiomeBlade_BitingEmbraceSmall";
private bool initialized = false;
Vector2 direction = Vector2.Zero;
public float rotation;
public ref float SwingMode => ref projectile.ai[0]; //0 = Up-Down small slash, 1 = Down-Up large slash, 2 = Thrust
public ref float MaxTime => ref projectile.ai[1];
public float Timer => MaxTime - projectile.timeLeft;
public int SwingDirection
{
get
{
switch (SwingMode)
{
case 0:
return -1 * Math.Sign(direction.X);
case 1:
return 1 * Math.Sign(direction.X);
default:
return 0;
}
}
}
public float SwingWidth
{
get
{
switch (SwingMode)
{
case 0:
return 2.3f;
default:
return 1.8f;
}
}
}
public Player Owner => Main.player[projectile.owner];
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Biting Embrace");
Main.projFrames[projectile.type] = 6; //The true trolling is that we only really use this for the third swing.
}
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;
projectile.extraUpdates = 1;
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
//The hitbox is simplified into a line collision.
float collisionPoint = 0f;
float bladeLenght = 0f;
Vector2 displace = Vector2.Zero;
switch (SwingMode)
{
case 0:
bladeLenght = 90f * projectile.scale;
break;
case 1:
bladeLenght = 110f * projectile.scale;
break;
case 2:
bladeLenght = projectile.frame <= 2 ? 85f : 150f; //Only use the extended hitbox after the blade actually extends. For realism.
bladeLenght *= projectile.scale;
displace = direction * ThrustDisplaceRatio() * 60f;
break;
}
return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Owner.Center + displace, Owner.Center + displace + (rotation.ToRotationVector2() * bladeLenght), 24, ref collisionPoint);
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
base.OnHitNPC(target, damage, knockback, crit);
if (SwingMode == 2)
target.AddBuff(BuffType<GlacialState>(), 20);
}
public override void AI()
{
if (!initialized) //Initialization
{
projectile.timeLeft = (int)MaxTime;
switch (SwingMode)
{
case 0:
projectile.width = projectile.height = 100;
Main.PlaySound(SoundID.DD2_MonkStaffSwing, projectile.Center);
break;
case 1:
projectile.width = projectile.height = 140;
Main.PlaySound(SoundID.DD2_OgreSpit, projectile.Center);
projectile.damage = (int)(projectile.damage * BiomeBlade.ColdAttunement_SecondSwingBoost);
break;
case 2:
projectile.width = projectile.height = 130;
Main.PlaySound(SoundID.DD2_PhantomPhoenixShot, projectile.Center);
projectile.damage = (int)(projectile.damage * BiomeBlade.ColdAttunement_ThirdSwingBoost);
break;
}
//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
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 + (direction * 30);
//rotation = projectile.rotation + MathHelper.SmoothStep(SwingWidth / 2 * SwingDirection, -SwingWidth / 2 * SwingDirection, Timer / MaxTime);
float factor = 1 - (float)Math.Pow((double)-(Timer / MaxTime) + 1, 2d);
rotation = projectile.rotation + MathHelper.Lerp(SwingWidth / 2 * SwingDirection, -SwingWidth / 2 * SwingDirection, factor);
projectile.scale = 1f + ((float)Math.Sin(Timer / MaxTime * MathHelper.Pi) * 0.6f); //SWAGGER
Lighting.AddLight(Owner.MountedCenter, new Vector3(0.75f, 1f, 1f) * (float)Math.Sin(Timer/MaxTime * MathHelper.Pi));
//Add the thrust motion & animation for the third combo state
if (SwingMode == 2)
{
projectile.scale = 1f + (ThrustScaleRatio() * 0.6f);
projectile.Center = Owner.Center + (direction * ThrustDisplaceRatio() * 60);
projectile.frameCounter++;
if (projectile.frameCounter % 5 == 0 && projectile.frame + 1 < Main.projFrames[projectile.type])
projectile.frame++;
if (Main.rand.NextBool())
{
Particle mist = new MediumMistParticle(Owner.Center + direction * 40 + Main.rand.NextVector2Circular(30f, 30f), Vector2.Zero, new Color(172, 238, 255), new Color(145, 170, 188), Main.rand.NextFloat(0.5f, 1.5f), 245 - Main.rand.Next(50), 0.02f);
mist.Velocity = (mist.Position - Owner.Center) * 0.2f + Owner.velocity;
GeneralParticleHandler.SpawnParticle(mist);
}
}
else if (Main.rand.NextFloat(0f, 1f) > 0.75f)
{
Vector2 particlePosition = Owner.Center + (rotation.ToRotationVector2() * 100f * projectile.scale);
Particle snowflake = new SnowflakeSparkle(particlePosition, rotation.ToRotationVector2() * 3f, Color.White, new Color(75, 177, 250), Main.rand.NextFloat(0.3f, 1.5f), 40, 0.5f);
GeneralParticleHandler.SpawnParticle(snowflake);
}
//Make the owner look like theyre holding the sword bla bla
Owner.heldProj = projectile.whoAmI;
Owner.direction = Math.Sign(rotation.ToRotationVector2().X);
Owner.itemRotation = rotation;
if (Owner.direction != 1)
{
Owner.itemRotation -= 3.14f;
}
Owner.itemRotation = MathHelper.WrapAngle(Owner.itemRotation);
}
//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 });
//Animation keys
public CurveSegment expandSize = new CurveSegment(EasingType.ExpIn, 0f, 0f, 1f);
public CurveSegment holdSize = new CurveSegment(EasingType.Linear, 0.1f, 1f, 0f);
public CurveSegment shrinkSize = new CurveSegment(EasingType.ExpIn, 0.85f, 1f, -1f);
internal float ThrustScaleRatio() => PiecewiseAnimation(Timer / MaxTime, new CurveSegment[] { expandSize, holdSize, shrinkSize });
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D handle = GetTexture("CalamityMod/Items/Weapons/Melee/BiomeBlade");
if (SwingMode != 2)
{
Texture2D blade = GetTexture("CalamityMod/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace" + (SwingMode == 0 ? "Small" : "Big"));
float drawAngle = rotation;
float drawRotation = rotation + MathHelper.PiOver4;
Vector2 drawOrigin = new Vector2(0f, handle.Height);
Vector2 drawOffset = Owner.Center + drawAngle.ToRotationVector2() * 10f - 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);
drawOffset = Owner.Center + (drawAngle.ToRotationVector2() * 28f * projectile.scale) - Main.screenPosition;
spriteBatch.Draw(blade, drawOffset, null, Color.Lerp(Color.White, lightColor, 0.5f) * 0.8f, drawRotation, drawOrigin, projectile.scale, 0f, 0f);
//Back to normal
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
}
else
{
Texture2D blade = GetTexture("CalamityMod/Projectiles/Melee/BrokenBiomeBlade_BitingEmbraceThrust");
Vector2 thrustDisplace = direction * (ThrustDisplaceRatio() * 60);
float drawAngle = rotation;
float drawRotation = rotation + MathHelper.PiOver4;
Vector2 drawOrigin = new Vector2(0f, handle.Height);
Vector2 drawOffset = Owner.Center + drawAngle.ToRotationVector2() * 10f - Main.screenPosition;
spriteBatch.Draw(handle, drawOffset + thrustDisplace, 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, 114f);
drawOffset = Owner.Center + (direction * 28f * projectile.scale) - Main.screenPosition;
//Anim stuff
Rectangle frameRectangle = new Rectangle(0, 0 + (116 * projectile.frame), 114, 114);
spriteBatch.Draw(blade, drawOffset + thrustDisplace, frameRectangle, Color.Lerp(Color.White, lightColor, 0.5f) * 0.9f, drawRotation, drawOrigin, projectile.scale, 0f, 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;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(initialized);
writer.WriteVector2(direction);
writer.Write(rotation);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
initialized = reader.ReadBoolean();
direction = reader.ReadVector2();
rotation = reader.ReadSingle();
}
}
public class AridGrandeur : ModProjectile
{
public override string Texture => "CalamityMod/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur";
private bool initialized = false;
Vector2 direction = Vector2.Zero;
public ref float Shred => ref projectile.ai[0]; //How much the attack is, attacking
public float ShredRatio => MathHelper.Clamp(Shred / (maxShred * 0.5f), 0f, 1f);
public ref float PogoCooldown => ref projectile.ai[1]; //Cooldown for the pogo
public Player Owner => Main.player[projectile.owner];
public bool CanPogo => Owner.velocity.Y != 0 && PogoCooldown <= 0; //Only pogo when in the air and if the cooldown is zero
private bool OwnerCanShoot => Owner.channel && !Owner.noItems && !Owner.CCed;
public const float pogoStrenght = 16f; //How much the player gets pogoed up
public const float maxShred = 500; //How much shred you get
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Arid Grandeur");
}
public override void SetDefaults()
{
projectile.melee = true;
projectile.width = projectile.height = 70;
projectile.tileCollide = false;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.extraUpdates = 1;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = BiomeBlade.HotAttunement_LocalIFrames;
}
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
{
float collisionPoint = 0f;
float bladeLenght = 84 * projectile.scale;
float bladeWidth = 76 * projectile.scale;
return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Owner.Center, Owner.Center + (direction * bladeLenght), bladeWidth, ref collisionPoint);
}
public void Pogo()
{
if (CanPogo && Main.myPlayer == Owner.whoAmI)
{
Owner.velocity = -direction.SafeNormalize(Vector2.Zero) * pogoStrenght; //Bounce
Owner.fallStart = (int)(Owner.position.Y / 16f);
PogoCooldown = 30; //Cooldown
Main.PlaySound(SoundID.DD2_MonkStaffGroundImpact, projectile.position);
Vector2 hitPosition = Owner.Center + (direction * 84 * projectile.scale);
for (int i = 0; i < 8; i++)
{
Vector2 hitPositionDisplace = direction.RotatedBy(MathHelper.PiOver2) * Main.rand.NextFloat(-10f, 10f);
Vector2 flyDirection = -direction.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4));
Particle smoke = new SmallSmokeParticle(hitPosition + hitPositionDisplace, flyDirection * 9f, Color.OrangeRed, new Color(130, 130, 130), Main.rand.NextFloat(1.8f, 2.6f), 115 - Main.rand.Next(30));
GeneralParticleHandler.SpawnParticle(smoke);
Particle Glow = new StrongBloom(hitPosition - hitPositionDisplace * 3, -direction * 6 * Main.rand.NextFloat(0.5f, 1f), Color.Orange * 0.5f, 0.01f + Main.rand.NextFloat(0f, 0.2f), 20 + Main.rand.Next(40));
GeneralParticleHandler.SpawnParticle(Glow);
}
for (int i = 0; i < 3; i++)
{
Vector2 hitPositionDisplace = direction.RotatedBy(MathHelper.PiOver2) * Main.rand.NextFloat(-10f, 10f);
Vector2 flyDirection = -direction.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4));
Particle Rock = new StoneDebrisParticle(hitPosition - hitPositionDisplace * 3, flyDirection * Main.rand.NextFloat(3f, 6f), Color.Beige, 1f + Main.rand.NextFloat(0f, 0.4f), 30 + Main.rand.Next(50), 0.1f);
GeneralParticleHandler.SpawnParticle(Rock);
}
if (Owner.HeldItem.type == ItemType<BiomeBlade>())
(Owner.HeldItem.modItem as BiomeBlade).CanLunge = 1; // Reset the lunge counter on pogo. This should make for more interesting and fun synergies
}
}
public override void AI()
{
if (!initialized) //Initialization. Here its litterally just playing a sound tho lmfao
{
Main.PlaySound(SoundID.Item90, projectile.Center);
initialized = true;
}
if (!OwnerCanShoot)
{
projectile.Kill();
return;
}
if (Shred >= maxShred)
Shred = maxShred;
if (Shred < 0)
Shred = 0;
Lighting.AddLight(projectile.Center, new Vector3(1f, 0.56f, 0.56f) * ShredRatio);
//Manage position and rotation
direction = Owner.DirectionTo(Main.MouseWorld);
direction.Normalize();
projectile.rotation = direction.ToRotation();
projectile.Center = Owner.Center + (direction * 60);
//Scaling based on shred
projectile.localNPCHitCooldown = BiomeBlade.HotAttunement_LocalIFrames - (int)(MathHelper.Lerp(0, BiomeBlade.HotAttunement_LocalIFrames - BiomeBlade.HotAttunement_LocalIFramesCharged, ShredRatio)); //Increase the hit frequency
projectile.scale = 1f + (ShredRatio * 1f); //SWAGGER
if (Collision.SolidCollision(Owner.Center + (direction * 84 * projectile.scale) - Vector2.One * 5f, 10, 10))
{
Pogo();
projectile.netUpdate = true;
projectile.netSpam = 0;
}
//Make the owner look like theyre holding the sword bla bla
Owner.heldProj = projectile.whoAmI;
Owner.direction = Math.Sign(direction.X);
Owner.itemRotation = direction.ToRotation();
if (Owner.direction != 1)
{
Owner.itemRotation -= 3.14f;
}
Owner.itemRotation = MathHelper.WrapAngle(Owner.itemRotation);
Owner.itemTime = 2;
Owner.itemAnimation = 2;
Shred--;
PogoCooldown--;
projectile.timeLeft = 2;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => ShredTarget(target);
public override void OnHitPvp(Player target, int damage, bool crit) => ShredTarget(target);
private void ShredTarget(Entity target)
{
if (Main.myPlayer != Owner.whoAmI)
return;
// get lifted up
if (PogoCooldown <= 0)
{
Main.PlaySound(SoundID.NPCHit30, projectile.Center); //Sizzle
Shred += 62; //Augment the shredspeed
if (Owner.velocity.Y > 0)
Owner.velocity.Y = -2f; //Get "stuck" into the enemy partly
Owner.GiveIFrames(BiomeBlade.HotAttunement_ShredIFrames); // i framez.
PogoCooldown = 20;
}
}
public override void Kill(int timeLeft)
{
Main.PlaySound(SoundID.NPCHit43, projectile.Center);
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D handle = GetTexture("CalamityMod/Items/Weapons/Melee/BiomeBlade");
Texture2D blade = GetTexture("CalamityMod/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur");
int bladeAmount = 4;
float drawAngle = direction.ToRotation();
float drawRotation = drawAngle + MathHelper.PiOver4;
Vector2 drawOrigin = new Vector2(0f, handle.Height);
Vector2 drawOffset = Owner.Center + direction * 10f - 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);
drawOffset = Owner.Center + (drawAngle.ToRotationVector2() * 32f * projectile.scale) - Main.screenPosition;
spriteBatch.Draw(blade, drawOffset, null, Color.Lerp(Color.White, lightColor, 0.5f) * 0.9f, drawRotation, drawOrigin, projectile.scale, 0f, 0f);
for (int i = 0; i < bladeAmount; i++) //Draw extra copies
{
blade = GetTexture("CalamityMod/Projectiles/Melee/BrokenBiomeBlade_AridGrandeurExtra");
drawAngle = direction.ToRotation();
float circleCompletion = (float)Math.Sin(Main.GlobalTime * 5 + i * MathHelper.PiOver2);
drawRotation = drawAngle + MathHelper.PiOver4 + (circleCompletion * MathHelper.Pi / 10f) - (circleCompletion * (MathHelper.Pi / 7f) * ShredRatio);
drawOrigin = new Vector2(0f, blade.Height);
Vector2 drawOffsetStraight = Owner.Center + direction * (float)Math.Sin(Main.GlobalTime * 7) * 10 - Main.screenPosition; //How far from the player
Vector2 drawDisplacementAngle = direction.RotatedBy(MathHelper.PiOver2) * circleCompletion.ToRotationVector2().Y * (20 + 40 * ShredRatio); //How far perpendicularly
spriteBatch.Draw(blade, drawOffsetStraight + drawDisplacementAngle, null, Color.Lerp(Color.White, lightColor, 0.5f) * 0.8f, drawRotation, drawOrigin, projectile.scale, 0f, 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;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(initialized);
writer.WriteVector2(direction);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
initialized = reader.ReadBoolean();
direction = reader.ReadVector2();
}
}
public class GrovetendersTouch : ModProjectile
{
public override string Texture => "CalamityMod/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouchBlade";
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];
const float MaxTime = 90;
const int coyoteTimeFrames = 15; //How many frames does the whip stay extended
const int MaxReach = 400;
const float SnappingPoint = 0.7f; //When does the snap occur.
const float ReelBackStrenght = 14f;
public BezierCurve curve;
private Vector2 controlPoint1;
private Vector2 controlPoint2;
internal bool ReelingBack => Timer / MaxTime > SnappingPoint;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Grovetender's Touch");
}
public override void SetDefaults()
{
projectile.melee = true;
projectile.width = projectile.height = 36;
projectile.tileCollide = false;
projectile.friendly = true;
projectile.penetrate = -1;
projectile.extraUpdates = 2;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = BiomeBlade.TropicalAttunement_LocalIFrames;
}
public override bool? CanCutTiles() => false; //Itd be quite counterproductive to make the whip cut the tiles it just grew
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;
}
return base.Colliding(projHitbox, targetHitbox);
}
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
{
base.ModifyHitNPC(target, ref damage, ref knockback, ref crit, ref hitDirection);
Vector2 projectileHalfLenght = (projectile.Size / 2f) * 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 < 3; 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 * BiomeBlade.TropicalAttunement_ChainDamageReduction); //If the enemy is hit with the chain of the whip, the damage gets reduced
}
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.Item41, projectile.Center); //Snap
HasSnapped = 1f;
SnapCoyoteTime = coyoteTimeFrames;
}
if (SnapCoyoteTime > 0) //keep checking for the tile hook
{
Lighting.AddLight(projectile.Center, 0.8f, 1f, 0.35f);
HookToTile();
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 = -Owner.direction;
Owner.itemRotation = MathHelper.WrapAngle(Owner.AngleTo(Main.MouseWorld) - (Owner.direction < 0 ? MathHelper.Pi : 0));
}
public void HookToTile()
{
if (Main.myPlayer == Owner.whoAmI)
{
//Shmoove the player if a tile is hit. This movement always happens if the owner isnt on the ground, but will only happen if the projectile is above the player if they are standing on the ground)
if (Collision.SolidCollision(projectile.position, 32, 32) && (Owner.velocity.Y != 0 || projectile.position.Y < Owner.position.Y))
{
Owner.velocity = Owner.DirectionTo(projectile.Center) * ReelBackStrenght;
SnapCoyoteTime = 0f;
}
Main.PlaySound(SoundID.Item65, projectile.position);
}
}
internal float EaseInFunction(float progress) => progress == 0 ? 0f : (float)Math.Pow(2, 10 * progress - 10); //Potion seller i need your strongest easeIns
private float GetSwingRatio()
{
float ratio = (Timer - SnappingPoint * MaxTime) / (MaxTime * (1 - SnappingPoint)); //The ratio for the last section of the snap is a new curve.
if (!ReelingBack)
ratio = EaseInFunction(Timer / (MaxTime * SnappingPoint)); //Watch this ratio get eased
if (SnapCoyoteTime > 0)
ratio = 0f;
return ratio;
}
private Vector2 SwingPosition(float progress)
{
//Whip windup and snap part
if (!ReelingBack)
{
float distance = MaxReach * MathHelper.Lerp((float)Math.Sin(progress * MathHelper.PiOver2), 1, 0.04f); //half arc
distance = Math.Max(distance, 65); //Dont be too close to player
float angleDeviation = MathHelper.Pi / 1.2f;
float angleOffset = Owner.direction * MathHelper.Lerp(-angleDeviation, 0, progress); //Go from very angled to straight at the zenith of the attack
return projectile.velocity.RotatedBy(angleOffset) * distance;
}
else
{
float distance = MathHelper.Lerp(MaxReach, 0f, progress); //Quickly zip back to the player . No angles or minimum distance from player.
return projectile.velocity * distance;
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
if (Timer == 0)
return false;
Texture2D handle = GetTexture("CalamityMod/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouchBlade");
Texture2D blade = GetTexture("CalamityMod/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouchGlow");
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 += SnapCoyoteTime > 0 ? MathHelper.Pi : 0; //During coyote time the blade flips for some reason. Prevent that from happening
drawRotation += projectile.spriteDirection < 0 ? 0f : 0f;
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, 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, 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/BrokenBiomeBlade_GrovetendersTouchChain");
float ratio = GetSwingRatio();
if (!ReelingBack) //Make the curve be formed from points slightly ahead of the projectile, but clamped to the max rotation (straight line ahead)
{
controlPoint1 = Owner.MountedCenter + SwingPosition(MathHelper.Clamp(ratio + 0.5f, 0f, 1f)) * 0.2f;
controlPoint2 = Owner.MountedCenter + SwingPosition(MathHelper.Clamp(ratio + 0.2f, 0f, 1f)) * 0.5f;
}
else //After the whip snaps, make the curve be a wave
{
Vector2 perpendicular = SwingPosition(ratio).SafeNormalize(Vector2.Zero).RotatedBy(MathHelper.PiOver2);
controlPoint1 = Owner.MountedCenter + SwingPosition(MathHelper.Lerp(ratio, 1f, ratio)) + perpendicular * MathHelper.SmoothStep(0f, 1f, ratio) * -155f;
controlPoint2 = Owner.MountedCenter + SwingPosition(MathHelper.Lerp(ratio, 1f, ratio / 2)) + perpendicular * MathHelper.SmoothStep(0f, 1f, ratio) * 100f;
}
BezierCurve curve = new BezierCurve(new Vector2[] { Owner.MountedCenter, controlPoint1, controlPoint2, projBottom });
int numPoints = 30; //"Should make dynamic based on curve length, but I'm not sure how to smoothly do that while using a bezier curve" -Graydee, from the code i referenced. I do agree.
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
if (ReelingBack)
chainLightColor *= 1 - EaseInFunction(ratio); //Make the chain fade when reeling it back
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);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
initialized = reader.ReadBoolean();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 760 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

-279
View File
@@ -1,279 +0,0 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Buffs.Potions;
using CalamityMod.CalPlayer;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Melee
{
public class Galaxia : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Orb");
ProjectileID.Sets.TrailCacheLength[projectile.type] = 6;
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
}
public override void SetDefaults()
{
projectile.width = 24;
projectile.height = 24;
projectile.friendly = true;
projectile.tileCollide = false;
projectile.ignoreWater = true;
projectile.alpha = 50;
projectile.penetrate = 3;
projectile.timeLeft = 240;
projectile.melee = true;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 10;
}
public override void AI()
{
if (projectile.soundDelay == 0)
{
projectile.soundDelay = 20 + Main.rand.Next(40);
if (Main.rand.NextBool(5))
{
Main.PlaySound(SoundID.Item9, projectile.position);
}
}
projectile.alpha -= 15;
int num58 = 150;
if (projectile.Center.Y >= projectile.ai[1])
{
num58 = 0;
}
if (projectile.alpha < num58)
{
projectile.alpha = num58;
}
projectile.localAI[0] += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction;
projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f * (float)projectile.direction;
if (Main.rand.NextBool(8))
{
Vector2 value3 = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)projectile.velocity.ToRotation(), default);
int num59 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 66, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.2f);
Main.dust[num59].noGravity = true;
Main.dust[num59].velocity = value3 * 0.66f;
Main.dust[num59].position = projectile.Center + value3 * 12f;
}
if (Main.rand.NextBool(24))
{
int num60 = Gore.NewGore(projectile.Center, new Vector2(projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f), 16, 1f);
Main.gore[num60].velocity *= 0.66f;
Main.gore[num60].velocity += projectile.velocity * 0.3f;
}
if (projectile.ai[1] == 1f)
{
projectile.light = 0.9f;
if (Main.rand.NextBool(5))
{
int num59 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 66, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.2f);
Main.dust[num59].noGravity = true;
}
if (Main.rand.NextBool(10))
{
Gore.NewGore(projectile.position, new Vector2(projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f), Main.rand.Next(16, 18), 1f);
}
}
CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 300f, 12f, 20f);
}
public override Color? GetAlpha(Color lightColor)
{
return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, projectile.alpha);
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1);
return false;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
Player player = Main.player[projectile.owner];
CalamityPlayer modPlayer = player.Calamity();
bool astral = modPlayer.ZoneAstral;
bool jungle = player.ZoneJungle;
bool snow = player.ZoneSnow;
bool beach = player.ZoneBeach;
bool corrupt = player.ZoneCorrupt;
bool crimson = player.ZoneCrimson;
bool dungeon = player.ZoneDungeon;
bool desert = player.ZoneDesert;
bool glow = player.ZoneGlowshroom;
bool hell = player.ZoneUnderworldHeight;
bool holy = player.ZoneHoly;
bool nebula = player.ZoneTowerNebula;
bool stardust = player.ZoneTowerStardust;
bool solar = player.ZoneTowerSolar;
bool vortex = player.ZoneTowerVortex;
bool bloodMoon = Main.bloodMoon;
bool snowMoon = Main.snowMoon;
bool pumpkinMoon = Main.pumpkinMoon;
int duration = 180;
if (bloodMoon)
{
player.AddBuff(BuffID.Battle, duration);
}
if (snowMoon)
{
player.AddBuff(BuffID.RapidHealing, duration);
}
if (pumpkinMoon)
{
player.AddBuff(BuffID.WellFed, duration);
}
if (astral)
{
target.AddBuff(ModContent.BuffType<AstralInfectionDebuff>(), duration);
player.AddBuff(ModContent.BuffType<GravityNormalizerBuff>(), duration);
int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ModContent.ProjectileType<AstralStar>(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
if (proj.WithinBounds(Main.maxProjectiles))
Main.projectile[proj].Calamity().forceMelee = true;
}
else if (jungle)
{
target.AddBuff(ModContent.BuffType<Plague>(), duration);
player.AddBuff(BuffID.Thorns, duration);
int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.Leaf, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
if (proj.WithinBounds(Main.maxProjectiles))
Main.projectile[proj].Calamity().forceMelee = true;
}
else if (snow)
{
target.AddBuff(ModContent.BuffType<GlacialState>(), 30);
player.AddBuff(BuffID.Warmth, duration);
Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.IceBolt, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
}
else if (beach)
{
target.AddBuff(ModContent.BuffType<CrushDepth>(), duration);
player.AddBuff(BuffID.Wet, duration);
int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, ProjectileID.FlaironBubble, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
if (proj.WithinBounds(Main.maxProjectiles))
Main.projectile[proj].Calamity().forceMelee = true;
}
else if (corrupt)
{
player.AddBuff(BuffID.Wrath, duration);
int ball = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.CursedFlameFriendly, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
if (ball.WithinBounds(Main.maxProjectiles))
{
Main.projectile[ball].Calamity().forceMelee = true;
Main.projectile[ball].penetrate = 1;
}
}
else if (crimson)
{
player.AddBuff(BuffID.Rage, duration);
int ball = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.GoldenShowerFriendly, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
if (ball.WithinBounds(Main.maxProjectiles))
{
Main.projectile[ball].Calamity().forceMelee = true;
Main.projectile[ball].penetrate = 1;
}
}
else if (dungeon)
{
target.AddBuff(BuffID.Frostburn, duration);
player.AddBuff(BuffID.Dangersense, duration);
int ball = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.WaterBolt, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
if (ball.WithinBounds(Main.maxProjectiles))
{
Main.projectile[ball].Calamity().forceMelee = true;
Main.projectile[ball].penetrate = 1;
}
}
else if (desert)
{
target.AddBuff(ModContent.BuffType<HolyFlames>(), duration);
player.AddBuff(BuffID.Endurance, duration);
int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.BlackBolt, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
if (proj.WithinBounds(Main.maxProjectiles))
Main.projectile[proj].Calamity().forceMelee = true;
}
else if (glow)
{
target.AddBuff(ModContent.BuffType<TemporalSadness>(), 30);
player.AddBuff(BuffID.Spelunker, duration);
int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.Mushroom, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
if (proj.WithinBounds(Main.maxProjectiles))
Main.projectile[proj].Calamity().forceMelee = true;
}
else if (hell)
{
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), duration);
player.AddBuff(BuffID.Inferno, duration);
int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.BallofFire, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
if (proj.WithinBounds(Main.maxProjectiles))
Main.projectile[proj].Calamity().forceMelee = true;
}
else if (holy)
{
target.AddBuff(ModContent.BuffType<HolyFlames>(), duration);
player.AddBuff(BuffID.Heartreach, duration);
int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.RainbowCrystalExplosion, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
if (proj.WithinBounds(Main.maxProjectiles))
{
Main.projectile[proj].Calamity().forceMelee = true;
Main.projectile[proj].usesLocalNPCImmunity = true;
Main.projectile[proj].localNPCHitCooldown = -1;
}
}
else if (nebula)
{
player.AddBuff(BuffID.MagicPower, duration);
int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.NebulaBlaze1, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
if (proj.WithinBounds(Main.maxProjectiles))
Main.projectile[proj].Calamity().forceMelee = true;
}
else if (stardust)
{
player.AddBuff(BuffID.Summoning, duration);
int ball = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.StardustCellMinionShot, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
if (ball.WithinBounds(Main.maxProjectiles))
{
Main.projectile[ball].Calamity().forceMelee = true;
Main.projectile[ball].penetrate = 1;
}
}
else if (solar)
{
player.AddBuff(BuffID.Titan, duration);
Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.SolarWhipSwordExplosion, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f);
}
else if (vortex)
{
player.AddBuff(BuffID.AmmoReservation, duration);
int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.VortexBeaterRocket, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
if (proj.WithinBounds(Main.maxProjectiles))
{
Main.projectile[proj].Calamity().forceMelee = true;
Main.projectile[proj].usesLocalNPCImmunity = true;
Main.projectile[proj].localNPCHitCooldown = -1;
}
}
else
{
target.AddBuff(ModContent.BuffType<ArmorCrunch>(), duration);
player.AddBuff(BuffID.DryadsWard, duration);
int ball = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.TerrarianBeam, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
if (ball.WithinBounds(Main.maxProjectiles))
{
Main.projectile[ball].penetrate = 1;
}
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

File diff suppressed because it is too large. Load diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

File diff suppressed because it is too large. Load diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 970 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

Loaded 100 of 130 files, more files were not shown because too many files have changed in this diff. Show more