diff --git a/Items/Weapons/Summon/AquasScepter.cs b/Items/Weapons/Summon/AquasScepter.cs index dc24133056..2200082cca 100644 --- a/Items/Weapons/Summon/AquasScepter.cs +++ b/Items/Weapons/Summon/AquasScepter.cs @@ -1,4 +1,4 @@ -using CalamityMod.Projectiles.Summon; //God forbid someone has to read all the code relating to this weapon in the future. I salute you. -AquaSG +using CalamityMod.Projectiles.Summon; using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -15,10 +15,10 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetStaticDefaults() { DisplayName.SetDefault("Aqua's Scepter"); - Tooltip.SetDefault("'Captain! I think- we've got a risk of rain!'\n" + //Yes, it's cheesy, I know. It's a joke. - "Summons a giant storm cloud sentry to rain down on your foes, and strike nearby enemies with overloading tesla energy"); + Tooltip.SetDefault("Summons a giant storm cloud sentry to rain down on your foes, and strike nearby enemies with overloading tesla energy\n" + + "'Captain! I think- we've got a risk of rain!'"); //Yes, it's cheesy, I know. It's a joke. - CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1; + CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1; ItemID.Sets.GamepadWholeScreenUseRange[Item.type] = true; ItemID.Sets.LockOnIgnoresCollision[Item.type] = true; } diff --git a/Projectiles/Summon/AquasScepterCloud.cs b/Projectiles/Summon/AquasScepterCloud.cs index b00b31644b..9f954b7ee3 100644 --- a/Projectiles/Summon/AquasScepterCloud.cs +++ b/Projectiles/Summon/AquasScepterCloud.cs @@ -1,16 +1,17 @@ -using Microsoft.Xna.Framework; //God forbid someone has to read all the code relating to this weapon in the future. I salute you. -AquaSG +using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; -using Terraria.ModLoader; using Terraria.Audio; +using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { public class AquasScepterCloud : ModProjectile { - public int LightningTimer; //int that is incremented every loop of AI. This is used for the cooldown of the tesla aura attack. - public int RainTimer; //int that is incremented every loop of AI. This is used for the cooldown between raindrops. - public int UpdateCounter; //int that is incremented every loop of AI. This is used for sprite animation. + public ref float LightningTimer => ref Projectile.ai[0]; + public ref float RainTimer => ref Projectile.ai[1]; + public override void SetStaticDefaults() { DisplayName.SetDefault("Storm Cloud"); // Sets the amount of frames this minion has on its spritesheet @@ -24,7 +25,8 @@ namespace CalamityMod.Projectiles.Summon public sealed override void SetDefaults() { Projectile.width = 252; Projectile.height = 78; - Projectile.tileCollide = false; + Projectile.hide = true; + Projectile.tileCollide = false; Projectile.timeLeft = Projectile.SentryLifeTime; Projectile.friendly = true; Projectile.sentry = true; @@ -34,15 +36,15 @@ namespace CalamityMod.Projectiles.Summon Projectile.light = 1f; } - public override bool? CanCutTiles() { - return false; - } + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + behindProjectiles.Add(index); + behindNPCs.Add(index); + } - public override bool MinionContactDamage() { - return false; - } + public override bool? CanDamage() => false; - public override Color? GetAlpha(Color drawColor) + public override Color? GetAlpha(Color drawColor) { return Color.White; } @@ -54,56 +56,49 @@ namespace CalamityMod.Projectiles.Summon LightningTimer++; RainTimer++; - UpdateCounter++; - if (UpdateCounter % 6 == 0) // Goes to the next frame of cloud animation every 6 frames - { - Projectile.frameCounter++; - Projectile.frame++; - } - if (Projectile.frameCounter >= 5) // Resets the spritesheet to the beginning once it reaches the final frame - { - Projectile.frameCounter = 0; - Projectile.frame = 0; - UpdateCounter = 0; - } - + Projectile.frameCounter++; + if (Projectile.frameCounter >= 6) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame >= Main.projFrames[Projectile.type]) + Projectile.frame = 0; - if (RainTimer >= 3) // Spawns a raindrop every 3 frames, displaced down and randomly along the length of the cloud + if (RainTimer >= 3f) // Spawns a raindrop every 3 frames, displaced down and randomly along the length of the cloud { Projectile.NewProjectile(Projectile.GetSource_FromThis(), (Projectile.Center.X + Main.rand.Next(-110, 111)), (Projectile.Center.Y + 44f), 0f, 15f, ModContent.ProjectileType(), Projectile.damage, 0, Projectile.owner); - RainTimer = 0; + RainTimer = 0f; } - if (!foundTarget) { - for (int i = 0; i < Main.maxNPCs; i++) { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy()) { - float between = Vector2.Distance(npc.Center, Projectile.Center); - bool closest = Vector2.Distance(Projectile.Center, targetCenter) > between; - bool inRange = between < distanceFromTarget; + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; - if ((closest && inRange) || !foundTarget) { - distanceFromTarget = between; - targetCenter = npc.Center; - foundTarget = true; - } - } - } - } - if (foundTarget) { - if (distanceFromTarget < 272f) { - if (LightningTimer >= 60) { //Every 60 AI cycles, plays the lightning sound and spawns 6 projectiles: 3 projectile slot holders, The tesla aura visual, the tesla aura hitbox, and the projectile that simulates the cloud changing brightness. + if (npc.CanBeChasedBy()) + { + float between = Vector2.Distance(npc.Center, Projectile.Center); + bool closest = Vector2.Distance(Projectile.Center, targetCenter) > between; + bool inRange = between < distanceFromTarget; + + if ((closest && inRange) || !foundTarget) + { + distanceFromTarget = between; + targetCenter = npc.Center; + foundTarget = true; + } + } + } + if (foundTarget) { + if (distanceFromTarget < 300) { + if (LightningTimer >= 60f) { //Every 60 AI cycles, plays the lightning sound and spawns 2 projectiles: the tesla aura for dealing damage in an aoe, and the cloud flash to simulate the brightness of the main cloud changing. SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/LightningAura")); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0, Projectile.owner); //Spawning 3 projectiles for 1 frame each to make sure that the latter 3 projectiles are rendered on top of the main storm cloud - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0, Projectile.owner); //Without these 3 projectiles here, some of the projectiles (more importantly, the cloud flash) are rendered below the cloud in some situations. This prevents 99% of said situations. It should be fine. - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0, Projectile.owner); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (Projectile.damage*20), 16, Projectile.owner); // Uses a different projectile for the hitbox because I don't want anything to do with Projectile.scale fuckery - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (Projectile.damage*20), 16, Projectile.owner); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0, Projectile.owner); - LightningTimer = 0; + LightningTimer = 0f; } } } diff --git a/Projectiles/Summon/AquasScepterCloudFlash.cs b/Projectiles/Summon/AquasScepterCloudFlash.cs index 7c0cf2d711..22f63bde39 100644 --- a/Projectiles/Summon/AquasScepterCloudFlash.cs +++ b/Projectiles/Summon/AquasScepterCloudFlash.cs @@ -21,11 +21,9 @@ namespace CalamityMod.Projectiles.Summon Projectile.alpha = 125; } - public override bool? CanCutTiles() { - return false; - } + public override bool? CanDamage() => false; - public override void AI() { + public override void AI() { Projectile.alpha += 5; } } diff --git a/Projectiles/Summon/AquasScepterProjectileSlotHolder.cs b/Projectiles/Summon/AquasScepterProjectileSlotHolder.cs deleted file mode 100644 index f88bdf1228..0000000000 --- a/Projectiles/Summon/AquasScepterProjectileSlotHolder.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Summon -{ - public class AquasScepterProjectileSlotHolder : ModProjectile //The sole purpose of this projectile is to hold a slot earlier in the projectile array than AquasScepterCloud so that the projectile AquasScepterCloudFlash can be drawn above AquasScepterCloud for the purpose of properply displaying the flash animation 99.9% of the time. - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Projectile Slot Holder"); - // Sets the amount of frames this minion has on its spritesheet - Main.projFrames[Projectile.type] = 1; - - } - - public sealed override void SetDefaults() - { - Projectile.width = 2; - Projectile.height = 2; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.penetrate = 0; - Projectile.timeLeft = 1; - Projectile.alpha = 255; - } - - public override bool? CanCutTiles() - { - return false; - } - } -} diff --git a/Projectiles/Summon/AquasScepterProjectileSlotHolder.png b/Projectiles/Summon/AquasScepterProjectileSlotHolder.png deleted file mode 100644 index 636bb5a01b..0000000000 Binary files a/Projectiles/Summon/AquasScepterProjectileSlotHolder.png and /dev/null differ diff --git a/Projectiles/Summon/AquasScepterRaindrop.cs b/Projectiles/Summon/AquasScepterRaindrop.cs index 05c51c251a..738c3595d1 100644 --- a/Projectiles/Summon/AquasScepterRaindrop.cs +++ b/Projectiles/Summon/AquasScepterRaindrop.cs @@ -9,11 +9,9 @@ namespace CalamityMod.Projectiles.Summon DisplayName.SetDefault("Rain Droplet"); // Sets the amount of frames this minion has on its spritesheet Main.projFrames[Projectile.type] = 1; - - Main.projPet[Projectile.type] = true; // Denotes that this projectile is a pet or minion } - public sealed override void SetDefaults() //If you want to change the damage of this projectile, just change the base damage of AquasScepter, the item. Note that this will affect the damage of AquasScepterTeslaAuraHitbox as well, because the damage of said projectile is set as a multiple of the base daamge at the bottom of AquasScepterCloud.cs + public sealed override void SetDefaults() //If you want to change the damage of this projectile, just change the base damage of AquasScepter, the item. Note that this will affect the damage of AquasScepterTeslaAura as well, because the damage of said projectile is set as a multiple of the base damage at the bottom of AquasScepterCloud.cs { Projectile.width = 20; //The sprite for the raindrop deliberately has invisible pixels added on each side of it to increase the width of the hitbox easily Projectile.height = 48; diff --git a/Projectiles/Summon/AquasScepterTeslaAura.cs b/Projectiles/Summon/AquasScepterTeslaAura.cs index e6acb44acd..184d03470b 100644 --- a/Projectiles/Summon/AquasScepterTeslaAura.cs +++ b/Projectiles/Summon/AquasScepterTeslaAura.cs @@ -1,41 +1,58 @@ -using Terraria; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class AquasScepterTeslaAura : ModProjectile //THIS IS ONLY THE VISUALS OF THE AURA. YOU ALSO NEED TO SPAWN 'AquasScepterTeslaAuraHitbox' + public class AquasScepterTeslaAura : ModProjectile { - public int UpdateCounter; //int that is incremented every loop of AI. This is used for sprite animation. + static float TeslaAuraScale = 3f; //Changing this float will change the radius of the hitbox and scale of the sprite at the same time, making the visual match the hitbox no matter what size is chosen. + public bool ableToHit = true; // bool that controls the state of CanDamage() public override void SetStaticDefaults() { DisplayName.SetDefault("Tesla Aura"); // Sets the amount of frames this minion has on its spritesheet Main.projFrames[Projectile.type] = 5; } - public sealed override void SetDefaults() { + public sealed override void SetDefaults() //If you want to change the damage of this projectile, look near the bottom of AquasScepterCloud.cs because this projectile's damage is set in Projectile.NewProjectile as a multiple of the AquasScepterCloud damage value + { Projectile.width = 216; Projectile.height = 216; Projectile.tileCollide = false; Projectile.ignoreWater = true; - Projectile.penetrate = -1; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Summon; + Projectile.penetrate = -1; Projectile.timeLeft = 27; - Projectile.alpha = 0; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 28; + Projectile.alpha = 0; } - public override bool? CanCutTiles() { - return false; - } + public override bool? CanDamage() => ableToHit; + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, (TeslaAuraScale * 96.0f), targetHitbox); public override void AI() { - Projectile.scale = 3f; - UpdateCounter++; - Projectile.alpha += 10; + Projectile.scale = TeslaAuraScale; + Projectile.alpha += 11; + Projectile.ai[0]++; - if (UpdateCounter%4==0) // Goes to the next frame of cloud animation every 4 frames. Doesn't need to be reset, because the projectile becomes invisible by update 26 via Projectile.alpha + Projectile.frameCounter++; + if (Projectile.frameCounter >= 4) { - Projectile.frameCounter++; - Projectile.frame++; + Projectile.frame++; + Projectile.frameCounter = 0; } - } + if (Projectile.frame >= Main.projFrames[Projectile.type]) + Projectile.frame = 0; + + if (Projectile.ai[0] > 8f) //After the Tesla Aura has been alive for 8 frames, disables it's ability to deal damage. This is done so that there is some leniency on allowing new enemies to enter the damaging range for a bit to make the sentry feel better to use. + { + ableToHit = false; + } + } } } diff --git a/Projectiles/Summon/AquasScepterTeslaAuraHitbox.cs b/Projectiles/Summon/AquasScepterTeslaAuraHitbox.cs deleted file mode 100644 index 2c6d464dbb..0000000000 --- a/Projectiles/Summon/AquasScepterTeslaAuraHitbox.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Microsoft.Xna.Framework; -using System; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Summon -{ - public class AquasScepterTeslaAuraHitbox : ModProjectile - { - private static float TeslaAuraRadius = 288.0f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Tesla Aura"); - // Sets the amount of frames this minion has on its spritesheet - Main.projFrames[Projectile.type] = 1; - - Main.projPet[Projectile.type] = true; // Denotes that this projectile is a pet or minion - - } - - public sealed override void SetDefaults() //If you want to change the damage of this projectile, look near the bottom of AquasScepterCloud.cs because this projectile's damage is set in Projectile.NewProjectile as a multiple of the AquasScepterCloud damage value - { - Projectile.width = 480; - Projectile.height = 480; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Summon; - Projectile.penetrate = -1; - Projectile.timeLeft = 5; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 6; - Projectile.alpha = 255; - } - - public override bool? CanCutTiles() - { - return true; - } - - public override bool MinionContactDamage() - { - return true; - } - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, TeslaAuraRadius, targetHitbox); - - } -} diff --git a/Projectiles/Summon/AquasScepterTeslaAuraHitbox.png b/Projectiles/Summon/AquasScepterTeslaAuraHitbox.png deleted file mode 100644 index ec81d17ab7..0000000000 Binary files a/Projectiles/Summon/AquasScepterTeslaAuraHitbox.png and /dev/null differ