From c74963e9ca86c93a343ed509dbaeb3ce98ff9b02 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sun, 5 Apr 2020 19:47:46 -0400 Subject: [PATCH] internally renamed dance of light & nerfed flash --- Items/CalamityGlobalItem.cs | 4 +- .../{TheDanceofLight.cs => Judgement.cs} | 2 +- .../{TheDanceofLight.png => Judgement.png} | Bin ModSupport/WeakReferenceSupport.cs | 2 +- NPCs/SupremeCalamitas/SupremeCalamitas.cs | 2 +- Projectiles/Magic/BlindingLight.cs | 47 ++++++++++++++---- Projectiles/Magic/LightBlade.cs | 8 +-- 7 files changed, 46 insertions(+), 19 deletions(-) rename Items/Weapons/Magic/{TheDanceofLight.cs => Judgement.cs} (98%) rename Items/Weapons/Magic/{TheDanceofLight.png => Judgement.png} (100%) diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 3b28398042..17f7bcd7aa 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -846,8 +846,8 @@ namespace CalamityMod.Items tt2.overrideColor = new Color(Main.DiscoR, 100, 255); if (item.type == ModContent.ItemType()) tt2.overrideColor = new Color(0, 0, 255); - if (item.type == ModContent.ItemType()) - tt2.overrideColor = TheDanceofLight.GetSyncedLightColor(); + if (item.type == ModContent.ItemType()) + tt2.overrideColor = Judgement.GetSyncedLightColor(); if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) tt2.overrideColor = new Color(0.34f, 0.34f + 0.66f * Main.DiscoG / 255f, 0.34f + 0.5f * Main.DiscoG / 255f); if (item.type == ModContent.ItemType()) diff --git a/Items/Weapons/Magic/TheDanceofLight.cs b/Items/Weapons/Magic/Judgement.cs similarity index 98% rename from Items/Weapons/Magic/TheDanceofLight.cs rename to Items/Weapons/Magic/Judgement.cs index db646e7d37..50a9903fd5 100644 --- a/Items/Weapons/Magic/TheDanceofLight.cs +++ b/Items/Weapons/Magic/Judgement.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class TheDanceofLight : ModItem + public class Judgement : ModItem { public const int HitsPerFlash = 300; public const int FlashBaseDamage = 80000; diff --git a/Items/Weapons/Magic/TheDanceofLight.png b/Items/Weapons/Magic/Judgement.png similarity index 100% rename from Items/Weapons/Magic/TheDanceofLight.png rename to Items/Weapons/Magic/Judgement.png diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index a084a6fa83..df8bd2dd4f 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -534,7 +534,7 @@ namespace CalamityMod BossDifficulty.TryGetValue("SupremeCalamitas", out float order); int type = NPCType(); int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; List collection = new List() { ItemType(), ItemType(), ItemType() }; string instructions = $"Use an [i:{summon}]"; string despawn = CalamityUtils.ColorMessage("Please don't waste my time.", new Color(0xFF, 0xA5, 0x00)); diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 8470366d9b..9c80bb8839 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -2165,7 +2165,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), // Staff of Blushie ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), // Voidragon ModContent.ItemType(), ModContent.ItemType(), diff --git a/Projectiles/Magic/BlindingLight.cs b/Projectiles/Magic/BlindingLight.cs index 8c1314463d..4c2bcb7e5c 100644 --- a/Projectiles/Magic/BlindingLight.cs +++ b/Projectiles/Magic/BlindingLight.cs @@ -30,10 +30,10 @@ namespace CalamityMod.Projectiles.Magic public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { - float dist1 = Vector2.Distance(projectile.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(projectile.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(projectile.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(projectile.Center, targetHitbox.BottomRight()); + float dist1 = projectile.Distance(targetHitbox.TopLeft()); + float dist2 = projectile.Distance(targetHitbox.TopRight()); + float dist3 = projectile.Distance(targetHitbox.BottomLeft()); + float dist4 = projectile.Distance(targetHitbox.BottomRight()); float minDist = dist1; if (dist2 < minDist) @@ -51,7 +51,10 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { if (projectile.timeLeft == Lifetime) + { ConsumeNearbyBlades(); + DivideDamageAmongstTargets(); + } projectile.ai[0]++; float progress = (float)Math.Sin(projectile.ai[0] / Lifetime * MathHelper.Pi); @@ -66,22 +69,46 @@ namespace CalamityMod.Projectiles.Magic Filters.Scene["CalamityMod:LightBurst"].GetShader().UseProgress(progress); } } - public override void Kill(int timeLeft) - { - Filters.Scene.Deactivate("CalamityMod:LightBurst"); - } + + public override void Kill(int timeLeft) => Filters.Scene.Deactivate("CalamityMod:LightBurst"); + private void ConsumeNearbyBlades() { int lightBlade = ModContent.ProjectileType(); + int extraDamage = 0; for (int i = 0; i < Main.maxProjectiles; ++i) { Projectile otherProj = Main.projectile[i]; if (otherProj is null || !otherProj.active || otherProj.owner != projectile.owner || otherProj.type != lightBlade) continue; - projectile.damage += otherProj.damage; + // Can only consume blades within the flash radius (which should be most if not all of them anyway) + if (projectile.Distance(otherProj.Center) > Radius) + continue; + extraDamage += otherProj.damage / 2; otherProj.Kill(); - } + } + projectile.damage += extraDamage; + } + + private void DivideDamageAmongstTargets() + { + int numTargets = 0; + for(int i = 0; i < Main.maxNPCs; ++i) + { + NPC npc = Main.npc[i]; + if (npc is null || !npc.active || npc.friendly || npc.dontTakeDamage || npc.immortal) + continue; + if (projectile.Colliding(default, npc.Hitbox)) + ++numTargets; + } + + // The number of targets is minimum one to prevent dividing by zero. + if (numTargets <= 0) + numTargets = 1; + + // Divide damage by the square root of nearby targets. 25 targets = 1/5th damage, for example. + projectile.damage = (int)(projectile.damage / Math.Sqrt(numTargets)); } } } diff --git a/Projectiles/Magic/LightBlade.cs b/Projectiles/Magic/LightBlade.cs index c51d545c6f..71c43ec66b 100644 --- a/Projectiles/Magic/LightBlade.cs +++ b/Projectiles/Magic/LightBlade.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Magic projectile.ignoreWater = true; projectile.tileCollide = false; projectile.alpha = 255; - projectile.penetrate = 3; + projectile.penetrate = 2; projectile.extraUpdates = 2; projectile.timeLeft = Lifetime; projectile.usesLocalNPCImmunity = true; @@ -87,7 +87,7 @@ namespace CalamityMod.Projectiles.Magic { // Pick a random sword sprite and a random color to use. projectile.frame = Main.rand.Next(14); - lightColor = TheDanceofLight.GetRandomLightColor(); + lightColor = Judgement.GetRandomLightColor(); // Spawn starting dust. Vector2 baseOffsetVec = new Vector2(1f, 4f); @@ -114,12 +114,12 @@ namespace CalamityMod.Projectiles.Magic Player player = Main.player[projectile.owner]; CalamityPlayer calPlayer = player.Calamity(); calPlayer.danceOfLightCharge++; - if (calPlayer.danceOfLightCharge >= TheDanceofLight.HitsPerFlash) + if (calPlayer.danceOfLightCharge >= Judgement.HitsPerFlash) { calPlayer.danceOfLightCharge = 0; if (projectile.owner == Main.myPlayer) { - int flashDamage = (int)(TheDanceofLight.FlashBaseDamage * player.MagicDamage()); + int flashDamage = (int)(Judgement.FlashBaseDamage * player.MagicDamage()); Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), flashDamage, 0f, projectile.owner); } }