diff --git a/Buffs/Pets/RotomBuff.cs b/Buffs/Pets/RotomBuff.cs index e667577316..fe3f71b6cb 100644 --- a/Buffs/Pets/RotomBuff.cs +++ b/Buffs/Pets/RotomBuff.cs @@ -1,28 +1,29 @@ using CalamityMod.Projectiles.Pets; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Buffs.Pets { - public class RotomBuff : ModBuff - { - public override void SetDefaults() - { - DisplayName.SetDefault("Electric Troublemaker"); - Description.SetDefault("Lightning never strikes the same place twice"); - Main.buffNoTimeDisplay[Type] = true; - Main.vanityPet[Type] = true; - } + public class RotomBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Electric Troublemaker"); + Description.SetDefault("Lightning never strikes the same place twice"); + Main.buffNoTimeDisplay[Type] = true; + Main.vanityPet[Type] = true; + } - public override void Update(Player player, ref int buffIndex) - { - player.buffTime[buffIndex] = 18000; - player.Calamity().rotomPet = true; - bool PetProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; - if (PetProjectileNotSpawned && player.whoAmI == Main.myPlayer) - { - Projectile.NewProjectile(player.position.X + (player.width / 2), player.position.Y + (player.height / 2), 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 50f, 0f); - } - } - } + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + player.Calamity().rotomPet = true; + bool PetProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; + if (PetProjectileNotSpawned && player.whoAmI == Main.myPlayer) + { + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); + } + } + } } diff --git a/Buffs/StatBuffs/BloodyBoost.cs b/Buffs/StatBuffs/BloodyBoost.cs new file mode 100644 index 0000000000..b9dbc83448 --- /dev/null +++ b/Buffs/StatBuffs/BloodyBoost.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.StatBuffs +{ + public class BloodyBoost : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Bloody Boost"); + Description.SetDefault("Increased offensive and defensive stats\n" + + "Healing potions grant more health"); + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = false; + longerExpertDebuff = false; + canBeCleared = false; + } + + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().bloodPactBoost = true; + } + } +} diff --git a/Buffs/StatBuffs/BloodyBoost.png b/Buffs/StatBuffs/BloodyBoost.png new file mode 100644 index 0000000000..020e7e63c1 Binary files /dev/null and b/Buffs/StatBuffs/BloodyBoost.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 3a0aee860d..68ae703692 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -15,6 +15,7 @@ using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Items.Weapons.Typeless; using CalamityMod.NPCs; @@ -119,6 +120,7 @@ namespace CalamityMod.CalPlayer public double contactDamageReduction = 0D; public double projectileDamageReduction = 0D; public bool brimlashBusterBoost = false; + public float animusBoost = 1f; #endregion public int CurrentlyViewedFactoryX = -1; @@ -489,6 +491,7 @@ namespace CalamityMod.CalPlayer public bool fleshTotem = false; public bool fleshTotemCooldown = false; public bool bloodPact = false; + public bool bloodPactBoost = false; public bool bloodflareCore = false; public bool coreOfTheBloodGod = false; public bool elementalHeart = false; @@ -582,6 +585,10 @@ namespace CalamityMod.CalPlayer public bool rustyMedal = false; public bool noStupidNaturalARSpawns = false; public bool burdenBreakerYeet = false; + public bool roverDrive = false; + public int roverDriveTimer = 0; + public int roverFrameCounter = 0; + public int roverFrame = 0; #endregion #region Armor Set @@ -1610,6 +1617,7 @@ namespace CalamityMod.CalPlayer rustyMedal = false; noStupidNaturalARSpawns = false; burdenBreakerYeet = false; + roverDrive = false; daedalusReflect = false; daedalusSplit = false; @@ -1819,6 +1827,7 @@ namespace CalamityMod.CalPlayer polarisBoostTwo = false; polarisBoostThree = false; bloodfinBoost = false; + bloodPactBoost = false; killSpikyBalls = false; @@ -2022,6 +2031,7 @@ namespace CalamityMod.CalPlayer sulphurBubbleCooldown = 0; ladHearts = 0; prismaticLasers = 0; + roverDriveTimer = 0; alcoholPoisoning = false; shadowflame = false; @@ -2200,6 +2210,7 @@ namespace CalamityMod.CalPlayer revivify = false; healCounter = 300; danceOfLightCharge = 0; + bloodPactBoost = false; #endregion #region Armorbonuses @@ -2324,6 +2335,7 @@ namespace CalamityMod.CalPlayer KameiBladeUseDelay = 0; lastProjectileHit = null; brimlashBusterBoost = false; + animusBoost = 1f; if (CalamityWorld.bossRushActive) { @@ -2885,7 +2897,7 @@ namespace CalamityMod.CalPlayer plagueReaperCooldown = 1800; if (forbiddenCirclet && forbiddenCooldown <= 0) { - forbiddenCooldown = 20; + forbiddenCooldown = 45; int stormMana = (int)(ForbiddenCirclet.manaCost * player.manaCost); if (player.statMana < stormMana) { @@ -4187,6 +4199,8 @@ namespace CalamityMod.CalPlayer #region Get Heal Life public override void GetHealLife(Item item, bool quickHeal, ref int healValue) { + if (bloodPactBoost) + healValue = (int)(healValue * 1.5); if (CalamityWorld.ironHeart) healValue = 0; } @@ -4341,112 +4355,105 @@ namespace CalamityMod.CalPlayer player.itemAnimation == (int)(player.itemAnimationMax * 0.7) || player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - float num339 = 0f; - float num340 = 0f; - float num341 = 0f; - float num342 = 0f; + float yVel = 0f; + float xVel = 0f; + float yOffset = 0f; + float xOffset = 0f; if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - num339 = -7f; + yVel = -7f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - num339 = -6f; - num340 = 2f; + yVel = -6f; + xVel = 2f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.5)) { - num339 = -4f; - num340 = 4f; + yVel = -4f; + xVel = 4f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3)) { - num339 = -2f; - num340 = 6f; + yVel = -2f; + xVel = 6f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1)) { - num340 = 7f; + xVel = 7f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - num342 = 26f; + xOffset = 26f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3)) { - num342 -= 4f; - num341 -= 20f; + xOffset -= 4f; + yOffset -= 20f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1)) { - num341 += 6f; + yOffset += 6f; } if (player.direction == -1) { if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - num342 -= 8f; + xOffset -= 8f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - num342 -= 6f; + xOffset -= 6f; } } - num339 *= 1.5f; - num340 *= 1.5f; - num342 *= (float)player.direction; - num341 *= player.gravDir; - Projectile.NewProjectile((float)(hitbox.X + hitbox.Width / 2) + num342, (float)(hitbox.Y + hitbox.Height / 2) + num341, (float)player.direction * num340, num339 * player.gravDir, ProjectileID.Mushroom, (int)(item.damage * 0.25f * player.MeleeDamage()), 0f, player.whoAmI, 0f, 0f); + yVel *= 1.5f; + xVel *= 1.5f; + xOffset *= (float)player.direction; + yOffset *= player.gravDir; + Projectile.NewProjectile((float)(hitbox.X + hitbox.Width / 2) + xOffset, (float)(hitbox.Y + hitbox.Height / 2) + yOffset, (float)player.direction * xVel, yVel * player.gravDir, ProjectileID.Mushroom, (int)(item.damage * 0.25f * player.MeleeDamage()), 0f, player.whoAmI, 0f, 0f); } } if (aWeapon) { if (Main.rand.NextBool(3)) { - int num280 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, ModContent.DustType(), player.velocity.X * 0.2f + (float)(player.direction * 3), player.velocity.Y * 0.2f, 100, default, 0.75f); - } - } - if (aChicken) - { - if (Main.rand.NextBool(3)) - { - int num280 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 244, player.velocity.X * 0.2f + (float)(player.direction * 3), player.velocity.Y * 0.2f, 100, default, 0.75f); + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, ModContent.DustType(), player.velocity.X * 0.2f + player.direction * 3f, player.velocity.Y * 0.2f, 100, default, 0.75f); } } if (eGauntlet) { if (Main.rand.NextBool(3)) { - int num280 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 66, player.velocity.X * 0.2f + (float)(player.direction * 3), player.velocity.Y * 0.2f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.25f); - Main.dust[num280].noGravity = true; + int element = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 66, player.velocity.X * 0.2f + player.direction * 3f, player.velocity.Y * 0.2f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.25f); + Main.dust[element].noGravity = true; } } if (cryogenSoul) { if (Main.rand.NextBool(3)) { - int num280 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 67, player.velocity.X * 0.2f + (float)(player.direction * 3), player.velocity.Y * 0.2f, 100, default, 0.75f); + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 67, player.velocity.X * 0.2f + player.direction * 3f, player.velocity.Y * 0.2f, 100, default, 0.75f); } } if (xerocSet) { if (Main.rand.NextBool(3)) { - int num280 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 58, player.velocity.X * 0.2f + (float)(player.direction * 3), player.velocity.Y * 0.2f, 100, default, 1.25f); + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 58, player.velocity.X * 0.2f + player.direction * 3f, player.velocity.Y * 0.2f, 100, default, 1.25f); } } if (reaverBlast) { if (Main.rand.NextBool(3)) { - int num280 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 74, player.velocity.X * 0.2f + (float)(player.direction * 3), player.velocity.Y * 0.2f, 100, default, 0.75f); + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 74, player.velocity.X * 0.2f + player.direction * 3f, player.velocity.Y * 0.2f, 100, default, 0.75f); } } if (dsSetBonus) { if (Main.rand.NextBool(3)) { - int num280 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 27, player.velocity.X * 0.2f + (float)(player.direction * 3), player.velocity.Y * 0.2f, 100, default, 2.5f); + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 27, player.velocity.X * 0.2f + player.direction * 3f, player.velocity.Y * 0.2f, 100, default, 2.5f); } } } @@ -4469,11 +4476,8 @@ namespace CalamityMod.CalPlayer } } } - if (!item.melee && (int) player.meleeEnchant == 7) - Projectile.NewProjectile(target.Center.X, target.Center.Y, target.velocity.X, target.velocity.Y, ProjectileID.ConfettiMelee, 0, 0f, player.whoAmI, 0f, 0f); - - if (item.melee) - titanBoost = 600; + if (!item.melee && player.meleeEnchant == 7) + Projectile.NewProjectile(target.Center, target.velocity, ProjectileID.ConfettiMelee, 0, 0f, player.whoAmI, 0f, 0f); if (omegaBlueChestplate) target.AddBuff(ModContent.BuffType(), 240); @@ -4496,6 +4500,7 @@ namespace CalamityMod.CalPlayer if (item.melee) //prevents Deep Sea Dumbell from snagging true melee debuff memes { + titanBoost = 600; if (eGauntlet) { int duration = 90; @@ -4571,9 +4576,13 @@ namespace CalamityMod.CalPlayer case 8: target.AddBuff(BuffID.Poisoned, 60 * Main.rand.Next(5, 10), false); break; - /*case 4: + case 4: target.AddBuff(BuffID.Midas, 120, false); - break;*/ + break; + } + if (titanHeartMask) + { + target.AddBuff(ModContent.BuffType(), 60 * Main.rand.Next(1,6), false); // 1 to 5 seconds } } if (holyWrath) @@ -4763,9 +4772,9 @@ namespace CalamityMod.CalPlayer case 8: target.AddBuff(BuffID.Poisoned, 60 * Main.rand.Next(5, 10), false); break; - /*case 4: + case 4: target.AddBuff(BuffID.Midas, 120, false); - break;*/ + break; } if (etherealExtorter) { @@ -4787,6 +4796,10 @@ namespace CalamityMod.CalPlayer target.AddBuff(ModContent.BuffType(), 240, false); } } + if (titanHeartMask) + { + target.AddBuff(ModContent.BuffType(), 60 * Main.rand.Next(1,6), false); // 1 to 5 seconds + } } if (vexation) { @@ -4820,11 +4833,8 @@ namespace CalamityMod.CalPlayer } } - if (!item.melee && (int) player.meleeEnchant == 7) - Projectile.NewProjectile(target.Center.X, target.Center.Y, target.velocity.X, target.velocity.Y, ProjectileID.ConfettiMelee, 0, 0f, player.whoAmI, 0f, 0f); - - if (item.melee) - titanBoost = 600; + if (!item.melee && player.meleeEnchant == 7) + Projectile.NewProjectile(target.Center, target.velocity, ProjectileID.ConfettiMelee, 0, 0f, player.whoAmI, 0f, 0f); if (omegaBlueChestplate) target.AddBuff(ModContent.BuffType(), 240); @@ -4847,6 +4857,7 @@ namespace CalamityMod.CalPlayer if (item.melee) { + titanBoost = 600; if (eGauntlet) { int duration = 90; @@ -4915,6 +4926,10 @@ namespace CalamityMod.CalPlayer target.AddBuff(BuffID.Midas, 120, false); break;*/ } + if (titanHeartMask) + { + target.AddBuff(ModContent.BuffType(), 60 * Main.rand.Next(1,6), false); // 1 to 5 seconds + } } if (holyWrath) { @@ -5122,6 +5137,10 @@ namespace CalamityMod.CalPlayer target.AddBuff(ModContent.BuffType(), 240, false); } } + if (titanHeartMask) + { + target.AddBuff(ModContent.BuffType(), 60 * Main.rand.Next(1,6), false); // 1 to 5 seconds + } } if (vexation) { @@ -5241,22 +5260,16 @@ namespace CalamityMod.CalPlayer { if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 3) { - Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(damage * 0.15), 2f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(damage * 0.15), 2f, player.whoAmI, 0f, 0f); } } } if (unstablePrism && crit) { - for (int num252 = 0; num252 < 3; num252++) + for (int s = 0; s < 3; s++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(30, 61) * 0.1f; - Projectile.NewProjectile(target.Center.X, target.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(damage * 0.15), 0f, player.whoAmI, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); + Projectile.NewProjectile(target.Center, velocity, ModContent.ProjectileType(), (int)(damage * 0.15), 0f, player.whoAmI); } } if (astralStarRain && crit && astralStarRainCooldown <= 0) @@ -5264,25 +5277,13 @@ namespace CalamityMod.CalPlayer astralStarRainCooldown = 60; for (int n = 0; n < 3; n++) { - float x = target.position.X + (float)Main.rand.Next(-400, 400); - float y = target.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num13 = target.position.X + (float)(target.width / 2) - vector.X; - float num14 = target.position.Y + (float)(target.height / 2) - vector.Y; - num13 += (float)Main.rand.Next(-100, 101); - float speed = 25f; int projectileType = Utils.SelectRandom(Main.rand, new int[] { ModContent.ProjectileType(), ProjectileID.HallowStar, ModContent.ProjectileType() }); - float num16 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14)); - num16 = speed / num16; - num13 *= num16; - num14 *= num16; - int num17 = Projectile.NewProjectile(x, y, num13, num14, projectileType, 120, 5f, player.whoAmI, 0f, 0f); - Main.projectile[num17].Calamity().forceTypeless = true; + CalamityUtils.ProjectileRain(target.Center, 400f, 100f, 500f, 800f, 25f, projectileType, (int)(120 * player.AverageDamage()), 5f, player.whoAmI, 6); } } if (bloodflareMelee && item.melee) @@ -5434,7 +5435,7 @@ namespace CalamityMod.CalPlayer if (randomChance < 15) randomChance = 15; - if (Main.rand.Next(randomChance) == 0) + if (Main.rand.NextBool(randomChance)) damageMult += 1.0; } if (silvaCountdown > 0 && hasSilvaEffect && silvaRanged && proj.ranged) @@ -5611,7 +5612,7 @@ namespace CalamityMod.CalPlayer // Forbidden armor reduces said nerf when holding the respective helmet's preferred weapon type // Profaned Soul Crystal encourages use of other weapons, nerfing the damage would not make sense. bool forbidden = player.head == ArmorIDs.Head.AncientBattleArmor && player.body == ArmorIDs.Body.AncientBattleArmor && player.legs == ArmorIDs.Legs.AncientBattleArmor; - bool reducedNerf = fearmongerSet || (forbidden && heldItem.magic) || (forbiddenCirclet && heldItem.Calamity().rogue); + bool reducedNerf = fearmongerSet || (forbidden && heldItem.magic); double summonNerfMult = 0.5; if (reducedNerf) summonNerfMult = 0.75; @@ -5664,36 +5665,24 @@ namespace CalamityMod.CalPlayer { if (theBee && player.statLife >= player.statLifeMax2) { - Main.PlaySound(SoundID.Item, (int)proj.position.X, (int)proj.position.Y, 110); + Main.PlaySound(SoundID.Item110, proj.Center); } if (unstablePrism && crit) { - for (int num252 = 0; num252 < 3; num252++) + for (int s = 0; s < 3; s++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(30, 61) * 0.1f; - Projectile.NewProjectile(proj.oldPosition.X + (float)(proj.width / 2), proj.oldPosition.Y + (float)(proj.height / 2), value15.X, value15.Y, ModContent.ProjectileType(), (int)(damage * 0.15), 0f, player.whoAmI, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); + Projectile.NewProjectile(target.Center, velocity, ModContent.ProjectileType(), (int)(damage * 0.15), 0f, player.whoAmI); } } if (electricianGlove && proj.Calamity().stealthStrike && proj.Calamity().rogue) { - for (int num252 = 0; num252 < 3; num252++) + for (int s = 0; s < 3; s++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(30, 61) * 0.1f; - int num17 = Projectile.NewProjectile(proj.oldPosition.X + (float)(proj.width / 2), proj.oldPosition.Y + (float)(proj.height / 2), value15.X, value15.Y, ModContent.ProjectileType(), (int)(damage * 0.1), 0f, player.whoAmI, 0f, 0f); - Main.projectile[num17].Calamity().forceRogue = true; - Main.projectile[num17].localNPCHitCooldown = -1; + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); + int spark = Projectile.NewProjectile(target.Center, velocity, ModContent.ProjectileType(), (int)(damage * 0.1), 0f, player.whoAmI); + Main.projectile[spark].Calamity().forceRogue = true; + Main.projectile[spark].localNPCHitCooldown = -1; } } if (astralStarRain && crit && astralStarRainCooldown <= 0) @@ -5701,41 +5690,22 @@ namespace CalamityMod.CalPlayer astralStarRainCooldown = 60; for (int n = 0; n < 3; n++) { - float x = target.position.X + (float)Main.rand.Next(-400, 400); - float y = target.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num13 = target.position.X + (float)(target.width / 2) - vector.X; - float num14 = target.position.Y + (float)(target.height / 2) - vector.Y; - num13 += (float)Main.rand.Next(-100, 101); - float speed = 25f; int projectileType = Utils.SelectRandom(Main.rand, new int[] { ModContent.ProjectileType(), ProjectileID.HallowStar, ModContent.ProjectileType() }); - float num16 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14)); - num16 = speed / num16; - num13 *= num16; - num14 *= num16; - int num17 = Projectile.NewProjectile(x, y, num13, num14, projectileType, 120, 5f, player.whoAmI, 0f, 0f); - Main.projectile[num17].Calamity().forceTypeless = true; + CalamityUtils.ProjectileRain(target.Center, 400f, 100f, 500f, 800f, 25f, projectileType, (int)(120 * player.AverageDamage()), 5f, player.whoAmI, 6); } } if (tarraRanged && crit && proj.ranged) { - int num251 = Main.rand.Next(2, 4); - for (int num252 = 0; num252 < num251; num252++) + int leafAmt = Main.rand.Next(2, 4); + for (int l = 0; l < leafAmt; l++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int FUCKYOU = Projectile.NewProjectile(target.position.X + (float)(target.width / 2), target.position.Y + (float)(target.height / 2), - value15.X, value15.Y, ProjectileID.Leaf, (int)(damage * 0.25), 0f, player.whoAmI, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int FUCKYOU = Projectile.NewProjectile(target.Center, velocity, ProjectileID.Leaf, (int)(damage * 0.25), 0f, player.whoAmI); Main.projectile[FUCKYOU].Calamity().forceTypeless = true; Main.projectile[FUCKYOU].netUpdate = true; } @@ -5744,22 +5714,22 @@ namespace CalamityMod.CalPlayer { if (target.canGhostHeal) { - float num11 = 0.03f; - num11 -= (float)proj.numHits * 0.015f; - if (num11 < 0f) + float projHitMult = 0.03f; + projHitMult -= (float)proj.numHits * 0.015f; + if (projHitMult < 0f) { - num11 = 0f; + projHitMult = 0f; } - float num12 = (float)proj.damage * num11; - if (num12 < 0f) + float cooldownMult = proj.damage * projHitMult; + if (cooldownMult < 0f) { - num12 = 0f; + cooldownMult = 0f; } if (player.lifeSteal > 0f) { player.statLife += 1; player.HealEffect(1); - player.lifeSteal -= num12 * 2f; + player.lifeSteal -= cooldownMult * 2f; } } } @@ -5768,22 +5738,15 @@ namespace CalamityMod.CalPlayer bloodflareMageCooldown = 120; for (int i = 0; i < 3; i++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int fire = Projectile.NewProjectile(target.position.X + (float)(target.width / 2), target.position.Y + (float)(target.height / 2), - value15.X, value15.Y, ProjectileID.BallofFire, (int)(damage * 0.5), 0f, player.whoAmI, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int fire = Projectile.NewProjectile(target.Center, velocity, ProjectileID.BallofFire, (int)(damage * 0.5), 0f, player.whoAmI); Main.projectile[fire].Calamity().forceTypeless = true; Main.projectile[fire].netUpdate = true; } } if (umbraphileSet && proj.Calamity().rogue && (Main.rand.NextBool(4) || proj.Calamity().stealthStrike) && proj.type != ModContent.ProjectileType()) { - Projectile.NewProjectile(proj.Center.X, proj.Center.Y, 0f, 0f, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.25, 50), 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(proj.Center, Vector2.Zero, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.25, 50), 0f, player.whoAmI); } if (bloodflareMelee && isTrueMelee) { @@ -6907,7 +6870,7 @@ namespace CalamityMod.CalPlayer break; case ProjectileID.MartianTurretBolt: - if ((bannerNPCType == NPCID.MartianTurret && Main.invasionType == InvasionID.MartianMadness) || (bannerNPCType == ModContent.NPCType() && Main.invasionType != InvasionID.MartianMadness)) + if ((bannerNPCType == NPCID.MartianTurret && Main.invasionType == InvasionID.MartianMadness) || ((bannerNPCType == ModContent.NPCType() || bannerNPCType == ModContent.NPCType()) && Main.invasionType != InvasionID.MartianMadness)) { reduceDamage = true; } @@ -6976,7 +6939,7 @@ namespace CalamityMod.CalPlayer { if (sulfurSet && !proj.friendly) { - if (Main.player[proj.owner] == null) + if (Main.player[proj.owner] is null) { if (!Main.npc[proj.owner].friendly) Main.npc[proj.owner].AddBuff(BuffID.Poisoned, 120); @@ -7082,7 +7045,7 @@ namespace CalamityMod.CalPlayer #region Can Hit public override bool? CanHitNPC(Item item, NPC target) { - if (camper && ((double)Math.Abs(player.velocity.X) > 0.05 || (double)Math.Abs(player.velocity.Y) > 0.05)) + if (camper && player.StandingStill()) { return false; } @@ -7091,7 +7054,7 @@ namespace CalamityMod.CalPlayer public override bool? CanHitNPCWithProj(Projectile proj, NPC target) { - if (camper && ((double)Math.Abs(player.velocity.X) > 0.05 || (double)Math.Abs(player.velocity.Y) > 0.05)) + if (camper && player.StandingStill()) { return false; } @@ -7158,9 +7121,12 @@ namespace CalamityMod.CalPlayer num79 *= num80; float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; - int p = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, type, (int)(damage * 0.15f), (int)(knockBack), player.whoAmI, 0f, (float)Main.rand.Next(15)); - Main.projectile[p].knockBack /= 2; + int p = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, type, (int)(damage * 0.15f), knockBack * 0.5f, player.whoAmI); Main.projectile[p].Calamity().forceRogue = true; //in case melee/rogue variants bug out + if (item.type == ModContent.ItemType()) + { + Main.projectile[p].ai[1] = 1f; + } if (StealthStrikeAvailable()) { int knifeCount = 15; @@ -7402,8 +7368,13 @@ namespace CalamityMod.CalPlayer (DoGLore ? 0.1 : 0.0) + ((player.beetleDefense && player.beetleOrbs > 0) ? (0.05 * player.beetleOrbs) : 0.0) + (enraged ? 0.25 : 0.0) + - ((CalamityWorld.defiled && Main.rand.NextBool(4)) ? 0.5 : 0.0) + - ((bloodPact && Main.rand.NextBool(4)) ? 1.5 : 0.0); + ((CalamityWorld.defiled && Main.rand.NextBool(4)) ? 0.5 : 0.0); + + if (bloodPact && Main.rand.NextBool(4)) + { + player.AddBuff(ModContent.BuffType(), 600); + damageMult += 1.25; + } if (CalamityWorld.revenge) { @@ -7507,76 +7478,48 @@ namespace CalamityMod.CalPlayer { Main.PlaySound(SoundID.NPCKilled, (int)player.position.X, (int)player.position.Y, 14); player.AddBuff(ModContent.BuffType(), 10830); - for (int num621 = 0; num621 < 20; num621++) + for (int d = 0; d < 20; d++) { - int num622 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 31, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int dust = Dust.NewDust(player.position, player.width, player.height, 31, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; if (Main.rand.NextBool(2)) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 35; num623++) + for (int d = 0; d < 35; d++) { - int num624 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 6, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 6, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - for (int num625 = 0; num625 < 3; num625++) - { - float scaleFactor10 = 0.33f; - if (num625 == 1) - { - scaleFactor10 = 0.66f; - } - if (num625 == 2) - { - scaleFactor10 = 1f; - } - int num626 = Gore.NewGore(new Vector2(player.position.X + (float)(player.width / 2) - 24f, player.position.Y + (float)(player.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f); - Gore gore = Main.gore[num626]; - gore.velocity *= scaleFactor10; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - num626 = Gore.NewGore(new Vector2(player.position.X + (float)(player.width / 2) - 24f, player.position.Y + (float)(player.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f); - gore.velocity *= scaleFactor10; - gore.velocity.X -= 1f; - gore.velocity.Y += 1f; - num626 = Gore.NewGore(new Vector2(player.position.X + (float)(player.width / 2) - 24f, player.position.Y + (float)(player.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f); - gore.velocity *= scaleFactor10; - gore.velocity.X += 1f; - gore.velocity.Y -= 1f; - num626 = Gore.NewGore(new Vector2(player.position.X + (float)(player.width / 2) - 24f, player.position.Y + (float)(player.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f); - gore.velocity *= scaleFactor10; - gore.velocity.X -= 1f; - gore.velocity.Y -= 1f; + int fire = Dust.NewDust(player.position, player.width, player.height, DustID.Fire, 0f, 0f, 100, default, 3f); + Main.dust[fire].noGravity = true; + Main.dust[fire].velocity *= 5f; + fire = Dust.NewDust(player.position, player.width, player.height, DustID.Fire, 0f, 0f, 100, default, 2f); + Main.dust[fire].velocity *= 2f; } + CalamityUtils.ExplosionGores(player.Center, 3); } } if (sirenIce) { - Main.PlaySound(SoundID.NPCKilled, (int)player.position.X, (int)player.position.Y, 7); + Main.PlaySound(SoundID.NPCKilled, (int)player.Center.X, (int)player.Center.Y, 7); player.AddBuff(ModContent.BuffType(), 1800); - for (int num621 = 0; num621 < 10; num621++) + for (int d = 0; d < 10; d++) { - int num622 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 67, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int ice = Dust.NewDust(player.position, player.width, player.height, 67, 0f, 0f, 100, default, 2f); + Main.dust[ice].velocity *= 3f; if (Main.rand.NextBool(2)) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[ice].scale = 0.5f; + Main.dust[ice].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 15; num623++) + for (int d = 0; d < 15; d++) { - int num624 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 67, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 67, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int ice = Dust.NewDust(player.position, player.width, player.height, 67, 0f, 0f, 100, default, 3f); + Main.dust[ice].noGravity = true; + Main.dust[ice].velocity *= 5f; + ice = Dust.NewDust(player.position, player.width, player.height, 67, 0f, 0f, 100, default, 2f); + Main.dust[ice].velocity *= 2f; } } if (tarraMelee) @@ -7602,24 +7545,24 @@ namespace CalamityMod.CalPlayer { if (Main.npc[m].active && !Main.npc[m].friendly) { - float distance = (Main.npc[m].Center - player.Center).Length(); - float num10 = (float)Main.rand.Next(200 + (int)damage / 2, 301 + (int)damage * 2); - if (num10 > 500f) + float npcDist = (Main.npc[m].Center - player.Center).Length(); + float freezeDist = (float)Main.rand.Next(200 + (int)damage / 2, 301 + (int)damage * 2); + if (freezeDist > 500f) { - num10 = 500f + (num10 - 500f) * 0.75f; + freezeDist = 500f + (freezeDist - 500f) * 0.75f; } - if (num10 > 700f) + if (freezeDist > 700f) { - num10 = 700f + (num10 - 700f) * 0.5f; + freezeDist = 700f + (freezeDist - 700f) * 0.5f; } - if (num10 > 900f) + if (freezeDist > 900f) { - num10 = 900f + (num10 - 900f) * 0.25f; + freezeDist = 900f + (freezeDist - 900f) * 0.25f; } - if (distance < num10) + if (npcDist < freezeDist) { - float num11 = (float)Main.rand.Next(90 + (int)damage / 3, 240 + (int)damage / 2); - Main.npc[m].AddBuff(ModContent.BuffType(), (int)num11, false); + float duration = (float)Main.rand.Next(90 + (int)damage / 3, 240 + (int)damage / 2); + Main.npc[m].AddBuff(ModContent.BuffType(), (int)duration, false); } } } @@ -7742,18 +7685,7 @@ namespace CalamityMod.CalPlayer { for (int n = 0; n < 4; n++) { - float x = player.position.X + (float)Main.rand.Next(-400, 400); - float y = player.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num13 = player.position.X + (float)(player.width / 2) - vector.X; - float num14 = player.position.Y + (float)(player.height / 2) - vector.Y; - num13 += (float)Main.rand.Next(-100, 101); - int num15 = 20; - float num16 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14)); - num16 = (float)num15 / num16; - num13 *= num16; - num14 *= num16; - int num17 = Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType(), (int)(20 * player.AverageDamage()), 1f, player.whoAmI, 0f, 0f); + CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 20f, ModContent.ProjectileType(), (int)(20 * player.AverageDamage()), 1f, player.whoAmI); } } } @@ -7767,39 +7699,14 @@ namespace CalamityMod.CalPlayer int starAmt = aBulwarkRare ? 12 : 5; for (int n = 0; n < starAmt; n++) { - float x = player.position.X + (float)Main.rand.Next(-400, 400); - float y = player.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num13 = player.position.X + (float)(player.width / 2) - vector.X; - float num14 = player.position.Y + (float)(player.height / 2) - vector.Y; - num13 += (float)Main.rand.Next(-100, 101); - int num15 = 29; - float num16 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14)); - num16 = (float)num15 / num16; - num13 *= num16; - num14 *= num16; - int num17 = Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType(), (int)(320 * player.AverageDamage()), 5f, player.whoAmI, 0f, 0f); + CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), (int)(320 * player.AverageDamage()), 5f, player.whoAmI); } } if (dAmulet) { for (int n = 0; n < 3; n++) { - float x = player.position.X + (float)Main.rand.Next(-400, 400); - float y = player.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num13 = player.position.X + (float)(player.width / 2) - vector.X; - float num14 = player.position.Y + (float)(player.height / 2) - vector.Y; - num13 += (float)Main.rand.Next(-100, 101); - int num15 = 29; - float num16 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14)); - num16 = (float)num15 / num16; - num13 *= num16; - num14 *= num16; - int star = Projectile.NewProjectile(x, y, num13, num14, ProjectileID.HallowStar, (int)(130 * player.AverageDamage()), 4f, player.whoAmI, 0f, 0f); - Main.projectile[star].usesLocalNPCImmunity = true; - Main.projectile[star].localNPCHitCooldown = 5; - Main.projectile[star].Calamity().forceTypeless = true; + CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 29f, ProjectileID.HallowStar, (int)(130 * player.AverageDamage()), 4f, player.whoAmI, 6, 1, 5); } /*int num = 1; @@ -7820,21 +7727,7 @@ namespace CalamityMod.CalPlayer { for (int n = 0; n < 3; n++) { - float x = player.position.X + (float)Main.rand.Next(-400, 400); - float y = player.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num13 = player.position.X + (float)(player.width / 2) - vector.X; - float num14 = player.position.Y + (float)(player.height / 2) - vector.Y; - num13 += (float)Main.rand.Next(-100, 101); - int num15 = 29; - float num16 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14)); - num16 = (float)num15 / num16; - num13 *= num16; - num14 *= num16; - int star = Projectile.NewProjectile(x, y, num13, num14, ProjectileID.HallowStar, (int)(150 * player.AverageDamage()), 4f, player.whoAmI, 0f, 0f); - Main.projectile[star].usesLocalNPCImmunity = true; - Main.projectile[star].localNPCHitCooldown = 5; - Main.projectile[star].Calamity().forceTypeless = true; + CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 29f, ProjectileID.HallowStar, (int)(150 * player.AverageDamage()), 4f, player.whoAmI, 6, 1, 5); } int num = 1; if (Main.rand.NextBool(3)) @@ -7860,17 +7753,16 @@ namespace CalamityMod.CalPlayer double startAngle = Math.Atan2(player.velocity.X, player.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; double offsetAngle; - int i; int fDamage = (int)(56 * player.AverageDamage()); if (player.whoAmI == Main.myPlayer) { - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { float xPos = Main.rand.NextBool(2) ? player.Center.X + 100 : player.Center.X - 100; - Vector2 vector2 = new Vector2(xPos, player.Center.Y + Main.rand.Next(-100, 101)); + Vector2 spawnPos = new Vector2(xPos, player.Center.Y + Main.rand.Next(-100, 101)); offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - int spore1 = Projectile.NewProjectile(vector2.X, vector2.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ProjectileID.TruffleSpore, fDamage, 1.25f, player.whoAmI, 0f, 0f); - int spore2 = Projectile.NewProjectile(vector2.X, vector2.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ProjectileID.TruffleSpore, fDamage, 1.25f, player.whoAmI, 0f, 0f); + int spore1 = Projectile.NewProjectile(spawnPos.X, spawnPos.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ProjectileID.TruffleSpore, fDamage, 1.25f, player.whoAmI, 0f, 0f); + int spore2 = Projectile.NewProjectile(spawnPos.X, spawnPos.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ProjectileID.TruffleSpore, fDamage, 1.25f, player.whoAmI, 0f, 0f); Main.projectile[spore1].timeLeft = 120; Main.projectile[spore2].timeLeft = 120; } @@ -7886,13 +7778,12 @@ namespace CalamityMod.CalPlayer double startAngle = Math.Atan2(player.velocity.X, player.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; double offsetAngle; - int i; int sDamage = hardMode ? 36 : 6; if (aSparkRare) sDamage += hardMode ? 12 : 2; if (player.whoAmI == Main.myPlayer) { - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; int spark1 = Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)(sDamage * player.AverageDamage()), 1.25f, player.whoAmI, 0f, 0f); @@ -7914,7 +7805,7 @@ namespace CalamityMod.CalPlayer for (int i = 0; i < 5; i++) { Main.PlaySound(SoundID.Item, (int)Main.player[Main.myPlayer].position.X, (int)Main.player[Main.myPlayer].position.Y, 61); - int inkBomb = Projectile.NewProjectile(player.Center.X, player.Center.Y, Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-0f, -4f), ModContent.ProjectileType(), 0, 0, player.whoAmI); + Projectile.NewProjectile(player.Center.X, player.Center.Y, Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-0f, -4f), ModContent.ProjectileType(), 0, 0, player.whoAmI); } } } @@ -7942,7 +7833,7 @@ namespace CalamityMod.CalPlayer int eDamage = (int)(100 * player.AverageDamage()); if (player.whoAmI == Main.myPlayer) { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), eDamage, 1f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), eDamage, 1f, player.whoAmI, 0f, 0f); } } } @@ -7955,17 +7846,16 @@ namespace CalamityMod.CalPlayer double startAngle = Math.Atan2(player.velocity.X, player.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; double offsetAngle; - int i; int sDamage = (int)(27 * player.RangedDamage()); //daedalus ranged helm if (player.whoAmI == Main.myPlayer) { - for (i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) { float randomSpeed = (float)Main.rand.Next(1, 7); float randomSpeed2 = (float)Main.rand.Next(1, 7); offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - int shard = Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f) + randomSpeed, 90, sDamage, 1f, player.whoAmI, 0f, 0f); - int shard2 = Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f) + randomSpeed2, 90, sDamage, 1f, player.whoAmI, 0f, 0f); + int shard = Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f) + randomSpeed, ProjectileID.CrystalShard, sDamage, 1f, player.whoAmI, 0f, 0f); + int shard2 = Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f) + randomSpeed2, ProjectileID.CrystalShard, sDamage, 1f, player.whoAmI, 0f, 0f); Main.projectile[shard].Calamity().forceTypeless = true; Main.projectile[shard2].Calamity().forceTypeless = true; } @@ -7981,19 +7871,18 @@ namespace CalamityMod.CalPlayer double startAngle = Math.Atan2(player.velocity.X, player.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; double offsetAngle; - int i; int rDamage = (int)(58 * player.RogueDamage()); //Reaver rogue helm if (player.whoAmI == Main.myPlayer) { - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { float xPos = Main.rand.NextBool(2) ? player.Center.X + 100 : player.Center.X - 100; - Vector2 vector2 = new Vector2(xPos, player.Center.Y + Main.rand.Next(-100, 101)); + Vector2 spawnPos = new Vector2(xPos, player.Center.Y + Main.rand.Next(-100, 101)); offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - int rspore1 = Projectile.NewProjectile(vector2.X, vector2.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), 567, rDamage, 2f, player.whoAmI, 0f, 0f); + int rspore1 = Projectile.NewProjectile(spawnPos.X, spawnPos.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), rDamage, 2f, player.whoAmI, 0f, 0f); Main.projectile[rspore1].usesLocalNPCImmunity = true; Main.projectile[rspore1].localNPCHitCooldown = 60; - int rspore2 = Projectile.NewProjectile(vector2.X, vector2.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), 568, rDamage, 2f, player.whoAmI, 0f, 0f); + int rspore2 = Projectile.NewProjectile(spawnPos.X, spawnPos.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), rDamage, 2f, player.whoAmI, 1f, 0f); Main.projectile[rspore2].usesLocalNPCImmunity = true; Main.projectile[rspore2].localNPCHitCooldown = 60; } @@ -8009,10 +7898,9 @@ namespace CalamityMod.CalPlayer double startAngle = Math.Atan2(player.velocity.X, player.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; double offsetAngle; - int i; if (player.whoAmI == Main.myPlayer) { - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; Projectile.NewProjectile(player.Center.X, player.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)(900 * player.MeleeDamage()), 5f, player.whoAmI, 0f, 0f); @@ -8028,7 +7916,7 @@ namespace CalamityMod.CalPlayer Main.PlaySound(SoundID.Item, (int)player.position.X, (int)player.position.Y, 74); if (player.whoAmI == Main.myPlayer) { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)((auricSet ? 2400 : 1200) * player.MagicDamage()), 1f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)((auricSet ? 2400 : 1200) * player.MagicDamage()), 1f, player.whoAmI, 0f, 0f); } } } @@ -8038,41 +7926,11 @@ namespace CalamityMod.CalPlayer { for (int l = 0; l < 2; l++) { - float x = player.position.X + (float)Main.rand.Next(-400, 400); - float y = player.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num15 = player.position.X + (float)(player.width / 2) - vector.X; - float num16 = player.position.Y + (float)(player.height / 2) - vector.Y; - num15 += (float)Main.rand.Next(-100, 101); - int num17 = 22; - float num18 = (float)Math.Sqrt((double)(num15 * num15 + num16 * num16)); - num18 = (float)num17 / num18; - num15 *= num18; - num16 *= num18; - int num19 = Projectile.NewProjectile(x, y, num15, num16, ProjectileID.ShadowBeamFriendly, (int)(3000 * player.AverageDamage()), 7f, player.whoAmI, 0f, 0f); - Main.projectile[num19].ai[1] = player.position.Y; - Main.projectile[num19].usesLocalNPCImmunity = true; - Main.projectile[num19].localNPCHitCooldown = 10; - Main.projectile[num19].Calamity().forceTypeless = true; + CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ProjectileID.ShadowBeamFriendly, (int)(3000 * player.AverageDamage()), 7f, player.whoAmI, 6, 1); } for (int l = 0; l < 5; l++) { - float x = player.position.X + (float)Main.rand.Next(-400, 400); - float y = player.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num15 = player.position.X + (float)(player.width / 2) - vector.X; - float num16 = player.position.Y + (float)(player.height / 2) - vector.Y; - num15 += (float)Main.rand.Next(-100, 101); - int num17 = 22; - float num18 = (float)Math.Sqrt((double)(num15 * num15 + num16 * num16)); - num18 = (float)num17 / num18; - num15 *= num18; - num16 *= num18; - int num19 = Projectile.NewProjectile(x, y, num15, num16, ProjectileID.DemonScythe, (int)(5000 * player.AverageDamage()), 7f, player.whoAmI, 0f, 0f); - Main.projectile[num19].ai[1] = player.position.Y; - Main.projectile[num19].usesLocalNPCImmunity = true; - Main.projectile[num19].localNPCHitCooldown = 10; - Main.projectile[num19].Calamity().forceTypeless = true; + CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ProjectileID.DemonScythe, (int)(5000 * player.AverageDamage()), 7f, player.whoAmI, 6, 1); } } } @@ -9890,6 +9748,15 @@ namespace CalamityMod.CalPlayer } tailFrameUp = 0; } + + int frameAmt = 11; + if (roverFrameCounter >= 7) + { + roverFrameCounter = -1; + roverFrame = roverFrame == frameAmt - 1 ? 0 : roverFrame + 1; + } + roverFrameCounter++; + for (int i = 0; i < player.dye.Length; i++) { if (player.dye[i].type == ModContent.ItemType()) @@ -10002,6 +9869,28 @@ namespace CalamityMod.CalPlayer } }); + public static readonly PlayerLayer RoverDriveShield = new PlayerLayer("CalamityMod", "RoverDrive", PlayerLayer.Skin, (drawInfo) => + { + Player drawPlayer = drawInfo.drawPlayer; + CalamityPlayer modPlayer = drawPlayer.Calamity(); + if (modPlayer.roverDriveTimer < 616 && modPlayer.roverDrive) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/ExtraTextures/RoverAccShield"); + int frameAmt = 11; + int height = texture.Height / frameAmt; + int frameHeight = height * modPlayer.roverFrame; + Vector2 drawPos = drawPlayer.Center - Main.screenPosition + new Vector2(0f, drawPlayer.gfxOffY); + Rectangle frame = new Rectangle(0, frameHeight, texture.Width, height); + Color color = Color.White * 0.625f; + Vector2 origin = new Vector2(texture.Width / 2f, height / 2f); + float scale = 1f + (float)Math.Cos(Main.GlobalTime) * 0.1f; + SpriteEffects spriteEffects = drawPlayer.direction != -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + + DrawData data = new DrawData(texture, drawPos, frame, color, 0f, origin, scale, spriteEffects, 0); + Main.playerDrawData.Add(data); + } + }); + public static readonly PlayerLayer StratusSphereDrawing = new PlayerLayer("CalamityMod", "StratusSphereDrawing", PlayerLayer.HeldProjFront, (drawInfo) => { Player drawPlayer = drawInfo.drawPlayer; @@ -10202,6 +10091,7 @@ namespace CalamityMod.CalPlayer list.Insert(drawTheStupidSign, ForbiddenCircletSign); } list.Add(ColdDivinityOverlay); + list.Add(RoverDriveShield); list.Add(StratusSphereDrawing); list.Add(ProfanedMoonlightDyeEffects); list.Add(IbanDevRobot); @@ -10374,7 +10264,7 @@ namespace CalamityMod.CalPlayer } if (IBoots) { - if (((double)Math.Abs(player.velocity.X) > 0.05 || (double)Math.Abs(player.velocity.Y) > 0.05) && !player.mount.Active) + if (player.velocity.Length() > 0.05f && !player.mount.Active) { if (Main.rand.NextBool(2) && drawInfo.shadow == 0f) { @@ -10394,7 +10284,7 @@ namespace CalamityMod.CalPlayer } if (elysianFire) { - if (((double)Math.Abs(player.velocity.X) > 0.05 || (double)Math.Abs(player.velocity.Y) > 0.05) && !player.mount.Active) + if (player.velocity.Length() > 0.05f && !player.mount.Active) { if (Main.rand.NextBool(2) && drawInfo.shadow == 0f) { @@ -10414,7 +10304,7 @@ namespace CalamityMod.CalPlayer } if (dsSetBonus) { - if (((double)Math.Abs(player.velocity.X) > 0.05 || (double)Math.Abs(player.velocity.Y) > 0.05) && !player.mount.Active) + if (player.velocity.Length() > 0.05f && !player.mount.Active) { if (Main.rand.NextBool(2) && drawInfo.shadow == 0f) { @@ -10434,7 +10324,7 @@ namespace CalamityMod.CalPlayer } if (auricSet) { - if (((double)Math.Abs(player.velocity.X) > 0.05 || (double)Math.Abs(player.velocity.Y) > 0.05) && !player.mount.Active) + if (player.velocity.Length() > 0.05f && !player.mount.Active) { if (drawInfo.shadow == 0f) { @@ -10664,7 +10554,7 @@ namespace CalamityMod.CalPlayer fullBright = true; } } - if (draedonsHeart && !shadeRegen && !cFreeze && (double)Math.Abs(player.velocity.X) < 0.05 && (double)Math.Abs(player.velocity.Y) < 0.05 && player.itemAnimation == 0) + if (draedonsHeart && !shadeRegen && !cFreeze && player.StandingStill() && player.itemAnimation == 0) { if (noRogueStealth) { @@ -10916,8 +10806,14 @@ namespace CalamityMod.CalPlayer private float UpdateStealthGenStats() { + int finalDawnProjCount = player.ownedProjectileCounts[ModContent.ProjectileType()] + + player.ownedProjectileCounts[ModContent.ProjectileType()] + + player.ownedProjectileCounts[ModContent.ProjectileType()] + + player.ownedProjectileCounts[ModContent.ProjectileType()] + + player.ownedProjectileCounts[ModContent.ProjectileType()]; + // If you are actively using an item, you cannot gain stealth. - if (player.itemAnimation > 0) + if (player.itemAnimation > 0 || finalDawnProjCount > 0) return 0f; // Penumbra Potion provides various boosts to rogue stealth generation @@ -10988,7 +10884,7 @@ namespace CalamityMod.CalPlayer // You get 100% stealth regen while standing still and not on a mount. Otherwise, you get your stealth regeneration while moving. // Stealth only regenerates at 1/3 speed while moving. - bool standstill = Math.Abs(player.velocity.X) < 0.1f && Math.Abs(player.velocity.Y) < 0.1f && !player.mount.Active; + bool standstill = player.StandingStill(0.1f) && !player.mount.Active; return standstill ? stealthGenStandstill : stealthGenMoving * 0.333333f * stealthAcceleration; } diff --git a/CalPlayer/CalamityPlayerFishing.cs b/CalPlayer/CalamityPlayerFishing.cs index d42c7755f3..d803b09b2d 100644 --- a/CalPlayer/CalamityPlayerFishing.cs +++ b/CalPlayer/CalamityPlayerFishing.cs @@ -168,7 +168,7 @@ namespace CalamityMod.CalPlayer { if (Main.rand.Next(100) < chanceForCrates) { - if (Main.rand.NextBool(chanceForRareItems) && modPlayer.enchantedPearl && modPlayer.fishingStation && player.cratePotion) + if (Main.rand.NextBool(chanceForBiomeCrate)) { if (modPlayer.ZoneCalamity) caughtType = ModContent.ItemType(); @@ -438,14 +438,14 @@ namespace CalamityMod.CalPlayer } } - if (power >= 60 && player.FindBuffIndex(BuffID.Gills) > -1 && CalamityWorld.downedCalamitas && Main.rand.NextBool(25) && power < 160) + if (player.FindBuffIndex(BuffID.Gills) > -1 && CalamityWorld.downedCalamitas && Main.rand.NextBool(25)) { caughtType = ModContent.ItemType(); } if (junk) { - if (canSulphurFish && power < 40) + if (canSulphurFish) { caughtType = ModContent.ItemType(); } @@ -474,23 +474,17 @@ namespace CalamityMod.CalPlayer if (canSulphurFish) { - if (power >= 40) + if (Main.rand.NextBool(15)) { - if (Main.rand.NextBool(15) && power < 80) + caughtType = ModContent.ItemType(); + } + if (Main.rand.NextFloat() < 0.08f) + { + caughtType = Utils.SelectRandom(Main.rand, new int[] { - caughtType = ModContent.ItemType(); - } - if (Main.rand.NextBool(25) && power < 160) - { - caughtType = ModContent.ItemType(); - } - if (power >= 110) - { - if (Main.rand.NextBool(25) && power < 240) - { - caughtType = ModContent.ItemType(); - } - } + ModContent.ItemType(), + ModContent.ItemType() + }); } if (player.cratePotion && Main.rand.NextBool(5)) // 20% { diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 5899ddd699..51b45ca9eb 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -596,7 +596,7 @@ namespace CalamityMod.CalPlayer if (modPlayer.absorber) { - if (Math.Abs(player.velocity.X) < 0.05f && Math.Abs(player.velocity.Y) < 0.05f && player.itemAnimation == 0) + if (player.StandingStill() && player.itemAnimation == 0) player.lifeRegen += 2; } @@ -691,6 +691,10 @@ namespace CalamityMod.CalPlayer player.lifeRegen += 2; } if (modPlayer.handWarmer && modPlayer.eskimoSet) + { + player.lifeRegen += 2; + } + if (modPlayer.bloodPactBoost) { player.lifeRegen += 2; } @@ -719,7 +723,7 @@ namespace CalamityMod.CalPlayer int lifeRegenMaxBoost = CalamityPlayer.areThereAnyDamnBosses ? 1 : 4; float lifeRegenLifeRegenTimeMaxBoost = CalamityPlayer.areThereAnyDamnBosses ? 8f : 30f; - if (Math.Abs(player.velocity.X) < 0.05f && Math.Abs(player.velocity.Y) < 0.05f && player.itemAnimation == 0) + if (player.StandingStill() && player.itemAnimation == 0) { bool boostedRegen = false; bool noSunlight = false; @@ -865,7 +869,7 @@ namespace CalamityMod.CalPlayer if (player.statLife < modPlayer.actualMaxLife) { bool noLifeRegenCap = (player.shinyStone || modPlayer.draedonsHeart || modPlayer.cFreeze || modPlayer.shadeRegen || modPlayer.photosynthesis || modPlayer.camper) && - Math.Abs(player.velocity.X) < 0.05f && Math.Abs(player.velocity.Y) < 0.05f && player.itemAnimation == 0; + player.StandingStill() && player.itemAnimation == 0; if (!noLifeRegenCap) { diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 0d1c9ef6bf..85d6977afc 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -465,10 +465,10 @@ namespace CalamityMod.CalPlayer { if (CalamityWorld.rainingAcid && modPlayer.ZoneSulphur && !CalamityPlayer.areThereAnyDamnBosses && player.Center.Y < Main.worldSurface * 16f + 800f) { - int acidRainDropRate = (int)(MathHelper.Clamp(Main.invasionSize * 0.4f, 13.5f, 50) * 2.25); + int slimeRainRate = (int)(MathHelper.Clamp(Main.invasionSize * 0.4f, 13.5f, 50) * 2.25); Vector2 spawnPoint = new Vector2(player.Center.X + Main.rand.Next(-1000, 1001), player.Center.Y - Main.rand.Next(700, 801)); - if (player.miscCounter % acidRainDropRate == 0f) + if (player.miscCounter % slimeRainRate == 0f) { if (CalamityWorld.downedAquaticScourge && !CalamityWorld.downedPolterghast && Main.rand.NextBool(12)) { @@ -483,12 +483,12 @@ namespace CalamityMod.CalPlayer { if (modPlayer.hydrothermalSmoke) { - if ((double)player.velocity.X > 0 || (double)player.velocity.Y > 0 || (double)player.velocity.X < -0.1 || (double)player.velocity.Y < -0.1) + if (Math.Abs(player.velocity.X) > 0.1f || Math.Abs(player.velocity.Y) > 0.1f) { - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); } } - //trying to find a workaround because apparently putting the bool in ResetEffects prevents it from working + //Trying to find a workaround because apparently putting the bool in ResetEffects prevents it from working if (!player.armorEffectDrawOutlines) { modPlayer.hydrothermalSmoke = false; @@ -556,12 +556,12 @@ namespace CalamityMod.CalPlayer // Thorn and spike effects // 10 = crimson/corruption thorns, 17 = jungle thorns, 40 = dungeon spikes, 60 = temple spikes - Vector2 vector; + Vector2 tileType; if (!player.mount.Active || !player.mount.Cart) - vector = Collision.HurtTiles(player.position, player.velocity, player.width, player.height, player.fireWalk); + tileType = Collision.HurtTiles(player.position, player.velocity, player.width, player.height, player.fireWalk); else - vector = Collision.HurtTiles(player.position, player.velocity, player.width, player.height - 16, player.fireWalk); - switch ((int)vector.Y) + tileType = Collision.HurtTiles(player.position, player.velocity, player.width, player.height - 16, player.fireWalk); + switch ((int)tileType.Y) { case 10: player.AddBuff(BuffID.Weak, 300, false); @@ -610,7 +610,7 @@ namespace CalamityMod.CalPlayer // Ice shards, lightning and sharknadoes bool nearPillar = player.PillarZone(); - if (player.ZoneOverworldHeight && !CalamityPlayer.areThereAnyDamnBosses && Main.invasionType == InvasionID.None && NPC.MoonLordCountdown == 0 && !player.InSpace() && !DD2Event.Ongoing && !nearPillar) + if (player.ZoneOverworldHeight && !CalamityPlayer.areThereAnyDamnBosses && !CalamityPlayer.areThereAnyDamnEvents && NPC.MoonLordCountdown == 0 && !player.InSpace()) { Vector2 sharknadoSpawnPoint = new Vector2(player.Center.X - Main.rand.Next(300, 701), player.Center.Y - Main.rand.Next(700, 801)); if (point.X > Main.maxTilesX / 2) @@ -632,7 +632,7 @@ namespace CalamityMod.CalPlayer Vector2 velocity = new Vector2(windVelocity * 0.2f, 3f * Main.rand.NextFloat()); if (player.miscCounter % divisor == 0 && Main.rand.NextBool(3)) - Projectile.NewProjectile(spawnPoint.X, spawnPoint.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), 20, 0f, player.whoAmI, 2f, 0f); + Projectile.NewProjectile(spawnPoint, velocity, ModContent.ProjectileType(), 20, 0f, player.whoAmI, 2f, 0f); } } else @@ -643,31 +643,31 @@ namespace CalamityMod.CalPlayer if (player.miscCounter == 280 && Main.rand.NextBool(randomFrequency) && player.ownedProjectileCounts[ProjectileID.Cthulunado] < 1) { Main.PlaySound(SoundID.NPCDeath19, (int)sharknadoSpawnPoint.X, (int)sharknadoSpawnPoint.Y); - int num331 = (int)(sharknadoSpawnPoint.Y / 16f); - int num332 = (int)(sharknadoSpawnPoint.X / 16f); - int num333 = 100; - if (num332 < 10) - num332 = 10; - if (num332 > Main.maxTilesX - 10) - num332 = Main.maxTilesX - 10; - if (num331 < 10) - num331 = 10; - if (num331 > Main.maxTilesY - num333 - 10) - num331 = Main.maxTilesY - num333 - 10; + int y = (int)(sharknadoSpawnPoint.Y / 16f); + int x = (int)(sharknadoSpawnPoint.X / 16f); + int yAdjust = 100; + if (x < 10) + x = 10; + if (x > Main.maxTilesX - 10) + x = Main.maxTilesX - 10; + if (y < 10) + y = 10; + if (y > Main.maxTilesY - yAdjust - 10) + y = Main.maxTilesY - yAdjust - 10; - int spawnAreaY = Main.maxTilesY - num331; - for (int num334 = num331; num334 < num331 + spawnAreaY; num334++) + int spawnAreaY = Main.maxTilesY - y; + for (int j = y; j < y + spawnAreaY; j++) { - Tile tile = Main.tile[num332, num334]; + Tile tile = Main.tile[x, j]; if ((tile.active() && Main.tileSolid[tile.type]) || tile.liquid >= 200) { - num331 = num334; + y = j; break; } } - int num336 = Projectile.NewProjectile(num332 * 16 + 8, num331 * 16 - 24, 0f, 0f, ProjectileID.Cthulunado, 50, 4f, player.whoAmI, 16f, 24f); - Main.projectile[num336].netUpdate = true; + int tornado = Projectile.NewProjectile(x * 16 + 8, y * 16 - 24, 0f, 0f, ProjectileID.Cthulunado, 50, 4f, player.whoAmI, 16f, 24f); + Main.projectile[tornado].netUpdate = true; } } @@ -680,8 +680,8 @@ namespace CalamityMod.CalPlayer { float randomVelocity = Main.rand.NextFloat() - 0.5f; Vector2 fireTo = new Vector2(spawnPoint.X + 100f * randomVelocity, spawnPoint.Y + 900f); - Vector2 ai0 = fireTo - spawnPoint; - Vector2 velocity = Vector2.Normalize(ai0) * 12f; + Vector2 direction = fireTo - spawnPoint; + Vector2 velocity = Vector2.Normalize(direction) * 12f; Projectile.NewProjectile(spawnPoint.X, spawnPoint.Y, 0f, velocity.Y, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); } } @@ -693,32 +693,32 @@ namespace CalamityMod.CalPlayer { if (player.miscCounter == 280 && Main.rand.NextBool(10) && player.ownedProjectileCounts[ProjectileID.Sharknado] < 1) { - Main.PlaySound(SoundID.NPCDeath19, (int)sharknadoSpawnPoint.X, (int)sharknadoSpawnPoint.Y); - int num331 = (int)(sharknadoSpawnPoint.Y / 16f); - int num332 = (int)(sharknadoSpawnPoint.X / 16f); + Main.PlaySound(SoundID.NPCDeath19, sharknadoSpawnPoint); + int y = (int)(sharknadoSpawnPoint.Y / 16f); + int x = (int)(sharknadoSpawnPoint.X / 16f); int num333 = 100; - if (num332 < 10) - num332 = 10; - if (num332 > Main.maxTilesX - 10) - num332 = Main.maxTilesX - 10; - if (num331 < 10) - num331 = 10; - if (num331 > Main.maxTilesY - num333 - 10) - num331 = Main.maxTilesY - num333 - 10; + if (x < 10) + x = 10; + if (x > Main.maxTilesX - 10) + x = Main.maxTilesX - 10; + if (y < 10) + y = 10; + if (y > Main.maxTilesY - num333 - 10) + y = Main.maxTilesY - num333 - 10; - int spawnAreaY = Main.maxTilesY - num331; - for (int num334 = num331; num334 < num331 + spawnAreaY; num334++) + int spawnAreaY = Main.maxTilesY - y; + for (int j = y; j < y + spawnAreaY; j++) { - Tile tile = Main.tile[num332, num334]; + Tile tile = Main.tile[x, j]; if ((tile.active() && Main.tileSolid[tile.type]) || tile.liquid >= 200) { - num331 = num334; + y = j; break; } } - int num336 = Projectile.NewProjectile(num332 * 16 + 8, num331 * 16 - 24, 0.01f, 0f, ProjectileID.Sharknado, 25, 4f, player.whoAmI, 16f, 15f); - Main.projectile[num336].netUpdate = true; + int tornado = Projectile.NewProjectile(x * 16 + 8, y * 16 - 24, 0.01f, 0f, ProjectileID.Sharknado, 25, 4f, player.whoAmI, 16f, 15f); + Main.projectile[tornado].netUpdate = true; } } } @@ -825,7 +825,7 @@ namespace CalamityMod.CalPlayer if (modPlayer.omegaBlueSet) { // Add tentacles - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 6) + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 6 && Main.myPlayer == player.whoAmI) { bool[] tentaclesPresent = new bool[6]; for (int i = 0; i < Main.maxProjectiles; i++) @@ -856,7 +856,7 @@ namespace CalamityMod.CalPlayer player.allDamage += damageUp; modPlayer.AllCritBoost(critUp); } - bool canProvideBuffs = player.Calamity().profanedCrystalBuffs || (!modPlayer.profanedCrystal && modPlayer.pArtifact) || (player.Calamity().profanedCrystal && CalamityWorld.downedSCal); + bool canProvideBuffs = modPlayer.profanedCrystalBuffs || (!modPlayer.profanedCrystal && modPlayer.pArtifact) || (modPlayer.profanedCrystal && CalamityWorld.downedSCal); bool attack = player.ownedProjectileCounts[ModContent.ProjectileType()] > 0; // Guardian bonuses if not burnt out if (!modPlayer.bOut && canProvideBuffs) @@ -870,8 +870,8 @@ namespace CalamityMod.CalPlayer if (modPlayer.healCounter <= 0) { - bool enrage = player.statLife <= (int)((double)player.statLifeMax2 * 0.5); - modPlayer.healCounter = (!enrage && player.Calamity().profanedCrystalBuffs) ? 360 : 300; + bool enrage = player.statLife <= (int)(player.statLifeMax2 * 0.5); + modPlayer.healCounter = (!enrage && modPlayer.profanedCrystalBuffs) ? 360 : 300; if (player.whoAmI == Main.myPlayer) { int healAmount = 5 + @@ -988,6 +988,15 @@ namespace CalamityMod.CalPlayer modPlayer.dogTextCooldown--; if (modPlayer.titanCooldown > 0) modPlayer.titanCooldown--; + if (modPlayer.roverDrive) + { + if (modPlayer.roverDriveTimer < CalamityUtils.SecondsToFrames(30f)) + modPlayer.roverDriveTimer++; + if (modPlayer.roverDriveTimer >= CalamityUtils.SecondsToFrames(30f)) + modPlayer.roverDriveTimer = 0; + } + else + modPlayer.roverDriveTimer = CalamityUtils.SecondsToFrames(10f) + 1; //Doesn't reset to zero to prevent exploits // Silva invincibility effects if (modPlayer.silvaCountdown > 0 && modPlayer.hasSilvaEffect && modPlayer.silvaSet) @@ -998,19 +1007,19 @@ namespace CalamityMod.CalPlayer player.buffImmune[ModContent.BuffType()] = true; modPlayer.silvaCountdown -= modPlayer.auricSet ? 2 : 1; if (modPlayer.silvaCountdown <= 0) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SilvaDispel"), (int)player.position.X, (int)player.position.Y); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SilvaDispel"), player.Center); for (int j = 0; j < 2; j++) { - int num = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 157, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 2f); - Main.dust[num].position.X += (float)Main.rand.Next(-20, 21); - Main.dust[num].position.Y += (float)Main.rand.Next(-20, 21); - Main.dust[num].velocity *= 0.9f; - Main.dust[num].noGravity = true; - Main.dust[num].scale *= 1f + (float)Main.rand.Next(40) * 0.01f; - Main.dust[num].shader = GameShaders.Armor.GetSecondaryShader(player.cWaist, player); + int green = Dust.NewDust(player.position, player.width, player.height, 157, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 2f); + Main.dust[green].position.X += (float)Main.rand.Next(-20, 21); + Main.dust[green].position.Y += (float)Main.rand.Next(-20, 21); + Main.dust[green].velocity *= 0.9f; + Main.dust[green].noGravity = true; + Main.dust[green].scale *= 1f + (float)Main.rand.Next(40) * 0.01f; + Main.dust[green].shader = GameShaders.Armor.GetSecondaryShader(player.cWaist, player); if (Main.rand.NextBool(2)) - Main.dust[num].scale *= 1f + (float)Main.rand.Next(40) * 0.01f; + Main.dust[green].scale *= 1f + (float)Main.rand.Next(40) * 0.01f; } } @@ -1027,8 +1036,8 @@ namespace CalamityMod.CalPlayer for (int j = 0; j < 2; j++) { - int num = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 157, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 2f); - Dust dust = Main.dust[num]; + int green = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, 157, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 2f); + Dust dust = Main.dust[green]; dust.position.X += (float)Main.rand.Next(-20, 21); dust.position.Y += (float)Main.rand.Next(-20, 21); dust.velocity *= 0.9f; @@ -1107,8 +1116,8 @@ namespace CalamityMod.CalPlayer for (int j = 0; j < 2; j++) { - int num = Dust.NewDust(new Vector2(player.position.X, player.position.Y), player.width, player.height, DustID.Blood, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[num]; + int blood = Dust.NewDust(player.position, player.width, player.height, DustID.Blood, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[blood]; dust.position.X += (float)Main.rand.Next(-20, 21); dust.position.Y += (float)Main.rand.Next(-20, 21); dust.velocity *= 0.9f; @@ -1152,6 +1161,13 @@ namespace CalamityMod.CalPlayer player.statDefense += 20; } + if (modPlayer.roverDriveTimer < 616) + { + player.statDefense += 10; + if (modPlayer.roverDriveTimer > 606) + player.statDefense -= modPlayer.roverDriveTimer - 606; //so it scales down when the shield dies + } + // Absorber bonus if (modPlayer.absorber) { @@ -1160,7 +1176,7 @@ namespace CalamityMod.CalPlayer player.thorns += 0.5f; player.endurance += 0.05f; - if (Math.Abs(player.velocity.X) < 0.05f && Math.Abs(player.velocity.Y) < 0.05f && player.itemAnimation == 0) + if (player.StandingStill() && player.itemAnimation == 0) player.manaRegenBonus += 2; } @@ -1207,7 +1223,7 @@ namespace CalamityMod.CalPlayer if (modPlayer.draedonsHeart) { player.allDamage += 0.05f; - if (Math.Abs(player.velocity.X) < 0.05f && Math.Abs(player.velocity.Y) < 0.05f && player.itemAnimation == 0) + if (player.StandingStill() && player.itemAnimation == 0) player.statDefense += 25; } @@ -1302,9 +1318,9 @@ namespace CalamityMod.CalPlayer player.velocity.X = 0f; player.velocity.Y = -0.4f; //should negate gravity - int d = Dust.NewDust(player.position, player.width, player.height, 88); - Main.dust[d].noGravity = true; - Main.dust[d].velocity *= 2f; + int ice = Dust.NewDust(player.position, player.width, player.height, 88); + Main.dust[ice].noGravity = true; + Main.dust[ice].velocity *= 2f; player.buffImmune[BuffID.Frozen] = true; player.buffImmune[BuffID.Chilled] = true; @@ -1314,20 +1330,19 @@ namespace CalamityMod.CalPlayer // Cosmic Discharge Cosmic Freeze buff, gives surrounding enemies the Glacial State debuff if (modPlayer.cFreeze) { - int num = ModContent.BuffType(); - float num2 = 200f; - int random = Main.rand.Next(5); + int buffType = ModContent.BuffType(); + float freezeDist = 200f; if (player.whoAmI == Main.myPlayer) { - if (random == 0) + if (Main.rand.NextBool(5)) { for (int l = 0; l < Main.maxNPCs; l++) { - NPC nPC = Main.npc[l]; - if (nPC.active && !nPC.friendly && nPC.damage > 0 && !nPC.dontTakeDamage && !nPC.buffImmune[num] && Vector2.Distance(player.Center, nPC.Center) <= num2) + NPC npc = Main.npc[l]; + if (npc.active && !npc.friendly && npc.damage > 0 && !npc.dontTakeDamage && !npc.buffImmune[buffType] && Vector2.Distance(player.Center, npc.Center) <= freezeDist) { - if (nPC.FindBuffIndex(num) == -1) - nPC.AddBuff(num, 120, false); + if (npc.FindBuffIndex(buffType) == -1) + npc.AddBuff(buffType, 120, false); } } } @@ -1403,25 +1418,25 @@ namespace CalamityMod.CalPlayer float knockBack = 1f; if (Main.rand.NextBool(15)) { - int num = 0; + int projCount = 0; for (int i = 0; i < Main.maxProjectiles; i++) { if (Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].type == ModContent.ProjectileType()) - num++; + projCount++; } - if (Main.rand.Next(15) >= num && num < 6) + if (Main.rand.Next(15) >= projCount && projCount < 6) { - int num2 = 50; + int loopAmt = 50; int num3 = 24; int num4 = 90; - for (int j = 0; j < num2; j++) + for (int j = 0; j < loopAmt; j++) { - int num5 = Main.rand.Next(200 - j * 2, 400 + j * 2); + int sourceVariance = Main.rand.Next(200 - j * 2, 400 + j * 2); Vector2 center = player.Center; - center.X += (float)Main.rand.Next(-num5, num5 + 1); - center.Y += (float)Main.rand.Next(-num5, num5 + 1); + center.X += (float)Main.rand.Next(-sourceVariance, sourceVariance + 1); + center.Y += (float)Main.rand.Next(-sourceVariance, sourceVariance + 1); if (!Collision.SolidCollision(center, num3, num3) && !Collision.WetCollision(center, num3, num3)) { @@ -1430,12 +1445,12 @@ namespace CalamityMod.CalPlayer if (Collision.CanHit(new Vector2(player.Center.X, player.position.Y), 1, 1, center, 1, 1) || Collision.CanHit(new Vector2(player.Center.X, player.position.Y - 50f), 1, 1, center, 1, 1)) { - int num6 = (int)center.X / 16; - int num7 = (int)center.Y / 16; - bool flag = false; + int xSpawn = (int)center.X / 16; + int ySpawn = (int)center.Y / 16; + bool shouldSpawn = false; - if (Main.rand.NextBool(3) && Main.tile[num6, num7] != null && Main.tile[num6, num7].wall > 0) - flag = true; + if (Main.rand.NextBool(3) && Main.tile[xSpawn, ySpawn] != null && Main.tile[xSpawn, ySpawn].wall > 0) + shouldSpawn = true; else { center.X -= (float)(num4 / 2); @@ -1445,23 +1460,23 @@ namespace CalamityMod.CalPlayer { center.X += (float)(num4 / 2); center.Y += (float)(num4 / 2); - flag = true; + shouldSpawn = true; } } - if (flag) + if (shouldSpawn) { for (int k = 0; k < Main.maxProjectiles; k++) { if (Main.projectile[k].active && Main.projectile[k].owner == player.whoAmI && Main.projectile[k].type == ModContent.ProjectileType() && (center - Main.projectile[k].Center).Length() < 48f) { - flag = false; + shouldSpawn = false; break; } } - if (flag && Main.myPlayer == player.whoAmI) - Projectile.NewProjectile(center.X, center.Y, 0f, 0f, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + if (shouldSpawn && Main.myPlayer == player.whoAmI) + Projectile.NewProjectile(center, Vector2.Zero, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); } } } @@ -1518,34 +1533,36 @@ namespace CalamityMod.CalPlayer if (player.spelunkerTimer >= 10) { player.spelunkerTimer = 0; - int num65 = 30; - int num66 = (int)player.Center.X / 16; - int num67 = (int)player.Center.Y / 16; + int distance = 30; + int i = (int)player.Center.X / 16; + int j = (int)player.Center.Y / 16; - for (int num68 = num66 - num65; num68 <= num66 + num65; num68++) + for (int x = i - distance; x <= i + distance; x++) { - for (int num69 = num67 - num65; num69 <= num67 + num65; num69++) + for (int y = j - distance; y <= j + distance; y++) { + Tile tile = Main.tile[x, y]; if (Main.rand.NextBool(4)) { - Vector2 vector = new Vector2((float)(num66 - num68), (float)(num67 - num69)); - if (vector.Length() < (float)num65 && num68 > 0 && num68 < Main.maxTilesX - 1 && num69 > 0 && num69 < Main.maxTilesY - 1 && Main.tile[num68, num69] != null && Main.tile[num68, num69].active()) + Vector2 vector = new Vector2((float)(i - x), (float)(j - y)); + if (vector.Length() < (float)distance && x > 0 && x < Main.maxTilesX - 1 && y > 0 && y < Main.maxTilesY - 1 && tile != null && tile.active()) { - bool flag7 = false; - if (Main.tile[num68, num69].type == 185 && Main.tile[num68, num69].frameY == 18) + bool shouldSpawnDust = false; + //These checks are for money piles. They share a sheet with other background objects so it checks for frames. + if (tile.type == TileID.SmallPiles && tile.frameY == 18) { - if (Main.tile[num68, num69].frameX >= 576 && Main.tile[num68, num69].frameX <= 882) - flag7 = true; + if (tile.frameX >= 576 && tile.frameX <= 882) + shouldSpawnDust = true; } - else if (Main.tile[num68, num69].type == 186 && Main.tile[num68, num69].frameX >= 864 && Main.tile[num68, num69].frameX <= 1170) - flag7 = true; + else if (tile.type == TileID.LargePiles && tile.frameX >= 864 && tile.frameX <= 1170) + shouldSpawnDust = true; - if (flag7 || Main.tileSpelunker[(int)Main.tile[num68, num69].type] || (Main.tileAlch[(int)Main.tile[num68, num69].type] && Main.tile[num68, num69].type != 82)) + if (shouldSpawnDust || Main.tileSpelunker[tile.type] || (Main.tileAlch[tile.type] && tile.type != TileID.ImmatureHerbs)) { - int num70 = Dust.NewDust(new Vector2((float)(num68 * 16), (float)(num69 * 16)), 16, 16, 204, 0f, 0f, 150, default, 0.3f); - Main.dust[num70].fadeIn = 0.75f; - Main.dust[num70].velocity *= 0.1f; - Main.dust[num70].noLight = true; + int sparkle = Dust.NewDust(new Vector2((x * 16f), (y * 16f)), 16, 16, 204, 0f, 0f, 150, default, 0.3f); + Main.dust[sparkle].fadeIn = 0.75f; + Main.dust[sparkle].velocity *= 0.1f; + Main.dust[sparkle].noLight = true; } } } @@ -1563,7 +1580,7 @@ namespace CalamityMod.CalPlayer } if (modPlayer.golemLore) { - if (Math.Abs(player.velocity.X) < 0.05f && Math.Abs(player.velocity.Y) < 0.05f && player.itemAnimation == 0) + if (player.StandingStill() && player.itemAnimation == 0) player.statDefense += 10; } if (modPlayer.dukeFishronLore) @@ -1615,59 +1632,52 @@ namespace CalamityMod.CalPlayer { for (int j = 0; j < Main.maxItems; j++) { - if (Main.item[j].active && Main.item[j].noGrabDelay == 0 && Main.item[j].owner == player.whoAmI) + Item item = Main.item[j]; + if (item.active && item.noGrabDelay == 0 && item.owner == player.whoAmI) { - Main.item[j].beingGrabbed = true; - if ((double)player.position.X + (double)player.width * 0.5 > (double)Main.item[j].position.X + (double)Main.item[j].width * 0.5) + item.beingGrabbed = true; + if (player.Center.X > item.Center.X) { - if (Main.item[j].velocity.X < 90f + player.velocity.X) + if (item.velocity.X < 90f + player.velocity.X) { - Item item = Main.item[j]; item.velocity.X += 9f; } - if (Main.item[j].velocity.X < 0f) + if (item.velocity.X < 0f) { - Item item = Main.item[j]; item.velocity.X += 9f * 0.75f; } } else { - if (Main.item[j].velocity.X > -90f + player.velocity.X) + if (item.velocity.X > -90f + player.velocity.X) { - Item item = Main.item[j]; item.velocity.X -= 9f; } - if (Main.item[j].velocity.X > 0f) + if (item.velocity.X > 0f) { - Item item = Main.item[j]; item.velocity.X -= 9f * 0.75f; } } - if ((double)player.position.Y + (double)player.height * 0.5 > (double)Main.item[j].position.Y + (double)Main.item[j].height * 0.5) + if (player.Center.Y > item.Center.Y) { - if (Main.item[j].velocity.Y < 90f) + if (item.velocity.Y < 90f) { - Item item = Main.item[j]; item.velocity.Y += 9f; } - if (Main.item[j].velocity.Y < 0f) + if (item.velocity.Y < 0f) { - Item item = Main.item[j]; item.velocity.Y += 9f * 0.75f; } } else { - if (Main.item[j].velocity.Y > -90f) + if (item.velocity.Y > -90f) { - Item item = Main.item[j]; item.velocity.Y -= 9f; } - if (Main.item[j].velocity.Y > 0f) + if (item.velocity.Y > 0f) { - Item item = Main.item[j]; item.velocity.Y -= 9f * 0.75f; } } @@ -1678,14 +1688,14 @@ namespace CalamityMod.CalPlayer // Spectral Veil effects if (modPlayer.spectralVeil && modPlayer.spectralVeilImmunity > 0) { - Rectangle sVeilRectangle = new Rectangle((int)((double)player.position.X + (double)player.velocity.X * 0.5 - 4.0), (int)((double)player.position.Y + (double)player.velocity.Y * 0.5 - 4.0), player.width + 8, player.height + 8); + Rectangle sVeilRectangle = new Rectangle((int)(player.position.X + player.velocity.X * 0.5f - 4f), (int)(player.position.Y + player.velocity.Y * 0.5f - 4f), player.width + 8, player.height + 8); for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[i].active && !Main.npc[i].dontTakeDamage && !Main.npc[i].friendly && !Main.npc[i].townNPC && Main.npc[i].immune[player.whoAmI] <= 0 && Main.npc[i].damage > 0) + NPC npc = Main.npc[i]; + if (npc.active && !npc.dontTakeDamage && !npc.friendly && !npc.townNPC && npc.immune[player.whoAmI] <= 0 && npc.damage > 0) { - NPC nPC = Main.npc[i]; - Rectangle rect = nPC.getRect(); - if (sVeilRectangle.Intersects(rect) && (nPC.noTileCollide || player.CanHit(nPC))) + Rectangle rect = npc.getRect(); + if (sVeilRectangle.Intersects(rect) && (npc.noTileCollide || player.CanHit(npc))) { if (player.whoAmI == Main.myPlayer) { @@ -1710,7 +1720,7 @@ namespace CalamityMod.CalPlayer Main.dust[sVeilDustIndex2].noLight = false; } - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SilvaDispel"), (int)Main.player[Main.myPlayer].position.X, (int)Main.player[Main.myPlayer].position.Y); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SilvaDispel"), player.Center); } break; } @@ -1719,9 +1729,9 @@ namespace CalamityMod.CalPlayer for (int i = 0; i < Main.maxProjectiles; i++) { - if (Main.projectile[i].active && !Main.projectile[i].friendly && Main.projectile[i].hostile && Main.projectile[i].damage > 0) + Projectile proj = Main.projectile[i]; + if (proj.active && !proj.friendly && proj.hostile && proj.damage > 0) { - Projectile proj = Main.projectile[i]; Rectangle rect = proj.getRect(); if (sVeilRectangle.Intersects(rect)) { @@ -1748,7 +1758,7 @@ namespace CalamityMod.CalPlayer Main.dust[sVeilDustIndex2].noLight = false; } - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SilvaDispel"), (int)Main.player[Main.myPlayer].position.X, (int)Main.player[Main.myPlayer].position.Y); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SilvaDispel"), player.Center); } break; } @@ -1757,7 +1767,7 @@ namespace CalamityMod.CalPlayer } // Plagued Fuel Pack effects - if (modPlayer.plaguedFuelPackDash > 0) + if (modPlayer.plaguedFuelPackDash > 0 && player.whoAmI == Main.myPlayer) { int velocityMult = modPlayer.plaguedFuelPackDash > 1 ? 25 : 5; player.velocity = new Vector2(modPlayer.plaguedFuelPackDirection, -1) * velocityMult; @@ -1782,7 +1792,7 @@ namespace CalamityMod.CalPlayer } // Blunder Booster effects - if (modPlayer.blunderBoosterDash > 0) + if (modPlayer.blunderBoosterDash > 0 && player.whoAmI == Main.myPlayer) { int velocityMult = modPlayer.blunderBoosterDash > 1 ? 35 : 5; player.velocity = new Vector2(modPlayer.blunderBoosterDirection, -1) * velocityMult; @@ -1807,7 +1817,7 @@ namespace CalamityMod.CalPlayer } // Gravistar Sabaton effects - if (modPlayer.gSabaton) + if (modPlayer.gSabaton && player.whoAmI == Main.myPlayer) { if (modPlayer.gSabatonCooldown <= 0 && !player.mount.Active) { @@ -2133,7 +2143,7 @@ namespace CalamityMod.CalPlayer modPlayer.chiBuffTimer = 0; } - if (Math.Abs(player.velocity.X) < 0.1f && Math.Abs(player.velocity.Y) < 0.1f && !player.mount.Active) + if (player.StandingStill(0.1f) && !player.mount.Active) { if (modPlayer.chiBuffTimer < 120) modPlayer.chiBuffTimer++; @@ -2155,7 +2165,7 @@ namespace CalamityMod.CalPlayer if (modPlayer.aquaticBoost > 0f) { modPlayer.aquaticBoost -= 0.0002f; // 0.015 - if ((double)modPlayer.aquaticBoost <= 0.0) + if (modPlayer.aquaticBoost <= 0f) { modPlayer.aquaticBoost = 0f; if (Main.netMode == NetmodeID.MultiplayerClient) @@ -2184,7 +2194,7 @@ namespace CalamityMod.CalPlayer if (player.itemAnimation > 0) modPlayer.modStealthTimer = 5; - if (Math.Abs(player.velocity.X) < 0.1f && Math.Abs(player.velocity.Y) < 0.1f && !player.mount.Active) + if (player.StandingStill(0.1f) && !player.mount.Active) { if (modPlayer.modStealthTimer == 0 && modPlayer.modStealth > 0f) { @@ -2199,8 +2209,8 @@ namespace CalamityMod.CalPlayer } else { - float num27 = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); - modPlayer.modStealth += num27 * 0.0075f; + float playerVel = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + modPlayer.modStealth += playerVel * 0.0075f; if (modPlayer.modStealth > 1f) modPlayer.modStealth = 1f; if (player.mount.Active) @@ -2223,12 +2233,12 @@ namespace CalamityMod.CalPlayer if (player.itemAnimation > 0) modPlayer.modStealthTimer = 5; - if (Math.Abs(player.velocity.X) < 0.1f && Math.Abs(player.velocity.Y) < 0.1f && !player.mount.Active) + if (player.StandingStill(0.1f) && !player.mount.Active) { if (modPlayer.modStealthTimer == 0 && modPlayer.modStealth > 0f) { modPlayer.modStealth -= 0.015f; - if ((double)modPlayer.modStealth <= 0.0) + if (modPlayer.modStealth <= 0f) { modPlayer.modStealth = 0f; if (Main.netMode == NetmodeID.MultiplayerClient) @@ -2238,8 +2248,8 @@ namespace CalamityMod.CalPlayer } else { - float num27 = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); - modPlayer.modStealth += num27 * 0.0075f; + float playerVel = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + modPlayer.modStealth += playerVel * 0.0075f; if (modPlayer.modStealth > 1f) modPlayer.modStealth = 1f; if (player.mount.Active) @@ -2262,7 +2272,7 @@ namespace CalamityMod.CalPlayer { if (modPlayer.elysianAegis) { - bool flag14 = false; + bool spawnDust = false; // Activate buff if (modPlayer.elysianGuard) @@ -2270,14 +2280,14 @@ namespace CalamityMod.CalPlayer if (player.whoAmI == Main.myPlayer) player.AddBuff(ModContent.BuffType(), 2, false); - float num29 = modPlayer.shieldInvinc; + float shieldBoostInitial = modPlayer.shieldInvinc; modPlayer.shieldInvinc -= 0.08f; if (modPlayer.shieldInvinc < 0f) modPlayer.shieldInvinc = 0f; else - flag14 = true; + spawnDust = true; - if (modPlayer.shieldInvinc == 0f && num29 != modPlayer.shieldInvinc && Main.netMode == NetmodeID.MultiplayerClient) + if (modPlayer.shieldInvinc == 0f && shieldBoostInitial != modPlayer.shieldInvinc && Main.netMode == NetmodeID.MultiplayerClient) NetMessage.SendData(MessageID.PlayerStealth, -1, -1, null, player.whoAmI, 0f, 0f, 0f, 0, 0, 0); float damageBoost = (5f - modPlayer.shieldInvinc) * 0.03f; @@ -2297,38 +2307,38 @@ namespace CalamityMod.CalPlayer // Remove buff else { - float num30 = modPlayer.shieldInvinc; + float shieldBoostInitial = modPlayer.shieldInvinc; modPlayer.shieldInvinc += 0.08f; if (modPlayer.shieldInvinc > 5f) modPlayer.shieldInvinc = 5f; else - flag14 = true; + spawnDust = true; - if (modPlayer.shieldInvinc == 5f && num30 != modPlayer.shieldInvinc && Main.netMode == NetmodeID.MultiplayerClient) + if (modPlayer.shieldInvinc == 5f && shieldBoostInitial != modPlayer.shieldInvinc && Main.netMode == NetmodeID.MultiplayerClient) NetMessage.SendData(MessageID.PlayerStealth, -1, -1, null, player.whoAmI, 0f, 0f, 0f, 0, 0, 0); } // Emit dust - if (flag14) + if (spawnDust) { if (Main.rand.NextBool(2)) { - Vector2 vector = Vector2.UnitY.RotatedByRandom(6.2831854820251465); + Vector2 vector = Vector2.UnitY.RotatedByRandom(Math.PI * 2D); Dust dust = Main.dust[Dust.NewDust(player.Center - vector * 30f, 0, 0, (int)CalamityDusts.ProfanedFire, 0f, 0f, 0, default, 1f)]; dust.noGravity = true; dust.position = player.Center - vector * (float)Main.rand.Next(5, 11); - dust.velocity = vector.RotatedBy(1.5707963705062866, default) * 4f; + dust.velocity = vector.RotatedBy(Math.PI / 2D, default) * 4f; dust.scale = 0.5f + Main.rand.NextFloat(); dust.fadeIn = 0.5f; } if (Main.rand.NextBool(2)) { - Vector2 vector2 = Vector2.UnitY.RotatedByRandom(6.2831854820251465); + Vector2 vector2 = Vector2.UnitY.RotatedByRandom(Math.PI * 2D); Dust dust2 = Main.dust[Dust.NewDust(player.Center - vector2 * 30f, 0, 0, 246, 0f, 0f, 0, default, 1f)]; dust2.noGravity = true; dust2.position = player.Center - vector2 * 12f; - dust2.velocity = vector2.RotatedBy(-1.5707963705062866, default) * 2f; + dust2.velocity = vector2.RotatedBy(-Math.PI / 2D, default) * 2f; dust2.scale = 0.5f + Main.rand.NextFloat(); dust2.fadeIn = 0.5f; } @@ -2516,6 +2526,15 @@ namespace CalamityMod.CalPlayer player.magicQuiver = true; } + if (modPlayer.bloodPactBoost) + { + player.allDamage += 0.05f; + player.statDefense += 20; + player.endurance += 0.1f; + player.longInvince = true; + player.crimsonRegen = true; + } + if (modPlayer.fabsolVodka) { player.allDamage += 0.08f; @@ -2676,6 +2695,11 @@ namespace CalamityMod.CalPlayer if (player.ActiveItem().type != ModContent.ItemType() && player.ActiveItem().type != ModContent.ItemType()) modPlayer.brimlashBusterBoost = false; } + if (modPlayer.animusBoost > 1f) + { + if (player.ActiveItem().type != ModContent.ItemType()) + modPlayer.animusBoost = 1f; + } if (modPlayer.etherealExtorter) { @@ -2701,7 +2725,7 @@ namespace CalamityMod.CalPlayer if (modPlayer.ZoneAstral) { if (player.wingTimeMax > 0) - player.wingTimeMax = (int)((double)player.wingTimeMax * 1.05); + player.wingTimeMax = (int)(player.wingTimeMax * 1.05); } if (player.ZoneJungle && CalamityMod.natureWeaponList.Contains(player.ActiveItem().type)) @@ -3085,35 +3109,10 @@ namespace CalamityMod.CalPlayer { player.panic = true; player.pStone = true; - player.armorPenetration += 10; + player.armorPenetration += modPlayer.rampartOfDeities ? 20 : 10; } - if (modPlayer.rampartOfDeities) - { - player.armorPenetration += 10; - player.noKnockback = true; - if (player.statLife > (int)(player.statLifeMax2 * 0.25)) - { - player.hasPaladinShield = true; - if (player.whoAmI != Main.myPlayer && player.miscCounter % 10 == 0) - { - int myPlayer = Main.myPlayer; - if (Main.player[myPlayer].team == player.team && player.team != 0) - { - Vector2 otherPlayerPos = player.position - Main.player[myPlayer].position; - - if (otherPlayerPos.Length() < 800f) - Main.player[myPlayer].AddBuff(BuffID.PaladinsShield, 20, true); - } - } - } - - if (player.statLife <= (int)(player.statLifeMax2 * 0.5)) - player.AddBuff(BuffID.IceBarrier, 5, true); - if (player.statLife <= (int)(player.statLifeMax2 * 0.15)) - player.endurance += 0.05f; - } - else if (modPlayer.fBulwark) + if (modPlayer.fBulwark) { player.noKnockback = true; if (player.statLife > (int)(player.statLifeMax2 * 0.25)) @@ -3208,7 +3207,8 @@ namespace CalamityMod.CalPlayer if (modPlayer.reaperToothNecklace) { player.allDamage += 0.25f; - player.statDefense /= 2; + if (player.statDefense > 0) + player.statDefense /= 2; } if (modPlayer.deepDiver) @@ -3270,12 +3270,12 @@ namespace CalamityMod.CalPlayer for (int i = 0; i < Main.maxNPCs; ++i) { - NPC nPC = Main.npc[i]; - if (!nPC.active || nPC.friendly || nPC.damage <= 0 || nPC.dontTakeDamage) + NPC npc = Main.npc[i]; + if (!npc.active || npc.friendly || npc.damage <= 0 || npc.dontTakeDamage) continue; - if (Vector2.Distance(player.Center, nPC.Center) <= range) - Projectile.NewProjectileDirect(nPC.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, i); + if (Vector2.Distance(player.Center, npc.Center) <= range) + Projectile.NewProjectileDirect(npc.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, i); } } } @@ -3297,23 +3297,23 @@ namespace CalamityMod.CalPlayer for (int i = 0; i < Main.maxNPCs; ++i) { - NPC nPC = Main.npc[i]; - if (!nPC.active || nPC.friendly || nPC.damage <= 0 || nPC.dontTakeDamage) + NPC npc = Main.npc[i]; + if (!npc.active || npc.friendly || npc.damage <= 0 || npc.dontTakeDamage) continue; - if (Vector2.Distance(player.Center, nPC.Center) <= range) - Projectile.NewProjectileDirect(nPC.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, i); + if (Vector2.Distance(player.Center, npc.Center) <= range) + Projectile.NewProjectileDirect(npc.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, i); // Occasionally spawn cute sparks so it looks like an electrical aura if (Main.rand.NextBool(10)) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - while (value15.X == 0f && value15.Y == 0f) - value15 = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); + Vector2 velocity = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); + while (velocity.X == 0f && velocity.Y == 0f) + velocity = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - value15.Normalize(); - value15 *= (float)Main.rand.Next(30, 61) * 0.1f; - int spark = Projectile.NewProjectile(nPC.Center.X, nPC.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), damage / 2, 0f, player.whoAmI, 0f, 0f); + velocity.Normalize(); + velocity *= (float)Main.rand.Next(30, 61) * 0.1f; + int spark = Projectile.NewProjectile(npc.Center, velocity, ModContent.ProjectileType(), damage / 2, 0f, player.whoAmI, 0f, 0f); Main.projectile[spark].Calamity().forceTypeless = true; Main.projectile[spark].localNPCHitCooldown = -2; Main.projectile[spark].penetrate = 5; @@ -3340,15 +3340,15 @@ namespace CalamityMod.CalPlayer for (int i = 0; i < Main.maxNPCs; ++i) { - NPC nPC = Main.npc[i]; - if (!nPC.active || nPC.friendly || nPC.damage <= 0 || nPC.dontTakeDamage) + NPC npc = Main.npc[i]; + if (!npc.active || npc.friendly || npc.damage <= 0 || npc.dontTakeDamage) continue; - if (Vector2.Distance(player.Center, nPC.Center) <= range) + if (Vector2.Distance(player.Center, npc.Center) <= range) { - nPC.AddBuff(ModContent.BuffType(), 120); + npc.AddBuff(ModContent.BuffType(), 120); if (modPlayer.brimLoreInfernoTimer == 0) - Projectile.NewProjectileDirect(nPC.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, i); + Projectile.NewProjectileDirect(npc.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, i); } } } @@ -3427,7 +3427,7 @@ namespace CalamityMod.CalPlayer player.AddBuff(ModContent.BuffType(), 3600, true); if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 2) - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(232f * player.MinionDamage()), 2f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(232f * player.MinionDamage()), 2f, Main.myPlayer, 0f, 0f); } } @@ -3439,6 +3439,8 @@ namespace CalamityMod.CalPlayer player.AddBuff(ModContent.BuffType(), 3600, true); bool crystal = modPlayer.profanedCrystal && !modPlayer.profanedCrystalForce; + bool summonSet = modPlayer.tarraSummon || modPlayer.bloodflareSummon || modPlayer.godSlayerSummon || modPlayer.silvaSummon || modPlayer.dsSetBonus || modPlayer.omegaBlueSet || modPlayer.fearmongerSet; + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -6f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); @@ -3450,7 +3452,7 @@ namespace CalamityMod.CalPlayer Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -3f, ModContent.ProjectileType(), 1, 1f, Main.myPlayer, 0f, 0f); } - if (crystal || (modPlayer.tarraSummon || modPlayer.bloodflareSummon || modPlayer.godSlayerSummon || modPlayer.silvaSummon || modPlayer.dsSetBonus || modPlayer.omegaBlueSet || modPlayer.fearmongerSet)) + if (crystal || summonSet) { player.Calamity().gOffense = true; @@ -3500,10 +3502,10 @@ namespace CalamityMod.CalPlayer bool special = player.name == "Amber" || player.name == "Nincity" || player.name == "IbanPlay" || player.name == "Chen"; //People who either helped create the item or test it. for (int i = 0; i < 3; i++) { - int num469 = Dust.NewDust(player.position, player.width, player.height, special ? 231 : (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, special ? Color.DarkRed : default, 1f); - Main.dust[num469].scale = special ? 1.169f : 2f; - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= special ? 10f : 6.9f; + int fire = Dust.NewDust(player.position, player.width, player.height, special ? 231 : (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, special ? Color.DarkRed : default, 1f); + Main.dust[fire].scale = special ? 1.169f : 2f; + Main.dust[fire].noGravity = true; + Main.dust[fire].velocity *= special ? 10f : 6.9f; } } } @@ -3527,8 +3529,7 @@ namespace CalamityMod.CalPlayer int damage = (int)(30 * player.MinionDamage()); for (int index = 0; index < beeCount; ++index) { - int bee = Projectile.NewProjectile(player.Center.X, player.Center.Y, Main.rand.NextFloat(-35f, 35f) * 0.02f, Main.rand.NextFloat(-35f, 35f) * 0.02f, (Main.rand.NextBool(4) ? ModContent.ProjectileType() : player.beeType()), damage, player.beeKB(0f), player.whoAmI, 0f, 0f); - Main.projectile[bee].Calamity().forceMinion = true; + int bee = Projectile.NewProjectile(player.Center.X, player.Center.Y, Main.rand.NextFloat(-35f, 35f) * 0.02f, Main.rand.NextFloat(-35f, 35f) * 0.02f, (Main.rand.NextBool(4) ? ModContent.ProjectileType() : player.beeType()), damage, player.beeKB(0f), player.whoAmI, 0f, 0f); Main.projectile[bee].usesLocalNPCImmunity = true; Main.projectile[bee].localNPCHitCooldown = 10; Main.projectile[bee].penetrate = 2; @@ -3573,7 +3574,7 @@ namespace CalamityMod.CalPlayer if (player.whoAmI == Main.myPlayer) { if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(30 * player.RogueDamage()), 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(30 * player.RogueDamage()), 0f, player.whoAmI, 0f, 0f); } } else if (player.ownedProjectileCounts[ModContent.ProjectileType()] != 0) @@ -3606,7 +3607,7 @@ namespace CalamityMod.CalPlayer } //Summon the aura if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(10 * player.AverageDamage()), 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(10 * player.AverageDamage()), 0f, player.whoAmI, 0f, 0f); } } else if (player.ownedProjectileCounts[ModContent.ProjectileType()] != 0) @@ -3668,10 +3669,10 @@ namespace CalamityMod.CalPlayer velocity.Y *= travelDist; velocity.X += Main.rand.Next(-50, 51) * 0.02f; velocity.Y += Main.rand.Next(-50, 51) * 0.02f; - int laser = Projectile.NewProjectile(startPos, velocity, ModContent.ProjectileType(), dmg, 4f, player.whoAmI, 0f, Main.rand.Next(10)); + int laser = Projectile.NewProjectile(startPos, velocity, ModContent.ProjectileType(), dmg, 4f, player.whoAmI, 0f, 0f); Main.projectile[laser].localNPCHitCooldown = 5; } - Main.PlaySound(SoundID.Item12, player.position); + Main.PlaySound(SoundID.Item12, player.Center); } if (modPlayer.prismaticLasers == 1800) { @@ -3699,13 +3700,13 @@ namespace CalamityMod.CalPlayer new Color(255, 0, 255, 50), //Fuschia new Color(255, 0, 128, 50) //Hot Pink }); - Vector2 vector6 = Vector2.Normalize(player.velocity) * new Vector2(player.width / 2f, player.height) * 0.75f; - vector6 = vector6.RotatedBy((dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / dustAmt, default) + player.Center; - Vector2 vector7 = vector6 - player.Center; - int dusty = Dust.NewDust(vector6 + vector7, 0, 0, 267, vector7.X * 1f, vector7.Y * 1f, 100, color, 1f); + Vector2 source = Vector2.Normalize(player.velocity) * new Vector2(player.width / 2f, player.height) * 0.75f; + source = source.RotatedBy((dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / dustAmt, default) + player.Center; + Vector2 dustVel = source - player.Center; + int dusty = Dust.NewDust(source + dustVel, 0, 0, 267, dustVel.X * 1f, dustVel.Y * 1f, 100, color, 1f); Main.dust[dusty].noGravity = true; Main.dust[dusty].noLight = true; - Main.dust[dusty].velocity = vector7; + Main.dust[dusty].velocity = dustVel; } } diff --git a/CalamityMod.cs b/CalamityMod.cs index 0702c76f83..9ecaf7bd76 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -2128,7 +2128,7 @@ namespace CalamityMod ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), - ModContent.ProjectileType(), + ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType() }; @@ -3391,6 +3391,13 @@ namespace CalamityMod StealthUI.Draw(Main.spriteBatch, Main.LocalPlayer); return true; }, InterfaceScaleType.None)); + + // Popup GUIs. + layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Popup GUIs", () => + { + PopupGUIManager.UpdateAndDraw(Main.spriteBatch); + return true; + }, InterfaceScaleType.None)); } // Invasion UI (used for Acid Rain) @@ -3406,11 +3413,6 @@ namespace CalamityMod return true; }, InterfaceScaleType.None)); } - layers.Add(new LegacyGameInterfaceLayer("Popup GUIs", () => - { - PopupGUIManager.UpdateAndDraw(Main.spriteBatch); - return true; - }, InterfaceScaleType.None)); } public static Color GetNPCColor(NPC npc, Vector2? position = null, bool effects = true, float shadowOverride = 0f) diff --git a/ExtraTextures/Chains/PlantationChain.png b/ExtraTextures/Chains/PlantationChain.png new file mode 100644 index 0000000000..0ce93ea713 Binary files /dev/null and b/ExtraTextures/Chains/PlantationChain.png differ diff --git a/ExtraTextures/RoverAccShield.png b/ExtraTextures/RoverAccShield.png new file mode 100644 index 0000000000..9250879d99 Binary files /dev/null and b/ExtraTextures/RoverAccShield.png differ diff --git a/ExtraTextures/WulfrumPylon.png b/ExtraTextures/WulfrumPylon.png new file mode 100644 index 0000000000..c578407dd3 Binary files /dev/null and b/ExtraTextures/WulfrumPylon.png differ diff --git a/Items/Accessories/AmalgamatedBrain.cs b/Items/Accessories/AmalgamatedBrain.cs index 333cd53aaa..031d0cea48 100644 --- a/Items/Accessories/AmalgamatedBrain.cs +++ b/Items/Accessories/AmalgamatedBrain.cs @@ -38,26 +38,8 @@ namespace CalamityMod.Items.Accessories { if (player.whoAmI == Main.myPlayer) { - for (int l = 0; l < 1; l++) - { - float x = player.position.X + (float)Main.rand.Next(-400, 400); - float y = player.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num15 = player.position.X + (float)(player.width / 2) - vector.X; - float num16 = player.position.Y + (float)(player.height / 2) - vector.Y; - num15 += (float)Main.rand.Next(-100, 101); - int num17 = 22; - float num18 = (float)Math.Sqrt((double)(num15 * num15 + num16 * num16)); - num18 = (float)num17 / num18; - num15 *= num18; - num16 *= num18; - int num19 = Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), (int)(60 * player.AverageDamage()), 2f, player.whoAmI, 0f, 0f); - Main.projectile[num19].ai[1] = player.position.Y; - Main.projectile[num19].tileCollide = false; - Main.projectile[num19].usesLocalNPCImmunity = true; - Main.projectile[num19].localNPCHitCooldown = 10; - Main.projectile[num19].Calamity().forceTypeless = true; - } + Projectile rain = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(60 * player.AverageDamage()), 2f, player.whoAmI, 6, 1); + rain.tileCollide = false; } } } diff --git a/Items/Accessories/AmbrosialAmpoule.cs b/Items/Accessories/AmbrosialAmpoule.cs index 4623368c48..21235fc272 100644 --- a/Items/Accessories/AmbrosialAmpoule.cs +++ b/Items/Accessories/AmbrosialAmpoule.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -16,8 +18,7 @@ namespace CalamityMod.Items.Accessories "5% increased damage reduction and increased life regen\n" + "Poison, Freeze, Chill, Frostburn, and Venom immunity\n" + "Honey-like life regen with no speed penalty\n" + - "Most bee/hornet enemies and projectiles do 75% damage to you\n" + - "Provides cold protection in Death Mode"); + "Most bee/hornet enemies and projectiles do 75% damage to you"); } public override void SetDefaults() @@ -30,12 +31,26 @@ namespace CalamityMod.Items.Accessories item.accessory = true; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip5") + { + line2.text = "Most bee/hornet enemies and projectiles do 75% damage to you\n" + + "Provides cold protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); modPlayer.beeResist = true; modPlayer.aAmpoule = true; - } public override void AddRecipes() diff --git a/Items/Accessories/AngelTreads.cs b/Items/Accessories/AngelTreads.cs index beb02fbfac..26391d7720 100644 --- a/Items/Accessories/AngelTreads.cs +++ b/Items/Accessories/AngelTreads.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -17,8 +19,7 @@ namespace CalamityMod.Items.Accessories "Increased flight time\n" + "Greater mobility on ice\n" + "Water and lava walking\n" + - "Temporary immunity to lava\n" + - "Provides heat protection in Death Mode"); + "Temporary immunity to lava"); } public override void SetDefaults() @@ -30,6 +31,21 @@ namespace CalamityMod.Items.Accessories item.accessory = true; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip5") + { + line2.text = "Temporary immunity to lava\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Accessories/BlazingCore.cs b/Items/Accessories/BlazingCore.cs index 2e6a725cc5..eb25eb462c 100644 --- a/Items/Accessories/BlazingCore.cs +++ b/Items/Accessories/BlazingCore.cs @@ -1,4 +1,6 @@ using CalamityMod.CalPlayer; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.DataStructures; using Terraria.ModLoader; @@ -15,8 +17,7 @@ namespace CalamityMod.Items.Accessories "Being hit creates a miniature sun that lingers, dealing damage to nearby enemies\n" + "The sun will slowly drag enemies into it\n" + "Only one sun can be active at once\n" + - "Provides a moderate amount of light in the Abyss\n" + - "Provides heat and cold protection in Death Mode"); + "Provides a moderate amount of light in the Abyss"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(5, 6)); } @@ -30,6 +31,21 @@ namespace CalamityMod.Items.Accessories item.value = CalamityGlobalItem.Rarity12BuyPrice; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip5") + { + line2.text = "Provides a moderate amount of light in the Abyss\n" + + "Provides heat and cold protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Accessories/BloodPact.cs b/Items/Accessories/BloodPact.cs index 3526c126d6..034f361058 100644 --- a/Items/Accessories/BloodPact.cs +++ b/Items/Accessories/BloodPact.cs @@ -10,7 +10,9 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Blood Pact"); Tooltip.SetDefault("Doubles your max HP\n" + - "Allows you to be critically hit 25% of the time"); + "Allows you to be critically hit 25% of the time\n" + + "After a critical hit, you gain various buffs for ten seconds\n" + + "Any healing potions consumed during this time period heal 50 percent more health"); } public override void SetDefaults() diff --git a/Items/Accessories/CalamityRing.cs b/Items/Accessories/CalamityRing.cs index 168d2e83cf..e96d9921a1 100644 --- a/Items/Accessories/CalamityRing.cs +++ b/Items/Accessories/CalamityRing.cs @@ -41,18 +41,7 @@ namespace CalamityMod.Items.Accessories { if (Main.rand.NextBool(10)) { - float x = player.position.X + (float)Main.rand.Next(-400, 400); - float y = player.position.Y - (float)Main.rand.Next(500, 800); - Vector2 source = new Vector2(x, y); - Vector2 velocity = player.Center - source; - velocity.X += (float)Main.rand.Next(-100, 101); - float speed = 22f; - float targetDist = velocity.Length(); - targetDist = speed / targetDist; - velocity.X *= targetDist; - velocity.Y *= targetDist; - int fire = Projectile.NewProjectile(source, velocity, ModContent.ProjectileType(), (int)(30 * player.AverageDamage()), 5f, player.whoAmI, 0f, 0f); - Main.projectile[fire].ai[1] = player.position.Y; + CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(30 * player.AverageDamage()), 5f, player.whoAmI); } } } diff --git a/Items/Accessories/ElementalGauntlet.cs b/Items/Accessories/ElementalGauntlet.cs index b63547e278..6204e7e09a 100644 --- a/Items/Accessories/ElementalGauntlet.cs +++ b/Items/Accessories/ElementalGauntlet.cs @@ -1,6 +1,8 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Tiles.Furniture.CraftingStations; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,8 +20,7 @@ namespace CalamityMod.Items.Accessories "Increased invincibility after taking damage\n" + "Temporary immunity to lava\n" + "Increased melee knockback\n" + - "Melee attacks have a chance to instantly kill normal enemies\n" + - "Provides heat and cold protection in Death Mode"); + "Melee attacks have a chance to instantly kill normal enemies"); } public override void SetDefaults() @@ -31,6 +32,21 @@ namespace CalamityMod.Items.Accessories item.Calamity().customRarity = CalamityRarity.DarkBlue; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip6") + { + line2.text = "Melee attacks have a chance to instantly kill normal enemies\n" + + "Provides heat and cold protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Accessories/EvasionScarf.cs b/Items/Accessories/EvasionScarf.cs index 7c7b45012c..9907cb2e8c 100644 --- a/Items/Accessories/EvasionScarf.cs +++ b/Items/Accessories/EvasionScarf.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Evasion Scarf"); - Tooltip.SetDefault("True melee strikes deal 30% more damage\n" + + Tooltip.SetDefault("True melee strikes deal 25% more damage\n" + "Grants the ability to dash; dashing into an attack will cause you to dodge it\n" + "After a dodge you will be granted a buff to all damage, melee speed, and all crit chance for a short time\n" + "After a successful dodge you must wait 13 seconds before you can dodge again\n" + diff --git a/Items/Accessories/FrigidBulwark.cs b/Items/Accessories/FrigidBulwark.cs index e0f561e3a5..781cffd5c5 100644 --- a/Items/Accessories/FrigidBulwark.cs +++ b/Items/Accessories/FrigidBulwark.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -15,8 +17,7 @@ namespace CalamityMod.Items.Accessories "Only active above 25% life\n" + "Grants immunity to knockback\n" + "Puts a shell around the owner when below 50% life that reduces damage\n" + - "The shell becomes more powerful when below 15% life and reduces damage even further\n" + - "Provides heat and cold protection in Death Mode"); + "The shell becomes more powerful when below 15% life and reduces damage even further"); } public override void SetDefaults() @@ -29,6 +30,21 @@ namespace CalamityMod.Items.Accessories item.accessory = true; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip4") + { + line2.text = "The shell becomes more powerful when below 15% life and reduces damage even further\n" + + "Provides heat and cold protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Accessories/FrostBarrier.cs b/Items/Accessories/FrostBarrier.cs index 8cab320dc5..95b82045cb 100644 --- a/Items/Accessories/FrostBarrier.cs +++ b/Items/Accessories/FrostBarrier.cs @@ -1,4 +1,6 @@ using CalamityMod.CalPlayer; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,8 +13,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Frost Barrier"); Tooltip.SetDefault("You will freeze enemies near you when you are struck\n" + - "You are immune to the chilled debuff\n" + - "Provides heat and cold protection in Death Mode"); + "You are immune to the chilled debuff"); } public override void SetDefaults() @@ -25,6 +26,21 @@ namespace CalamityMod.Items.Accessories item.accessory = true; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text = "You are immune to the chilled debuff\n" + + "Provides heat and cold protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Accessories/FrostFlare.cs b/Items/Accessories/FrostFlare.cs index 5e4c5660d3..17507e218b 100644 --- a/Items/Accessories/FrostFlare.cs +++ b/Items/Accessories/FrostFlare.cs @@ -1,4 +1,6 @@ using CalamityMod.CalPlayer; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.DataStructures; using Terraria.ModLoader; @@ -15,8 +17,7 @@ namespace CalamityMod.Items.Accessories "Resistant to cold attacks and +1 life regen\n" + "Being above 75% life grants the player 10% increased damage\n" + "Being below 25% life grants the player 10 defense and 15% increased max movement speed and acceleration\n" + - "Provides heat and cold protection in Death Mode\n" + - "Revengeance drop"); + "Revengeance drop"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(5, 4)); } @@ -30,6 +31,21 @@ namespace CalamityMod.Items.Accessories item.accessory = true; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip5") + { + line2.text = "Provides heat and cold protection in Death Mode\n" + + "Revengeance drop"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Accessories/GiantPearl.cs b/Items/Accessories/GiantPearl.cs index fc2a940535..c2e119ac94 100644 --- a/Items/Accessories/GiantPearl.cs +++ b/Items/Accessories/GiantPearl.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.giantPearl = true; - Lighting.AddLight((int)(player.position.X + (float)(player.width / 2)) / 16, (int)(player.position.Y + (float)(player.height / 2)) / 16, 0.45f, 0.8f, 0.8f); + Lighting.AddLight((int)player.Center.X / 16, (int)player.Center.Y / 16, 0.45f, 0.8f, 0.8f); } } } diff --git a/Items/Accessories/PermafrostsConcoction.cs b/Items/Accessories/PermafrostsConcoction.cs index bea2728aaf..fa2c7d887e 100644 --- a/Items/Accessories/PermafrostsConcoction.cs +++ b/Items/Accessories/PermafrostsConcoction.cs @@ -1,3 +1,5 @@ +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ModLoader; @@ -12,8 +14,7 @@ namespace CalamityMod.Items.Accessories Increases life regen as life decreases Increases life regen when afflicted with Poison, On Fire, or Brimstone Flames You will survive fatal damage and revive with 30% life on a 3 minute cooldown -You are encased in an ice barrier for 3 seconds when revived -Provides heat and cold protection in Death Mode"); +You are encased in an ice barrier for 3 seconds when revived"); } public override void SetDefaults() @@ -25,6 +26,21 @@ Provides heat and cold protection in Death Mode"); item.rare = 5; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip4") + { + line2.text = "You are encased in an ice barrier for 3 seconds when revived\n" + + "Provides heat and cold protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { player.Calamity().permafrostsConcoction = true; diff --git a/Items/Accessories/ProfanedSoulCrystal.cs b/Items/Accessories/ProfanedSoulCrystal.cs index 6f059f0239..36c2e250d0 100644 --- a/Items/Accessories/ProfanedSoulCrystal.cs +++ b/Items/Accessories/ProfanedSoulCrystal.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Accessories * bab spears being fired happens at the bottom of calplayer * Animation of legs is postupdate, animation of wings is frameeffects. * Projectiles transformed are ONLY affected by alldamage and summon damage bonuses, likewise the weapon's base damage/usetime is NOT taken into account. - * You enrage below below or at 50% hp. + * You enrage below or at 50% hp. */ public override void SetStaticDefaults() { @@ -39,9 +39,7 @@ namespace CalamityMod.Items.Accessories "Summons and empowers the profaned babs to fight alongside you\n" + "You are no longer affected by burn out when hit\n" + "Provides buffs depending on the time of day\n" + - "Provides heat and cold protection in Death Mode\n" + - "Thinking back, it was a boring life\n" + - "[c/FFBF49:And so we burn it all in the name of purity]"); + "This line is modified below"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(8, 4)); } @@ -97,6 +95,29 @@ namespace CalamityMod.Items.Accessories line.text = "[c/3a83e4:Transforms Magic attacks into a powerful splitting fireball for " + manaCost + " mana per cast]"; } } + if (CalamityWorld.death) + { + foreach (TooltipLine line in tooltips) + { + if (line.mod == "Terraria" && line.Name == "Tooltip11") + { + line.text = "Provides heat and cold protection in Death Mode\n" + + "Thinking back, it was a boring life\n" + + "[c/FFBF49:And so we burn it all in the name of purity]"; + } + } + } + else + { + foreach (TooltipLine line in tooltips) + { + if (line.mod == "Terraria" && line.Name == "Tooltip11") + { + line.text = "Thinking back, it was a boring life\n" + + "[c/FFBF49:And so we burn it all in the name of purity]"; + } + } + } } } diff --git a/Items/Accessories/RampartofDeities.cs b/Items/Accessories/RampartofDeities.cs index 449f87fd77..6be7867887 100644 --- a/Items/Accessories/RampartofDeities.cs +++ b/Items/Accessories/RampartofDeities.cs @@ -1,6 +1,8 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Tiles.Furniture.CraftingStations; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ModLoader; @@ -19,8 +21,7 @@ namespace CalamityMod.Items.Accessories "Only active above 25% life\n" + "Grants immunity to knockback and reduces the cooldown of healing potions\n" + "Puts a shell around the owner when below 50% life that reduces damage\n" + - "The shell becomes more powerful when below 15% life and reduces damage even further\n" + - "Provides heat and cold protection in Death Mode"); + "The shell becomes more powerful when below 15% life and reduces damage even further"); } public override void SetDefaults() @@ -33,11 +34,27 @@ namespace CalamityMod.Items.Accessories item.Calamity().customRarity = CalamityRarity.DarkBlue; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip8") + { + line2.text = "The shell becomes more powerful when below 15% life and reduces damage even further\n" + + "Provides heat and cold protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); modPlayer.dAmulet = true; modPlayer.rampartOfDeities = true; + modPlayer.fBulwark = true; modPlayer.jellyfishNecklace = true; } diff --git a/Items/Accessories/RottenBrain.cs b/Items/Accessories/RottenBrain.cs index 1f338e495d..6ada62f8f1 100644 --- a/Items/Accessories/RottenBrain.cs +++ b/Items/Accessories/RottenBrain.cs @@ -33,26 +33,8 @@ namespace CalamityMod.Items.Accessories { if (player.whoAmI == Main.myPlayer) { - for (int l = 0; l < 1; l++) - { - float x = player.position.X + (float)Main.rand.Next(-400, 400); - float y = player.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num15 = player.position.X + (float)(player.width / 2) - vector.X; - float num16 = player.position.Y + (float)(player.height / 2) - vector.Y; - num15 += (float)Main.rand.Next(-100, 101); - int num17 = 22; - float num18 = (float)Math.Sqrt((double)(num15 * num15 + num16 * num16)); - num18 = (float)num17 / num18; - num15 *= num18; - num16 *= num18; - int num19 = Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), (int)(18 * player.AverageDamage()), 2f, player.whoAmI, 0f, 0f); - Main.projectile[num19].ai[1] = player.position.Y; - Main.projectile[num19].tileCollide = false; - Main.projectile[num19].usesLocalNPCImmunity = true; - Main.projectile[num19].localNPCHitCooldown = 10; - Main.projectile[num19].Calamity().forceTypeless = true; - } + Projectile rain = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(18 * player.AverageDamage()), 2f, player.whoAmI, 6, 1); + rain.tileCollide = false; } } } diff --git a/Items/Accessories/RoverDrive.cs b/Items/Accessories/RoverDrive.cs new file mode 100644 index 0000000000..eb6db78b0b --- /dev/null +++ b/Items/Accessories/RoverDrive.cs @@ -0,0 +1,32 @@ +using CalamityMod.CalPlayer; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + public class RoverDrive : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rover Drive"); + Tooltip.SetDefault("Activates a protective shield that grants 10 defense for 10 seconds\n" + + //Actually 10.1 seconds at full power with a dissipation across 0.1666 seconds but whatever + "The shield then dissipates and recharges for 20 seconds before being reactivated"); + } + + public override void SetDefaults() + { + item.width = 38; + item.height = 26; + item.value = CalamityGlobalItem.Rarity1BuyPrice; + item.rare = 1; + item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.roverDrive = true; + } + } +} diff --git a/Items/Accessories/RoverDrive.png b/Items/Accessories/RoverDrive.png new file mode 100644 index 0000000000..dc5b42b8ba Binary files /dev/null and b/Items/Accessories/RoverDrive.png differ diff --git a/Items/Accessories/Sponge.cs b/Items/Accessories/Sponge.cs index 00b9534f64..3f051fdb75 100644 --- a/Items/Accessories/Sponge.cs +++ b/Items/Accessories/Sponge.cs @@ -1,9 +1,11 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Tiles.Furniture.CraftingStations; +using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; +using System.Collections.Generic; using Terraria; using Terraria.DataStructures; using Terraria.ModLoader; @@ -30,8 +32,7 @@ namespace CalamityMod.Items.Accessories "Enemies take damage when they hit you\n" + "Taking a hit will make you move very fast for a short time\n" + "You emit a mushroom spore and spark explosion when you are hit\n" + - "Enemy attacks will have part of their damage absorbed and used to heal you\n" + - "Provides cold protection in Death Mode"); + "Enemy attacks will have part of their damage absorbed and used to heal you"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(5, 30)); } @@ -45,6 +46,21 @@ namespace CalamityMod.Items.Accessories item.Calamity().customRarity = CalamityRarity.DarkBlue; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip12") + { + line2.text = "Enemy attacks will have part of their damage absorbed and used to heal you\n" + + "Provides cold protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Accessories/TheAbsorber.cs b/Items/Accessories/TheAbsorber.cs index e4132ff431..75215db544 100644 --- a/Items/Accessories/TheAbsorber.cs +++ b/Items/Accessories/TheAbsorber.cs @@ -55,6 +55,7 @@ namespace CalamityMod.Items.Accessories recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 5); @@ -68,6 +69,7 @@ namespace CalamityMod.Items.Accessories recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 5); diff --git a/Items/Accessories/TheAmalgam.cs b/Items/Accessories/TheAmalgam.cs index ea29214dd9..945040cc4b 100644 --- a/Items/Accessories/TheAmalgam.cs +++ b/Items/Accessories/TheAmalgam.cs @@ -5,7 +5,9 @@ using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; using CalamityMod.Tiles.Furniture.CraftingStations; +using CalamityMod.World; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -35,8 +37,7 @@ namespace CalamityMod.Items.Accessories "75% increased movement speed, 10% increase to all damage, and plus 40 defense while submerged in any liquid\n" + "The above bonuses also apply when passing through the clump's poisonous seawater\n" + "Temporary immunity to lava, greatly reduces lava burn damage, and 15% increased damage while in lava\n" + - "You have a damaging aura that envenoms nearby enemies and increased movement in liquids\n" + - "Provides heat protection in Death Mode"); + "You have a damaging aura that envenoms nearby enemies and increased movement in liquids"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(9, 6)); } @@ -50,6 +51,21 @@ namespace CalamityMod.Items.Accessories item.accessory = true; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip8") + { + line2.text = "You have a damaging aura that envenoms nearby enemies and increased movement in liquids\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool CanEquipAccessory(Player player, int slot) => !player.Calamity().fungalClump; public override void UpdateAccessory(Player player, bool hideVisual) @@ -115,26 +131,10 @@ namespace CalamityMod.Items.Accessories { if (player.whoAmI == Main.myPlayer) { - float x = player.position.X + Main.rand.NextFloat(-400, 400); - float y = player.position.Y - Main.rand.NextFloat(500, 800); - Vector2 projOrigin = new Vector2(x, y); - float xDist = player.Center.X - projOrigin.X; - float yDist = player.Center.Y - projOrigin.Y; - xDist += Main.rand.NextFloat(-100, 100); - float speed = 22f; - Vector2 playerVector = new Vector2(xDist, yDist); - float playerDist = playerVector.Length(); - playerDist = speed / playerDist; - playerVector.X *= playerDist; - playerVector.Y *= playerDist; int type = Main.rand.NextBool(2) ? ProjectileType() : ProjectileType(); - int rain = Projectile.NewProjectile(projOrigin, playerVector, type, (int)(ProjectileDamage * player.AverageDamage()), 1f, player.whoAmI, 0f, 0f); - Projectile proj = Main.projectile[rain]; - proj.tileCollide = false; - proj.usesLocalNPCImmunity = true; - proj.localNPCHitCooldown = 10; - proj.usesIDStaticNPCImmunity = false; - proj.Calamity().forceTypeless = true; + Projectile rain = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, type, (int)(ProjectileDamage * player.AverageDamage()), 5f, player.whoAmI, 6, 1); + if (type == ProjectileType()) + rain.tileCollide = false; } } } diff --git a/Items/Accessories/TheCamper.cs b/Items/Accessories/TheCamper.cs index 8decddc970..a1bc81a9f6 100644 --- a/Items/Accessories/TheCamper.cs +++ b/Items/Accessories/TheCamper.cs @@ -1,7 +1,9 @@ using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Typeless; +using CalamityMod.World; using Microsoft.Xna.Framework; using System; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -17,13 +19,12 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("The Camper"); - Tooltip.SetDefault("You deal no damage unless stationary\n" + + Tooltip.SetDefault("In rest may we find victory.\n" + + "You deal no damage unless stationary\n" + "Standing still grants buff(s) dependent on what weapon you're holding\n" + "Standing still provides a damaging aura around you\n" + "While moving, you regenerate health as if standing still\n" + - "Provides a small amount of light in the Abyss\n" + - "Provides cold protection in Death Mode\n" + - "In rest may we find victory."); + "Provides a small amount of light in the Abyss"); } public override void SetDefaults() @@ -36,6 +37,21 @@ namespace CalamityMod.Items.Accessories item.defense = 10; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip5") + { + line2.text = "Provides a small amount of light in the Abyss\n" + + "Provides cold protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Accessories/Vanity/Popo.cs b/Items/Accessories/Vanity/Popo.cs index e7e19e90e9..d07d44f54d 100644 --- a/Items/Accessories/Vanity/Popo.cs +++ b/Items/Accessories/Vanity/Popo.cs @@ -1,4 +1,6 @@ using CalamityMod.CalPlayer; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ModLoader; @@ -10,8 +12,7 @@ namespace CalamityMod.Items.Accessories.Vanity { DisplayName.SetDefault("Magic Scarf and Hat"); Tooltip.SetDefault("Don't let the demons steal your nose\n" + - "Transforms the holder into a snowman\n" + - "Provides heat and cold protection in Death Mode"); + "Transforms the holder into a snowman"); } public override void SetDefaults() @@ -23,6 +24,21 @@ namespace CalamityMod.Items.Accessories.Vanity item.rare = 5; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text = "Transforms the holder into a snowman\n" + + "Provides heat and cold protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Accessories/VoidofExtinction.cs b/Items/Accessories/VoidofExtinction.cs index ccbe436768..04e20bbf6c 100644 --- a/Items/Accessories/VoidofExtinction.cs +++ b/Items/Accessories/VoidofExtinction.cs @@ -1,8 +1,10 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Typeless; +using CalamityMod.World; using Microsoft.Xna.Framework; using System; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -22,8 +24,7 @@ namespace CalamityMod.Items.Accessories "Drops brimstone fireballs from the sky occasionally\n" + "15% increase to all damage\n" + "Brimstone fire rains down while invincibility is active\n" + - "Temporary immunity to lava, greatly reduces lava burn damage, and 25% increased damage while in lava\n" + - "Provides heat protection in Death Mode"); + "Temporary immunity to lava, greatly reduces lava burn damage, and 25% increased damage while in lava"); } public override void SetDefaults() @@ -36,6 +37,21 @@ namespace CalamityMod.Items.Accessories item.accessory = true; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip4") + { + line2.text = "Temporary immunity to lava, greatly reduces lava burn damage, and 25% increased damage while in lava\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool CanEquipAccessory(Player player, int slot) => !player.Calamity().calamityRing; public override void AddRecipes() @@ -69,21 +85,7 @@ namespace CalamityMod.Items.Accessories { if (player.whoAmI == Main.myPlayer) { - float x = player.position.X + (float)Main.rand.Next(-400, 400); - float y = player.position.Y - (float)Main.rand.Next(500, 800); - Vector2 source = new Vector2(x, y); - Vector2 velocity = player.Center - source; - velocity.X += (float)Main.rand.Next(-100, 101); - float speed = 22f; - float targetDist = velocity.Length(); - targetDist = speed / targetDist; - velocity.X *= targetDist; - velocity.Y *= targetDist; - int fire = Projectile.NewProjectile(source, velocity, ModContent.ProjectileType(), (int)(30 * player.AverageDamage()), 5f, player.whoAmI, 0f, 0f); - Main.projectile[fire].ai[1] = player.position.Y; - Main.projectile[fire].usesLocalNPCImmunity = true; - Main.projectile[fire].localNPCHitCooldown = 60; - Main.projectile[fire].usesIDStaticNPCImmunity = false; + CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(30 * player.AverageDamage()), 5f, player.whoAmI, 0, 1, 60); } } } diff --git a/Items/Accessories/Wings/CelestialTracers.cs b/Items/Accessories/Wings/CelestialTracers.cs index 893f69bc72..c45d509d0b 100644 --- a/Items/Accessories/Wings/CelestialTracers.cs +++ b/Items/Accessories/Wings/CelestialTracers.cs @@ -1,7 +1,9 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Tiles.Furniture.CraftingStations; +using CalamityMod.World; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ModLoader; @@ -24,8 +26,7 @@ namespace CalamityMod.Items.Accessories.Wings "Greater mobility on ice\n" + "Water and lava walking\n" + "Temporary immunity to lava\n" + - "Being hit for over 200 damage will make you immune for an extended period of time\n" + - "Provides heat protection in Death Mode"); + "Being hit for over 200 damage will make you immune for an extended period of time"); } public override void SetDefaults() @@ -37,6 +38,21 @@ namespace CalamityMod.Items.Accessories.Wings item.Calamity().customRarity = CalamityRarity.Violet; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip10") + { + line2.text = "Being hit for over 200 damage will make you immune for an extended period of time\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { if (player.controlJump && player.wingTime > 0f && !player.jumpAgainCloud && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) diff --git a/Items/Accessories/Wings/DiscordianWings.cs b/Items/Accessories/Wings/DiscordianWings.cs index cd414cbf12..7d5f86056d 100644 --- a/Items/Accessories/Wings/DiscordianWings.cs +++ b/Items/Accessories/Wings/DiscordianWings.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Accessories.Wings "Acceleration multiplier: 1.5\n" + "Average vertical speed\n" + "Flight time: 180\n" + - "10% increased damage while wearing the Hydrothermic Armor"); + "5% increased damage while wearing the Hydrothermic Armor"); } public override void SetDefaults() @@ -38,7 +38,7 @@ namespace CalamityMod.Items.Accessories.Wings player.armor[0].type == ModContent.ItemType()) && player.armor[1].type == ModContent.ItemType() && player.armor[2].type == ModContent.ItemType()) { - player.allDamage += 0.1f; + player.allDamage += 0.05f; } if (player.controlJump && player.wingTime > 0f && !player.jumpAgainCloud && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) diff --git a/Items/Accessories/Wings/ElysianTracers.cs b/Items/Accessories/Wings/ElysianTracers.cs index c3f71e9410..58d77ee823 100644 --- a/Items/Accessories/Wings/ElysianTracers.cs +++ b/Items/Accessories/Wings/ElysianTracers.cs @@ -1,6 +1,8 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -23,8 +25,7 @@ namespace CalamityMod.Items.Accessories.Wings "36% increased running acceleration\n" + "Greater mobility on ice\n" + "Water and lava walking\n" + - "Temporary immunity to lava\n" + - "Provides heat protection in Death Mode"); + "Temporary immunity to lava"); } public override void SetDefaults() @@ -36,6 +37,21 @@ namespace CalamityMod.Items.Accessories.Wings item.Calamity().customRarity = CalamityRarity.DarkBlue; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip9") + { + line2.text = "Temporary immunity to lava\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { if (player.controlJump && player.wingTime > 0f && !player.jumpAgainCloud && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) diff --git a/Items/Accessories/Wings/ElysianWings.cs b/Items/Accessories/Wings/ElysianWings.cs index 56799e89e8..8730a980a7 100644 --- a/Items/Accessories/Wings/ElysianWings.cs +++ b/Items/Accessories/Wings/ElysianWings.cs @@ -1,4 +1,6 @@ using CalamityMod.CalPlayer; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ModLoader; @@ -15,8 +17,7 @@ namespace CalamityMod.Items.Accessories.Wings "Acceleration multiplier: 2.7\n" + "Great vertical speed\n" + "Flight time: 200\n" + - "Temporary immunity to lava and 40% increased movement speed\n" + - "Provides heat protection in Death Mode"); + "Temporary immunity to lava and 40% increased movement speed"); } public override void SetDefaults() @@ -29,6 +30,21 @@ namespace CalamityMod.Items.Accessories.Wings item.accessory = true; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip5") + { + line2.text = "Temporary immunity to lava and 40% increased movement speed\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Accessories/Wings/InfinityBoots.cs b/Items/Accessories/Wings/InfinityBoots.cs index 30e1beaae1..df7f25a3cd 100644 --- a/Items/Accessories/Wings/InfinityBoots.cs +++ b/Items/Accessories/Wings/InfinityBoots.cs @@ -1,6 +1,8 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -23,8 +25,7 @@ namespace CalamityMod.Items.Accessories.Wings "24% increased running acceleration\n" + "Greater mobility on ice\n" + "Water and lava walking\n" + - "Temporary immunity to lava\n" + - "Provides heat protection in Death Mode"); + "Temporary immunity to lava"); } public override void SetDefaults() @@ -36,6 +37,21 @@ namespace CalamityMod.Items.Accessories.Wings item.Calamity().customRarity = CalamityRarity.Turquoise; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip9") + { + line2.text = "Temporary immunity to lava\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { if (player.controlJump && player.wingTime > 0f && !player.jumpAgainCloud && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) diff --git a/Items/Accessories/Wings/SoulofCryogen.cs b/Items/Accessories/Wings/SoulofCryogen.cs index 22d6fa0d82..4edba47e34 100644 --- a/Items/Accessories/Wings/SoulofCryogen.cs +++ b/Items/Accessories/Wings/SoulofCryogen.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Rogue; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.DataStructures; using Terraria.ModLoader; @@ -20,8 +22,7 @@ namespace CalamityMod.Items.Accessories.Wings "Flight time: 120\n" + "7% increase to all damage\n" + "All melee attacks and projectiles inflict frostburn\n" + - "Icicles rain down as you fly\n" + - "Provides heat and cold protection in Death Mode"); + "Icicles rain down as you fly"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 3)); } @@ -35,6 +36,21 @@ namespace CalamityMod.Items.Accessories.Wings item.accessory = true; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip8") + { + line2.text = "Icicles rain down as you fly\n" + + "Provides heat and cold protection in Death Mode"; + } + } + } + } + public override void Update(ref float gravity, ref float maxFallSpeed) { float num = (float)Main.rand.Next(90, 111) * 0.01f; diff --git a/Items/Accessories/Wings/XerocWings.cs b/Items/Accessories/Wings/XerocWings.cs index ad99258922..00ee2b732b 100644 --- a/Items/Accessories/Wings/XerocWings.cs +++ b/Items/Accessories/Wings/XerocWings.cs @@ -41,19 +41,19 @@ namespace CalamityMod.Items.Accessories.Wings if (player.controlJump && player.wingTime > 0f && !player.jumpAgainCloud && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + float xOffset = 4f; if (player.direction == 1) { - num59 = -40; + xOffset = -40f; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 242, 0f, 0f, 100, default, 2.4f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int index = Dust.NewDust(new Vector2(player.Center.X + xOffset, player.Center.Y - 15f), 30, 30, 62, 0f, 0f, 100, default, 2.4f); + Main.dust[index].noGravity = true; + Main.dust[index].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[index].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[index].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } player.wingTimeMax = 180; player.noFallDmg = true; diff --git a/Items/Accessories/YharimsInsignia.cs b/Items/Accessories/YharimsInsignia.cs index ad5fdfa204..54df009ba7 100644 --- a/Items/Accessories/YharimsInsignia.cs +++ b/Items/Accessories/YharimsInsignia.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -17,8 +19,7 @@ namespace CalamityMod.Items.Accessories "Melee attacks and melee projectiles inflict holy fire\n" + "Increased invincibility after taking damage\n" + "Temporary immunity to lava\n" + - "Increased melee knockback\n" + - "Provides heat protection in Death Mode"); + "Increased melee knockback"); } public override void SetDefaults() @@ -30,6 +31,21 @@ namespace CalamityMod.Items.Accessories item.Calamity().customRarity = CalamityRarity.Turquoise; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip6") + { + line2.text = "Increased melee knockback\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Armor/AtaxiaHeadgear.cs b/Items/Armor/AtaxiaHeadgear.cs index fbba6b04f1..fefda8b5b4 100644 --- a/Items/Armor/AtaxiaHeadgear.cs +++ b/Items/Armor/AtaxiaHeadgear.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,8 +15,7 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Hydrothermic Headgear"); Tooltip.SetDefault("12% increased ranged damage and 10% increased ranged critical strike chance\n" + - "Reduces ammo usage by 25%, temporary immunity to lava, and immunity to fire damage\n" + - "Provides heat protection in Death Mode"); + "Reduces ammo usage by 25%, temporary immunity to lava, and immunity to fire damage"); } public override void SetDefaults() @@ -26,6 +27,21 @@ namespace CalamityMod.Items.Armor item.defense = 15; //53 } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text = "Reduces ammo usage by 25%, temporary immunity to lava, and immunity to fire damage\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/AtaxiaHelm.cs b/Items/Armor/AtaxiaHelm.cs index 40fcb0cd07..2187c89c4d 100644 --- a/Items/Armor/AtaxiaHelm.cs +++ b/Items/Armor/AtaxiaHelm.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -15,8 +17,7 @@ namespace CalamityMod.Items.Armor Tooltip.SetDefault("12% increased melee damage and 10% increased melee critical strike chance\n" + "12% increased melee and movement speed\n" + "Melee attacks and melee projectiles inflict on fire\n" + - "Temporary immunity to lava and immunity to fire damage\n" + - "Provides heat protection in Death Mode"); + "Temporary immunity to lava and immunity to fire damage"); } public override void SetDefaults() @@ -28,6 +29,21 @@ namespace CalamityMod.Items.Armor item.defense = 25; //67 } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip3") + { + line2.text = "Temporary immunity to lava and immunity to fire damage\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/AtaxiaHelmet.cs b/Items/Armor/AtaxiaHelmet.cs index d29355e319..165ca43cc5 100644 --- a/Items/Armor/AtaxiaHelmet.cs +++ b/Items/Armor/AtaxiaHelmet.cs @@ -2,6 +2,8 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -16,8 +18,7 @@ namespace CalamityMod.Items.Armor DisplayName.SetDefault("Hydrothermic Helmet"); Tooltip.SetDefault("5% increased minion damage and increased minion knockback\n" + "+2 max minions\n" + - "Temporary immunity to lava and immunity to fire damage\n" + - "Provides heat protection in Death Mode"); + "Temporary immunity to lava and immunity to fire damage"); } public override void SetDefaults() @@ -29,6 +30,21 @@ namespace CalamityMod.Items.Armor item.defense = 6; //40 } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip2") + { + line2.text = "Temporary immunity to lava and immunity to fire damage\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/AtaxiaHood.cs b/Items/Armor/AtaxiaHood.cs index 23330ec8cd..df51b79164 100644 --- a/Items/Armor/AtaxiaHood.cs +++ b/Items/Armor/AtaxiaHood.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -14,8 +16,7 @@ namespace CalamityMod.Items.Armor DisplayName.SetDefault("Hydrothermic Hood"); Tooltip.SetDefault("12% increased rogue damage and 10% increased rogue critical strike chance\n" + "50% chance to not consume rogue items and 15% increased movement speed\n" + - "Temporary immunity to lava and immunity to fire damage\n" + - "Provides heat protection in Death Mode"); + "Temporary immunity to lava and immunity to fire damage"); } public override void SetDefaults() @@ -27,6 +28,21 @@ namespace CalamityMod.Items.Armor item.defense = 12; //49 } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip2") + { + line2.text = "Temporary immunity to lava and immunity to fire damage\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/AtaxiaMask.cs b/Items/Armor/AtaxiaMask.cs index 4299c241c8..339ae4ff52 100644 --- a/Items/Armor/AtaxiaMask.cs +++ b/Items/Armor/AtaxiaMask.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,8 +15,7 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Hydrothermic Mask"); Tooltip.SetDefault("12% increased magic damage, reduces mana usage by 15%, and 10% increased magic critical strike chance\n" + - "+100 max mana, temporary immunity to lava, and immunity to fire damage\n" + - "Provides heat protection in Death Mode"); + "+100 max mana, temporary immunity to lava, and immunity to fire damage"); } public override void SetDefaults() @@ -26,6 +27,21 @@ namespace CalamityMod.Items.Armor item.defense = 9; //45 } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text = "Temporary immunity to lava and immunity to fire damage\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/AuricTeslaBodyArmor.cs b/Items/Armor/AuricTeslaBodyArmor.cs index 308688ea12..a64c4cc0ef 100644 --- a/Items/Armor/AuricTeslaBodyArmor.cs +++ b/Items/Armor/AuricTeslaBodyArmor.cs @@ -2,6 +2,8 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Accessories; using CalamityMod.Items.Materials; using CalamityMod.Tiles.Furniture.CraftingStations; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ModLoader; @@ -17,8 +19,7 @@ namespace CalamityMod.Items.Armor "25% increased movement speed\n" + "Attacks have a 2% chance to do no damage to you\n" + "8% increased damage and 5% increased critical strike chance\n" + - "You will freeze enemies near you when you are struck\n" + - "Provides heat and cold protection in Death Mode"); + "You will freeze enemies near you when you are struck"); } public override void SetDefaults() @@ -30,6 +31,21 @@ namespace CalamityMod.Items.Armor item.Calamity().customRarity = CalamityRarity.Violet; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip4") + { + line2.text = "You will freeze enemies near you when you are struck\n" + + "Provides heat and cold protection in Death Mode"; + } + } + } + } + public override void UpdateEquip(Player player) { CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Armor/BloodflareHelm.cs b/Items/Armor/BloodflareHelm.cs index 5cb35e9c2f..b606d8a68a 100644 --- a/Items/Armor/BloodflareHelm.cs +++ b/Items/Armor/BloodflareHelm.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,8 +15,7 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Bloodflare Imp Mask"); Tooltip.SetDefault("You can move freely through liquids and have temporary immunity to lava\n" + - "10% increased rogue damage and critical strike chance, 15% increased movement speed\n" + - "Provides heat protection in Death Mode"); + "10% increased rogue damage and critical strike chance, 15% increased movement speed"); } public override void SetDefaults() @@ -26,6 +27,21 @@ namespace CalamityMod.Items.Armor item.Calamity().customRarity = CalamityRarity.PureGreen; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text = "10% increased rogue damage and critical strike chance, 15% increased movement speed\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/BloodflareHelmet.cs b/Items/Armor/BloodflareHelmet.cs index eced0d7cce..b3bb0eee2c 100644 --- a/Items/Armor/BloodflareHelmet.cs +++ b/Items/Armor/BloodflareHelmet.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,8 +15,7 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Bloodflare Wyvern Helm"); Tooltip.SetDefault("You can move freely through liquids and have temporary immunity to lava\n" + - "+3 max minions\n" + - "Provides heat protection in Death Mode"); + "+3 max minions"); } public override void SetDefaults() @@ -26,6 +27,21 @@ namespace CalamityMod.Items.Armor item.Calamity().customRarity = CalamityRarity.PureGreen; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text = "+3 max minions\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/BloodflareHornedHelm.cs b/Items/Armor/BloodflareHornedHelm.cs index 2169c9027f..44987146ec 100644 --- a/Items/Armor/BloodflareHornedHelm.cs +++ b/Items/Armor/BloodflareHornedHelm.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,8 +15,7 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Bloodflare Horned Helm"); Tooltip.SetDefault("You can move freely through liquids and have temporary immunity to lava\n" + - "10% increased ranged damage and critical strike chance\n" + - "Provides heat protection in Death Mode"); + "10% increased ranged damage and critical strike chance"); } public override void SetDefaults() @@ -26,6 +27,21 @@ namespace CalamityMod.Items.Armor item.Calamity().customRarity = CalamityRarity.PureGreen; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text = "10% increased ranged damage and critical strike chance\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/BloodflareHornedMask.cs b/Items/Armor/BloodflareHornedMask.cs index 0b9fcc6490..1e2cf84381 100644 --- a/Items/Armor/BloodflareHornedMask.cs +++ b/Items/Armor/BloodflareHornedMask.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,8 +15,7 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Bloodflare Hydra Hood"); Tooltip.SetDefault("You can move freely through liquids and have temporary immunity to lava\n" + - "10% increased magic damage and critical strike chance, +100 max mana, and 17% reduced mana usage\n" + - "Provides heat protection in Death Mode"); + "10% increased magic damage and critical strike chance, +100 max mana, and 17% reduced mana usage"); } public override void SetDefaults() @@ -26,6 +27,21 @@ namespace CalamityMod.Items.Armor item.Calamity().customRarity = CalamityRarity.PureGreen; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text = "10% increased magic damage and critical strike chance, +100 max mana, and 17% reduced mana usage\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/BloodflareMask.cs b/Items/Armor/BloodflareMask.cs index 6754860b83..563e01663c 100644 --- a/Items/Armor/BloodflareMask.cs +++ b/Items/Armor/BloodflareMask.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,8 +15,7 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Bloodflare Ram Mask"); Tooltip.SetDefault("You can move freely through liquids and have temporary immunity to lava\n" + - "10% increased melee damage and critical strike chance\n" + - "Provides heat protection in Death Mode"); + "10% increased melee damage and critical strike chance"); } public override void SetDefaults() @@ -26,6 +27,21 @@ namespace CalamityMod.Items.Armor item.Calamity().customRarity = CalamityRarity.PureGreen; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text = "10% increased melee damage and critical strike chance\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/FearmongerGreathelm.cs b/Items/Armor/FearmongerGreathelm.cs index 6d7d929d53..1224f14374 100644 --- a/Items/Armor/FearmongerGreathelm.cs +++ b/Items/Armor/FearmongerGreathelm.cs @@ -2,6 +2,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Materials; using CalamityMod.Tiles.Furniture.CraftingStations; +using CalamityMod.World; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -52,13 +53,25 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { - player.setBonus = @"30% increased minion damage + if (CalamityWorld.death) + { + player.setBonus = @"30% increased minion damage The minion damage nerf while wielding weaponry is reduced Immunity to all forms of frost and flame All minion attacks grant colossal life regeneration 15% increased damage reduction during the Pumpkin and Frost Moons This extra damage reduction ignores the soft cap Provides cold protection in Death Mode"; + } + else + { + player.setBonus = @"30% increased minion damage +The minion damage nerf while wielding weaponry is reduced +Immunity to all forms of frost and flame +All minion attacks grant colossal life regeneration +15% increased damage reduction during the Pumpkin and Frost Moons +This extra damage reduction ignores the soft cap"; + } // This bool encompasses cross-class nerf immunity, colossal life regen on minion attack, and the holiday moon DR player.Calamity().fearmongerSet = true; diff --git a/Items/Armor/ForbiddenCirclet.cs b/Items/Armor/ForbiddenCirclet.cs index 42a07d15bd..4f1fdde063 100644 --- a/Items/Armor/ForbiddenCirclet.cs +++ b/Items/Armor/ForbiddenCirclet.cs @@ -8,8 +8,8 @@ namespace CalamityMod.Items.Armor [AutoloadEquip(EquipType.Head)] public class ForbiddenCirclet : ModItem { - public const int manaCost = 50; - public const int tornadoBaseDmg = 100; + public const int manaCost = 60; + public const int tornadoBaseDmg = 80; public const float tornadoBaseKB = 1f; public override void SetStaticDefaults() @@ -48,7 +48,6 @@ namespace CalamityMod.Items.Armor player.setBonus = "Press " + hotkey + " to call an ancient storm to the cursor location\n" + "The ancient storm costs " + stormMana + " mana and benefits from both summon and rogue bonuses\n" + "Rogue stealth strikes spawn homing eaters on enemy hits\n" + - "The minion damage nerf is reduced while wielding rogue weapons\n" + "Rogue and summon attacks will scale off of the stat with a higher boost\n" + "Rogue stealth builds while not attacking and slower while moving, up to a max of 100\n" + "Once you have built max stealth, you will be able to perform a Stealth Strike\n" + diff --git a/Items/Armor/PlagueReaperMask.cs b/Items/Armor/PlagueReaperMask.cs index 8e665a4118..22915a3866 100644 --- a/Items/Armor/PlagueReaperMask.cs +++ b/Items/Armor/PlagueReaperMask.cs @@ -82,23 +82,7 @@ namespace CalamityMod.Items.Armor { if (Main.rand.NextBool(10)) { - for (int l = 0; l < 1; l++) - { - float x = player.position.X + (float)Main.rand.Next(-400, 400); - float y = player.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num15 = player.position.X + (float)(player.width / 2) - vector.X; - float num16 = player.position.Y + (float)(player.height / 2) - vector.Y; - num15 += (float)Main.rand.Next(-100, 101); - int num17 = 22; - float num18 = (float)Math.Sqrt((double)(num15 * num15 + num16 * num16)); - num18 = (float)num17 / num18; - num15 *= num18; - num16 *= num18; - int num19 = Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), (int)(40 * player.RangedDamage()),4f, player.whoAmI, 0f, 0f); - Main.projectile[num19].Calamity().rogue = false; - Main.projectile[num19].ai[1] = player.position.Y; - } + CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(40 * player.RangedDamage()), 4f, player.whoAmI, 6); } } } diff --git a/Items/Armor/SilvaHelm.cs b/Items/Armor/SilvaHelm.cs index 5f410f6923..6b76c3eec1 100644 --- a/Items/Armor/SilvaHelm.cs +++ b/Items/Armor/SilvaHelm.cs @@ -48,8 +48,7 @@ namespace CalamityMod.Items.Armor "Your max life will return to normal if you die\n" + "True melee strikes have a 25% chance to do five times damage\n" + "After the silva invincibility is over you will take 20% less contact damage\n" + - "Melee projectiles have a 25% chance to stun enemies for a very brief moment\n" + - "Provides cold protection in Death Mode"; + "Melee projectiles have a 25% chance to stun enemies for a very brief moment"; } public override void UpdateEquip(Player player) diff --git a/Items/Armor/SilvaHelmet.cs b/Items/Armor/SilvaHelmet.cs index 4eaee1cce4..9cae6f926f 100644 --- a/Items/Armor/SilvaHelmet.cs +++ b/Items/Armor/SilvaHelmet.cs @@ -50,8 +50,7 @@ namespace CalamityMod.Items.Armor "This effect only triggers once per life and if you are reduced to 400 max life the invincibility effect will stop\n" + "Your max life will return to normal if you die\n" + "Summons an ancient leaf prism to blast your enemies with life energy\n" + - "After the silva invulnerability time your minions will deal 10% more damage and you will gain +2 max minions\n" + - "Provides cold protection in Death Mode"; + "After the silva invulnerability time your minions will deal 10% more damage and you will gain +2 max minions"; if (player.whoAmI == Main.myPlayer) { if (player.FindBuffIndex(ModContent.BuffType()) == -1) diff --git a/Items/Armor/SilvaHornedHelm.cs b/Items/Armor/SilvaHornedHelm.cs index 299fa4eeba..0fd7d507e9 100644 --- a/Items/Armor/SilvaHornedHelm.cs +++ b/Items/Armor/SilvaHornedHelm.cs @@ -47,8 +47,7 @@ namespace CalamityMod.Items.Armor "This effect only triggers once per life and if you are reduced to 400 max life the invincibility effect will stop\n" + "Your max life will return to normal if you die\n" + "Increases your rate of fire with all ranged weapons\n" + - "During the silva invulnerability time your ranged weapons will do 40% more damage\n" + - "Provides cold protection in Death Mode"; + "During the silva invulnerability time your ranged weapons will do 40% more damage"; } public override void UpdateEquip(Player player) diff --git a/Items/Armor/SilvaMask.cs b/Items/Armor/SilvaMask.cs index f305f863c5..9d7829e77f 100644 --- a/Items/Armor/SilvaMask.cs +++ b/Items/Armor/SilvaMask.cs @@ -53,8 +53,7 @@ namespace CalamityMod.Items.Armor "Rogue stealth builds while not attacking and slower while moving, up to a max of 125\n" + "Once you have built max stealth, you will be able to perform a Stealth Strike\n" + "Rogue stealth only reduces when you attack, it does not reduce while moving\n" + - "The higher your rogue stealth the higher your rogue damage, crit, and movement speed\n" + - "Provides cold protection in Death Mode"; + "The higher your rogue stealth the higher your rogue damage, crit, and movement speed"; } public override void UpdateEquip(Player player) diff --git a/Items/Armor/SilvaMaskedCap.cs b/Items/Armor/SilvaMaskedCap.cs index 38dd271f2a..fe3aced15a 100644 --- a/Items/Armor/SilvaMaskedCap.cs +++ b/Items/Armor/SilvaMaskedCap.cs @@ -48,8 +48,7 @@ namespace CalamityMod.Items.Armor "This effect only triggers once per life and if you are reduced to 400 max life the invincibility effect will stop\n" + "Your max life will return to normal if you die\n" + "Magic projectiles have a 10% chance to cause a massive explosion on enemy hits\n" + - "After the silva invulnerability time your magic weapons will do 10% more damage\n" + - "Provides cold protection in Death Mode"; + "After the silva invulnerability time your magic weapons will do 10% more damage"; } public override void UpdateEquip(Player player) diff --git a/Items/Armor/TarragonBreastplate.cs b/Items/Armor/TarragonBreastplate.cs index 209474037e..bbb980ad81 100644 --- a/Items/Armor/TarragonBreastplate.cs +++ b/Items/Armor/TarragonBreastplate.cs @@ -11,9 +11,9 @@ namespace CalamityMod.Items.Armor public override void SetStaticDefaults() { DisplayName.SetDefault("Tarragon Breastplate"); - Tooltip.SetDefault("10% increased damage and 5% increased critical strike chance\n" + - "+2 life regen and +40 max life\n" + - "Breastplate of the exiler"); + Tooltip.SetDefault("Breastplate of the exiler\n" + + "10% increased damage and 5% increased critical strike chance\n" + + "+2 life regen and +40 max life"); } public override void SetDefaults() diff --git a/Items/Armor/TarragonHelm.cs b/Items/Armor/TarragonHelm.cs index 6e2c995c81..92116f98ca 100644 --- a/Items/Armor/TarragonHelm.cs +++ b/Items/Armor/TarragonHelm.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -16,8 +18,7 @@ namespace CalamityMod.Items.Armor "Temporary immunity to lava\n" + "Can move freely through liquids\n" + "5% increased damage reduction\n" + - "10% increased melee damage and critical strike chance\n" + - "Provides heat protection in Death Mode"); + "10% increased melee damage and critical strike chance"); } public override void SetDefaults() @@ -29,6 +30,21 @@ namespace CalamityMod.Items.Armor item.Calamity().customRarity = CalamityRarity.Turquoise; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip4") + { + line2.text = "10% increased melee damage and critical strike chance\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/TarragonHelmet.cs b/Items/Armor/TarragonHelmet.cs index 9662474c07..ce0d17de40 100644 --- a/Items/Armor/TarragonHelmet.cs +++ b/Items/Armor/TarragonHelmet.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -15,8 +17,7 @@ namespace CalamityMod.Items.Armor Tooltip.SetDefault("Temporary immunity to lava\n" + "Can move freely through liquids and 12% increased movement speed\n" + "10% increased rogue damage and critical strike chance\n" + - "5% increased damage reduction\n" + - "Provides heat protection in Death Mode"); + "5% increased damage reduction"); } public override void SetDefaults() @@ -28,6 +29,21 @@ namespace CalamityMod.Items.Armor item.Calamity().customRarity = CalamityRarity.Turquoise; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip3") + { + line2.text = "5% increased damage reduction\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/TarragonHornedHelm.cs b/Items/Armor/TarragonHornedHelm.cs index be2d471452..92498eb39a 100644 --- a/Items/Armor/TarragonHornedHelm.cs +++ b/Items/Armor/TarragonHornedHelm.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -14,8 +16,7 @@ namespace CalamityMod.Items.Armor DisplayName.SetDefault("Tarragon Horned Helm"); Tooltip.SetDefault("Temporary immunity to lava\n" + "Can move freely through liquids\n" + - "5% increased damage reduction and +3 max minions\n" + - "Provides heat protection in Death Mode"); + "5% increased damage reduction and +3 max minions"); } public override void SetDefaults() @@ -27,6 +28,21 @@ namespace CalamityMod.Items.Armor item.Calamity().customRarity = CalamityRarity.Turquoise; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip2") + { + line2.text = "5% increased damage reduction and +3 max minions\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/TarragonMask.cs b/Items/Armor/TarragonMask.cs index 664773c85f..1f7b49b661 100644 --- a/Items/Armor/TarragonMask.cs +++ b/Items/Armor/TarragonMask.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -15,8 +17,7 @@ namespace CalamityMod.Items.Armor Tooltip.SetDefault("Temporary immunity to lava\n" + "Can move freely through liquids\n" + "10% increased magic damage and critical strike chance\n" + - "5% increased damage reduction, +100 max mana, and 15% reduced mana usage\n" + - "Provides heat protection in Death Mode"); + "5% increased damage reduction, +100 max mana, and 15% reduced mana usage"); } public override void SetDefaults() @@ -28,6 +29,21 @@ namespace CalamityMod.Items.Armor item.Calamity().customRarity = CalamityRarity.Turquoise; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip3") + { + line2.text = "5% increased damage reduction, +100 max mana, and 15% reduced mana usage\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/TarragonVisage.cs b/Items/Armor/TarragonVisage.cs index 604e771624..acf2a59ff7 100644 --- a/Items/Armor/TarragonVisage.cs +++ b/Items/Armor/TarragonVisage.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -15,8 +17,7 @@ namespace CalamityMod.Items.Armor Tooltip.SetDefault("Temporary immunity to lava\n" + "Can move freely through liquids\n" + "10% increased ranged damage and critical strike chance\n" + - "5% increased damage reduction\n" + - "Provides heat protection in Death Mode"); + "5% increased damage reduction"); } public override void SetDefaults() @@ -28,6 +29,21 @@ namespace CalamityMod.Items.Armor item.Calamity().customRarity = CalamityRarity.Turquoise; } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip3") + { + line2.text = "5% increased damage reduction\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/TitanHeartBoots.cs b/Items/Armor/TitanHeartBoots.cs index 03bd012f0e..6f5db48111 100644 --- a/Items/Armor/TitanHeartBoots.cs +++ b/Items/Armor/TitanHeartBoots.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Armor public override void SetStaticDefaults() { DisplayName.SetDefault("Titan Heart Boots"); - Tooltip.SetDefault("10% increased rogue velocity and 5% boosted rogue knockback"); + Tooltip.SetDefault("4% increased rogue damage, 10% increased rogue velocity, and 5% increased rogue knockback"); } public override void SetDefaults() @@ -28,6 +28,7 @@ namespace CalamityMod.Items.Armor { player.Calamity().titanHeartBoots = true; player.Calamity().throwingVelocity += 0.1f; + player.Calamity().throwingDamage += 0.04f; } public override void AddRecipes() diff --git a/Items/Armor/TitanHeartMantle.cs b/Items/Armor/TitanHeartMantle.cs index 1b38d8e86d..6b90544891 100644 --- a/Items/Armor/TitanHeartMantle.cs +++ b/Items/Armor/TitanHeartMantle.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Armor { DisplayName.SetDefault("Titan Heart Mantle"); Tooltip.SetDefault("45% chance to not consume rogue items\n" + - "5% boosted rogue knockback but 20% lowered rogue shoot speed"); + "5% boosted rogue knockback but 15% lowered rogue shoot speed"); } public override void SetDefaults() diff --git a/Items/Armor/TitanHeartMask.cs b/Items/Armor/TitanHeartMask.cs index cbba9c0f80..c427c49faf 100644 --- a/Items/Armor/TitanHeartMask.cs +++ b/Items/Armor/TitanHeartMask.cs @@ -13,7 +13,8 @@ namespace CalamityMod.Items.Armor public override void SetStaticDefaults() { DisplayName.SetDefault("Titan Heart Mask"); - Tooltip.SetDefault("5% increased rogue damage and knockback"); + Tooltip.SetDefault("5% increased rogue damage and knockback\n" + + "Rogue weapons spread the astral infection"); } public override void SetDefaults() diff --git a/Items/Armor/WulfrumArmor.cs b/Items/Armor/WulfrumArmor.cs index 184f6f3e39..a310356c7a 100644 --- a/Items/Armor/WulfrumArmor.cs +++ b/Items/Armor/WulfrumArmor.cs @@ -32,6 +32,7 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddTile(TileID.Anvils); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Armor/WulfrumHeadgear.cs b/Items/Armor/WulfrumHeadgear.cs index 6cdfc216f8..9d4dabb104 100644 --- a/Items/Armor/WulfrumHeadgear.cs +++ b/Items/Armor/WulfrumHeadgear.cs @@ -48,6 +48,7 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddTile(TileID.Anvils); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Armor/WulfrumHelm.cs b/Items/Armor/WulfrumHelm.cs index 6282432f34..8aa0a192c9 100644 --- a/Items/Armor/WulfrumHelm.cs +++ b/Items/Armor/WulfrumHelm.cs @@ -48,6 +48,7 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddTile(TileID.Anvils); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Armor/WulfrumHelmet.cs b/Items/Armor/WulfrumHelmet.cs index b5491ec39c..39e6910971 100644 --- a/Items/Armor/WulfrumHelmet.cs +++ b/Items/Armor/WulfrumHelmet.cs @@ -49,6 +49,7 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddTile(TileID.Anvils); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Armor/WulfrumHood.cs b/Items/Armor/WulfrumHood.cs index ae10a22c7e..830e20dfeb 100644 --- a/Items/Armor/WulfrumHood.cs +++ b/Items/Armor/WulfrumHood.cs @@ -48,6 +48,7 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddTile(TileID.Anvils); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Armor/WulfrumLeggings.cs b/Items/Armor/WulfrumLeggings.cs index b769ea91a3..bf591c7ff6 100644 --- a/Items/Armor/WulfrumLeggings.cs +++ b/Items/Armor/WulfrumLeggings.cs @@ -32,6 +32,7 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddTile(TileID.Anvils); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Armor/WulfrumMask.cs b/Items/Armor/WulfrumMask.cs index 75e87db6d0..518a9ec763 100644 --- a/Items/Armor/WulfrumMask.cs +++ b/Items/Armor/WulfrumMask.cs @@ -56,6 +56,7 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddTile(TileID.Anvils); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Armor/XerocCuisses.cs b/Items/Armor/XerocCuisses.cs index c0ab2a23e2..6a568d2d42 100644 --- a/Items/Armor/XerocCuisses.cs +++ b/Items/Armor/XerocCuisses.cs @@ -11,9 +11,9 @@ namespace CalamityMod.Items.Armor public override void SetStaticDefaults() { DisplayName.SetDefault("Empyrean Cuisses"); - Tooltip.SetDefault("5% increased rogue damage and critical strike chance\n" + - "20% increased movement speed\n" + - "Speed of the cosmos"); + Tooltip.SetDefault("Speed of the cosmos\n" + + "5% increased rogue damage and critical strike chance\n" + + "20% increased movement speed"); } public override void SetDefaults() diff --git a/Items/Armor/XerocMask.cs b/Items/Armor/XerocMask.cs index c1e064b27c..15e13c5c86 100644 --- a/Items/Armor/XerocMask.cs +++ b/Items/Armor/XerocMask.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.World; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -12,10 +14,9 @@ namespace CalamityMod.Items.Armor public override void SetStaticDefaults() { DisplayName.SetDefault("Empyrean Mask"); - Tooltip.SetDefault("11% increased rogue damage and critical strike chance, 22% increased movement speed\n" + - "Temporary immunity to lava\n" + - "Provides heat protection in Death Mode\n" + - "Wrath of the cosmos"); + Tooltip.SetDefault("Wrath of the cosmos\n" + + "11% increased rogue damage and critical strike chance, 22% increased movement speed\n" + + "Temporary immunity to lava"); } public override void SetDefaults() @@ -27,6 +28,21 @@ namespace CalamityMod.Items.Armor item.defense = 20; //71 } + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip2") + { + line2.text = "Temporary immunity to lava\n" + + "Provides heat protection in Death Mode"; + } + } + } + } + public override bool IsArmorSet(Item head, Item body, Item legs) { return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); diff --git a/Items/Armor/XerocPlateMail.cs b/Items/Armor/XerocPlateMail.cs index 3d5091ce9d..93da93177a 100644 --- a/Items/Armor/XerocPlateMail.cs +++ b/Items/Armor/XerocPlateMail.cs @@ -11,10 +11,10 @@ namespace CalamityMod.Items.Armor public override void SetStaticDefaults() { DisplayName.SetDefault("Empyrean Cloak"); - Tooltip.SetDefault("+20 max life\n" + + Tooltip.SetDefault("Armor of the cosmos\n" + + "+20 max life\n" + "6% increased movement speed\n" + - "7% increased rogue damage and critical strike chance\n" + - "Armor of the cosmos"); + "7% increased rogue damage and critical strike chance"); } public override void SetDefaults() diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index d9d3805a90..2c3eb1158a 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -1355,14 +1355,27 @@ namespace CalamityMod.Items } if (item.type == ItemID.WarmthPotion) { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text += "\nMakes you immune to the Chilled, Frozen, and Glacial State debuffs\n" + - "Provides cold protection in Death Mode"; - } - } + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text += "\nMakes you immune to the Chilled, Frozen, and Glacial State debuffs\n" + + "Provides cold protection in Death Mode"; + } + } + } + else + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text += "\nMakes you immune to the Chilled, Frozen, and Glacial State debuffs"; + } + } + } } if (item.type == ItemID.FlaskofVenom) { @@ -1486,15 +1499,29 @@ namespace CalamityMod.Items } if (item.type == ItemID.FireGauntlet) { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip1") - { - line2.text = "14% increased melee damage and speed\n" + - "10% increased true melee damage\n" + - "Provides heat and cold protection in Death Mode"; - } - } + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text = "14% increased melee damage and speed\n" + + "10% increased true melee damage\n" + + "Provides heat and cold protection in Death Mode"; + } + } + } + else + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + { + line2.text = "14% increased melee damage and speed\n" + + "10% increased true melee damage"; + } + } + } } if (item.type == ItemID.SpectreHood) { @@ -1508,41 +1535,69 @@ namespace CalamityMod.Items } if (item.type == ItemID.ObsidianSkinPotion) { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Provides immunity to direct damage from touching lava\n" + - "Provides temporary immunity to lava burn damage\n" + - "Reduces lava burn damage\n" + - "Provides heat protection in Death Mode"; - } - } + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Provides immunity to direct damage from touching lava\n" + + "Provides temporary immunity to lava burn damage\n" + + "Reduces lava burn damage\n" + + "Provides heat protection in Death Mode"; + } + } + } + else + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Provides immunity to direct damage from touching lava\n" + + "Provides temporary immunity to lava burn damage\n" + + "Reduces lava burn damage"; + } + } + } } if (item.type == ItemID.ObsidianRose) { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - { - line2.text = "Reduced direct damage from touching lava\n" + - "Greatly reduces lava burn damage\n" + - "Provides heat protection in Death Mode"; - } - } + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Reduced direct damage from touching lava\n" + + "Greatly reduces lava burn damage\n" + + "Provides heat protection in Death Mode"; + } + } + } + else + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Reduced direct damage from touching lava\n" + + "Greatly reduces lava burn damage"; + } + } + } } - if (item.type == ItemID.MagmaStone) + if (item.type == ItemID.MagmaStone && CalamityWorld.death) { foreach (TooltipLine line2 in tooltips) { if (line2.mod == "Terraria" && line2.Name == "Tooltip0") { - line2.text = "Inflicts fire damage on attack\n" + - "Provides heat and cold protection in Death Mode"; + line2.text += "\nProvides heat and cold protection in Death Mode"; } } } - if (item.type == ItemID.LavaCharm) + if (item.type == ItemID.LavaCharm && CalamityWorld.death) { foreach (TooltipLine line2 in tooltips) { @@ -1552,7 +1607,7 @@ namespace CalamityMod.Items } } } - if (item.type == ItemID.LavaWaders) + if (item.type == ItemID.LavaWaders && CalamityWorld.death) { foreach (TooltipLine line2 in tooltips) { @@ -1825,27 +1880,44 @@ namespace CalamityMod.Items } if (item.type == ItemID.MoltenHelmet || item.type == ItemID.MoltenBreastplate || item.type == ItemID.MoltenGreaves) { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = @"Set Bonus: 17% extra melee damage + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text = @"Set Bonus: 17% extra melee damage 20% extra true melee damage Grants immunity to fire blocks, and temporary immunity to lava Provides heat and cold protection in Death Mode"; - } + } + } + } + else + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text = @"Set Bonus: 17% extra melee damage +20% extra true melee damage +Grants immunity to fire blocks, and temporary immunity to lava"; + } + } } } if (item.type == ItemID.FrostHelmet || item.type == ItemID.FrostBreastplate || item.type == ItemID.FrostLeggings) { - foreach (TooltipLine line2 in tooltips) - { - if (line2.mod == "Terraria" && line2.Name == "SetBonus") - { - line2.text = @"Set Bonus: Melee and ranged attacks cause frostburn -Provides heat and cold protection in Death Mode"; - } - } + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "SetBonus") + { + line2.text += "\nProvides heat and cold protection in Death Mode"; + } + } + } } if (item.type == ItemID.MagicQuiver) { @@ -2238,7 +2310,7 @@ Provides heat and cold protection in Death Mode"; "Acceleration multiplier: 0\n" + "Average vertical speed\n" + "Flight time: 160\n" + - "+5 defense, 5% increased damage, " + + "+5 defense, 5% increased damage,\n" + "10% increased movement speed and 24% increased jump speed"; } } @@ -2990,14 +3062,27 @@ Provides heat and cold protection in Death Mode"; player.statDefense += 2; player.fireWalk = true; player.lavaMax += 180; - player.setBonus = "+2 defense\n" + - "5% increased rogue damage and critical strike chance\n" + - "Grants immunity to fire blocks and temporary immunity to lava\n" + - "Rogue stealth builds while not attacking and not moving, up to a max of 80\n" + - "Once you have built max stealth, you will be able to perform a Stealth Strike\n" + - "Rogue stealth only reduces when you attack, it does not reduce while moving\n" + - "The higher your rogue stealth the higher your rogue damage, crit, and movement speed\n" + - "Provides heat protection in Death Mode"; + if (CalamityWorld.death) + { + player.setBonus = "+2 defense\n" + + "5% increased rogue damage and critical strike chance\n" + + "Grants immunity to fire blocks and temporary immunity to lava\n" + + "Rogue stealth builds while not attacking and not moving, up to a max of 80\n" + + "Once you have built max stealth, you will be able to perform a Stealth Strike\n" + + "Rogue stealth only reduces when you attack, it does not reduce while moving\n" + + "The higher your rogue stealth the higher your rogue damage, crit, and movement speed\n" + + "Provides heat protection in Death Mode"; + } + else + { + player.setBonus = "+2 defense\n" + + "5% increased rogue damage and critical strike chance\n" + + "Grants immunity to fire blocks and temporary immunity to lava\n" + + "Rogue stealth builds while not attacking and not moving, up to a max of 80\n" + + "Once you have built max stealth, you will be able to perform a Stealth Strike\n" + + "Rogue stealth only reduces when you attack, it does not reduce while moving\n" + + "The higher your rogue stealth the higher your rogue damage, crit, and movement speed"; + } } else if (set == "Molten") { @@ -3009,10 +3094,19 @@ Provides heat and cold protection in Death Mode"; modPlayer.eskimoSet = true; player.buffImmune[BuffID.Frostburn] = true; player.buffImmune[ModContent.BuffType()] = true; - player.setBonus = "All ice-themed weapons receive a 10% damage bonus\n" + - "Cold enemies will deal reduced contact damage to the player\n" + - "Provides immunity to the Frostburn and Glacial State debuffs\n" + - "Provides cold immunity in Death Mode"; + if (CalamityWorld.death) + { + player.setBonus = "All ice-themed weapons receive a 10% damage bonus\n" + + "Cold enemies will deal reduced contact damage to the player\n" + + "Provides immunity to the Frostburn and Glacial State debuffs\n" + + "Provides cold immunity in Death Mode"; + } + else + { + player.setBonus = "All ice-themed weapons receive a 10% damage bonus\n" + + "Cold enemies will deal reduced contact damage to the player\n" + + "Provides immunity to the Frostburn and Glacial State debuffs"; + } } else if (set == "Meteor") { @@ -3487,7 +3581,7 @@ Provides heat and cold protection in Death Mode"; for (int i = 54; i < Main.maxInventory; i++) { - if (player.inventory[i].ammo == item.useAmmo && player.inventory[i].stack >= ammoConsumed) + if (player.inventory[i].ammo == item.useAmmo && (player.inventory[i].stack >= ammoConsumed || !player.inventory[i].consumable)) { itemAmmo = player.inventory[i]; flag = true; @@ -3499,7 +3593,7 @@ Provides heat and cold protection in Death Mode"; { for (int j = 0; j < 54; j++) { - if (player.inventory[j].ammo == item.useAmmo && player.inventory[j].stack >= ammoConsumed) + if (player.inventory[j].ammo == item.useAmmo && (player.inventory[j].stack >= ammoConsumed || !player.inventory[j].consumable)) { itemAmmo = player.inventory[j]; break; diff --git a/Items/Fishing/BrimstoneCragCatches/Bloodfin.cs b/Items/Fishing/BrimstoneCragCatches/Bloodfin.cs index a7b68b1b4a..871ca5599d 100644 --- a/Items/Fishing/BrimstoneCragCatches/Bloodfin.cs +++ b/Items/Fishing/BrimstoneCragCatches/Bloodfin.cs @@ -40,6 +40,8 @@ The life regen boost is stronger if below 75% health"); public override void OnConsumeItem(Player player) { int healAmt = CalamityWorld.ironHeart ? 0 : 240; + if (player.Calamity().bloodPactBoost) + healAmt = (int)(healAmt * 1.5); player.statLife += healAmt; if (player.statLife > player.statLifeMax2) { @@ -66,7 +68,10 @@ The life regen boost is stronger if below 75% health"); // Forces the "Restores X life" tooltip to display the actual life restored instead of zero (due to the previous function). public override void ModifyTooltips(List tooltips) { - tooltips.Find(line => line.Name == "HealLife").text = "Restores " + (CalamityWorld.ironHeart ? 0 : item.healLife) + " life"; + float healMult = 1f; + if (Main.player[Main.myPlayer].Calamity().bloodPactBoost) + healMult = 1.5f; + tooltips.Find(line => line.Name == "HealLife").text = "Restores " + (CalamityWorld.ironHeart ? 0 : (int)(item.healLife * healMult)) + " life"; } } } diff --git a/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs b/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs index ca9397f4e0..f085d1a405 100644 --- a/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs +++ b/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Fishing.SunkenSeaCatches } // Weapons - DropHelper.DropItemFromSetCondition(player, CalamityWorld.downedCLAM && Main.hardMode, 0.2f, + DropHelper.DropItemFromSetCondition(player, CalamityWorld.downedCLAMHardMode, 0.2f, ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), diff --git a/Items/LoreItems/KnowledgeSlimeGod.cs b/Items/LoreItems/KnowledgeSlimeGod.cs index 624450dfde..0d60631de9 100644 --- a/Items/LoreItems/KnowledgeSlimeGod.cs +++ b/Items/LoreItems/KnowledgeSlimeGod.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.LoreItems modPlayer.slimeGodLoreProcessed = true; - if (player.dashDelay < 0) + if (player.dashDelay < 0 || (player.velocity.Length() >= 11f && CalamityPlayer.areThereAnyDamnBosses)) //If you go over 52.8 mph player.velocity.X *= 0.9f; player.slippy2 = true; diff --git a/Items/Materials/EnergyCore.cs b/Items/Materials/EnergyCore.cs new file mode 100644 index 0000000000..8a2a3343fa --- /dev/null +++ b/Items/Materials/EnergyCore.cs @@ -0,0 +1,22 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Materials +{ + public class EnergyCore : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Energy Core"); + Tooltip.SetDefault("It pulses with energy"); + } + + public override void SetDefaults() + { + item.width = item.height = 22; + item.maxStack = 999; + item.value = Item.sellPrice(copper: 80); + item.rare = 1; + } + } +} diff --git a/Items/Materials/EnergyCore.png b/Items/Materials/EnergyCore.png new file mode 100644 index 0000000000..5b2ee40e5d Binary files /dev/null and b/Items/Materials/EnergyCore.png differ diff --git a/Items/Materials/TitanHeart.cs b/Items/Materials/TitanHeart.cs index c51478954c..80eafd1844 100644 --- a/Items/Materials/TitanHeart.cs +++ b/Items/Materials/TitanHeart.cs @@ -8,6 +8,7 @@ namespace CalamityMod.Items.Materials public override void SetStaticDefaults() { DisplayName.SetDefault("Titan Heart"); + Tooltip.SetDefault("Also used at the Astral Beacon"); } public override void SetDefaults() diff --git a/Items/Pets/RotomRemote.cs b/Items/Pets/RotomRemote.cs index a1c7771531..6122e39750 100644 --- a/Items/Pets/RotomRemote.cs +++ b/Items/Pets/RotomRemote.cs @@ -10,39 +10,39 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Pets { - public class RotomRemote : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Triboluminescent Etomer"); - Tooltip.SetDefault("Summons an electric troublemaker\n" + + public class RotomRemote : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Triboluminescent Etomer"); + Tooltip.SetDefault("Summons an electric troublemaker\n" + "A little note is attached:\n" + "Thank you, Aloe! Very much appreciated from Ben"); - } + } - public override void SetDefaults() - { - item.damage = 0; - item.useTime = 20; - item.useAnimation = 20; - item.useStyle = ItemUseStyleID.SwingThrow; - item.noMelee = true; - item.width = 30; - item.height = 34; - item.value = Item.buyPrice(0, 4, 0, 0); - item.UseSound = SoundID.Item113; - item.shoot = ModContent.ProjectileType(); - item.buffType = ModContent.BuffType(); - item.rare = 3; - } + public override void SetDefaults() + { + item.damage = 0; + item.useTime = item.useAnimation = 20; + item.shoot = ModContent.ProjectileType(); + item.buffType = ModContent.BuffType(); - public override void UseStyle(Player player) - { - if (player.whoAmI == Main.myPlayer && player.itemTime == 0) - { - player.AddBuff(item.buffType, 3600, true); - } - } + item.width = 30; + item.height = 34; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.UseSound = SoundID.Item113; + item.value = Item.buyPrice(0, 4, 0, 0); + item.rare = 3; + } + + public override void UseStyle(Player player) + { + if (player.whoAmI == Main.myPlayer && player.itemTime == 0) + { + player.AddBuff(item.buffType, 3600, true); + } + } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { @@ -51,15 +51,15 @@ namespace CalamityMod.Items.Pets spriteBatch.Draw(texture, item.Center - Main.screenPosition, null, Color.White, rotation, origin, 1f, SpriteEffects.None, 0f); } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddRecipeGroup("AnyGoldBar", 8); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddRecipeGroup("AnyGoldBar", 8); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Placeables/Banners/WulfrumDroneBanner.png b/Items/Placeables/Banners/WulfrumDroneBanner.png index 42706a4b58..2bad292814 100644 Binary files a/Items/Placeables/Banners/WulfrumDroneBanner.png and b/Items/Placeables/Banners/WulfrumDroneBanner.png differ diff --git a/Items/Placeables/Banners/WulfrumGyratorBanner.cs b/Items/Placeables/Banners/WulfrumGyratorBanner.cs new file mode 100644 index 0000000000..b2e15cf919 --- /dev/null +++ b/Items/Placeables/Banners/WulfrumGyratorBanner.cs @@ -0,0 +1,26 @@ +using CalamityMod.Tiles; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.Banners +{ + public class WulfrumGyratorBanner : ModItem + { + public override void SetDefaults() + { + item.width = 10; + item.height = 24; + item.maxStack = 99; + item.useTurn = true; + item.autoReuse = true; + item.useAnimation = 15; + item.useTime = 10; + item.useStyle = ItemUseStyleID.SwingThrow; + item.consumable = true; + item.rare = 1; + item.value = Item.buyPrice(0, 0, 10, 0); + item.createTile = ModContent.TileType(); + item.placeStyle = 123; + } + } +} diff --git a/Items/Placeables/Banners/WulfrumGyratorBanner.png b/Items/Placeables/Banners/WulfrumGyratorBanner.png new file mode 100644 index 0000000000..5e24c1fe4c Binary files /dev/null and b/Items/Placeables/Banners/WulfrumGyratorBanner.png differ diff --git a/Items/Placeables/Banners/WulfrumHovercraftBanner.cs b/Items/Placeables/Banners/WulfrumHovercraftBanner.cs new file mode 100644 index 0000000000..bef6437bbb --- /dev/null +++ b/Items/Placeables/Banners/WulfrumHovercraftBanner.cs @@ -0,0 +1,26 @@ +using CalamityMod.Tiles; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.Banners +{ + public class WulfrumHovercraftBanner : ModItem + { + public override void SetDefaults() + { + item.width = 10; + item.height = 24; + item.maxStack = 99; + item.useTurn = true; + item.autoReuse = true; + item.useAnimation = 15; + item.useTime = 10; + item.useStyle = ItemUseStyleID.SwingThrow; + item.consumable = true; + item.rare = 1; + item.value = Item.buyPrice(0, 0, 10, 0); + item.createTile = ModContent.TileType(); + item.placeStyle = 124; + } + } +} diff --git a/Items/Placeables/Banners/WulfrumHovercraftBanner.png b/Items/Placeables/Banners/WulfrumHovercraftBanner.png new file mode 100644 index 0000000000..561441a62c Binary files /dev/null and b/Items/Placeables/Banners/WulfrumHovercraftBanner.png differ diff --git a/Items/Placeables/Banners/WulfrumPylonBanner.cs b/Items/Placeables/Banners/WulfrumPylonBanner.cs new file mode 100644 index 0000000000..eff89d3773 --- /dev/null +++ b/Items/Placeables/Banners/WulfrumPylonBanner.cs @@ -0,0 +1,26 @@ +using CalamityMod.Tiles; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.Banners +{ + public class WulfrumPylonBanner : ModItem + { + public override void SetDefaults() + { + item.width = 10; + item.height = 24; + item.maxStack = 99; + item.useTurn = true; + item.autoReuse = true; + item.useAnimation = 15; + item.useTime = 10; + item.useStyle = ItemUseStyleID.SwingThrow; + item.consumable = true; + item.rare = 1; + item.value = Item.buyPrice(0, 0, 10, 0); + item.createTile = ModContent.TileType(); + item.placeStyle = 126; + } + } +} diff --git a/Items/Placeables/Banners/WulfrumPylonBanner.png b/Items/Placeables/Banners/WulfrumPylonBanner.png new file mode 100644 index 0000000000..6e547011a3 Binary files /dev/null and b/Items/Placeables/Banners/WulfrumPylonBanner.png differ diff --git a/Items/Placeables/Banners/WulfrumRoverBanner.cs b/Items/Placeables/Banners/WulfrumRoverBanner.cs new file mode 100644 index 0000000000..00af6ecb9c --- /dev/null +++ b/Items/Placeables/Banners/WulfrumRoverBanner.cs @@ -0,0 +1,26 @@ +using CalamityMod.Tiles; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.Banners +{ + public class WulfrumRoverBanner : ModItem + { + public override void SetDefaults() + { + item.width = 10; + item.height = 24; + item.maxStack = 99; + item.useTurn = true; + item.autoReuse = true; + item.useAnimation = 15; + item.useTime = 10; + item.useStyle = ItemUseStyleID.SwingThrow; + item.consumable = true; + item.rare = 1; + item.value = Item.buyPrice(0, 0, 10, 0); + item.createTile = ModContent.TileType(); + item.placeStyle = 125; + } + } +} diff --git a/Items/Placeables/Banners/WulfrumRoverBanner.png b/Items/Placeables/Banners/WulfrumRoverBanner.png new file mode 100644 index 0000000000..3852b1568c Binary files /dev/null and b/Items/Placeables/Banners/WulfrumRoverBanner.png differ diff --git a/Items/Potions/Alcohol/GrapeBeer.cs b/Items/Potions/Alcohol/GrapeBeer.cs index 4f0a0bc2f4..52875fb9ef 100644 --- a/Items/Potions/Alcohol/GrapeBeer.cs +++ b/Items/Potions/Alcohol/GrapeBeer.cs @@ -42,6 +42,8 @@ Reduces defense by 2 and movement speed by 5%"); public override void OnConsumeItem(Player player) { int healAmt = CalamityWorld.ironHeart ? 0 : 100; + if (player.Calamity().bloodPactBoost) + healAmt = (int)(healAmt * 1.5); player.statLife += healAmt; player.statMana += 100; if (player.statLife > player.statLifeMax2) @@ -71,7 +73,10 @@ Reduces defense by 2 and movement speed by 5%"); // Forces the "Restores X life" tooltip to display the actual life restored instead of zero (due to the previous function). public override void ModifyTooltips(List tooltips) { - tooltips.Find(line => line.Name == "HealLife").text = "Restores " + (CalamityWorld.ironHeart ? 0 : item.healLife) + " life"; + float healMult = 1f; + if (Main.player[Main.myPlayer].Calamity().bloodPactBoost) + healMult = 1.5f; + tooltips.Find(line => line.Name == "HealLife").text = "Restores " + (CalamityWorld.ironHeart ? 0 : (int)(item.healLife * healMult)) + " life"; } } } diff --git a/Items/Potions/Alcohol/Margarita.cs b/Items/Potions/Alcohol/Margarita.cs index 884fd01e9d..a6c75e20a0 100644 --- a/Items/Potions/Alcohol/Margarita.cs +++ b/Items/Potions/Alcohol/Margarita.cs @@ -45,6 +45,8 @@ Reduces defense by 6 and life regen by 1"); public override void OnConsumeItem(Player player) { int healAmt = CalamityWorld.ironHeart ? 0 : 200; + if (player.Calamity().bloodPactBoost) + healAmt = (int)(healAmt * 1.5); player.statLife += healAmt; player.statMana += 200; if (player.statLife > player.statLifeMax2) @@ -74,7 +76,10 @@ Reduces defense by 6 and life regen by 1"); // Forces the "Restores X life" tooltip to display the actual life restored instead of zero (due to the previous function). public override void ModifyTooltips(List tooltips) { - tooltips.Find(line => line.Name == "HealLife").text = "Restores " + (CalamityWorld.ironHeart ? 0 : item.healLife) + " life"; + float healMult = 1f; + if (Main.player[Main.myPlayer].Calamity().bloodPactBoost) + healMult = 1.5f; + tooltips.Find(line => line.Name == "HealLife").text = "Restores " + (CalamityWorld.ironHeart ? 0 : (int)(item.healLife * healMult)) + " life"; } } } diff --git a/Items/Potions/SunkenStew.cs b/Items/Potions/SunkenStew.cs index 3c4ec5bf6a..598a592537 100644 --- a/Items/Potions/SunkenStew.cs +++ b/Items/Potions/SunkenStew.cs @@ -45,6 +45,8 @@ Grants Well Fed"); public override bool UseItem(Player player) { int healAmt = CalamityWorld.ironHeart ? 0 : 120; + if (player.Calamity().bloodPactBoost) + healAmt = (int)(healAmt * 1.5); player.statLife += healAmt; player.statMana += 150; if (player.statLife > player.statLifeMax2) @@ -79,7 +81,10 @@ Grants Well Fed"); // Forces the "Restores X life" tooltip to display the actual life restored instead of zero (due to the previous function). public override void ModifyTooltips(List tooltips) { - tooltips.Find(line => line.Name == "HealLife").text = "Restores " + (CalamityWorld.ironHeart ? 0 : item.healLife) + " life"; + float healMult = 1f; + if (Main.player[Main.myPlayer].Calamity().bloodPactBoost) + healMult = 1.5f; + tooltips.Find(line => line.Name == "HealLife").text = "Restores " + (CalamityWorld.ironHeart ? 0 : (int)(item.healLife * healMult)) + " life"; } public override void AddRecipes() diff --git a/Items/SummonItems/AncientMedallion.cs b/Items/SummonItems/AncientMedallion.cs index b92a0af850..1301cdb8df 100644 --- a/Items/SummonItems/AncientMedallion.cs +++ b/Items/SummonItems/AncientMedallion.cs @@ -35,8 +35,9 @@ namespace CalamityMod.Items.SummonItems Main.PlaySound(SoundID.Roar, player.position, 2); if (Main.netMode != NetmodeID.MultiplayerClient) { - int npc = NPC.NewNPC((int)(player.position.X + Main.rand.Next(-100, 101)), (int)(player.position.Y - 250f), ModContent.NPCType(), 1); + int npc = NPC.NewNPC((int)(player.position.X + Main.rand.Next(-100, 101)), (int)(player.position.Y - 350f), ModContent.NPCType(), 1); Main.npc[npc].timeLeft *= 20; + CalamityUtils.BossAwakenMessage(npc); } else NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); diff --git a/Items/SummonItems/AstralChunk.cs b/Items/SummonItems/AstralChunk.cs index bbcab930d0..0c77219aaa 100644 --- a/Items/SummonItems/AstralChunk.cs +++ b/Items/SummonItems/AstralChunk.cs @@ -38,6 +38,7 @@ namespace CalamityMod.Items.SummonItems { int npc = NPC.NewNPC((int)(player.position.X + Main.rand.Next(-50, 50)), (int)(player.position.Y - 150f), ModContent.NPCType(), 1); Main.npc[npc].timeLeft *= 20; + CalamityUtils.BossAwakenMessage(npc); } else NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); diff --git a/Items/SummonItems/DecapoditaSprout.cs b/Items/SummonItems/DecapoditaSprout.cs index eef52006d3..44ae8f77dd 100644 --- a/Items/SummonItems/DecapoditaSprout.cs +++ b/Items/SummonItems/DecapoditaSprout.cs @@ -36,6 +36,7 @@ namespace CalamityMod.Items.SummonItems { int npc = NPC.NewNPC((int)(player.position.X + Main.rand.Next(-50, 51)), (int)(player.position.Y - 50f), ModContent.NPCType(), 1); Main.npc[npc].timeLeft *= 20; + CalamityUtils.BossAwakenMessage(npc); } else NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); diff --git a/Items/SummonItems/EidolonTablet.cs b/Items/SummonItems/EidolonTablet.cs index 11a05971d9..6bf6978418 100644 --- a/Items/SummonItems/EidolonTablet.cs +++ b/Items/SummonItems/EidolonTablet.cs @@ -36,6 +36,7 @@ namespace CalamityMod.Items.SummonItems int npc = NPC.NewNPC((int)player.Center.X + 30, (int)player.Center.Y - 90, NPCID.CultistBoss, 1); Main.npc[npc].direction = Main.npc[npc].spriteDirection = Math.Sign(player.Center.X - player.Center.X - 30f); Main.npc[npc].timeLeft *= 20; + CalamityUtils.BossAwakenMessage(npc); } else NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, NPCID.CultistBoss); diff --git a/Items/SummonItems/ProfanedCore.cs b/Items/SummonItems/ProfanedCore.cs index c71c860b59..bafef3f868 100644 --- a/Items/SummonItems/ProfanedCore.cs +++ b/Items/SummonItems/ProfanedCore.cs @@ -41,6 +41,7 @@ namespace CalamityMod.Items.SummonItems { int npc = NPC.NewNPC((int)(player.position.X + Main.rand.Next(-500, 501)), (int)(player.position.Y - 250f), ModContent.NPCType(), 1); Main.npc[npc].timeLeft *= 20; + CalamityUtils.BossAwakenMessage(npc); } else NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); diff --git a/Items/SummonItems/ProfanedCoreUnlimited.cs b/Items/SummonItems/ProfanedCoreUnlimited.cs index 0d668f0cf4..c323f9b4f6 100644 --- a/Items/SummonItems/ProfanedCoreUnlimited.cs +++ b/Items/SummonItems/ProfanedCoreUnlimited.cs @@ -42,6 +42,7 @@ namespace CalamityMod.Items.SummonItems { int npc = NPC.NewNPC((int)(player.position.X + Main.rand.Next(-500, 501)), (int)(player.position.Y - 250f), ModContent.NPCType(), 1); Main.npc[npc].timeLeft *= 20; + CalamityUtils.BossAwakenMessage(npc); } else NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); diff --git a/Items/SummonItems/Teratoma.cs b/Items/SummonItems/Teratoma.cs index 97c0b66c08..6fc0084733 100644 --- a/Items/SummonItems/Teratoma.cs +++ b/Items/SummonItems/Teratoma.cs @@ -38,6 +38,7 @@ namespace CalamityMod.Items.SummonItems { int npc = NPC.NewNPC((int)(player.position.X + Main.rand.Next(-100, 100)), (int)(player.position.Y - 150f), ModContent.NPCType(), 1); Main.npc[npc].timeLeft *= 20; + CalamityUtils.BossAwakenMessage(npc); } else NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); diff --git a/Items/Tools/ClimateChange/Cosmolight.cs b/Items/Tools/ClimateChange/Cosmolight.cs index c372575163..681306c541 100644 --- a/Items/Tools/ClimateChange/Cosmolight.cs +++ b/Items/Tools/ClimateChange/Cosmolight.cs @@ -1,4 +1,4 @@ -using CalamityMod.NPCs; +using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Tools.ClimateChange public override bool CanUseItem(Player player) { - return !CalamityGlobalNPC.AnyBossNPCS(); + return !CalamityPlayer.areThereAnyDamnBosses; } public override bool UseItem(Player player) diff --git a/Items/Tools/ClimateChange/Daylight.cs b/Items/Tools/ClimateChange/Daylight.cs index 1d4e405fde..d9e280c78e 100644 --- a/Items/Tools/ClimateChange/Daylight.cs +++ b/Items/Tools/ClimateChange/Daylight.cs @@ -1,4 +1,4 @@ -using CalamityMod.NPCs; +using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Tools.ClimateChange public override bool CanUseItem(Player player) { - return !Main.dayTime && !CalamityGlobalNPC.AnyBossNPCS(); + return !Main.dayTime && !CalamityPlayer.areThereAnyDamnBosses; } public override bool UseItem(Player player) diff --git a/Items/Tools/ClimateChange/Moonlight.cs b/Items/Tools/ClimateChange/Moonlight.cs index 7ed05c712c..d5afd2cab2 100644 --- a/Items/Tools/ClimateChange/Moonlight.cs +++ b/Items/Tools/ClimateChange/Moonlight.cs @@ -1,5 +1,5 @@ using CalamityMod.Items.Materials; -using CalamityMod.NPCs; +using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Tools.ClimateChange public override bool CanUseItem(Player player) { - return Main.dayTime && !CalamityGlobalNPC.AnyBossNPCS(); + return Main.dayTime && !CalamityPlayer.areThereAnyDamnBosses; } public override bool UseItem(Player player) diff --git a/Items/Tools/CrystylCrusher.cs b/Items/Tools/CrystylCrusher.cs index f577715850..875f237fc3 100644 --- a/Items/Tools/CrystylCrusher.cs +++ b/Items/Tools/CrystylCrusher.cs @@ -31,8 +31,7 @@ namespace CalamityMod.Items.Tools item.crit += 25; item.width = 70; item.height = 70; - item.useTime = 20; - item.useAnimation = 20; + item.useTime = item.useAnimation = 2; item.useStyle = ItemUseStyleID.HoldingOut; item.knockBack = 9f; item.shootSpeed = 14f; @@ -50,10 +49,7 @@ namespace CalamityMod.Items.Tools return new Vector2(10, 10); } - public override bool AltFunctionUse(Player player) - { - return true; - } + public override bool AltFunctionUse(Player player) => true; public override bool CanUseItem(Player player) { @@ -65,8 +61,6 @@ namespace CalamityMod.Items.Tools item.tileBoost = 50; item.UseSound = SoundID.Item1; item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 2; - item.useAnimation = 2; item.useTurn = true; item.autoReuse = true; item.noMelee = false; @@ -80,8 +74,6 @@ namespace CalamityMod.Items.Tools item.tileBoost = 0; item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/CrystylCharge"); item.useStyle = ItemUseStyleID.HoldingOut; - item.useTime = 20; - item.useAnimation = 20; item.useTurn = false; item.autoReuse = false; item.noMelee = true; @@ -97,20 +89,13 @@ namespace CalamityMod.Items.Tools if (Main.rand.NextBool(3)) { - int num307 = Main.rand.Next(3); - if (num307 == 0) + int dustType = Utils.SelectRandom(Main.rand, new int[] { - num307 = 173; - } - else if (num307 == 1) - { - num307 = 57; - } - else - { - num307 = 58; - } - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, num307); + 173, + 57, + 58 + }); + int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, dustType); } } diff --git a/Items/Weapons/DraedonsArsenal/LaserRifle.cs b/Items/Weapons/DraedonsArsenal/LaserRifle.cs index d2c508ab4c..9add3a711d 100644 --- a/Items/Weapons/DraedonsArsenal/LaserRifle.cs +++ b/Items/Weapons/DraedonsArsenal/LaserRifle.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal { public class LaserRifle : ModItem { - private int BaseDamage = 200; + private int BaseDamage = 100; public override void SetStaticDefaults() { @@ -52,10 +52,12 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal velocity *= 5f; } - float SpeedX = velocity.X + (float)Main.rand.Next(-1, 2) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-1, 2) * 0.05f; - - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + for (int i = 0; i < 2; i++) + { + float SpeedX = velocity.X + Main.rand.Next(-1, 2) * 0.05f; + float SpeedY = velocity.Y + Main.rand.Next(-1, 2) * 0.05f; + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, i, 0f); + } // Consume 4 ammo per shot CalamityGlobalItem.ConsumeAdditionalAmmo(player, item, 4); diff --git a/Items/Weapons/DraedonsArsenal/MountedScanner.cs b/Items/Weapons/DraedonsArsenal/MountedScanner.cs index 58b9821f26..d0393af097 100644 --- a/Items/Weapons/DraedonsArsenal/MountedScanner.cs +++ b/Items/Weapons/DraedonsArsenal/MountedScanner.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal item.summon = true; item.damage = 15; item.knockBack = 2f; - item.useTime = item.useAnimation = 35; + item.useTime = item.useAnimation = 25; item.autoReuse = true; item.useStyle = ItemUseStyleID.HoldingUp; diff --git a/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs b/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs index 93e909c1cd..8823b67023 100644 --- a/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs +++ b/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs @@ -43,28 +43,13 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal item.Calamity().Chargeable = true; } - public override bool AltFunctionUse(Player player) - { - return true; - } + public override bool AltFunctionUse(Player player) => true; - public override bool CanUseItem(Player player) + public override float UseTimeMultiplier (Player player) { if (player.altFunctionUse == 2) - { - item.useAnimation = 15; - item.useTime = 15; - item.damage = BaseDamage / 3; - item.knockBack = 3f; - } - else - { - item.useAnimation = 45; - item.useTime = 45; - item.damage = BaseDamage; - item.knockBack = 7f; - } - return base.CanUseItem(player); + return 3f; + return 1f; } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) @@ -79,14 +64,18 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal int ammoConsumed = 20; float SpeedX = velocity.X + (float)Main.rand.Next(-3, 4) * 0.05f; float SpeedY = velocity.Y + (float)Main.rand.Next(-3, 4) * 0.05f; + float damageMult = 1f; + float kbMult = 1f; if (player.altFunctionUse == 2) { ammoConsumed = 5; SpeedX = velocity.X + (float)Main.rand.Next(-15, 16) * 0.05f; SpeedY = velocity.Y + (float)Main.rand.Next(-15, 16) * 0.05f; + damageMult = 0.3333f; + kbMult = 3f/7f; } - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(damage * damageMult), knockBack * kbMult, player.whoAmI, 0f, 0f); // Consume 20 or 5 ammo per shot CalamityGlobalItem.ConsumeAdditionalAmmo(player, item, ammoConsumed); diff --git a/Items/Weapons/DraedonsArsenal/SnakeEyes.cs b/Items/Weapons/DraedonsArsenal/SnakeEyes.cs index 878d9da33a..6e76fd1ac0 100644 --- a/Items/Weapons/DraedonsArsenal/SnakeEyes.cs +++ b/Items/Weapons/DraedonsArsenal/SnakeEyes.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override void SetDefaults() { item.shootSpeed = 10f; - item.damage = 11; + item.damage = 9; item.mana = 12; item.width = 38; item.height = 24; diff --git a/Items/Weapons/Magic/DeathhailStaff.cs b/Items/Weapons/Magic/DeathhailStaff.cs index f65ded93fc..f0fca04e3a 100644 --- a/Items/Weapons/Magic/DeathhailStaff.cs +++ b/Items/Weapons/Magic/DeathhailStaff.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Magic { DisplayName.SetDefault("Deathhail Staff"); Tooltip.SetDefault("Rain death upon your foes!\n" + - "Casts a storm of nebula shots from the sky"); + "Casts a storm of nebula lasers from the sky"); Item.staff[item.type] = true; } @@ -101,7 +101,7 @@ namespace CalamityMod.Items.Weapons.Magic num79 *= num80; float speedX4 = num78 + (float)Main.rand.Next(-50, 51) * 0.02f; float speedY5 = num79 + (float)Main.rand.Next(-50, 51) * 0.02f; - Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, type, num73, num74, i, 0f, (float)Main.rand.Next(10)); + Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, type, num73, num74, i, 0f, 0f); } return false; } diff --git a/Items/Weapons/Magic/EventHorizon.cs b/Items/Weapons/Magic/EventHorizon.cs index cc8c8b10fe..bb5632a978 100644 --- a/Items/Weapons/Magic/EventHorizon.cs +++ b/Items/Weapons/Magic/EventHorizon.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Magic item.width = 28; item.height = 30; - item.damage = 231; + item.damage = 369; item.knockBack = 3.5f; item.noMelee = true; item.magic = true; diff --git a/Items/Weapons/Magic/Fabstaff.cs b/Items/Weapons/Magic/Fabstaff.cs index 12267f8077..a67186ab49 100644 --- a/Items/Weapons/Magic/Fabstaff.cs +++ b/Items/Weapons/Magic/Fabstaff.cs @@ -13,14 +13,13 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetStaticDefaults() { DisplayName.SetDefault("Fabstaff"); - Tooltip.SetDefault("Casts a bouncing beam that splits when enemies are near it\n" + - "The splitting can trigger long after the beam has vanished"); + Tooltip.SetDefault("Casts a bouncing beam that splits when enemies are near it"); Item.staff[item.type] = true; } public override void SetDefaults() { - item.damage = 880; + item.damage = 616; item.magic = true; item.mana = 50; item.width = 84; diff --git a/Items/Weapons/Magic/FaceMelter.cs b/Items/Weapons/Magic/FaceMelter.cs index 1a68bc48c9..156297cc71 100644 --- a/Items/Weapons/Magic/FaceMelter.cs +++ b/Items/Weapons/Magic/FaceMelter.cs @@ -39,10 +39,7 @@ namespace CalamityMod.Items.Weapons.Magic item.shootSpeed = 20f; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-15, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-15, 0); public override void AddRecipes() { @@ -58,31 +55,33 @@ namespace CalamityMod.Items.Weapons.Magic recipe.AddRecipe(); } - public override bool AltFunctionUse(Player player) + public override bool AltFunctionUse(Player player) => true; + + public override bool CanUseItem(Player player) { - return true; + if (player.altFunctionUse == 2) + { + item.useTime = 20; + item.useAnimation = 20; + } + else + { + item.useTime = 5; + item.useAnimation = 10; + } + return base.CanUseItem(player); } 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 (player.altFunctionUse == 2) { - position = Main.MouseWorld; - speedX = 0; - speedY = 0; - item.useTime = 20; - item.useAnimation = 20; - item.reuseDelay = 0; - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); return false; } else { - item.useTime = 5; - item.useAnimation = 10; - float SpeedX = speedX; - float SpeedY = speedY; - int note = Main.rand.Next(0, 2); + int note = Main.rand.Next(2); if (note == 0) { damage = (int)(damage * 1.5f); @@ -90,11 +89,11 @@ namespace CalamityMod.Items.Weapons.Magic } else { - SpeedX *= 1.5f; - SpeedY *= 1.5f; + speedX *= 1.5f; + speedY *= 1.5f; type = ModContent.ProjectileType(); } - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); return false; } } diff --git a/Items/Weapons/Magic/ShiftingSands.cs b/Items/Weapons/Magic/ShiftingSands.cs index 7e69a5dbaa..e17a447727 100644 --- a/Items/Weapons/Magic/ShiftingSands.cs +++ b/Items/Weapons/Magic/ShiftingSands.cs @@ -6,45 +6,58 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { - public class ShiftingSands : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Shifting Sands"); - Tooltip.SetDefault("Casts a sand shard that follows the mouse cursor"); - } + public class ShiftingSands : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Shifting Sands"); + Tooltip.SetDefault("Casts a sand shard that follows the mouse cursor"); + } - public override void SetDefaults() - { - item.damage = 85; - item.magic = true; - item.channel = true; - item.mana = 20; - item.width = 58; - item.height = 58; - item.useTime = 30; - item.useAnimation = 30; - item.useStyle = ItemUseStyleID.SwingThrow; - item.noMelee = true; - item.knockBack = 5f; - item.value = Item.buyPrice(0, 60, 0, 0); - item.rare = 7; - item.UseSound = SoundID.Item20; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 7f; + public override void SetDefaults() + { + item.damage = 61; + item.knockBack = 5f; + item.useTime = item.useAnimation = 30; + item.mana = 20; + item.magic = true; + item.channel = true; item.autoReuse = true; - } + item.shootSpeed = 7f; + item.shoot = ModContent.ProjectileType(); - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.MagicMissile); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.AncientBattleArmorMaterial, 2); - recipe.AddIngredient(ItemID.SpectreBar, 5); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + item.width = item.height = 58; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.UseSound = SoundID.Item20; + item.value = Item.buyPrice(0, 60, 0, 0); + item.rare = 7; + } + + public override bool CanUseItem(Player player) + { + int projCount = 0; + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile proj = Main.projectile[x]; + if (proj.active && proj.owner == player.whoAmI && proj.type == item.shoot && proj.ai[0] <= 0f) + { + projCount++; + } + } + return projCount <= 0; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.MagicMissile); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.AncientBattleArmorMaterial, 2); + recipe.AddIngredient(ItemID.SpectreBar, 5); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Magic/UltraLiquidator.cs b/Items/Weapons/Magic/UltraLiquidator.cs index 172e9c85ef..b0b720d2ff 100644 --- a/Items/Weapons/Magic/UltraLiquidator.cs +++ b/Items/Weapons/Magic/UltraLiquidator.cs @@ -8,82 +8,77 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Magic { public class UltraLiquidator : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Ultra Liquidator"); - Tooltip.SetDefault("Summons liquidation blades that summon more blades on enemy hits\n" + - "The blades inflict ichor, cursed inferno, on fire, and frostburn"); - Item.staff[item.type] = true; - } + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Ultra Liquidator"); + Tooltip.SetDefault("Summons liquidation blades that summon more blades on enemy hits\n" + + "The blades inflict ichor, cursed inferno, on fire, and frostburn"); + Item.staff[item.type] = true; + } - public override void SetDefaults() - { - item.damage = 145; - item.magic = true; - item.mana = 25; - item.width = 16; - item.height = 16; - item.useAnimation = 15; - item.useTime = 3; - item.reuseDelay = item.useAnimation; - item.crit = 30; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.knockBack = 7f; - item.value = Item.buyPrice(1, 20, 0, 0); - item.rare = 10; - item.UseSound = SoundID.Item9; - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 16f; - item.Calamity().customRarity = CalamityRarity.Turquoise; - } + public override void SetDefaults() + { + item.damage = 145; + item.crit = 30; + item.knockBack = 7f; + item.useTime = 3; + item.reuseDelay = item.useAnimation = 15; + item.mana = 25; + item.magic = true; + item.autoReuse = true; + item.shootSpeed = 16f; + item.shoot = ModContent.ProjectileType(); - public override Vector2? HoldoutOrigin() - { - return new Vector2(15, 15); - } + item.width = item.height = 16; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.UseSound = SoundID.Item9; + item.value = Item.buyPrice(1, 20, 0, 0); + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.AquaScepter); + public override Vector2? HoldoutOrigin() => new Vector2(15, 15); + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddRecipeGroup("CursedFlameIchor", 20); + recipe.AddIngredient(ItemID.AquaScepter); recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ItemID.LunarBar, 5); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } + recipe.AddIngredient(ItemID.LunarBar, 5); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num72 = item.shootSpeed; - float num78 = Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = Main.mouseY + Main.screenPosition.Y - vector2.Y; - float f = Main.rand.NextFloat() * MathHelper.TwoPi; - float value12 = 20f; - float value13 = 60f; - Vector2 vector13 = vector2 + f.ToRotationVector2() * MathHelper.Lerp(value12, value13, Main.rand.NextFloat()); - for (int num202 = 0; num202 < 50; num202++) - { - vector13 = vector2 + f.ToRotationVector2() * MathHelper.Lerp(value12, value13, Main.rand.NextFloat()); - if (Collision.CanHit(vector2, 0, 0, vector13 + (vector13 - vector2).SafeNormalize(Vector2.UnitX) * 8f, 0, 0)) - { - break; - } - f = Main.rand.NextFloat() * MathHelper.TwoPi; - } - Vector2 mouseWorld = Main.MouseWorld; - Vector2 vector14 = mouseWorld - vector13; - Vector2 vector15 = new Vector2(num78, num79).SafeNormalize(Vector2.UnitY) * num72; - vector14 = vector14.SafeNormalize(vector15) * num72; - vector14 = Vector2.Lerp(vector14, vector15, 0.25f); - Projectile.NewProjectile(vector13, vector14, type, damage, knockBack, player.whoAmI, 0f, 0f); - return false; - } - } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float speed = item.shootSpeed; + float xVec = (float)Main.mouseX + Main.screenPosition.X - playerPos.X; + float yVec = (float)Main.mouseY + Main.screenPosition.Y - playerPos.Y; + float f = Main.rand.NextFloat() * MathHelper.TwoPi; + float lowerBoundOffset = 20f; + float upperBoundOffset = 60f; + Vector2 source = playerPos + f.ToRotationVector2() * MathHelper.Lerp(lowerBoundOffset, upperBoundOffset, Main.rand.NextFloat()); + for (int i = 0; i < 50; i++) + { + source = playerPos + f.ToRotationVector2() * MathHelper.Lerp(lowerBoundOffset, upperBoundOffset, Main.rand.NextFloat()); + if (Collision.CanHit(playerPos, 0, 0, source + (source - playerPos).SafeNormalize(Vector2.UnitX) * 8f, 0, 0)) + { + break; + } + f = Main.rand.NextFloat() * MathHelper.TwoPi; + } + Vector2 velocity = Main.MouseWorld - source; + Vector2 upperVelocityLimit = new Vector2(xVec, yVec).SafeNormalize(Vector2.UnitY) * speed; + velocity = velocity.SafeNormalize(upperVelocityLimit) * speed; + velocity = Vector2.Lerp(velocity, upperVelocityLimit, 0.25f); + Projectile.NewProjectile(source, velocity, type, damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } + } } diff --git a/Items/Weapons/Melee/AbyssBlade.cs b/Items/Weapons/Melee/AbyssBlade.cs index 6ca2dd8606..895c05577b 100644 --- a/Items/Weapons/Melee/AbyssBlade.cs +++ b/Items/Weapons/Melee/AbyssBlade.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Melee { item.width = 74; item.height = 74; - item.damage = 100; + item.damage = 90; item.melee = true; item.useAnimation = 26; item.useTime = 26; @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 0.8), knockBack, player.whoAmI); + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 0.75), knockBack, player.whoAmI); return false; } @@ -61,7 +61,7 @@ namespace CalamityMod.Items.Weapons.Melee { if (Main.rand.NextBool(3)) { - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 33); + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 33); } } diff --git a/Items/Weapons/Melee/Animus.cs b/Items/Weapons/Melee/Animus.cs index a9a09b298b..217fda9a0d 100644 --- a/Items/Weapons/Melee/Animus.cs +++ b/Items/Weapons/Melee/Animus.cs @@ -43,63 +43,70 @@ namespace CalamityMod.Items.Weapons.Melee recipe.AddRecipe(); } + public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) + { + float damageMult = player.Calamity().animusBoost; + damageMult -= 1f; + mult += damageMult; + } + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 6000); - int damageRan = Main.rand.Next(195); //0 to 195 + int damageRan = Main.rand.Next(195); //0 to 194 if (damageRan >= 50 && damageRan <= 99) //25% { - item.damage = 6000; + player.Calamity().animusBoost = 1.5f; } else if (damageRan >= 100 && damageRan <= 139) //20% { - item.damage = 9000; + player.Calamity().animusBoost = 2.25f; } else if (damageRan >= 140 && damageRan <= 169) //15% { - item.damage = 15000; + player.Calamity().animusBoost = 3.75f; } else if (damageRan >= 170 && damageRan <= 189) //10% { - item.damage = 30000; + player.Calamity().animusBoost = 7.5f; } else if (damageRan >= 190 && damageRan <= 194) //5% { - item.damage = 50000; + player.Calamity().animusBoost = 12.5f; } else { - item.damage = 4000; + player.Calamity().animusBoost = 1f; } } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 6000); - int damageRan = Main.rand.Next(195); //0 to 195 + int damageRan = Main.rand.Next(195); //0 to 194 if (damageRan >= 50 && damageRan <= 99) //25% { - item.damage = 6000; + player.Calamity().animusBoost = 1.5f; } else if (damageRan >= 100 && damageRan <= 139) //20% { - item.damage = 9000; + player.Calamity().animusBoost = 2.25f; } else if (damageRan >= 140 && damageRan <= 169) //15% { - item.damage = 15000; + player.Calamity().animusBoost = 3.75f; } else if (damageRan >= 170 && damageRan <= 189) //10% { - item.damage = 30000; + player.Calamity().animusBoost = 7.5f; } else if (damageRan >= 190 && damageRan <= 194) //5% { - item.damage = 50000; + player.Calamity().animusBoost = 12.5f; } else { - item.damage = 4000; + player.Calamity().animusBoost = 1f; } } } diff --git a/Items/Weapons/Melee/DraedonsExoblade.cs b/Items/Weapons/Melee/DraedonsExoblade.cs index 0abf7fbb2b..40e701a021 100644 --- a/Items/Weapons/Melee/DraedonsExoblade.cs +++ b/Items/Weapons/Melee/DraedonsExoblade.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -64,15 +62,7 @@ namespace CalamityMod.Items.Weapons.Melee { Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), knockback, Main.myPlayer); } - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); Main.PlaySound(SoundID.Item88, player.Center); float xPos = player.position.X + 800 * Main.rand.NextBool(2).ToDirectionInt(); float yPos = player.position.Y + Main.rand.Next(-800, 801); @@ -106,15 +96,7 @@ namespace CalamityMod.Items.Weapons.Melee { Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), item.knockBack, Main.myPlayer); } - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); Main.PlaySound(SoundID.Item88, player.Center); float xPos = player.position.X + 800 * Main.rand.NextBool(2).ToDirectionInt(); float yPos = player.position.Y + Main.rand.Next(-800, 801); diff --git a/Items/Weapons/Melee/ExoGladius.cs b/Items/Weapons/Melee/ExoGladius.cs index 543f56e7e1..faa1fc4a1c 100644 --- a/Items/Weapons/Melee/ExoGladius.cs +++ b/Items/Weapons/Melee/ExoGladius.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -68,84 +66,36 @@ namespace CalamityMod.Items.Weapons.Melee } } - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) + { + target.ExoDebuffs(); + OnHitEffects(player); + } + + public override void OnHitPvp(Player player, Player target, int damage, bool crit) + { + target.ExoDebuffs(); + OnHitEffects(player); + } + + private void OnHitEffects(Player player) { if (!player.immune) { player.immune = true; - if (player.immuneTime < 10) - player.immuneTime = 10; - if (player.hurtCooldowns[0] < 10) - player.hurtCooldowns[0] = 10; - if (player.hurtCooldowns[1] < 10) - player.hurtCooldowns[1] = 10; + if (player.immuneTime < 10) + player.immuneTime = 10; + if (player.hurtCooldowns[0] < 10) + player.hurtCooldowns[0] = 10; + if (player.hurtCooldowns[1] < 10) + player.hurtCooldowns[1] = 10; } - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); - - float x = target.Center.X + (float)Main.rand.Next(-400, 400); - float y = target.Center.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num15 = target.Center.X + (float)(target.width / 2) - vector.X; - float num16 = target.Center.Y + (float)(target.height / 2) - vector.Y; - num15 += (float)Main.rand.Next(-100, 101); - int num17 = 25; - float num18 = (float)Math.Sqrt((double)(num15 * num15 + num16 * num16)); - num18 = (float)num17 / num18; - num15 *= num18; - num16 *= num18; if (player.whoAmI == Main.myPlayer) { - Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), 15f, player.whoAmI, 0f, 0f); + int damage = player.GetWeaponDamage(player.ActiveItem()); + CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 25f, ModContent.ProjectileType(), damage, 15f, player.whoAmI); } } - - public override void OnHitPvp(Player player, Player target, int damage, bool crit) - { - if (!player.immune) - { - player.immune = true; - if (player.immuneTime < 10) - player.immuneTime = 10; - if (player.hurtCooldowns[0] < 10) - player.hurtCooldowns[0] = 10; - if (player.hurtCooldowns[1] < 10) - player.hurtCooldowns[1] = 10; - } - - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); - - float x = target.Center.X + (float)Main.rand.Next(-400, 400); - float y = target.Center.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num15 = target.Center.X + (float)(target.width / 2) - vector.X; - float num16 = target.Center.Y + (float)(target.height / 2) - vector.Y; - num15 += (float)Main.rand.Next(-100, 101); - int num17 = 25; - float num18 = (float)Math.Sqrt((double)(num15 * num15 + num16 * num16)); - num18 = (float)num17 / num18; - num15 *= num18; - num16 *= num18; - if (player.whoAmI == Main.myPlayer) - { - Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), 15f, player.whoAmI, 0f, 0f); - } - } - } + } } diff --git a/Items/Weapons/Melee/GalileoGladius.cs b/Items/Weapons/Melee/GalileoGladius.cs index fbdac3cadb..910ce6c587 100644 --- a/Items/Weapons/Melee/GalileoGladius.cs +++ b/Items/Weapons/Melee/GalileoGladius.cs @@ -81,25 +81,14 @@ namespace CalamityMod.Items.Weapons.Melee } private void SpawnMeteor(Player player) - { - float x = player.Center.X + (float)Main.rand.Next(-400, 400); - float y = player.Center.Y - (float)Main.rand.Next(500, 800); - Vector2 startPos = new Vector2(x, y); - Vector2 velocity = player.Center - startPos; - velocity.X += (float)Main.rand.Next(-100, 101); - float speed = 25f; - float targetDist = velocity.Length(); - targetDist = speed / targetDist; - velocity.X *= targetDist; - velocity.Y *= targetDist; + { if (player.whoAmI == Main.myPlayer) { if (player.Calamity().galileoCooldown <= 0) - { - int damage = player.GetWeaponDamage(player.ActiveItem()) * 2; - int meteor = Projectile.NewProjectile(startPos, velocity, ModContent.ProjectileType(), damage, 15f, player.whoAmI); - Main.projectile[meteor].ai[1] = player.position.Y; - player.Calamity().galileoCooldown = 15; + { + int damage = player.GetWeaponDamage(player.ActiveItem()) * 2; + CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 25f, ModContent.ProjectileType(), damage, 15f, player.whoAmI); + player.Calamity().galileoCooldown = 15; } } } diff --git a/Items/Weapons/Melee/NeptunesBounty.cs b/Items/Weapons/Melee/NeptunesBounty.cs index 12435c830a..e195edaca8 100644 --- a/Items/Weapons/Melee/NeptunesBounty.cs +++ b/Items/Weapons/Melee/NeptunesBounty.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Items.Weapons.Melee { if (Main.rand.NextBool(3)) { - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 33); + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 33); } } diff --git a/Items/Weapons/Melee/Roxcalibur.cs b/Items/Weapons/Melee/Roxcalibur.cs index c238771905..a500f545bc 100644 --- a/Items/Weapons/Melee/Roxcalibur.cs +++ b/Items/Weapons/Melee/Roxcalibur.cs @@ -213,7 +213,7 @@ namespace CalamityMod.Items.Weapons.Melee //Spawns a projectile on the tip of the sword in the alt fire float positionx; float positiony = position.Y + (item.height / 2) + 23; - ; + int cooldown = 0; //Check if the entire cooldown has passed if (Roxcooldown >= 600) diff --git a/Items/Weapons/Melee/StellarStriker.cs b/Items/Weapons/Melee/StellarStriker.cs index e8fe5209d7..ecd72572cd 100644 --- a/Items/Weapons/Melee/StellarStriker.cs +++ b/Items/Weapons/Melee/StellarStriker.cs @@ -39,56 +39,17 @@ namespace CalamityMod.Items.Weapons.Melee { return; } - Main.PlaySound(SoundID.Item88, player.position); - int i = Main.myPlayer; - float num72 = item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (player.gravDir == -1f) - { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; - } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) - { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; - } - else - { - num80 = num72 / num80; - } - - int num112 = 2; - for (int num113 = 0; num113 < num112; num113++) - { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num113); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X + (float)Main.rand.Next(-40, 41) * 0.03f; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) - { - num79 *= -1f; - } - if (num79 < 20f) - { - num79 = 20f; - } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float num114 = num78; - float num115 = num79 + (float)Main.rand.Next(-80, 81) * 0.02f; - int proj = Projectile.NewProjectile(vector2.X, vector2.Y, num114, num115, ProjectileID.LunarFlare, (int)(item.damage * player.MeleeDamage() * 0.5), knockback, i, 0f, (float)Main.rand.Next(3)); - Main.projectile[proj].Calamity().forceMelee = true; - } + if (player.whoAmI == Main.myPlayer) + SpawnFlares(player, knockback); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) + { + if (player.whoAmI == Main.myPlayer) + SpawnFlares(player, item.knockBack); + } + + private void SpawnFlares(Player player, float knockBack) { Main.PlaySound(SoundID.Item88, player.position); int i = Main.myPlayer; @@ -115,7 +76,7 @@ namespace CalamityMod.Items.Weapons.Melee int num112 = 2; for (int num113 = 0; num113 < num112; num113++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + vector2 = new Vector2(player.Center.X + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); vector2.Y -= (float)(100 * num113); num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X + (float)Main.rand.Next(-40, 41) * 0.03f; @@ -134,7 +95,7 @@ namespace CalamityMod.Items.Weapons.Melee num79 *= num80; float num114 = num78; float num115 = num79 + (float)Main.rand.Next(-80, 81) * 0.02f; - int proj = Projectile.NewProjectile(vector2.X, vector2.Y, num114, num115, ProjectileID.LunarFlare, (int)(item.damage * player.MeleeDamage() * 0.5), item.knockBack, i, 0f, (float)Main.rand.Next(3)); + int proj = Projectile.NewProjectile(vector2.X, vector2.Y, num114, num115, ProjectileID.LunarFlare, (int)(item.damage * player.MeleeDamage() * 0.5), knockBack, i, 0f, (float)Main.rand.Next(3)); Main.projectile[proj].Calamity().forceMelee = true; } } diff --git a/Items/Weapons/Melee/TrueForbiddenOathblade.cs b/Items/Weapons/Melee/TrueForbiddenOathblade.cs index 47a0e58a32..301bc8de9b 100644 --- a/Items/Weapons/Melee/TrueForbiddenOathblade.cs +++ b/Items/Weapons/Melee/TrueForbiddenOathblade.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Melee for (int i = -index; i <= index; i += index) { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); - Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage / 2, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position, perturbedSpeed, type, damage / 2, knockBack, player.whoAmI, 0f, 0f); } return false; } @@ -52,7 +52,7 @@ namespace CalamityMod.Items.Weapons.Melee ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 3); - recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddIngredient(ModContent.ItemType(), 3); recipe.AddIngredient(ItemID.BrokenHeroSword); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); @@ -81,9 +81,8 @@ namespace CalamityMod.Items.Weapons.Melee float num52 = 2f; Vector2 value3 = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); Vector2 value4 = value3 * target.velocity.Length(); - Main.PlaySound(SoundID.Item14, target.position); - int num3; - for (int num53 = 0; num53 < 40; num53 = num3 + 1) + Main.PlaySound(SoundID.Item14, target.Center); + for (int num53 = 0; num53 < 40; num53++) { int num54 = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 200, default, num50); Dust dust = Main.dust[num54]; @@ -100,9 +99,8 @@ namespace CalamityMod.Items.Weapons.Melee dust.fadeIn = 1f; dust.color = Color.Crimson * 0.5f; dust.velocity += value4 * Main.rand.NextFloat(); - num3 = num53; } - for (int num55 = 0; num55 < 20; num55 = num3 + 1) + for (int num55 = 0; num55 < 20; num55++) { int num56 = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 0, default, num52); Dust dust = Main.dust[num56]; @@ -111,7 +109,6 @@ namespace CalamityMod.Items.Weapons.Melee dust.velocity.Y -= 1.5f; dust.velocity *= 0.5f; dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - num3 = num55; } } } diff --git a/Items/Weapons/Ranged/Drataliornus.cs b/Items/Weapons/Ranged/Drataliornus.cs index b6f437caf7..885b7d96e6 100644 --- a/Items/Weapons/Ranged/Drataliornus.cs +++ b/Items/Weapons/Ranged/Drataliornus.cs @@ -28,9 +28,9 @@ Right click to fire two devastating barrages of five empowered fireballs. item.knockBack = 1f; item.shootSpeed = 18f; item.useStyle = ItemUseStyleID.HoldingOut; - item.useAnimation = 10; - item.useTime = 10; - item.reuseDelay = 0; + item.useAnimation = 24; + item.useTime = 12; + item.reuseDelay = 48; item.width = 64; item.height = 84; item.UseSound = SoundID.Item5; @@ -56,16 +56,10 @@ Right click to fire two devastating barrages of five empowered fireballs. { if (player.altFunctionUse == 2) { - item.useAnimation = 24; - item.useTime = 12; - item.reuseDelay = 48; item.noUseGraphic = false; } else { - item.useAnimation = 9; - item.useTime = 9; - item.reuseDelay = 0; item.noUseGraphic = true; if (player.ownedProjectileCounts[item.shoot] > 0) { @@ -88,7 +82,7 @@ Right click to fire two devastating barrages of five empowered fireballs. { float num8 = index1 - (num4 - 1) / 2; Vector2 vector2_5 = spinningpoint.RotatedBy(num3 * num8, new Vector2()); - Projectile.NewProjectile(position.X + vector2_5.X, position.Y + vector2_5.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 1f, 0f); + Projectile.NewProjectile(position.X + vector2_5.X, position.Y + vector2_5.Y, speedX, speedY, ModContent.ProjectileType(), (int)(damage * 0.69), knockBack, player.whoAmI, 1f, 0f); } } else diff --git a/Items/Weapons/Ranged/FirestormCannon.cs b/Items/Weapons/Ranged/FirestormCannon.cs index a70fae6475..858549f145 100644 --- a/Items/Weapons/Ranged/FirestormCannon.cs +++ b/Items/Weapons/Ranged/FirestormCannon.cs @@ -54,19 +54,16 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool CanUseItem(Player player) { - if (player.altFunctionUse == 2) - { - item.useTime = 27; - item.useAnimation = 27; - } - else - { - item.useTime = 9; - item.useAnimation = 9; - } return base.CanUseItem(player); } + public override float UseTimeMultiplier (Player player) + { + if (player.altFunctionUse == 2) + return 0.3333f; + return 1f; + } + 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 (player.altFunctionUse == 2) diff --git a/Items/Weapons/Ranged/Galeforce.cs b/Items/Weapons/Ranged/Galeforce.cs index f6524c3c2e..8036a8c90f 100644 --- a/Items/Weapons/Ranged/Galeforce.cs +++ b/Items/Weapons/Ranged/Galeforce.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 18; + item.damage = 16; item.ranged = true; item.width = 32; item.height = 52; @@ -30,9 +30,9 @@ namespace CalamityMod.Items.Weapons.Ranged item.rare = 3; item.UseSound = SoundID.Item5; item.autoReuse = true; - item.shoot = ProjectileID.PurificationPowder; + item.shoot = ProjectileID.WoodenArrowFriendly; item.shootSpeed = 20f; - item.useAmmo = 40; + item.useAmmo = AmmoID.Arrow; } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) diff --git a/Items/Weapons/Ranged/HalleysInferno.cs b/Items/Weapons/Ranged/HalleysInferno.cs index f313f0ea94..d30aae8053 100644 --- a/Items/Weapons/Ranged/HalleysInferno.cs +++ b/Items/Weapons/Ranged/HalleysInferno.cs @@ -8,53 +8,53 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class HalleysInferno : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Halley's Inferno"); - Tooltip.SetDefault("Halley came sooner than expected\n" + - "Fires a flaming comet\n" + - "50% chance to not consume gel\n" + - "Right click to zoom out"); - } + public class HalleysInferno : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Halley's Inferno"); + Tooltip.SetDefault("Halley came sooner than expected\n" + + "Fires a flaming comet\n" + + "50% chance to not consume gel\n" + + "Right click to zoom out"); + } - public override void SetDefaults() - { - item.damage = 1666; - item.crit += 20; - item.ranged = true; - item.width = 84; - item.height = 34; - item.useTime = 30; - item.useAnimation = 30; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.knockBack = 5f; - item.UseSound = SoundID.Item34; - item.value = Item.buyPrice(1, 40, 0, 0); - item.rare = 10; - item.Calamity().customRarity = CalamityRarity.PureGreen; - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 14.6f; - item.useAmmo = 23; - } + public override void SetDefaults() + { + item.damage = 1666; + item.crit += 20; + item.knockBack = 5f; + item.ranged = true; + item.useTime = item.useAnimation = 30; + item.autoReuse = true; + item.useAmmo = AmmoID.Gel; + item.shootSpeed = 14.6f; + item.shoot = ModContent.ProjectileType(); - public override Vector2? HoldoutOffset() => new Vector2(-15, 0); + item.width = 84; + item.height = 34; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.UseSound = SoundID.Item34; + item.value = Item.buyPrice(1, 40, 0, 0); + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.PureGreen; + } - public override bool ConsumeAmmo(Player player) => Main.rand.Next(100) >= 50; + public override Vector2? HoldoutOffset() => new Vector2(-15, 0); - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 6); - recipe.AddIngredient(ModContent.ItemType(), 4); - recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddIngredient(ItemID.SniperScope); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override bool ConsumeAmmo(Player player) => Main.rand.Next(100) >= 50; + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 6); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddIngredient(ItemID.SniperScope); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Ranged/HeavenlyGale.cs b/Items/Weapons/Ranged/HeavenlyGale.cs index e9f0bb684b..9cd820a391 100644 --- a/Items/Weapons/Ranged/HeavenlyGale.cs +++ b/Items/Weapons/Ranged/HeavenlyGale.cs @@ -5,109 +5,105 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Ranged { - public class HeavenlyGale : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Heavenly Gale"); - Tooltip.SetDefault("Fires a barrage of 5 random exo arrows\n" + - "Green exo arrows explode into a tornado on death\n" + - "Blue exo arrows cause a second group of arrows to fire on enemy hits\n" + - "Orange exo arrows cause explosions on death\n" + - "Teal exo arrows ignore enemy immunity frames\n" + - "66% chance to not consume ammo"); - } + public class HeavenlyGale : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Heavenly Gale"); + Tooltip.SetDefault("Fires a barrage of 5 random exo arrows\n" + + "Green exo arrows explode into a tornado on death\n" + + "Blue exo arrows cause a second group of arrows to fire on enemy hits\n" + + "Orange exo arrows cause explosions on death\n" + + "Teal exo arrows ignore enemy immunity frames\n" + + "66% chance to not consume ammo"); + } - public override void SetDefaults() - { - item.damage = 720; - item.ranged = true; - item.width = 44; - item.height = 58; - item.useTime = 11; - item.useAnimation = 22; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.knockBack = 4f; - item.value = Item.buyPrice(2, 50, 0, 0); - item.rare = 10; - item.UseSound = SoundID.Item5; - item.autoReuse = true; - item.shoot = ProjectileID.WoodenArrowFriendly; - item.shootSpeed = 17f; - item.useAmmo = 40; - item.Calamity().customRarity = CalamityRarity.Violet; - } + public override void SetDefaults() + { + item.damage = 600; + item.ranged = true; + item.width = 44; + item.height = 58; + item.useTime = 11; + item.useAnimation = 22; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.knockBack = 4f; + item.value = Item.buyPrice(2, 50, 0, 0); + item.rare = 10; + item.UseSound = SoundID.Item5; + item.autoReuse = true; + item.shoot = ProjectileID.WoodenArrowFriendly; + item.shootSpeed = 17f; + item.useAmmo = AmmoID.Arrow; + item.Calamity().customRarity = CalamityRarity.Violet; + } - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float dmg = 1f; - float num117 = 0.314159274f; - int num118 = 5; - Vector2 vector7 = new Vector2(speedX, speedY); - vector7.Normalize(); - vector7 *= 40f; - bool flag11 = Collision.CanHit(vector2, 0, 0, vector2 + vector7, 0, 0); - for (int num119 = 0; num119 < num118; num119++) - { - float num120 = (float)num119 - ((float)num118 - 1f) / 2f; - Vector2 value9 = vector7.RotatedBy((double)(num117 * num120), default); - if (!flag11) - { - value9 -= vector7; - } - switch (Main.rand.Next(10)) - { - case 0: - case 1: - case 2: - case 3: - type = ModContent.ProjectileType(); - dmg = 0.16f; - break; - case 4: - case 5: - case 6: - type = ModContent.ProjectileType(); - break; - case 7: - case 8: - type = ModContent.ProjectileType(); - break; - case 9: - type = ModContent.ProjectileType(); - dmg = 0.7f; - break; - } - Projectile.NewProjectile(vector2.X + value9.X, vector2.Y + value9.Y, speedX, speedY, type, (int)(damage * dmg), knockBack, player.whoAmI, 0.0f, 0.0f); - } - return false; - } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Vector2 source = player.RotatedRelativePoint(player.MountedCenter, true); + float dmgMult = 1f; + float piOver10 = MathHelper.Pi * 0.1f; + int arrowAmt = 5; + Vector2 speed = new Vector2(speedX, speedY); + speed.Normalize(); + speed *= 40f; + bool canHit = Collision.CanHit(source, 0, 0, source + speed, 0, 0); + for (int i = 0; i < arrowAmt; i++) + { + float offsetAmt = i - (arrowAmt - 1f) / 2f; + Vector2 offset = speed.RotatedBy((double)(piOver10 * offsetAmt), default); + if (!canHit) + { + offset -= speed; + } + int arrow = Utils.SelectRandom(Main.rand, new int[] + { + ProjectileType(), + ProjectileType(), + ProjectileType(), + ProjectileType() + }); + if (player.ownedProjectileCounts[ProjectileType()] + player.ownedProjectileCounts[ProjectileType()] > 5) + { + arrow = Utils.SelectRandom(Main.rand, new int[] + { + ProjectileType(), + ProjectileType(), + ProjectileType() + }); + } + if (arrow == ProjectileType()) + dmgMult = 0.5f; + Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, arrow, (int)(damage * dmgMult), knockBack, player.whoAmI); + } + return false; + } - public override bool ConsumeAmmo(Player player) - { - if (Main.rand.Next(0, 100) < 66) - return false; - return true; - } + public override bool ConsumeAmmo(Player player) + { + if (Main.rand.Next(0, 100) < 66) + return false; + return true; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 4); - recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType()); + recipe.AddIngredient(ItemType(), 4); + recipe.AddTile(TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Ranged/Pumpler.cs b/Items/Weapons/Ranged/Pumpler.cs index 1ef6a68d5a..021cd8b2a9 100644 --- a/Items/Weapons/Ranged/Pumpler.cs +++ b/Items/Weapons/Ranged/Pumpler.cs @@ -48,19 +48,22 @@ namespace CalamityMod.Items.Weapons.Ranged { if (player.altFunctionUse == 2) { - item.useTime = 36; - item.useAnimation = 36; item.shootSpeed = 4f; } else { - item.useTime = 10; - item.useAnimation = 10; item.shootSpeed = 11f; } return base.CanUseItem(player); } + public override float UseTimeMultiplier (Player player) + { + if (player.altFunctionUse == 2) + return (5f/18f); + return 1f; + } + 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 (player.altFunctionUse == 2) diff --git a/Items/Weapons/Ranged/SparkSpreader.cs b/Items/Weapons/Ranged/SparkSpreader.cs index 5b9e319afc..449eae6502 100644 --- a/Items/Weapons/Ranged/SparkSpreader.cs +++ b/Items/Weapons/Ranged/SparkSpreader.cs @@ -6,55 +6,48 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class SparkSpreader : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Spark Spreader"); - Tooltip.SetDefault("20% chance to not consume gel"); - } + public class SparkSpreader : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Spark Spreader"); + Tooltip.SetDefault("20% chance to not consume gel"); + } - public override void SetDefaults() - { - item.damage = 7; - item.ranged = true; - item.width = 52; - item.height = 20; - item.useTime = 10; - item.useAnimation = 30; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.knockBack = 1f; - item.UseSound = SoundID.Item34; - item.value = Item.buyPrice(0, 1, 0, 0); - item.rare = 1; - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 5f; - item.useAmmo = 23; - } + public override void SetDefaults() + { + item.damage = 7; + item.knockBack = 1f; + item.ranged = true; + item.autoReuse = true; + item.useTime = 10; + item.useAnimation = 30; + item.useAmmo = AmmoID.Gel; + item.shootSpeed = 5f; + item.shoot = ModContent.ProjectileType(); - public override Vector2? HoldoutOffset() - { - return new Vector2(-4, 0); - } + item.width = 52; + item.height = 20; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.UseSound = SoundID.Item34; + item.value = Item.buyPrice(0, 1, 0, 0); + item.rare = 1; + } - public override bool ConsumeAmmo(Player player) - { - if (Main.rand.Next(0, 100) < 20) - return false; - return true; - } + public override Vector2? HoldoutOffset() => new Vector2(-4, 0); - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.FlareGun, 1); - recipe.AddIngredient(ItemID.Ruby, 1); - recipe.AddIngredient(ItemID.Gel, 12); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override bool ConsumeAmmo(Player player) => Main.rand.Next(100) >= 20; + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.FlareGun); + recipe.AddIngredient(ItemID.Ruby); + recipe.AddIngredient(ItemID.Gel, 12); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Rogue/BloodsoakedCrasher.cs b/Items/Weapons/Rogue/BloodsoakedCrasher.cs index fc756358c2..55c542f890 100644 --- a/Items/Weapons/Rogue/BloodsoakedCrasher.cs +++ b/Items/Weapons/Rogue/BloodsoakedCrasher.cs @@ -7,56 +7,52 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class BloodsoakedCrasher : RogueWeapon //This weapon has been coded by Achilles|Termi|Ben + public class BloodsoakedCrasher : RogueWeapon //This weapon has been coded by Ben || Termi { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bloodsoaked Crasher"); - Tooltip.SetDefault("Slows down when hitting an enemy. Speeds up otherwise\n" + - "Heals on enemy hits\n" + - "Stealth strikes spawn homing blood on enemy hits"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bloodsoaked Crasher"); + Tooltip.SetDefault("Slows down when hitting an enemy. Speeds up otherwise\n" + + "Heals on enemy hits\n" + + "Stealth strikes spawn homing blood on enemy hits"); + } - public override void SafeSetDefaults() - { - item.width = 66; - item.damage = 300; - item.noMelee = true; - item.noUseGraphic = true; - item.useAnimation = 18; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 18; - item.knockBack = 3f; - item.UseSound = SoundID.Item1; - item.autoReuse = true; - item.height = 64; - item.value = Item.buyPrice(1, 40, 0, 0); - item.rare = 10; - item.Calamity().customRarity = CalamityRarity.PureGreen; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 15f; - item.Calamity().rogue = true; - } + public override void SafeSetDefaults() + { + item.damage = 300; + item.knockBack = 3f; + item.autoReuse = true; + item.Calamity().rogue = true; + item.useAnimation = item.useTime = 18; + item.shootSpeed = 15f; + item.shoot = ModContent.ProjectileType(); - 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 (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike - { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[stealth].Calamity().stealthStrike = true; - return false; - } - return true; - } + item.width = 66; + item.height = 64; + item.noMelee = true; + item.noUseGraphic = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; + item.value = Item.buyPrice(1, 40, 0, 0); + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.PureGreen; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); //post-Prov rogue weapon - recipe.AddIngredient(ModContent.ItemType(), 1); - recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); //setting the stealth strike + return false; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); //post-Prov rogue weapon + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Rogue/Celestus.cs b/Items/Weapons/Rogue/Celestus.cs index 75c4160d02..4db6dd2104 100644 --- a/Items/Weapons/Rogue/Celestus.cs +++ b/Items/Weapons/Rogue/Celestus.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Items.Weapons.Rogue public class Celestus : RogueWeapon { private int counter = 0; + private bool stealthScythes = false; public override void SetStaticDefaults() { @@ -42,21 +43,26 @@ namespace CalamityMod.Items.Weapons.Rogue public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - counter++; - if (counter >= 3) - counter = 0; - if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage / 2, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[stealth].Calamity().stealthStrike = true; - return false; - } - else if (counter == 1 || counter == 2) - { - return false; + stealthScythes = true; } - return true; + if (stealthScythes) + { + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage / 2, knockBack, player.whoAmI, 0f, 0f); + Main.projectile[stealth].Calamity().stealthStrike = true; + } + else if (counter == 0) + { + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); + } + counter++; + if (counter >= 3) + { + stealthScythes = false; + counter = 0; + } + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Rogue/EclipsesFall.cs b/Items/Weapons/Rogue/EclipsesFall.cs index 50ab8f9f39..8afad26224 100644 --- a/Items/Weapons/Rogue/EclipsesFall.cs +++ b/Items/Weapons/Rogue/EclipsesFall.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Rogue; +using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -7,60 +8,56 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class EclipsesFall : RogueWeapon - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Eclipse's Fall"); - Tooltip.SetDefault("When the sun goes dark, you will know judgment\n" + - "Summons spears from the sky on hit\n" + - "Stealth strikes impale enemies and summon a constant barrage of spears over time"); - } + public class EclipsesFall : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Eclipse's Fall"); + Tooltip.SetDefault("When the sun goes dark, you will know judgment\n" + + "Summons spears from the sky on hit\n" + + "Stealth strikes impale enemies and summon a constant barrage of spears over time"); + } - public override void SafeSetDefaults() - { - item.width = 72; - item.damage = 1060; - item.noMelee = true; - item.noUseGraphic = true; - item.useAnimation = 21; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 21; - item.knockBack = 3.5f; - item.UseSound = SoundID.Item1; - item.autoReuse = true; - item.height = 72; - item.value = Item.buyPrice(2, 50, 0, 0); - item.rare = 10; - item.Calamity().customRarity = CalamityRarity.Violet; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 15f; - item.Calamity().rogue = true; - } + public override void SafeSetDefaults() + { + item.damage = 1060; + item.knockBack = 3.5f; + item.useAnimation = item.useTime = 21; + item.autoReuse = true; + item.Calamity().rogue = true; + item.shootSpeed = 15f; + item.shoot = ModContent.ProjectileType(); - 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 (player.Calamity().StealthStrikeAvailable()) - { - int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[p].Calamity().stealthStrike = true; - } - else - { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - } - return false; - } + item.useStyle = ItemUseStyleID.SwingThrow; + item.width = item.height = 72; + item.noMelee = true; + item.noUseGraphic = true; + item.UseSound = SoundID.Item1; + item.value = Item.buyPrice(2, 50, 0, 0); + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.Violet; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 1); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ModContent.ItemType(), 6); - recipe.AddTile(TileID.LunarCraftingStation); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + 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 (player.Calamity().StealthStrikeAvailable()) + { + type = ModContent.ProjectileType(); + } + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + return false; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ModContent.ItemType(), 6); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Rogue/Hypothermia.cs b/Items/Weapons/Rogue/Hypothermia.cs index 889e1246ea..75a1075f72 100644 --- a/Items/Weapons/Rogue/Hypothermia.cs +++ b/Items/Weapons/Rogue/Hypothermia.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Rogue public class Hypothermia : RogueWeapon { private int counter = 0; - private bool justStealthStriked = false; + private bool stealthChunks = false; public override void SetStaticDefaults() { @@ -46,38 +46,31 @@ namespace CalamityMod.Items.Weapons.Rogue public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - counter++; - if (counter >= 7) - counter = 0; - - if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike + if (player.Calamity().StealthStrikeAvailable()) //setting up the stealth strikes + { + stealthChunks = true; + } + if (stealthChunks) { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); Main.projectile[stealth].Calamity().stealthStrike = true; - justStealthStriked = true; - return false; } - if (justStealthStriked == true) //this is Ben, no I don't know how what I did translates to what happened in game but we're rolling with it - { - if (counter == 1 || counter == 2 || counter == 3 || counter == 4 || counter == 5 || counter == 6) - { - if (counter == 6) - { - justStealthStriked = false; - } - return false; - } - } else { - int num6 = Main.rand.Next(1, 3); - for (int index = 0; index < num6; ++index) + int projAmt = Main.rand.Next(1, 3); + for (int index = 0; index < projAmt; ++index) { float SpeedX = speedX + (float)Main.rand.Next(-40, 41) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-40, 41) * 0.05f; - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0.0f, 0.0f); + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, Main.rand.Next(4), 0f); } - } + } + counter++; + if (counter >= 7) + { + counter = 0; + stealthChunks = false; + } return false; } diff --git a/Items/Weapons/Rogue/Prismalline.cs b/Items/Weapons/Rogue/Prismalline.cs index bb0c0bbc19..81ff9d8208 100644 --- a/Items/Weapons/Rogue/Prismalline.cs +++ b/Items/Weapons/Rogue/Prismalline.cs @@ -24,9 +24,9 @@ namespace CalamityMod.Items.Weapons.Rogue item.crit += 4; item.noMelee = true; item.noUseGraphic = true; - item.useAnimation = 14; + item.useAnimation = 16; item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 14; + item.useTime = 16; item.knockBack = 5f; item.UseSound = SoundID.Item1; item.autoReuse = true; diff --git a/Items/Weapons/Rogue/RogueWeapon.cs b/Items/Weapons/Rogue/RogueWeapon.cs index 2b3318cd0d..c2fffcc0a7 100644 --- a/Items/Weapons/Rogue/RogueWeapon.cs +++ b/Items/Weapons/Rogue/RogueWeapon.cs @@ -93,7 +93,7 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().gloveOfRecklessness) rogueAS += 0.2f; if (player.Calamity().titanHeartMantle) - rogueAS -= 0.2f; + rogueAS -= 0.15f; return rogueAS; } diff --git a/Items/Weapons/Rogue/StarofDestruction.cs b/Items/Weapons/Rogue/StarofDestruction.cs index 7187589b87..fb30175d44 100644 --- a/Items/Weapons/Rogue/StarofDestruction.cs +++ b/Items/Weapons/Rogue/StarofDestruction.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { item.width = item.height = 94; - item.damage = 175; + item.damage = 150; item.noMelee = true; item.noUseGraphic = true; item.useAnimation = 38; diff --git a/Items/Weapons/Rogue/StellarKnife.cs b/Items/Weapons/Rogue/StellarKnife.cs index 1dce4dda87..ca67e08474 100644 --- a/Items/Weapons/Rogue/StellarKnife.cs +++ b/Items/Weapons/Rogue/StellarKnife.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Rogue { speedX *= 0.9f; Vector2 perturbedspeed = new Vector2(speedX, speedY + Main.rand.Next(-3, 4)).RotatedBy(MathHelper.ToRadians(spread)); - Projectile.NewProjectile(position, perturbedspeed, type, damage, knockBack, player.whoAmI, 1f, i %5 == 0 ? 1f : 0f); + Projectile.NewProjectile(position, perturbedspeed, type, damage, knockBack, player.whoAmI, 1f, i % 5 == 0 ? 1f : 0f); spread -= Main.rand.Next(1, 3); } return false; diff --git a/Items/Weapons/Rogue/ToxicantTwister.cs b/Items/Weapons/Rogue/ToxicantTwister.cs index 2f3309268c..2c79249716 100644 --- a/Items/Weapons/Rogue/ToxicantTwister.cs +++ b/Items/Weapons/Rogue/ToxicantTwister.cs @@ -8,18 +8,19 @@ namespace CalamityMod.Items.Weapons.Rogue { public class ToxicantTwister : RogueWeapon { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Toxicant Twister"); - Tooltip.SetDefault("Throws a speedy, homing boomerang\n" + - "Stealth strikes fire two boomerangs that go much faster and release sand rapidly"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Toxicant Twister"); + Tooltip.SetDefault("Throws a slow moving boomerang\n" + + "After a few moments, the boomerang chooses a target and rapidly homes in\n" + + "Stealth strikes fire three boomerangs that home in faster and rapidly release sand"); + } public override void SafeSetDefaults() { item.width = 42; item.height = 46; - item.damage = 650; + item.damage = 750; item.noMelee = true; item.noUseGraphic = true; item.useAnimation = item.useTime = 20; @@ -39,21 +40,13 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - float SpeedX = speedX + (float)Main.rand.Next(-20, 21) * 0.05f; - float SpeedY = speedY + (float)Main.rand.Next(-20, 21) * 0.05f; - int stealth = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].velocity *= 1.5f; - Main.projectile[stealth].timeLeft = 420; - Main.projectile[stealth].penetrate = -1; - Main.projectile[stealth].localNPCHitCooldown = 6; - - float SpeedX2 = speedX + (float)Main.rand.Next(-20, 21) * 0.05f; - float SpeedY2 = speedY + (float)Main.rand.Next(-20, 21) * 0.05f; - int stealth2 = Projectile.NewProjectile(position.X, position.Y, SpeedX2, SpeedY2, type, (int)(damage * 0.6f), knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth2].Calamity().stealthStrike = true; - Main.projectile[stealth2].penetrate += 2; - Main.projectile[stealth2].localNPCHitCooldown = 8; + for (int i = 0; i < 3; i++) + { + float SpeedX = speedX + (float)Main.rand.Next(-20, 21) * 0.05f; + float SpeedY = speedY + (float)Main.rand.Next(-20, 21) * 0.05f; + int stealth = Projectile.NewProjectile(position, new Vector2(SpeedX, SpeedY), type, damage, knockBack, player.whoAmI); + Main.projectile[stealth].Calamity().stealthStrike = true; + } } else { diff --git a/Items/Weapons/Rogue/UtensilPoker.cs b/Items/Weapons/Rogue/UtensilPoker.cs index 700cb0d61e..8b3b8241ab 100644 --- a/Items/Weapons/Rogue/UtensilPoker.cs +++ b/Items/Weapons/Rogue/UtensilPoker.cs @@ -8,13 +8,14 @@ namespace CalamityMod.Items.Weapons.Rogue { public class UtensilPoker : RogueWeapon { + private int counter = 0; public override void SetStaticDefaults() { DisplayName.SetDefault("Utensil Poker"); - Tooltip.SetDefault("Fires random utensils in bursts of three\n" + + Tooltip.SetDefault("Space chickens, that is all.\n" + + "Fires random utensils in bursts of three\n" + "Grants Well Fed on enemy hits\n" + - "Stealth strikes launch an additional butcher knife\n" + - "'Space chickens, that is all.'"); + "Stealth strikes launch an additional butcher knife"); } public override void SafeSetDefaults() @@ -41,9 +42,9 @@ namespace CalamityMod.Items.Weapons.Rogue 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 (player.Calamity().StealthStrikeAvailable()) + if (player.Calamity().StealthStrikeAvailable() && counter == 0) { - int stealth = Projectile.NewProjectile(position.X, position.Y, speedX * 1.2f, speedY * 1.2f, ModContent.ProjectileType(), (int)(damage * 1.4), knockBack, Main.myPlayer); + int stealth = Projectile.NewProjectile(position.X, position.Y, speedX * 1.2f, speedY * 1.2f, ModContent.ProjectileType(), (int)(damage * 1.4), knockBack, player.whoAmI); Main.projectile[stealth].Calamity().stealthStrike = true; } int utensil = item.shoot; @@ -69,7 +70,11 @@ namespace CalamityMod.Items.Weapons.Rogue default: break; } - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, utensil, (int)(damage * dmgMult), knockBack * kbMult, Main.myPlayer); + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, utensil, (int)(damage * dmgMult), knockBack * kbMult, player.whoAmI); + + counter++; + if (counter >= 3) + counter = 0; return false; } } diff --git a/Items/Weapons/Rogue/XerocPitchfork.cs b/Items/Weapons/Rogue/XerocPitchfork.cs index a395ed989f..86bd16da89 100644 --- a/Items/Weapons/Rogue/XerocPitchfork.cs +++ b/Items/Weapons/Rogue/XerocPitchfork.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Rogue { public override void SetStaticDefaults() { - DisplayName.SetDefault("Xeroc Pitchfork"); + DisplayName.SetDefault("Shard of Antumbra"); Tooltip.SetDefault("Stealth strikes leave homing stars in their wake"); } @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.maxStack = 999; item.value = 10000; item.rare = 9; - item.shoot = ModContent.ProjectileType(); + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 16f; item.Calamity().rogue = true; } @@ -41,11 +41,10 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); Main.projectile[stealth].Calamity().stealthStrike = true; - return false; } - return true; + return !player.Calamity().StealthStrikeAvailable(); } public override void AddRecipes() diff --git a/Items/Weapons/Summon/BensUmbrella.cs b/Items/Weapons/Summon/BensUmbrella.cs index d53d17fc6e..dd6ca111be 100644 --- a/Items/Weapons/Summon/BensUmbrella.cs +++ b/Items/Weapons/Summon/BensUmbrella.cs @@ -9,66 +9,65 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { public class BensUmbrella : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Temporal Umbrella"); - Tooltip.SetDefault("Surprisingly sturdy, I reckon this could defeat the Mafia in a single blow\n" + + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Temporal Umbrella"); + Tooltip.SetDefault("Surprisingly sturdy, I reckon this could defeat the Mafia in a single blow\n" + "Summons a magic hat to hover above your head\n" + - "The hat will release a variety of objects to assault your foes\n" + - "Requires 5 minion slots to use\n" + - "There can only be one"); - } + "The hat will release a variety of objects to assault your foes\n" + + "Requires 5 minion slots to use\n" + + "There can only be one"); + } - public override void SetDefaults() - { - item.mana = 99; - item.damage = 963; - item.useStyle = ItemUseStyleID.SwingThrow; - item.width = 74; - item.height = 72; - item.useTime = item.useAnimation = 10; - item.noMelee = true; - item.knockBack = 1f; - item.value = Item.buyPrice(5, 0, 0, 0); - item.Calamity().customRarity = CalamityRarity.ItemSpecific; - item.rare = 10; - item.UseSound = SoundID.Item68; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 10f; - item.summon = true; - } + public override void SetDefaults() + { + item.damage = 963; + item.knockBack = 1f; + item.mana = 99; + item.useTime = item.useAnimation = 10; + item.summon = true; + item.shootSpeed = 0f; + item.shoot = ModContent.ProjectileType(); - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && player.maxMinions >= 5; + item.useStyle = ItemUseStyleID.SwingThrow; + item.width = 74; + item.height = 72; + item.noMelee = true; + item.UseSound = SoundID.Item68; + item.value = Item.buyPrice(5, 0, 0, 0); + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.ItemSpecific; + } - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - position = Main.MouseWorld; - speedX = 0; - speedY = 0; - for (int x = 0; x < Main.projectile.Length; x++) - { - Projectile projectile = Main.projectile[x]; - if (projectile.active && projectile.owner == player.whoAmI && projectile.type == type) - { - projectile.Kill(); - } - } - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - return false; - } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && player.maxMinions >= 5; - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ItemID.Umbrella); - recipe.AddIngredient(ItemID.TopHat); + 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 x = 0; x < Main.maxProjectiles; x++) + { + Projectile proj = Main.projectile[x]; + if (proj.active && proj.owner == player.whoAmI && proj.type == type) + { + proj.Kill(); + break; + } + } + Projectile.NewProjectile(position, Vector2.Zero, type, damage, knockBack, player.whoAmI); + return false; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.Umbrella); + recipe.AddIngredient(ItemID.TopHat); recipe.AddIngredient(ModContent.ItemType(), 4); recipe.AddTile(ModContent.TileType()); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Summon/ColdDivinity.cs b/Items/Weapons/Summon/ColdDivinity.cs index 9252d4b813..629807bda4 100644 --- a/Items/Weapons/Summon/ColdDivinity.cs +++ b/Items/Weapons/Summon/ColdDivinity.cs @@ -1,6 +1,8 @@ using CalamityMod.Buffs.Summon; using CalamityMod.Projectiles.Summon; +using CalamityMod.World; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,11 +15,12 @@ namespace CalamityMod.Items.Weapons.Summon { DisplayName.SetDefault("Cold Divinity"); Tooltip.SetDefault("Legendary Drop\n" + - "Summons the power of the ancient ice castle\n" + + "Summons the power of the ancient ice castle\n" + "For each minion slot used, you will gain an additional orbiting shield spike\n" + "These spikes accelerate rapidly towards a nearby enemy to inflict heavy damage\n" + "They take some time to regenerate after launching themselves at the target, however\n" + "On right click, summons a duplicate ring around the targeted enemy, which slowly converges before exploding\n" + + "Minion damage bonuses apply to this weapon twice for more damage\n" + "Revengeance Drop"); Item.staff[item.type] = true; } @@ -41,9 +44,30 @@ namespace CalamityMod.Items.Weapons.Summon item.shootSpeed = 10f; item.summon = true; } + + public override void ModifyTooltips(List list) + { + if (CalamityWorld.death) + { + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip7") + { + line2.text = "Provides heat and cold protection in Death Mode when in use\n" + + "Revengeance Drop"; + } + } + } + } + + public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) + { + mult += player.MinionDamage() - 1f; + } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - damage = (int)(damage * player.MinionDamage()); + //damage = (int)(damage * player.MinionDamage()); float totalMinionSlots = 0f; for (int i = 0; i < Main.projectile.Length; i++) { diff --git a/Items/Weapons/Summon/DeepseaStaff.cs b/Items/Weapons/Summon/DeepseaStaff.cs index 5b0e65337e..4e341143a6 100644 --- a/Items/Weapons/Summon/DeepseaStaff.cs +++ b/Items/Weapons/Summon/DeepseaStaff.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - item.damage = 48; + item.damage = 42; item.mana = 10; item.width = 46; item.height = 46; diff --git a/Items/Weapons/Summon/MidnightSunBeacon.cs b/Items/Weapons/Summon/MidnightSunBeacon.cs index 18e914fde0..bd4d3be5a7 100644 --- a/Items/Weapons/Summon/MidnightSunBeacon.cs +++ b/Items/Weapons/Summon/MidnightSunBeacon.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - item.damage = 200; + item.damage = 240; item.mana = 12; item.width = item.height = 32; item.useTime = item.useAnimation = 10; diff --git a/Items/Weapons/Summon/PlantationStaff.cs b/Items/Weapons/Summon/PlantationStaff.cs index 50228da310..a844859e51 100644 --- a/Items/Weapons/Summon/PlantationStaff.cs +++ b/Items/Weapons/Summon/PlantationStaff.cs @@ -14,15 +14,14 @@ namespace CalamityMod.Items.Weapons.Summon { DisplayName.SetDefault("Plantation Staff"); Tooltip.SetDefault("Summons a miniature plantera to protect you\n" + - "Fires seeds and spiky balls from afar to poison targets\n" + - "Enrages when you get under 50% health and begins ramming enemies\n" + - "While enraged, it will additionally start firing spore clouds\n" + - "Occupies 2 minion slots and there can only be one"); + "Fires seeds, spiky balls, and spore clouds from afar to poison targets\n" + + "Enrages when you get under 75% health and begins ramming enemies\n" + + "Occupies 3 minion slots and there can only be one"); } public override void SetDefaults() { - item.damage = 70; + item.damage = 55; item.mana = 10; item.width = 66; item.height = 70; @@ -38,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Summon item.summon = true; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && player.maxMinions >= 2; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && player.maxMinions >= 3; public override void AddRecipes() { diff --git a/Items/Weapons/Summon/SarosPossession.cs b/Items/Weapons/Summon/SarosPossession.cs index e1e49715f2..afa9e2884b 100644 --- a/Items/Weapons/Summon/SarosPossession.cs +++ b/Items/Weapons/Summon/SarosPossession.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Summon item.summon = true; item.mana = 100; - item.damage = 640; + item.damage = 426; item.knockBack = 4f; item.useTime = item.useAnimation = 10; item.shoot = ModContent.ProjectileType(); @@ -47,10 +47,10 @@ namespace CalamityMod.Items.Weapons.Summon double minionCount = 0; for (int j = 0; j < Main.projectile.Length; j++) { - Projectile projectile = Main.projectile[j]; - if (projectile.active && projectile.owner == player.whoAmI && projectile.minion && projectile.type != ModContent.ProjectileType() && projectile.type != ModContent.ProjectileType()) + Projectile proj = Main.projectile[j]; + if (proj.active && proj.owner == player.whoAmI && proj.minion && proj.type != item.shoot) { - minionCount += projectile.minionSlots; + minionCount += proj.minionSlots; } } radianceSlots = (int)(player.maxMinions - minionCount); @@ -65,16 +65,14 @@ namespace CalamityMod.Items.Weapons.Summon { for (int x = 0; x < Main.projectile.Length; x++) { - Projectile projectile = Main.projectile[x]; - if (projectile.active && projectile.owner == player.whoAmI && projectile.type == ModContent.ProjectileType() && projectile.type != ModContent.ProjectileType()) + Projectile proj = Main.projectile[x]; + if (proj.active && proj.owner == player.whoAmI && proj.type == type) { - projectile.Kill(); + proj.Kill(); + break; } } - position = Main.MouseWorld; - speedX = 0; - speedY = 0; - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, radianceSlots); + Projectile.NewProjectile(position, Vector2.Zero, type, damage, knockBack, player.whoAmI, radianceSlots); return false; } diff --git a/Items/Weapons/Summon/Sirius.cs b/Items/Weapons/Summon/Sirius.cs index 37e60e7d4b..23f78749e8 100644 --- a/Items/Weapons/Summon/Sirius.cs +++ b/Items/Weapons/Summon/Sirius.cs @@ -46,13 +46,13 @@ namespace CalamityMod.Items.Weapons.Summon double minionCount = 0; for (int j = 0; j < Main.projectile.Length; j++) { - Projectile projectile = Main.projectile[j]; - if (projectile.active && projectile.owner == player.whoAmI && projectile.minion && projectile.type != ModContent.ProjectileType() && projectile.type != ModContent.ProjectileType()) + Projectile proj = Main.projectile[j]; + if (proj.active && proj.owner == player.whoAmI && proj.minion && proj.type != item.shoot) { - minionCount += projectile.minionSlots; + minionCount += proj.minionSlots; } } - siriusSlots = (int)((double)player.maxMinions - minionCount); + siriusSlots = (int)(player.maxMinions - minionCount); } public override bool CanUseItem(Player player) @@ -64,16 +64,14 @@ namespace CalamityMod.Items.Weapons.Summon { for (int x = 0; x < Main.projectile.Length; x++) { - Projectile projectile2 = Main.projectile[x]; - if (projectile2.active && projectile2.owner == player.whoAmI && projectile2.type == ModContent.ProjectileType() && projectile2.type != ModContent.ProjectileType()) + Projectile proj = Main.projectile[x]; + if (proj.active && proj.owner == player.whoAmI && proj.type == type) { - projectile2.Kill(); + proj.Kill(); + break; } } - position = Main.MouseWorld; - speedX = 0; - speedY = 0; - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, siriusSlots, 30f); + Projectile.NewProjectile(position, Vector2.Zero, type, damage, knockBack, player.whoAmI, siriusSlots, 30f); return false; } diff --git a/Items/Weapons/Summon/SunGodStaff.cs b/Items/Weapons/Summon/SunGodStaff.cs index 4da962d734..ebe9ce9e11 100644 --- a/Items/Weapons/Summon/SunGodStaff.cs +++ b/Items/Weapons/Summon/SunGodStaff.cs @@ -47,18 +47,16 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - position = Main.MouseWorld; - speedX = 0; - speedY = 0; for (int x = 0; x < Main.maxProjectiles; x++) { - Projectile projectile = Main.projectile[x]; - if (projectile.active && projectile.owner == player.whoAmI && projectile.type == ModContent.ProjectileType()) + Projectile proj = Main.projectile[x]; + if (proj.active && proj.owner == player.whoAmI && proj.type == type) { - projectile.Kill(); + proj.Kill(); + break; } } - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + Projectile.NewProjectile(position, Vector2.Zero, type, damage, knockBack, player.whoAmI); return false; } } diff --git a/Items/Weapons/Summon/SunSpiritStaff.cs b/Items/Weapons/Summon/SunSpiritStaff.cs index 00f9a88a12..e874d3e8cd 100644 --- a/Items/Weapons/Summon/SunSpiritStaff.cs +++ b/Items/Weapons/Summon/SunSpiritStaff.cs @@ -44,18 +44,16 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - position = Main.MouseWorld; - speedX = 0; - speedY = 0; - for (int x = 0; x < 1000; x++) + for (int x = 0; x < Main.maxProjectiles; x++) { - Projectile projectile = Main.projectile[x]; - if (projectile.active && projectile.owner == player.whoAmI && projectile.type == ModContent.ProjectileType()) + Projectile proj = Main.projectile[x]; + if (proj.active && proj.owner == player.whoAmI && proj.type == type) { - projectile.Kill(); + proj.Kill(); + break; } } - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + Projectile.NewProjectile(position, Vector2.Zero, type, damage, knockBack, player.whoAmI); return false; } } diff --git a/Items/Weapons/Typeless/YanmeisKnife.cs b/Items/Weapons/Typeless/YanmeisKnife.cs index fabdacfe67..162fd7a9ad 100644 --- a/Items/Weapons/Typeless/YanmeisKnife.cs +++ b/Items/Weapons/Typeless/YanmeisKnife.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Typeless DisplayName.SetDefault("Yanmei's Knife"); Tooltip.SetDefault("When hitting a boss or its minions, you gain various boosts and cripple the enemy hit\n" + "A knife from an unknown world\n" + - "An owner who's heart is pure and free of taint\n" + + "An owner whose heart is pure and free of taint\n" + "A heart of iron and valor"); } diff --git a/Items/Weapons/Typeless/YanmeisKnife.png b/Items/Weapons/Typeless/YanmeisKnife.png index 36c6bc6c06..b7f214f8f4 100644 Binary files a/Items/Weapons/Typeless/YanmeisKnife.png and b/Items/Weapons/Typeless/YanmeisKnife.png differ diff --git a/Localization/CalamityLocalization.cs b/Localization/CalamityLocalization.cs index d883788023..2c9dae7289 100644 --- a/Localization/CalamityLocalization.cs +++ b/Localization/CalamityLocalization.cs @@ -95,7 +95,6 @@ namespace CalamityMod.Localization new [] { "AureusBossText2", "A faint ethereal click can be heard from the dungeon." }, new [] { "AstralBossText", "The seal of the stars has been broken! You can now mine Astral Ore." }, new [] { "DeusText", "A star-spawned horror tunnels through the astral infection." }, - new [] { "DeusAltarRejectText", "The god of the stars rejects your offering. You must unleash the power of the lunar Cultist to perform the ritual." }, new [] { "DeusAltarRejectNightText", "The god of the stars rejects your offering. The ritual can only be performed at night." }, new [] { "CalamitasBossText", "You underestimate my power..." }, diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 42a01ddd1c..e037e4d520 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -272,7 +272,7 @@ namespace CalamityMod List bosses = new List() { NPCType(), NPCType(), NPCType() }; int summon = ItemType(); List loot = new List() { ItemType(), ItemID.Gel, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.HealingPotion }; - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; string instructions = $"Use an [i:{summon}]"; string despawn = CalamityUtils.ColorMessage("The gelatinous monstrosity achieved vengeance for its brethren.", new Color(0xBA, 0x55, 0x33)); AddBoss(bossChecklist, calamity, "Slime God", order, bosses, DownedSlimeGod, summon, loot, collection, instructions, despawn); @@ -522,7 +522,7 @@ namespace CalamityMod BossDifficulty.TryGetValue("Yharon", 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() }; + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), /*ItemType(), */ItemType() }; List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; string instructions = $"Use a [i:{summon}] in the Jungle Biome"; // TODO -- this setup code is only run once, so the despawn message can't be changed post-eclipse. Find a way around this. diff --git a/NPCs/Abyss/ColossalSquid.cs b/NPCs/Abyss/ColossalSquid.cs index 248cd84d61..a8c338cbc4 100644 --- a/NPCs/Abyss/ColossalSquid.cs +++ b/NPCs/Abyss/ColossalSquid.cs @@ -44,7 +44,24 @@ namespace CalamityMod.NPCs.Abyss npc.buffImmune[k] = true; } npc.buffImmune[BuffID.Ichor] = false; - npc.buffImmune[BuffID.CursedInferno] = false; + npc.buffImmune[BuffID.Frostburn] = false; + npc.buffImmune[BuffID.CursedInferno] = false; + npc.buffImmune[BuffID.Daybreak] = false; + npc.buffImmune[BuffID.StardustMinionBleed] = false; + npc.buffImmune[BuffID.DryadsWardDebuff] = false; + npc.buffImmune[BuffID.Oiled] = false; + npc.buffImmune[BuffID.BetsysCurse] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.timeLeft = NPC.activeTime * 30; npc.value = Item.buyPrice(0, 25, 0, 0); npc.HitSound = SoundID.NPCHit20; diff --git a/NPCs/Abyss/Reaper.cs b/NPCs/Abyss/Reaper.cs index a569c8dadf..0ab539d84a 100644 --- a/NPCs/Abyss/Reaper.cs +++ b/NPCs/Abyss/Reaper.cs @@ -44,7 +44,24 @@ namespace CalamityMod.NPCs.Abyss npc.buffImmune[k] = true; } npc.buffImmune[BuffID.Ichor] = false; - npc.buffImmune[BuffID.CursedInferno] = false; + npc.buffImmune[BuffID.Frostburn] = false; + npc.buffImmune[BuffID.CursedInferno] = false; + npc.buffImmune[BuffID.Daybreak] = false; + npc.buffImmune[BuffID.StardustMinionBleed] = false; + npc.buffImmune[BuffID.DryadsWardDebuff] = false; + npc.buffImmune[BuffID.Oiled] = false; + npc.buffImmune[BuffID.BetsysCurse] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.timeLeft = NPC.activeTime * 30; npc.value = Item.buyPrice(0, 25, 0, 0); npc.HitSound = SoundID.NPCHit56; diff --git a/NPCs/Astral/AstralProbe.cs b/NPCs/Astral/AstralProbe.cs index 32e721f569..89cc96864f 100644 --- a/NPCs/Astral/AstralProbe.cs +++ b/NPCs/Astral/AstralProbe.cs @@ -254,31 +254,28 @@ namespace CalamityMod.NPCs.Astral if (npc.life <= 0) { - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); - npc.width = 30; - npc.height = 30; - npc.position.X = npc.position.X - (float)(npc.width / 2); - npc.position.Y = npc.position.Y - (float)(npc.height / 2); - for (int num621 = 0; num621 < 5; num621++) + npc.position = npc.Center; + npc.width = npc.height = 30; + npc.Center = npc.position; + for (int d = 0; d < 5; d++) { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int purple = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 2f); + Main.dust[purple].velocity *= 3f; if (Main.rand.NextBool(2)) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[purple].scale = 0.5f; + Main.dust[purple].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int d = 0; d < 10; d++) { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int cosmos = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 3f); + Main.dust[cosmos].noGravity = true; + Main.dust[cosmos].velocity *= 5f; + cosmos = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 2f); + Main.dust[cosmos].velocity *= 2f; } - npc.ExplosionGores(3); + CalamityUtils.ExplosionGores(npc.Center, 3); } } diff --git a/NPCs/AstrumAureus/AstrumAureus.cs b/NPCs/AstrumAureus/AstrumAureus.cs index f2f4ab3a78..5e04094fc7 100644 --- a/NPCs/AstrumAureus/AstrumAureus.cs +++ b/NPCs/AstrumAureus/AstrumAureus.cs @@ -74,6 +74,7 @@ namespace CalamityMod.NPCs.AstrumAureus npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; diff --git a/NPCs/BrimstoneElemental/Brimling.cs b/NPCs/BrimstoneElemental/Brimling.cs index ac6ec63800..6393cead33 100644 --- a/NPCs/BrimstoneElemental/Brimling.cs +++ b/NPCs/BrimstoneElemental/Brimling.cs @@ -48,6 +48,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental npc.buffImmune[BuffID.StardustMinionBleed] = false; npc.buffImmune[BuffID.DryadsWardDebuff] = false; npc.buffImmune[BuffID.Oiled] = false; + npc.buffImmune[BuffID.BoneJavelin] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; @@ -57,8 +58,10 @@ namespace CalamityMod.NPCs.BrimstoneElemental npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; diff --git a/NPCs/BrimstoneElemental/BrimstoneElemental.cs b/NPCs/BrimstoneElemental/BrimstoneElemental.cs index d141e1810a..4e9be7f37f 100644 --- a/NPCs/BrimstoneElemental/BrimstoneElemental.cs +++ b/NPCs/BrimstoneElemental/BrimstoneElemental.cs @@ -74,6 +74,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; diff --git a/NPCs/Bumblebirb/Bumblefuck.cs b/NPCs/Bumblebirb/Bumblefuck.cs index 53c12c6c7c..a4f9598b73 100644 --- a/NPCs/Bumblebirb/Bumblefuck.cs +++ b/NPCs/Bumblebirb/Bumblefuck.cs @@ -68,6 +68,7 @@ namespace CalamityMod.NPCs.Bumblebirb npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.boss = true; diff --git a/NPCs/Bumblebirb/Bumblefuck2.cs b/NPCs/Bumblebirb/Bumblefuck2.cs index 28332eb788..b297c15e81 100644 --- a/NPCs/Bumblebirb/Bumblefuck2.cs +++ b/NPCs/Bumblebirb/Bumblefuck2.cs @@ -51,6 +51,7 @@ namespace CalamityMod.NPCs.Bumblebirb npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.lavaImmune = true; diff --git a/NPCs/Calamitas/Calamitas.cs b/NPCs/Calamitas/Calamitas.cs index 2c9a25d28b..92af87c878 100644 --- a/NPCs/Calamitas/Calamitas.cs +++ b/NPCs/Calamitas/Calamitas.cs @@ -64,6 +64,7 @@ namespace CalamityMod.NPCs.Calamitas npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; diff --git a/NPCs/Calamitas/CalamitasRun.cs b/NPCs/Calamitas/CalamitasRun.cs index 1d1618fbdb..5676b4eff7 100644 --- a/NPCs/Calamitas/CalamitasRun.cs +++ b/NPCs/Calamitas/CalamitasRun.cs @@ -64,6 +64,7 @@ namespace CalamityMod.NPCs.Calamitas npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; diff --git a/NPCs/Calamitas/CalamitasRun2.cs b/NPCs/Calamitas/CalamitasRun2.cs index b3f99c1857..59f73007db 100644 --- a/NPCs/Calamitas/CalamitasRun2.cs +++ b/NPCs/Calamitas/CalamitasRun2.cs @@ -66,6 +66,7 @@ namespace CalamityMod.NPCs.Calamitas npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; diff --git a/NPCs/Calamitas/CalamitasRun3.cs b/NPCs/Calamitas/CalamitasRun3.cs index 525a07add1..dab41f1c2a 100644 --- a/NPCs/Calamitas/CalamitasRun3.cs +++ b/NPCs/Calamitas/CalamitasRun3.cs @@ -78,6 +78,7 @@ namespace CalamityMod.NPCs.Calamitas npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; diff --git a/NPCs/Calamitas/SoulSeeker.cs b/NPCs/Calamitas/SoulSeeker.cs index 75e3acf003..f42c3741ef 100644 --- a/NPCs/Calamitas/SoulSeeker.cs +++ b/NPCs/Calamitas/SoulSeeker.cs @@ -63,6 +63,7 @@ namespace CalamityMod.NPCs.Calamitas npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; diff --git a/NPCs/CalamityGlobalAI.cs b/NPCs/CalamityGlobalAI.cs index e967625348..97ff6db526 100644 --- a/NPCs/CalamityGlobalAI.cs +++ b/NPCs/CalamityGlobalAI.cs @@ -17709,10 +17709,7 @@ namespace CalamityMod.NPCs { npc.direction *= -1; - if (npcType == ModContent.NPCType()) - npc.spriteDirection = (npc.direction > 0) ? 1 : -1; - else - npc.spriteDirection = npc.direction; + npc.spriteDirection = npc.direction; npc.ai[0] = 0f; } @@ -19699,7 +19696,7 @@ namespace CalamityMod.NPCs else { int alteredDirection = npc.spriteDirection; - if (npcType == NPCID.VortexRifleman || npcType == ModContent.NPCType()) + if (npcType == NPCID.VortexRifleman) { alteredDirection *= -1; } @@ -22502,132 +22499,149 @@ namespace CalamityMod.NPCs } #endregion - #region Antlion AI - public static bool BuffedAntlionAI(NPC npc, Mod mod) - { - npc.TargetClosest(true); + #region Antlion AI + public static bool BuffedAntlionAI(NPC npc, Mod mod) + { + npc.TargetClosest(true); - float num270 = 12f; - Vector2 vector32 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num271 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector32.X; - float num272 = Main.player[npc.target].position.Y - vector32.Y; - float num273 = (float)Math.Sqrt((double)(num271 * num271 + num272 * num272)); + //Calculate speed and velocity of the sand balls + float speed = 12f; + float xVel = Main.player[npc.target].Center.X - npc.Center.X; + float yVel = Main.player[npc.target].position.Y - npc.Center.Y; + Vector2 velocity = new Vector2(xVel, yVel); + float targetDist = velocity.Length(); - num273 = num270 / num273; - num271 *= num273; - num272 *= num273; + targetDist = speed / targetDist; + velocity.X *= targetDist; + velocity.Y *= targetDist; - bool flag17 = false; - if (npc.directionY < 0) - { - npc.rotation = (float)(Math.Atan2((double)num272, (double)num271) + MathHelper.PiOver2); - flag17 = ((double)npc.rotation >= -1.2 && (double)npc.rotation <= 1.2); - if ((double)npc.rotation < -0.8) - { - npc.rotation = -0.8f; - } - else if ((double)npc.rotation > 0.8) - { - npc.rotation = 0.8f; - } - if (npc.velocity.X != 0f) - { - npc.velocity.X = npc.velocity.X * 0.9f; - if ((double)npc.velocity.X > -0.1 || (double)npc.velocity.X < 0.1) - { - npc.netUpdate = true; - npc.velocity.X = 0f; - } - } - } + //Adjust rotation and velocity + bool canShoot = false; + if (npc.directionY < 0) + { + //Set rotation based on the target location + npc.rotation = velocity.ToRotation() + MathHelper.PiOver2; + //Antlions can only shoot if rotated between a certain cone of spread based on the target location + canShoot = Math.Abs(npc.rotation) <= 1.2f; - if (npc.ai[0] > 0f) - { - if (npc.ai[0] == 200f) - { - Main.PlaySound(SoundID.NPCDeath13, npc.position); - } - npc.ai[0] -= 1f; - } + //Hardcap rotation so it doesn't look weird, but since the above calculation happens first, it ignores this cap + if (npc.rotation < -0.8f) + { + npc.rotation = -0.8f; + } + else if (npc.rotation > 0.8f) + { + npc.rotation = 0.8f; + } - if (Main.netMode != NetmodeID.MultiplayerClient && flag17 && npc.ai[0] == 0f && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - npc.ai[0] = 200f; - int damage = 10; - int projType = ProjectileID.SandBallFalling; + //Antlions generally don't move horizontally so prevent that as needed + if (npc.velocity.X != 0f) + { + npc.velocity.X *= 0.9f; + if (Math.Abs(npc.velocity.X) < 0.1f) + { + npc.netUpdate = true; + npc.velocity.X = 0f; + } + } + } - int projAmt = Main.rand.Next(8, 14); - if (Main.rand.NextBool(1000)) - projAmt = Main.rand.Next(80, 131); + //Decrement the firing cooldown, play a sound if at full meaning it just fired + if (npc.ai[0] > 0f) + { + if (npc.ai[0] == 200f) + { + Main.PlaySound(SoundID.NPCDeath13, npc.position); + } + npc.ai[0] -= 1f; + } - for (int i = 0; i < projAmt; i++) - { - num271 += (float)Main.rand.Next(-30, 31) * 0.05f; - num272 += (float)Main.rand.Next(-30, 31) * 0.05f; - int num276 = Projectile.NewProjectile(vector32.X, vector32.Y, num271, num272, projType, damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[num276].ai[0] = 2f; - Main.projectile[num276].timeLeft = 300; - Main.projectile[num276].friendly = false; - NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, num276, 0f, 0f, 0f, 0, 0, 0); - } - npc.netUpdate = true; - } + //Antlions should only fire if the target is in the shooting cone and has a line of sight as well as not being on cooldown. + bool lineofSight = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + if (Main.netMode != NetmodeID.MultiplayerClient && canShoot && npc.ai[0] == 0f && lineofSight) + { + //Reset the firing cooldown to 3.3333 seconds + npc.ai[0] = 200f; - try - { - int num277 = (int)npc.position.X / 16; - int num278 = (int)(npc.position.X + (float)(npc.width / 2)) / 16; - int num279 = (int)(npc.position.X + (float)npc.width) / 16; - int num280 = (int)(npc.position.Y + (float)npc.height) / 16; - bool flag18 = false; - if (Main.tile[num277, num280] == null) - { - Main.tile[num277, num280] = new Tile(); - } - if (Main.tile[num278, num280] == null) - { - Main.tile[num277, num280] = new Tile(); - } - if (Main.tile[num279, num280] == null) - { - Main.tile[num277, num280] = new Tile(); - } - if ((Main.tile[num277, num280].nactive() && Main.tileSolid[(int)Main.tile[num277, num280].type]) || (Main.tile[num278, num280].nactive() && Main.tileSolid[(int)Main.tile[num278, num280].type]) || (Main.tile[num279, num280].nactive() && Main.tileSolid[(int)Main.tile[num279, num280].type])) - { - flag18 = true; - } - if (flag18) - { - npc.noGravity = true; - npc.noTileCollide = true; - npc.velocity.Y = -0.2f; - } - else - { - npc.noGravity = false; - npc.noTileCollide = false; - if (Main.rand.Next(2) == 0) - { - int num281 = Dust.NewDust(new Vector2(npc.position.X - 4f, npc.position.Y + (float)npc.height - 8f), npc.width + 8, 24, 32, 0f, npc.velocity.Y / 2f, 0, default(Color), 1f); - Dust var_9_DC3B_cp_0_cp_0 = Main.dust[num281]; - var_9_DC3B_cp_0_cp_0.velocity.X = var_9_DC3B_cp_0_cp_0.velocity.X * 0.4f; - Dust var_9_DC5F_cp_0_cp_0 = Main.dust[num281]; - var_9_DC5F_cp_0_cp_0.velocity.Y = var_9_DC5F_cp_0_cp_0.velocity.Y * -1f; - if (Main.rand.Next(2) == 0) - { - Main.dust[num281].noGravity = true; - Dust dust = Main.dust[num281]; - dust.scale += 0.2f; - } - } - } - } - catch - { - } - return false; - } - #endregion + //With the Rev and Death damage calculations, this becomes 56 damage. + int damage = 10; + + int projType = ProjectileID.SandBallFalling; + int projAmt = Main.rand.Next(8, 14); + if (Main.rand.NextBool(1000)) + projAmt = Main.rand.Next(80, 131); + + for (int i = 0; i < projAmt; i++) + { + //Adjust the velocity to make it a shotgun-like spread + velocity.X += (float)Main.rand.Next(-30, 31) * 0.05f; + velocity.Y += (float)Main.rand.Next(-30, 31) * 0.05f; + + int sandBall = Projectile.NewProjectile(npc.Center, velocity, projType, damage, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[sandBall].ai[0] = 2f; + Main.projectile[sandBall].timeLeft = 300; + Main.projectile[sandBall].friendly = false; + NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, sandBall, 0f, 0f, 0f, 0, 0, 0); + } + npc.netUpdate = true; + } + + try + { + //This tile checking behavior is used for when Antlions cover themselves in sand and need to rise upward to get to the surface + int xLeft = (int)npc.position.X / 16; + int xCenter = (int)npc.Center.X / 16; + int xRight = (int)(npc.position.X + (float)npc.width) / 16; + int y = (int)(npc.position.Y + (float)npc.height) / 16; + bool tileClimbing = false; + if (Main.tile[xLeft, y] is null) + { + Main.tile[xLeft, y] = new Tile(); + } + if (Main.tile[xCenter, y] is null) + { + Main.tile[xLeft, y] = new Tile(); + } + if (Main.tile[xRight, y] is null) + { + Main.tile[xLeft, y] = new Tile(); + } + if ((Main.tile[xLeft, y].nactive() && Main.tileSolid[(int)Main.tile[xLeft, y].type]) || (Main.tile[xCenter, y].nactive() && Main.tileSolid[(int)Main.tile[xCenter, y].type]) || (Main.tile[xRight, y].nactive() && Main.tileSolid[(int)Main.tile[xRight, y].type])) + { + tileClimbing = true; + } + if (tileClimbing) + { + npc.noGravity = true; + npc.noTileCollide = true; + npc.velocity.Y = -0.2f; + } + + //If not rising up through tiles, occasionally spawn some dust + else + { + npc.noGravity = false; + npc.noTileCollide = false; + if (Main.rand.NextBool(2)) + { + int sand = Dust.NewDust(new Vector2(npc.position.X - 4f, npc.position.Y + (float)npc.height - 8f), npc.width + 8, 24, 32, 0f, npc.velocity.Y / 2f, 0, default(Color), 1f); + Dust dust = Main.dust[sand]; + dust.velocity.X *= 0.4f; + dust.velocity.Y *= -1f; + if (Main.rand.NextBool(2)) + { + dust.noGravity = true; + dust.scale += 0.2f; + } + } + } + } + catch + { + } + return false; + } + #endregion #region Spike Ball AI public static bool BuffedSpikeBallAI(NPC npc, Mod mod) @@ -22775,6 +22789,7 @@ namespace CalamityMod.NPCs int proj = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector255.X, vector255.Y, ProjectileID.FlamesTrap, 20, 0f, Main.myPlayer, 0f, 0f); Main.projectile[proj].tileCollide = false; Main.projectile[proj].friendly = false; + Main.projectile[proj].trap = false; } } } @@ -24813,7 +24828,7 @@ namespace CalamityMod.NPCs { for (int j = npcY - 1; j <= npcY + 1; j++) { - if (Main.tile[i, j] == null) + if (Main.tile[i, j] is null) { return false; } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 5da258093e..5bd2a8dca7 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -49,6 +49,8 @@ using CalamityMod.NPCs.SulphurousSea; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.TownNPCs; using CalamityMod.NPCs.Yharon; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Projectiles.DraedonsArsenal; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; @@ -860,6 +862,8 @@ namespace CalamityMod.NPCs npc.buffImmune[BuffType()] = false; } + if (YanmeisKnifeSlash.CanRecieveCoolEffectsFrom(npc)) + npc.buffImmune[BuffType()] = false; npc.buffImmune[BuffType()] = false; } #endregion @@ -1912,7 +1916,7 @@ namespace CalamityMod.NPCs } break; case 3: - if (npc.type == NPCType() || npc.type == NPCType() || + if (npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType()) { return CalamityGlobalAI.BuffedFighterAI(npc, mod); @@ -3616,15 +3620,15 @@ namespace CalamityMod.NPCs { damage = (int)(damage * 0.2); } - else if (ProjectileID.Sets.StardustDragon[projectile.type] || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileID.Electrosphere) + else if (ProjectileID.Sets.StardustDragon[projectile.type] || projectile.type == ProjectileType() || projectile.type == ProjectileType()) { - damage = (int)(damage * 0.4); + damage = (int)(damage * 0.25); } - else if (projectile.type == ProjectileType()) + else if (projectile.type == ProjectileID.DD2BetsyArrow || projectile.type == ProjectileType() || projectile.type == ProjectileType()) { damage = (int)(damage * 0.5); } - else if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileID.InfernoFriendlyBolt || projectile.type == ProjectileID.InfernoFriendlyBlast || projectile.type == ProjectileID.RainbowFront || projectile.type == ProjectileID.RainbowBack || projectile.type == ProjectileType() || projectile.type == ProjectileID.DD2BetsyArrow || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileID.ChargedBlasterLaser) + else if (projectile.type == ProjectileType() || projectile.type == ProjectileID.InfernoFriendlyBolt || projectile.type == ProjectileID.InfernoFriendlyBlast || projectile.type == ProjectileID.RainbowFront || projectile.type == ProjectileID.RainbowBack || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileID.ChargedBlasterLaser || projectile.type == ProjectileID.Electrosphere) { damage = (int)(damage * 0.75); } @@ -3693,7 +3697,7 @@ namespace CalamityMod.NPCs { damage = (int)(damage * 0.9); } - if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) + if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType()) { damage = (int)(damage * 0.5); } @@ -5933,7 +5937,7 @@ namespace CalamityMod.NPCs return true; } } - return false; + return CalamityUtils.FindFirstProjectile(ProjectileType()) != -1; } #endregion @@ -6203,22 +6207,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { int num8 = NPC.NewNPC((int)projectile.Center.X, (int)projectile.Center.Y + 100, type); - string typeName2 = Main.npc[num8].TypeName; - - if (Main.netMode == NetmodeID.SinglePlayer) - { - Main.NewText(Language.GetTextValue("Announcement.HasAwoken", typeName2), new Color(175, 75, 255)); - return; - } - - if (Main.netMode == NetmodeID.Server) - { - NetMessage.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", new object[] - { - Main.npc[num8].GetTypeNetName() - }), new Color(175, 75, 255)); - return; - } + CalamityUtils.BossAwakenMessage(num8); } else { diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index 6ce5843b65..cf93d7848a 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -79,6 +79,7 @@ namespace CalamityMod.NPCs.Cryogen npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadS.cs b/NPCs/DevourerofGods/DevourerofGodsHeadS.cs index 930a2dae76..3cfde01c12 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHeadS.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHeadS.cs @@ -1009,7 +1009,7 @@ namespace CalamityMod.NPCs.DevourerofGods DropHelper.DropBags(npc); - DropHelper.DropItem(npc, ModContent.ItemType(), 8, 14); + DropHelper.DropItem(npc, ModContent.ItemType(), 5, 15); DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedDoG); DropHelper.DropResidentEvilAmmo(npc, CalamityWorld.downedDoG, 6, 3, 2); diff --git a/NPCs/GreatSandShark/GreatSandShark.cs b/NPCs/GreatSandShark/GreatSandShark.cs index 13f47fd4eb..ebc05a0905 100644 --- a/NPCs/GreatSandShark/GreatSandShark.cs +++ b/NPCs/GreatSandShark/GreatSandShark.cs @@ -53,6 +53,7 @@ namespace CalamityMod.NPCs.GreatSandShark npc.buffImmune[BuffID.StardustMinionBleed] = false; npc.buffImmune[BuffID.DryadsWardDebuff] = false; npc.buffImmune[BuffID.Oiled] = false; + npc.buffImmune[BuffID.BetsysCurse] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; @@ -62,6 +63,7 @@ namespace CalamityMod.NPCs.GreatSandShark npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.behindTiles = true; diff --git a/NPCs/Leviathan/Leviathan.cs b/NPCs/Leviathan/Leviathan.cs index 7d7843c103..f8e6cbef7e 100644 --- a/NPCs/Leviathan/Leviathan.cs +++ b/NPCs/Leviathan/Leviathan.cs @@ -70,6 +70,7 @@ namespace CalamityMod.NPCs.Leviathan npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; diff --git a/NPCs/Leviathan/LeviathanStart.cs b/NPCs/Leviathan/LeviathanStart.cs index e8b78494f4..b083d0b277 100644 --- a/NPCs/Leviathan/LeviathanStart.cs +++ b/NPCs/Leviathan/LeviathanStart.cs @@ -126,7 +126,8 @@ namespace CalamityMod.NPCs.Leviathan { if (Main.netMode != NetmodeID.MultiplayerClient) { - NPC.NewNPC((int)npc.Center.X, (int)npc.position.Y + npc.height, ModContent.NPCType(), npc.whoAmI); + int siren = NPC.NewNPC((int)npc.Center.X, (int)npc.position.Y + npc.height, ModContent.NPCType(), npc.whoAmI); + CalamityUtils.BossAwakenMessage(siren); } } } diff --git a/NPCs/Leviathan/Parasea.cs b/NPCs/Leviathan/Parasea.cs index 849a0c71b6..9611a5fd0b 100644 --- a/NPCs/Leviathan/Parasea.cs +++ b/NPCs/Leviathan/Parasea.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.Banners; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -22,8 +23,7 @@ namespace CalamityMod.NPCs.Leviathan npc.noTileCollide = true; npc.canGhostHeal = false; npc.damage = 50; - npc.width = 30; - npc.height = 30; + npc.width = npc.height = 30; npc.defense = 8; npc.lifeMax = 650; if (CalamityWorld.bossRushActive) @@ -63,6 +63,18 @@ namespace CalamityMod.NPCs.Leviathan npc.frame.Y = frame * frameHeight; } + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + Texture2D texture = Main.npcTexture[npc.type]; + int height = texture.Height / Main.npcFrameCount[npc.type]; + int width = texture.Width; + SpriteEffects spriteEffects = SpriteEffects.FlipHorizontally; + if (npc.spriteDirection == -1) + spriteEffects = SpriteEffects.None; + Main.spriteBatch.Draw(texture, npc.Center - Main.screenPosition + new Vector2(0f, npc.gfxOffY), npc.frame, npc.GetAlpha(drawColor), npc.rotation, new Vector2((float)width / 2f, (float)height / 2f), npc.scale, spriteEffects, 0f); + return false; + } + public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(BuffID.Wet, 60, true); diff --git a/NPCs/Leviathan/Siren.cs b/NPCs/Leviathan/Siren.cs index d12d062578..4f2cebfad0 100644 --- a/NPCs/Leviathan/Siren.cs +++ b/NPCs/Leviathan/Siren.cs @@ -68,6 +68,7 @@ namespace CalamityMod.NPCs.Leviathan npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; @@ -155,7 +156,8 @@ namespace CalamityMod.NPCs.Leviathan else music = MusicID.Boss3; - NPC.NewNPC((int)vector.X, (int)vector.Y + 480, ModContent.NPCType(), 1); + int levi = NPC.NewNPC((int)vector.X, (int)vector.Y + 480, ModContent.NPCType(), 1); + CalamityUtils.BossAwakenMessage(levi); spawnedLevi = true; } } @@ -591,8 +593,9 @@ namespace CalamityMod.NPCs.Leviathan if (npc.ai[1] >= (revenge ? 45f : 60f)) { forceChargeFrames = true; - npc.ai[0] = npc.ai[2] >= ((leviAlive && !phase4) ? 2f : 3f) ? -1f : 4f; - npc.ai[1] = npc.ai[2] >= ((leviAlive && !phase4) ? 2f : 3f) ? 3f : 0f; + float aiInterval = (leviAlive && !phase4) ? 2f : 3f; + npc.ai[0] = (npc.ai[2] >= aiInterval) ? -1f : 4f; + npc.ai[1] = (npc.ai[2] >= aiInterval) ? 3f : 0f; npc.localAI[0] = 0f; // Velocity and rotation diff --git a/NPCs/NormalNPCs/CrimulanBlightSlime.cs b/NPCs/NormalNPCs/CrimulanBlightSlime.cs index 8b66fe1c81..da8584888f 100644 --- a/NPCs/NormalNPCs/CrimulanBlightSlime.cs +++ b/NPCs/NormalNPCs/CrimulanBlightSlime.cs @@ -1,6 +1,8 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Weapons.Melee; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -70,7 +72,10 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { - DropHelper.DropItem(npc, ModContent.ItemType(), 15, 16); + int item = Item.NewItem(npc.Center, npc.Size, ModContent.ItemType(), Main.rand.Next(15, 21), false, 0, false, false); + Main.item[item].color = new Color(250, 50, 50, 255); + NetMessage.SendData(88, -1, -1, null, item, 1f, 0f, 0f, 0, 0, 0); + DropHelper.DropItem(npc, ItemID.Gel, 10, 14); DropHelper.DropItemCondition(npc, ModContent.ItemType(), NPC.downedBoss3, 0.01f, 1, 1); } diff --git a/NPCs/NormalNPCs/Horse.cs b/NPCs/NormalNPCs/Horse.cs index cda681d088..8c4860a721 100644 --- a/NPCs/NormalNPCs/Horse.cs +++ b/NPCs/NormalNPCs/Horse.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Tools.ClimateChange; @@ -40,7 +41,26 @@ namespace CalamityMod.NPCs.NormalNPCs npc.buffImmune[k] = true; } npc.buffImmune[BuffID.Ichor] = false; - npc.buffImmune[BuffID.CursedInferno] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[BuffID.Frostburn] = false; + npc.buffImmune[BuffID.CursedInferno] = false; + npc.buffImmune[BuffID.Daybreak] = false; + npc.buffImmune[BuffID.StardustMinionBleed] = false; + npc.buffImmune[BuffID.DryadsWardDebuff] = false; + npc.buffImmune[BuffID.Oiled] = false; + npc.buffImmune[BuffID.BetsysCurse] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.knockBackResist = 0f; npc.value = Item.buyPrice(0, 1, 50, 0); npc.noGravity = true; @@ -136,7 +156,7 @@ namespace CalamityMod.NPCs.NormalNPCs num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Fire, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - npc.ExplosionGores(3); + CalamityUtils.ExplosionGores(npc.Center, 3); } } diff --git a/NPCs/NormalNPCs/ImpiousImmolator.cs b/NPCs/NormalNPCs/ImpiousImmolator.cs index abd4505594..5def4150d7 100644 --- a/NPCs/NormalNPCs/ImpiousImmolator.cs +++ b/NPCs/NormalNPCs/ImpiousImmolator.cs @@ -50,6 +50,7 @@ namespace CalamityMod.NPCs.NormalNPCs npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.value = Item.buyPrice(0, 0, 50, 0); diff --git a/NPCs/NormalNPCs/ScornEater.cs b/NPCs/NormalNPCs/ScornEater.cs index bf44d5a9bb..885319a7fe 100644 --- a/NPCs/NormalNPCs/ScornEater.cs +++ b/NPCs/NormalNPCs/ScornEater.cs @@ -45,6 +45,7 @@ namespace CalamityMod.NPCs.NormalNPCs npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.lavaImmune = true; diff --git a/NPCs/NormalNPCs/WulfrumDrone.cs b/NPCs/NormalNPCs/WulfrumDrone.cs index feebdb3e5f..a818545724 100644 --- a/NPCs/NormalNPCs/WulfrumDrone.cs +++ b/NPCs/NormalNPCs/WulfrumDrone.cs @@ -4,54 +4,142 @@ using CalamityMod.Items.Placeables.Banners; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using System; +using Microsoft.Xna.Framework; + namespace CalamityMod.NPCs.NormalNPCs { + internal enum DroneAIState + { + Searching = 0, + Charging = 1 + } public class WulfrumDrone : ModNPC { + internal DroneAIState AIState + { + get => (DroneAIState)(int)npc.ai[0]; + set => npc.ai[0] = (int)value; + } + public float HorizontalChargeTime + { + get => npc.ai[1]; + set => npc.ai[1] = value; + } + public float Time + { + get => npc.ai[2]; + set => npc.ai[2] = value; + } + public float SuperchargeTimer + { + get => npc.ai[3]; + set => npc.ai[3] = value; + } + public bool Supercharged => SuperchargeTimer > 0; + + public const float TotalHorizontalChargeTime = 75f; public override void SetStaticDefaults() { DisplayName.SetDefault("Wulfrum Drone"); - Main.npcFrameCount[npc.type] = 5; + Main.npcFrameCount[npc.type] = 6; } public override void SetDefaults() { - npc.damage = 10; - npc.aiStyle = 3; - aiType = NPCID.GoblinScout; - npc.width = 40; - npc.height = 30; + aiType = -1; + npc.aiStyle = -1; + npc.damage = 16; + npc.width = 32; + npc.height = 32; npc.defense = 4; - npc.lifeMax = 22; + npc.lifeMax = 21; npc.knockBackResist = 0.35f; - npc.value = Item.buyPrice(0, 0, 0, 50); + npc.value = Item.buyPrice(0, 0, 1, 20); + npc.noGravity = true; + npc.noTileCollide = true; npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; banner = npc.type; bannerItem = ModContent.ItemType(); - npc.buffImmune[BuffID.Confused] = false; } - public override void PostAI() + public override void AI() { - npc.spriteDirection = (npc.direction > 0) ? 1 : -1; + npc.TargetClosest(false); + + Player player = Main.player[npc.target]; + + if (Supercharged) + { + SuperchargeTimer--; + } + + if (AIState == DroneAIState.Searching) + { + if (npc.direction == 0) + npc.direction = 1; + Vector2 destination = player.Center + new Vector2(300f * npc.direction, -90f); + npc.velocity = Vector2.Lerp(npc.velocity, npc.DirectionTo(destination) * 8f, 0.1f); + if (npc.Distance(destination) < 40f) + { + Time++; + npc.velocity *= 0.95f; + if (Time >= 40f) + { + AIState = DroneAIState.Charging; + npc.netUpdate = true; + } + } + } + else + { + if (HorizontalChargeTime < 25) + { + npc.velocity = Vector2.Lerp(npc.velocity, npc.DirectionTo(player.Center) * 8f, 0.1f); + } + if (Supercharged && Main.netMode != NetmodeID.MultiplayerClient && HorizontalChargeTime % 30f == 29f) + { + Projectile.NewProjectile(npc.Center + Vector2.UnitX * 6f * npc.spriteDirection, npc.DirectionTo(player.Center) * 6f, ProjectileID.MartianTurretBolt, 14, 0f); + } + HorizontalChargeTime++; + if (HorizontalChargeTime > TotalHorizontalChargeTime) + { + AIState = DroneAIState.Searching; + HorizontalChargeTime = 0f; + npc.direction = (player.Center.X - npc.Center.X < 0).ToDirectionInt(); + npc.netUpdate = true; + } + } + npc.spriteDirection = (npc.velocity.X < 0).ToDirectionInt(); + npc.rotation = npc.velocity.X / 25f; + + // Generate idle dust + if (!Main.dedServ) + { + Dust dust = Dust.NewDustPerfect(npc.Bottom, 229); + dust.color = Color.Green; + dust.scale = 0.9f; + } } public override void FindFrame(int frameHeight) { - npc.frameCounter += 0.15f; - npc.frameCounter %= Main.npcFrameCount[npc.type]; - int frame = (int)npc.frameCounter; + npc.frameCounter++; + int frame = (int)(npc.frameCounter / 5) % (Main.npcFrameCount[npc.type] / 2); + if (Supercharged) + frame += Main.npcFrameCount[npc.type] / 2; + npc.frame.Y = frame * frameHeight; } public override float SpawnChance(NPCSpawnInfo spawnInfo) { + float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 2f : 1f; if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) - { return 0f; - } - return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.05f : 0.2f); + + return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.05f : 0.2f) * pylonMult; } public override void HitEffect(int hitDirection, double damage) @@ -72,8 +160,9 @@ namespace CalamityMod.NPCs.NormalNPCs public override void NPCLoot() { DropHelper.DropItem(npc, ModContent.ItemType(), 1, 3); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, 1, 1); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode); DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Supercharged); } } } diff --git a/NPCs/NormalNPCs/WulfrumDrone.png b/NPCs/NormalNPCs/WulfrumDrone.png index 63a3927889..f529f6a27e 100644 Binary files a/NPCs/NormalNPCs/WulfrumDrone.png and b/NPCs/NormalNPCs/WulfrumDrone.png differ diff --git a/NPCs/NormalNPCs/WulfrumGyrator.cs b/NPCs/NormalNPCs/WulfrumGyrator.cs new file mode 100644 index 0000000000..3323ce5634 --- /dev/null +++ b/NPCs/NormalNPCs/WulfrumGyrator.cs @@ -0,0 +1,178 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Banners; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.NPCs.NormalNPCs +{ + public class WulfrumGyrator : ModNPC + { + public float TimeSpentStuck + { + get => npc.ai[0]; + set => npc.ai[0] = value; + } + public float SuperchargeTimer + { + get => npc.ai[3]; + set => npc.ai[3] = value; + } + public bool Supercharged => SuperchargeTimer > 0; + + public const float PlayerTargetingThreshold = 90f; + public const float PlayerSearchDistance = 500f; + public const float StuckJumpPromptTime = 45f; + public const float MaxMovementSpeedX = 8f; + public const float JumpSpeed = -9f; + public const float NPCGravity = 0.3f; // NPC.cs has this, but it's private, and there's no way in hell I'm using reflection. + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wulfrum Gyrator"); + Main.npcFrameCount[npc.type] = 10; + } + + public override void SetDefaults() + { + aiType = -1; + npc.aiStyle = -1; + npc.damage = 15; + npc.width = 40; + npc.height = 40; + npc.defense = 5; + npc.lifeMax = 18; + npc.knockBackResist = 0.15f; + npc.value = Item.buyPrice(0, 0, 1, 15); + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + banner = npc.type; + bannerItem = ModContent.ItemType(); + npc.buffImmune[BuffID.Confused] = false; + } + + public override void FindFrame(int frameHeight) + { + npc.frameCounter++; + int frame = (int)(npc.frameCounter / 5) % (Main.npcFrameCount[npc.type] / 2); + if (Supercharged) + frame += Main.npcFrameCount[npc.type] / 2; + + npc.frame.Y = frame * frameHeight; + } + + public override void AI() + { + npc.TargetClosest(false); + + Player player = Main.player[npc.target]; + + if (Supercharged) + { + float chargeJumpSpeed = -14f; + + float maxHeight = chargeJumpSpeed * chargeJumpSpeed * (float)Math.Pow(Math.Sin(npc.AngleTo(player.Center)), 2) / (4f * NPCGravity); + bool jumpWouldHitPlayer = maxHeight > Math.Abs(player.Center.Y - npc.Center.Y) && maxHeight < Math.Abs(player.Center.Y - npc.Center.Y) + player.height; + if (jumpWouldHitPlayer && npc.collideY && npc.velocity.Y == 0f) + { + npc.velocity.Y = chargeJumpSpeed; + } + SuperchargeTimer--; + } + + // Jump if there's an obstacle ahead. + if (HoleAtPosition(npc.Center.X + npc.velocity.X * 4f) && npc.collideY && npc.velocity.Y == 0f) + { + npc.velocity.Y = JumpSpeed; + } + if (Collision.CanHitLine(player.position, player.width, player.height, npc.position, npc.width, npc.height) && + Math.Abs(player.Center.X - npc.Center.X) < PlayerSearchDistance && + Math.Abs(player.Center.X - npc.Center.X) > PlayerTargetingThreshold) + { + int direction = Math.Sign(player.Center.X - npc.Center.X) * (npc.confused ? -1 : 1); + if (npc.direction != direction) + { + npc.direction = direction; + npc.netUpdate = true; + } + } + else if (npc.collideX && npc.collideY && npc.velocity.Y == 0f) + { + npc.velocity.Y = JumpSpeed; + } + + if (npc.oldPosition == npc.position) + { + TimeSpentStuck++; + if (TimeSpentStuck > StuckJumpPromptTime) + { + npc.velocity.Y = JumpSpeed; + TimeSpentStuck = 0f; + npc.netUpdate = true; + } + } + else + { + TimeSpentStuck = 0f; + } + + npc.velocity.X = MathHelper.Lerp(npc.velocity.X, MaxMovementSpeedX * npc.direction * (Supercharged ? 1.333f : 1f), Supercharged ? 0.025f : 0.015f); + Vector4 adjustedVectors = Collision.WalkDownSlope(npc.position, npc.velocity, npc.width, npc.height, NPCGravity); + npc.position = adjustedVectors.XY(); + npc.velocity = adjustedVectors.ZW(); + } + private bool HoleAtPosition(float xPosition) + { + int tileWidth = npc.width / 16; + xPosition = (int)(xPosition / 16f) - tileWidth; + if (npc.velocity.X > 0) + { + xPosition += tileWidth; + } + int tileY = (int)((npc.position.Y + npc.height) / 16f); + for (int y = tileY; y < tileY + 2; y++) + { + for (int x = (int)xPosition; x < xPosition + tileWidth; x++) + { + if (Main.tile[x, y].active()) + { + return false; + } + } + } + return true; + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 2f : 1f; + if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) + return 0f; + return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.0333f : 0.15f) * pylonMult; + } + + public override void HitEffect(int hitDirection, double damage) + { + if (!Main.dedServ) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 3, hitDirection, -1f, 0, default, 1f); + } + if (npc.life <= 0) + { + for (int k = 0; k < 20; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 3, hitDirection, -1f, 0, default, 1f); + } + } + } + } + + public override void NPCLoot() + { + DropHelper.DropItem(npc, ModContent.ItemType(), 1, 2); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Supercharged); + } + } +} diff --git a/NPCs/NormalNPCs/WulfrumGyrator.png b/NPCs/NormalNPCs/WulfrumGyrator.png new file mode 100644 index 0000000000..05d8021a90 Binary files /dev/null and b/NPCs/NormalNPCs/WulfrumGyrator.png differ diff --git a/NPCs/NormalNPCs/WulfrumHovercraft.cs b/NPCs/NormalNPCs/WulfrumHovercraft.cs new file mode 100644 index 0000000000..c03dd17b80 --- /dev/null +++ b/NPCs/NormalNPCs/WulfrumHovercraft.cs @@ -0,0 +1,255 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Banners; +using Microsoft.Xna.Framework; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.NormalNPCs +{ + public class WulfrumHovercraft : ModNPC + { + internal enum HovercraftAIState + { + Searching = 0, + Hover = 1, + Slowdown = 2, + SwoopDownward = 3 + } + public float StunTime; + internal HovercraftAIState AIState + { + get => (HovercraftAIState)(int)npc.ai[0]; + set => npc.ai[0] = (int)value; + } + public float SubphaseTime + { + get => npc.ai[1]; + set => npc.ai[1] = value; + } + public float SearchDirection + { + get => npc.ai[2]; + set => npc.ai[2] = value; + } + public float SuperchargeTimer + { + get => npc.ai[3]; + set => npc.ai[3] = value; + } + public bool Supercharged => SuperchargeTimer > 0; + + public const float StunTimeMax = 45f; + public const float SearchXOffset = 345f; + public const float SearchSpeed = 7f; + public const float HoverSpeed = 5f; + public const float TotalSubphaseTime = 110f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wulfrum Hovercraft"); + Main.npcFrameCount[npc.type] = 12; + } + + public override void SetDefaults() + { + aiType = -1; + npc.aiStyle = -1; + npc.damage = 15; + npc.width = 40; + npc.height = 38; + npc.defense = 4; + npc.lifeMax = 20; + npc.value = Item.buyPrice(0, 0, 1, 50); + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + npc.noGravity = true; + npc.noTileCollide = true; + banner = npc.type; + bannerItem = ModContent.ItemType(); + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(StunTime); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + StunTime = reader.ReadSingle(); + } + + public override void FindFrame(int frameHeight) + { + npc.frameCounter++; + int frame = (int)(npc.frameCounter / 5) % (Main.npcFrameCount[npc.type] / 2); + if (Supercharged) + frame += Main.npcFrameCount[npc.type] / 2; + + npc.frame.Y = frame * frameHeight; + } + + public override void AI() + { + npc.knockBackResist = 0.1f; + + if (npc.target < 0 || npc.target >= 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + { + npc.TargetClosest(false); + + // Fly away if there is no living target, or the closest target is too far away. + if (Main.player[npc.target].dead || + !Main.player[npc.target].active || + npc.Distance(Main.player[npc.target].Center) > 1100f) + { + npc.velocity = Vector2.Lerp(npc.velocity, Vector2.UnitY * -8f, 0.1f); + npc.rotation = npc.rotation.AngleTowards(0f, MathHelper.ToRadians(15f)); + return; + } + } + + Lighting.AddLight(npc.Center - Vector2.UnitY * 8f, Color.Lime.ToVector3() * 1.5f); + + if (StunTime > 0) + { + if (!Main.dedServ && Main.rand.NextBool(4)) + { + for (int i = 0; i < 2; i++) + { + Dust.NewDustPerfect(npc.Center + Main.rand.NextVector2Circular(8f, 8f), 226).scale = 0.7f; + } + } + + npc.rotation = npc.rotation.AngleTowards(0f, MathHelper.ToRadians(15f)); + if (StunTime > StunTimeMax - 15) + npc.velocity *= 0.6f; + else + npc.knockBackResist = 2.4f; + + StunTime--; + return; + } + + Player player = Main.player[npc.target]; + if (SearchDirection == 0f) + { + if (Math.Abs(player.Center.X + SearchXOffset - npc.Center.X) < Math.Abs(player.Center.X - SearchXOffset - npc.Center.X)) + SearchDirection = 1f; + else + SearchDirection = -1f; + + npc.netUpdate = true; + } + if (AIState == HovercraftAIState.Searching || + AIState == HovercraftAIState.Hover) + { + Vector2 destination = player.Center + new Vector2(SearchXOffset * SearchDirection, -160f); + npc.velocity = npc.DirectionTo(destination) * (Supercharged ? 8.5f : 6f); + if (AIState == HovercraftAIState.Hover) + { + destination = player.Center + new Vector2(SearchXOffset * -SearchDirection, -160f); + npc.velocity = npc.DirectionTo(destination) * (Supercharged ? 7f : 5f); + } + + npc.rotation = npc.velocity.X / 16f; + if (npc.Distance(destination) < 50f) + { + if (AIState == HovercraftAIState.Searching) + { + AIState = HovercraftAIState.Slowdown; + } + else + { + AIState = HovercraftAIState.SwoopDownward; + } + npc.netUpdate = true; + } + } + + if (AIState == HovercraftAIState.Slowdown) + { + SubphaseTime++; + if (SubphaseTime < 30f) + { + npc.velocity *= 0.96f; + } + else + { + AIState = HovercraftAIState.Hover; + SubphaseTime = 0f; + npc.netUpdate = true; + } + } + + if (AIState == HovercraftAIState.SwoopDownward) + { + npc.rotation = 0f; + float swoopType = Supercharged ? TotalSubphaseTime - 40f : TotalSubphaseTime; + float swoopSlowdownTime = Supercharged ? 10f : 45f; + Vector2 swoopVelocity = Vector2.UnitY.RotatedBy(MathHelper.Pi * SubphaseTime / swoopType * -SearchDirection) * (Supercharged ? 13f : 10f); + + SubphaseTime++; + if (SubphaseTime < swoopSlowdownTime) + { + swoopVelocity *= MathHelper.Lerp(1f, 0.75f, Utils.InverseLerp(45f, 0f, SubphaseTime)); + } + if (SubphaseTime >= swoopType - swoopSlowdownTime) + { + swoopVelocity *= MathHelper.Lerp(1f, 0.75f, Utils.InverseLerp(swoopType - 45f, swoopType, SubphaseTime)); + } + swoopVelocity.Y *= 0.5f; + + npc.velocity = Vector2.Lerp(npc.velocity, swoopVelocity, 0.25f); + + if (SubphaseTime >= swoopType) + { + AIState = HovercraftAIState.Searching; + SearchDirection = 0f; + SubphaseTime = 0f; + npc.netUpdate = true; + } + npc.rotation = npc.velocity.X / 12f; + } + npc.spriteDirection = (npc.velocity.X < 0).ToDirectionInt(); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 2f : 1f; + if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) + return 0f; + return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.025f : 0.125f) * pylonMult; + } + + public override void HitEffect(int hitDirection, double damage) + { + if (!Main.dedServ) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 3, hitDirection, -1f, 0, default, 1f); + } + if (npc.life <= 0) + { + for (int k = 0; k < 20; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 3, hitDirection, -1f, 0, default, 1f); + } + } + } + } + + public override void OnHitByItem(Player player, Item item, int damage, float knockback, bool crit) + { + StunTime = StunTimeMax; + npc.netUpdate = true; + } + + public override void NPCLoot() + { + DropHelper.DropItem(npc, ModContent.ItemType(), 2, 3); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Supercharged); + } + } +} diff --git a/NPCs/NormalNPCs/WulfrumHovercraft.png b/NPCs/NormalNPCs/WulfrumHovercraft.png new file mode 100644 index 0000000000..b3df311349 Binary files /dev/null and b/NPCs/NormalNPCs/WulfrumHovercraft.png differ diff --git a/NPCs/NormalNPCs/WulfrumPylon.cs b/NPCs/NormalNPCs/WulfrumPylon.cs new file mode 100644 index 0000000000..88443a1876 --- /dev/null +++ b/NPCs/NormalNPCs/WulfrumPylon.cs @@ -0,0 +1,160 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Banners; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using System.Collections.Generic; + +namespace CalamityMod.NPCs.NormalNPCs +{ + public class WulfrumPylon : ModNPC + { + public bool Charging + { + get => npc.ai[0] != 0f; + set => npc.ai[0] = value.ToInt(); + } + public float ChargeRadius + { + get => npc.ai[1]; + set => npc.ai[1] = value; + } + public static List SuperchargableEnemies = new List() + { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType() + }; + public const float ChargeRadiusMax = 200f; + public const float SuperchargeTime = 600f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wulfrum Pylon"); + Main.npcFrameCount[npc.type] = 6; + } + + public override void SetDefaults() + { + aiType = -1; + npc.aiStyle = -1; + npc.damage = 16; + npc.width = 44; + npc.height = 44; + npc.defense = 4; + npc.lifeMax = 49; + npc.knockBackResist = 0f; + npc.value = Item.buyPrice(0, 0, 1, 50); + npc.noGravity = false; + npc.noTileCollide = false; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + npc.buffImmune[BuffID.Confused] = false; + banner = npc.type; + bannerItem = ModContent.ItemType(); + } + + public override void AI() + { + npc.TargetClosest(false); + + Player player = Main.player[npc.target]; + + if (!Charging && npc.Distance(player.Center) < ChargeRadiusMax * 0.667f) + { + Charging = true; + npc.netUpdate = true; + } + else if (Charging) + { + ChargeRadius = (int)MathHelper.Lerp(ChargeRadius, ChargeRadiusMax, 0.1f); + + if (Main.rand.NextBool(4)) + { + float dustCount = MathHelper.TwoPi * ChargeRadius / 5f; + for (int i = 0; i < dustCount; i++) + { + float angle = MathHelper.TwoPi * i / dustCount; + Dust dust = Dust.NewDustPerfect(npc.Center, 229); + dust.position = npc.Center + angle.ToRotationVector2() * ChargeRadius; + dust.noGravity = true; + dust.velocity = npc.velocity; + } + } + + for (int i = 0; i < Main.npc.Length; i++) + { + NPC npcAtIndex = Main.npc[i]; + if (!npcAtIndex.active) + continue; + + // For some strange reason, the Wulfrum Rover is not counted when it's added to a static list. + // What I assume is going on is that it hasn't been loaded yet since it's later alphabetically (Pylon is before Rover). + // As a result, they are checked separately. + if (!SuperchargableEnemies.Contains(npcAtIndex.type) && + npcAtIndex.type != ModContent.NPCType()) + continue; + if (npcAtIndex.ai[3] > 0f) + continue; + if (npc.Distance(npcAtIndex.Center) > ChargeRadius) + continue; + + npcAtIndex.ai[3] = SuperchargeTime; // Supercharge the npc for a while if isn't already supercharged. + npcAtIndex.netUpdate = true; + + // And emit some dust. + + // Dust doesn't need to be spawned for the server. + if (Main.dedServ) + continue; + + for (int j = 0; j < 10; j++) + { + Dust.NewDust(npcAtIndex.position, npcAtIndex.width, npcAtIndex.height, 226); + } + } + } + } + + public override void FindFrame(int frameHeight) + { + npc.frameCounter++; + int frame = (int)(npc.frameCounter / 8) % Main.npcFrameCount[npc.type]; + + npc.frame.Y = frame * frameHeight; + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) + return 0f; + + // Only spawn in the other thirds of the world bounds. + if (spawnInfo.playerFloorX > Main.maxTilesX * 0.333f && spawnInfo.playerFloorX < Main.maxTilesX - Main.maxTilesX * 0.333f) + return 0f; + + return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.06f : 0.22f); + } + + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, DustID.GrassBlades, hitDirection, -1f, 0, default, 1f); + } + if (npc.life <= 0) + { + for (int k = 0; k < 15; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, DustID.GrassBlades, hitDirection, -1f, 0, default, 1f); + } + } + } + + public override void NPCLoot() + { + DropHelper.DropItem(npc, ModContent.ItemType(), 2, 3); + DropHelper.DropItem(npc, ModContent.ItemType()); + } + } +} diff --git a/NPCs/NormalNPCs/WulfrumPylon.png b/NPCs/NormalNPCs/WulfrumPylon.png new file mode 100644 index 0000000000..c578407dd3 Binary files /dev/null and b/NPCs/NormalNPCs/WulfrumPylon.png differ diff --git a/NPCs/NormalNPCs/WulfrumRover.cs b/NPCs/NormalNPCs/WulfrumRover.cs new file mode 100644 index 0000000000..1344b783bf --- /dev/null +++ b/NPCs/NormalNPCs/WulfrumRover.cs @@ -0,0 +1,146 @@ +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Banners; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.NPCs.NormalNPCs +{ + public class WulfrumRover : ModNPC + { + public float SuperchargeTimer + { + get => npc.ai[3]; + set => npc.ai[3] = value; + } + public const float PlayerTargetingThreshold = 90f; + public const float PlayerSearchDistance = 500f; + public const float StuckJumpPromptTime = 90f; + public const float MaxMovementSpeedX = 8f; + public bool Supercharged => SuperchargeTimer > 0; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wulfrum Rover"); + Main.npcFrameCount[npc.type] = 16; + } + + public override void SetDefaults() + { + aiType = -1; + npc.aiStyle = -1; + npc.damage = 10; + npc.width = 40; + npc.height = 40; + npc.defense = 4; + npc.lifeMax = 32; + npc.knockBackResist = 0.15f; + npc.value = Item.buyPrice(0, 0, 1, 15); + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + banner = npc.type; + bannerItem = ModContent.ItemType(); + npc.buffImmune[BuffID.Confused] = false; + } + + public override void FindFrame(int frameHeight) + { + npc.frameCounter++; + int frame = (int)(npc.frameCounter / 5) % (Main.npcFrameCount[npc.type] / 2); + if (Supercharged) + frame += Main.npcFrameCount[npc.type] / 2; + + npc.frame.Y = frame * frameHeight; + } + + public override void AI() + { + npc.TargetClosest(false); + + if (Supercharged) + { + SuperchargeTimer--; + npc.defense = 13; + } + else if (!Supercharged) + { + npc.defense = 4; + } + + Player player = Main.player[npc.target]; + if (Collision.CanHitLine(player.position, player.width, player.height, npc.position, npc.width, npc.height) && + Math.Abs(player.Center.X - npc.Center.X) < PlayerSearchDistance && + Math.Abs(player.Center.X - npc.Center.X) > PlayerTargetingThreshold) + { + int direction = Math.Sign(player.Center.X - npc.Center.X) * (npc.confused ? -1 : 1); + if (npc.direction != direction) + { + npc.direction = direction; + npc.netUpdate = true; + } + } + else if (npc.collideX) + { + npc.direction *= -1; + npc.netUpdate = true; + } + + npc.spriteDirection = -npc.direction; + npc.velocity.X = MathHelper.Lerp(npc.velocity.X, MaxMovementSpeedX * npc.direction, 0.015f); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 2f : 1f; + if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) + return 0f; + return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.05f : 0.2f) * pylonMult; + } + + public override void HitEffect(int hitDirection, double damage) + { + if (!Main.dedServ) + { + for (int k = 0; k < 4; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 3, hitDirection, -1f, 0, default, 1f); + } + if (npc.life <= 0) + { + for (int k = 0; k < 20; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 3, hitDirection, -1f, 0, default, 1f); + } + } + } + } + + public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) + { + if (Supercharged) + { + Texture2D shieldTexture = ModContent.GetTexture("CalamityMod/NPCs/NormalNPCs/WulfrumRoverShield"); + Rectangle frame = shieldTexture.Frame(1, 11, 0, (int)(Main.GlobalTime * 8) % 11); + spriteBatch.Draw(shieldTexture, + npc.Center - Main.screenPosition + Vector2.UnitY * (npc.gfxOffY + 6f), + frame, + Color.White * 0.625f, + npc.rotation, + shieldTexture.Size() * 0.5f / new Vector2(1f, 11f), + npc.scale + (float)Math.Cos(Main.GlobalTime) * 0.1f, + SpriteEffects.None, + 0f); + } + } + + public override void NPCLoot() + { + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Supercharged); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + } + } +} diff --git a/NPCs/NormalNPCs/WulfrumRover.png b/NPCs/NormalNPCs/WulfrumRover.png new file mode 100644 index 0000000000..aa460fa07c Binary files /dev/null and b/NPCs/NormalNPCs/WulfrumRover.png differ diff --git a/NPCs/NormalNPCs/WulfrumRoverShield.png b/NPCs/NormalNPCs/WulfrumRoverShield.png new file mode 100644 index 0000000000..9a824907ea Binary files /dev/null and b/NPCs/NormalNPCs/WulfrumRoverShield.png differ diff --git a/NPCs/NormalNPCs/WulfrumSlime.cs b/NPCs/NormalNPCs/WulfrumSlime.cs index 9202d0bb22..8ac0ef9fb2 100644 --- a/NPCs/NormalNPCs/WulfrumSlime.cs +++ b/NPCs/NormalNPCs/WulfrumSlime.cs @@ -5,64 +5,65 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class WulfrumSlime : ModNPC - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Wulfrum Slime"); - Main.npcFrameCount[npc.type] = 2; - } + public class WulfrumSlime : ModNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wulfrum Slime"); + Main.npcFrameCount[npc.type] = 2; + } - public override void SetDefaults() - { - npc.aiStyle = 1; - npc.damage = 8; - npc.width = 30; - npc.height = 22; - npc.defense = 2; - npc.lifeMax = 12; - npc.knockBackResist = 0f; - animationType = NPCID.CorruptSlime; - npc.value = Item.buyPrice(0, 0, 0, 30); - npc.alpha = 60; - npc.lavaImmune = false; - npc.noGravity = false; - npc.noTileCollide = false; - npc.HitSound = SoundID.NPCHit1; - npc.DeathSound = SoundID.NPCDeath1; - banner = npc.type; - bannerItem = ModContent.ItemType(); - npc.buffImmune[BuffID.Confused] = false; - } + public override void SetDefaults() + { + npc.aiStyle = 1; + npc.damage = 8; + npc.width = 30; + npc.height = 22; + npc.defense = 2; + npc.lifeMax = 12; + npc.knockBackResist = 0f; + animationType = NPCID.CorruptSlime; + npc.value = Item.buyPrice(0, 0, 0, 30); + npc.alpha = 60; + npc.lavaImmune = false; + npc.noGravity = false; + npc.noTileCollide = false; + npc.HitSound = SoundID.NPCHit1; + npc.DeathSound = SoundID.NPCDeath1; + banner = npc.type; + bannerItem = ModContent.ItemType(); + npc.buffImmune[BuffID.Confused] = false; + } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) - { - return 0f; - } - return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.08f : 0.33f); - } + /*public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 2f : 1f; + if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) + { + return 0f; + } + return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.08f : 0.33f) * pylonMult; + }*/ - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 3, hitDirection, -1f, 0, default, 1f); - } - if (npc.life <= 0) - { - for (int k = 0; k < 15; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 3, hitDirection, -1f, 0, default, 1f); - } - } - } + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 3, hitDirection, -1f, 0, default, 1f); + } + if (npc.life <= 0) + { + for (int k = 0; k < 15; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, 3, hitDirection, -1f, 0, default, 1f); + } + } + } - public override void NPCLoot() - { - DropHelper.DropItem(npc, ModContent.ItemType(), 1, 1); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, 0.5f, 1, 1); - } - } + public override void NPCLoot() + { + DropHelper.DropItem(npc, ModContent.ItemType(), 1, 1); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, 0.5f, 1, 1); + } + } } diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs index 3b4a0d1001..14a4b61a6a 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs @@ -80,6 +80,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.noGravity = true; diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerShade.cs b/NPCs/PlaguebringerGoliath/PlaguebringerShade.cs index b39009f77d..c239471a9a 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerShade.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerShade.cs @@ -61,6 +61,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.noGravity = true; diff --git a/NPCs/Polterghast/PolterPhantom.cs b/NPCs/Polterghast/PolterPhantom.cs index 1290ff6cfc..0de5edf868 100644 --- a/NPCs/Polterghast/PolterPhantom.cs +++ b/NPCs/Polterghast/PolterPhantom.cs @@ -44,6 +44,7 @@ namespace CalamityMod.NPCs.Polterghast npc.buffImmune[BuffID.CursedInferno] = false; npc.buffImmune[BuffID.Daybreak] = false; npc.buffImmune[BuffID.StardustMinionBleed] = false; + npc.buffImmune[BuffID.BetsysCurse] = false; npc.buffImmune[BuffID.Oiled] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; diff --git a/NPCs/Polterghast/Polterghast.cs b/NPCs/Polterghast/Polterghast.cs index 18dfbde209..46ec7ec2d7 100644 --- a/NPCs/Polterghast/Polterghast.cs +++ b/NPCs/Polterghast/Polterghast.cs @@ -67,6 +67,7 @@ namespace CalamityMod.NPCs.Polterghast npc.buffImmune[BuffID.CursedInferno] = false; npc.buffImmune[BuffID.Daybreak] = false; npc.buffImmune[BuffID.StardustMinionBleed] = false; + npc.buffImmune[BuffID.BetsysCurse] = false; npc.buffImmune[BuffID.Oiled] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs index f64a523829..9bd4a810ff 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs @@ -70,6 +70,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.value = Item.buyPrice(0, 25, 0, 0); diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs index 9c5eeadece..e49436ef05 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs @@ -63,6 +63,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.HitSound = SoundID.NPCHit52; diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs index 5e20f63e61..08be31b070 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs @@ -63,6 +63,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.HitSound = SoundID.NPCHit52; diff --git a/NPCs/Providence/ProvSpawnDefense.cs b/NPCs/Providence/ProvSpawnDefense.cs index f13cdc8d20..693765e465 100644 --- a/NPCs/Providence/ProvSpawnDefense.cs +++ b/NPCs/Providence/ProvSpawnDefense.cs @@ -46,6 +46,7 @@ namespace CalamityMod.NPCs.Providence npc.buffImmune[BuffID.Ichor] = false; npc.buffImmune[BuffID.CursedInferno] = false; npc.buffImmune[BuffID.StardustMinionBleed] = false; + npc.buffImmune[BuffID.Oiled] = false; npc.buffImmune[BuffID.BetsysCurse] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; @@ -54,6 +55,7 @@ namespace CalamityMod.NPCs.Providence npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.HitSound = SoundID.NPCHit52; diff --git a/NPCs/Providence/ProvSpawnHealer.cs b/NPCs/Providence/ProvSpawnHealer.cs index cdff9f17c6..c96e2456f8 100644 --- a/NPCs/Providence/ProvSpawnHealer.cs +++ b/NPCs/Providence/ProvSpawnHealer.cs @@ -55,6 +55,7 @@ namespace CalamityMod.NPCs.Providence npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.HitSound = SoundID.NPCHit52; diff --git a/NPCs/Providence/ProvSpawnOffense.cs b/NPCs/Providence/ProvSpawnOffense.cs index c3817fdd76..f1d2ecf919 100644 --- a/NPCs/Providence/ProvSpawnOffense.cs +++ b/NPCs/Providence/ProvSpawnOffense.cs @@ -58,6 +58,7 @@ namespace CalamityMod.NPCs.Providence npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.HitSound = SoundID.NPCHit52; diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 97d36946ad..08b830ed59 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -92,6 +92,7 @@ namespace CalamityMod.NPCs.Providence npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.noGravity = true; diff --git a/NPCs/Ravager/RavagerBody.cs b/NPCs/Ravager/RavagerBody.cs index a03b512b93..0b96fbe8b6 100644 --- a/NPCs/Ravager/RavagerBody.cs +++ b/NPCs/Ravager/RavagerBody.cs @@ -77,6 +77,7 @@ namespace CalamityMod.NPCs.Ravager npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.boss = true; diff --git a/NPCs/Ravager/RavagerClawLeft.cs b/NPCs/Ravager/RavagerClawLeft.cs index a2b2b97661..75b6fbe069 100644 --- a/NPCs/Ravager/RavagerClawLeft.cs +++ b/NPCs/Ravager/RavagerClawLeft.cs @@ -48,6 +48,7 @@ namespace CalamityMod.NPCs.Ravager npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.noGravity = true; diff --git a/NPCs/Ravager/RavagerClawRight.cs b/NPCs/Ravager/RavagerClawRight.cs index d8ad21ba85..caeafb145c 100644 --- a/NPCs/Ravager/RavagerClawRight.cs +++ b/NPCs/Ravager/RavagerClawRight.cs @@ -48,6 +48,7 @@ namespace CalamityMod.NPCs.Ravager npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.noGravity = true; diff --git a/NPCs/Ravager/RavagerHead.cs b/NPCs/Ravager/RavagerHead.cs index 8bf80ad127..46d19d2639 100644 --- a/NPCs/Ravager/RavagerHead.cs +++ b/NPCs/Ravager/RavagerHead.cs @@ -47,6 +47,7 @@ namespace CalamityMod.NPCs.Ravager npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.noGravity = true; diff --git a/NPCs/Ravager/RavagerLegLeft.cs b/NPCs/Ravager/RavagerLegLeft.cs index 1fc5f5d55e..33f5f05a1c 100644 --- a/NPCs/Ravager/RavagerLegLeft.cs +++ b/NPCs/Ravager/RavagerLegLeft.cs @@ -46,6 +46,7 @@ namespace CalamityMod.NPCs.Ravager npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.noGravity = true; npc.canGhostHeal = false; diff --git a/NPCs/Ravager/RavagerLegRight.cs b/NPCs/Ravager/RavagerLegRight.cs index a9d8ab3e9d..c3d8445d1f 100644 --- a/NPCs/Ravager/RavagerLegRight.cs +++ b/NPCs/Ravager/RavagerLegRight.cs @@ -46,6 +46,7 @@ namespace CalamityMod.NPCs.Ravager npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.noGravity = true; npc.canGhostHeal = false; diff --git a/NPCs/Signus/Signus.cs b/NPCs/Signus/Signus.cs index 1291d17118..a2404f48ce 100644 --- a/NPCs/Signus/Signus.cs +++ b/NPCs/Signus/Signus.cs @@ -81,6 +81,7 @@ namespace CalamityMod.NPCs.Signus npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; + npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.buffImmune[ModContent.BuffType()] = false; npc.noGravity = true; diff --git a/NPCs/StormWeaver/StasisProbe.cs b/NPCs/StormWeaver/StasisProbe.cs index b35d0c287c..55a130d888 100644 --- a/NPCs/StormWeaver/StasisProbe.cs +++ b/NPCs/StormWeaver/StasisProbe.cs @@ -238,7 +238,7 @@ namespace CalamityMod.NPCs.StormWeaver Main.dust[num624].velocity *= 2f; } Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/StasisProbe1"),1f); - npc.ExplosionGores(1); + CalamityUtils.ExplosionGores(npc.Center, 1); } } diff --git a/NPCs/StormWeaver/StasisProbeNaked.cs b/NPCs/StormWeaver/StasisProbeNaked.cs index 708b3b2166..aeb40c143d 100644 --- a/NPCs/StormWeaver/StasisProbeNaked.cs +++ b/NPCs/StormWeaver/StasisProbeNaked.cs @@ -238,7 +238,7 @@ namespace CalamityMod.NPCs.StormWeaver Main.dust[num624].velocity *= 2f; } Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/StasisProbeNaked1"), 1f); - npc.ExplosionGores(1); + CalamityUtils.ExplosionGores(npc.Center, 1); } } diff --git a/NPCs/SulphurousSea/Mauler.cs b/NPCs/SulphurousSea/Mauler.cs index bb7a967fe0..aefec17e21 100644 --- a/NPCs/SulphurousSea/Mauler.cs +++ b/NPCs/SulphurousSea/Mauler.cs @@ -147,25 +147,25 @@ namespace CalamityMod.NPCs.SulphurousSea } else { - npc.velocity.X = npc.velocity.X + (float)npc.direction * 0.2f; + npc.velocity.X += (float)npc.direction * 0.2f; if (npc.velocity.X < -4f || npc.velocity.X > 4f) { - npc.velocity.X = npc.velocity.X * 0.95f; + npc.velocity.X *= 0.95f; } if (npc.ai[0] == -1f) { - npc.velocity.Y = npc.velocity.Y - 0.01f; - if ((double)npc.velocity.Y < -0.3) - { - npc.ai[0] = 1f; - } - } - else - { - npc.velocity.Y = npc.velocity.Y + 0.01f; - if ((double)npc.velocity.Y > 0.3) - { - npc.ai[0] = -1f; + npc.velocity.Y -= 0.01f; + if (npc.velocity.Y < -0.3f) + { + npc.ai[0] = 1f; + } + } + else + { + npc.velocity.Y += 0.01f; + if (npc.velocity.Y > 0.3f) + { + npc.ai[0] = -1f; } } } @@ -194,9 +194,9 @@ namespace CalamityMod.NPCs.SulphurousSea npc.ai[0] = -1f; } } - if ((double)npc.velocity.Y > 0.4 || (double)npc.velocity.Y < -0.4) + if (npc.velocity.Y > 0.4f || npc.velocity.Y < -0.4f) { - npc.velocity.Y = npc.velocity.Y * 0.95f; + npc.velocity.Y *= 0.95f; } } else @@ -261,11 +261,11 @@ namespace CalamityMod.NPCs.SulphurousSea } } npc.rotation = npc.velocity.Y * (float)npc.direction * 0.1f; - if ((double)npc.rotation < -0.2) + if (npc.rotation < -0.2f) { npc.rotation = -0.2f; } - if ((double)npc.rotation > 0.2) + if (npc.rotation > 0.2f) { npc.rotation = 0.2f; return; @@ -303,7 +303,7 @@ namespace CalamityMod.NPCs.SulphurousSea } for (int num621 = 0; num621 < 25; num621++) { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 31, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(npc.position, npc.width, npc.height, 31, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -314,10 +314,10 @@ namespace CalamityMod.NPCs.SulphurousSea } for (int num623 = 0; num623 < 50; num623++) { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 5, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 5, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; Main.dust[num624].noGravity = true; } @@ -351,7 +351,7 @@ namespace CalamityMod.NPCs.SulphurousSea public override void NPCLoot() { DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedPolterghast, 3, 1, 1); - int item = Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.SharkFin, Main.rand.Next(2, 5), false, 0, false, false); + int item = Item.NewItem(npc.Center, npc.Size, ItemID.SharkFin, Main.rand.Next(2, 5), false, 0, false, false); Main.item[item].color = new Color(151, 115, 57, 255); NetMessage.SendData(88, -1, -1, null, item, 1f, 0f, 0f, 0, 0, 0); } diff --git a/NPCs/SunkenSea/GiantClam.cs b/NPCs/SunkenSea/GiantClam.cs index c2d3aa4716..ae08fbb541 100644 --- a/NPCs/SunkenSea/GiantClam.cs +++ b/NPCs/SunkenSea/GiantClam.cs @@ -427,6 +427,7 @@ namespace CalamityMod.NPCs.SunkenSea // Mark Giant Clam as dead CalamityWorld.downedCLAM = true; + CalamityWorld.downedCLAMHardMode = Main.hardMode || CalamityWorld.downedCLAMHardMode; CalamityMod.UpdateServerBoolean(); } } diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 09b830060a..70d40aece3 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -227,6 +227,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas CalamityMod.StopRain(); bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; + bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; bool death = CalamityWorld.death || CalamityWorld.bossRushActive; bool enraged = npc.Calamity().enraged > 0 || (CalamityConfig.Instance.BossRushXerocCurse && CalamityWorld.bossRushActive); Vector2 vectorCenter = npc.Center; @@ -677,7 +678,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas { Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1000), player.position.Y - 1000f, 0f, 10f * uDieLul, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); } - if (bulletHellCounter2 % 225 == 0 && expertMode) //giant homing fireballs + int divisor = revenge ? 225 : expertMode ? 450 : 675; + if (bulletHellCounter2 % divisor == 0 && expertMode) //giant homing fireballs { Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1000), player.position.Y - 1000f, 0f, 1f * uDieLul, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, passedVar); passedVar += 1f; @@ -2197,7 +2199,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Weapons // All non-hybrid weapons are listed twice so that the drop rates are actually equal between each unique weapon - DropHelper.DropItemFromSetCondition(npc, Main.expertMode, + DropHelper.DropItemFromSetCondition(npc, true, Main.expertMode, ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), @@ -2219,11 +2221,11 @@ namespace CalamityMod.NPCs.SupremeCalamitas ModContent.ItemType(), ModContent.ItemType(), //Temporal Umbrella ModContent.ItemType(), ModContent.ItemType() ); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), Main.expertMode, CalamityWorld.revenge); // Vanity - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.death); + DropHelper.DropItem(npc, ModContent.ItemType(), Main.expertMode); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.death); // Other DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); diff --git a/NPCs/TownNPCs/DILF.cs b/NPCs/TownNPCs/DILF.cs index f1839bb6de..f042fc5f0c 100644 --- a/NPCs/TownNPCs/DILF.cs +++ b/NPCs/TownNPCs/DILF.cs @@ -52,19 +52,21 @@ namespace CalamityMod.NPCs.TownNPCs animationType = NPCID.Guide; } - public override bool CanTownNPCSpawn(int numTownNPCs, int money) - { - return CalamityWorld.downedCryogen; - } + public override void AI() + { + if (!CalamityWorld.foundHomePermafrost && !npc.homeless) + { + CalamityWorld.foundHomePermafrost = true; + } + } - public override string TownNPCName() - { - return "Permafrost"; - } + public override bool CanTownNPCSpawn(int numTownNPCs, int money) => CalamityWorld.downedCryogen; + + public override string TownNPCName() => "Permafrost"; public override string GetChat() { - if (npc.homeless) //not sure how to check if he has ever found a home before (to make this dialogue only run when he first spawns) + if (npc.homeless && !CalamityWorld.foundHomePermafrost) { if (Main.rand.NextBool(2)) return "I deeply appreciate you rescuing me from being trapped within my frozen castle... It's been many, many years..."; diff --git a/NPCs/TownNPCs/THIEF.cs b/NPCs/TownNPCs/THIEF.cs index f4a75b7319..417d4f3a62 100644 --- a/NPCs/TownNPCs/THIEF.cs +++ b/NPCs/TownNPCs/THIEF.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.TownNPCs "Penelope", "Marisa", "Maribel", "Valerie", "Jessica", "Rowan", "Jessie", "Jade", "Hearn", - "Amber", "Anne", "Indiana", + "Amber", "Anne", "Indiana", "Xplizzy" }; public override void SetStaticDefaults() @@ -252,6 +252,8 @@ namespace CalamityMod.NPCs.TownNPCs shop.item[nextSlot].SetDefaults(ModContent.ItemType()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 40, 0, 0); nextSlot++; + shop.item[nextSlot].SetDefaults(ItemID.TigerClimbingGear); + nextSlot++; if (CalamityWorld.downedSlimeGod) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 40b95c9754..17b23cde45 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -2825,11 +2825,11 @@ namespace CalamityMod.NPCs.Yharon DropHelper.DropItem(npc, ModContent.ItemType(), true, soulFragMin, soulFragMax); // Equipment - DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType(), Main.expertMode); // Weapons - DropHelper.DropItemChance(npc, ModContent.ItemType(), DropHelper.RareVariantDropRateInt); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 100); //not affected by defiled and not a leggie + DropHelper.DropItemChance(npc, ModContent.ItemType(), Main.expertMode, DropHelper.RareVariantDropRateInt); + DropHelper.DropItemChance(npc, ModContent.ItemType(), Main.expertMode, 100); //not affected by defiled and not a leggie // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); diff --git a/Projectiles/BaseProjectiles/BaseLaserbeamProjectile.cs b/Projectiles/BaseProjectiles/BaseLaserbeamProjectile.cs index 2bdecf4355..3abf6c5637 100644 --- a/Projectiles/BaseProjectiles/BaseLaserbeamProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseLaserbeamProjectile.cs @@ -1,6 +1,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; +using System.Linq; using Terraria; using Terraria.Enums; using Terraria.ModLoader; @@ -9,6 +10,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles { public abstract class BaseLaserbeamProjectile : ModProjectile { + #region Auto-Properties public float RotationalSpeed { get => projectile.ai[0]; @@ -24,6 +26,13 @@ namespace CalamityMod.Projectiles.BaseProjectiles get => projectile.localAI[1]; set => projectile.localAI[1] = value; } + #endregion + + #region Virtual Methods + + /// + /// Handles all AI logic for the laser. Can be overridden, but you probably won't need to do that. + /// public virtual void Behavior() { // Attach to some arbitrary thing/position optionally. (The ai[1] value is a reserved for this in vanilla's Phantasmal Deathray) @@ -49,18 +58,25 @@ namespace CalamityMod.Projectiles.BaseProjectiles DelegateMethods.v3_1 = LightCastColor.ToVector3(); Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * LaserLength, projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); } + + /// + /// Handles movement logic for the laser. By default causes arcing/sweeping motiom. + /// public virtual void UpdateLaserMotion() { // This part is rather complicated at a glance. // What it's doing is converting the velocity to an angle, doing something with that angle, and changing it back into the velocity. - // In this case, "doing something with that angle" means incrementing it by a constant. + // In this case, "doing something with that angle" means incrementing it by a constant. This allows the laser to perform "arcing" motion. // You could attempt to make it intelligent by having it move towards the target like the Last Prism, but that's not done here. - // This allows one to cause an arcing motion. float updatedVelocityDirection = projectile.velocity.ToRotation() + RotationalSpeed; projectile.rotation = updatedVelocityDirection - MathHelper.PiOver2; // Pretty much all lasers have a vertical sheet. projectile.velocity = updatedVelocityDirection.ToRotationVector2(); } + + /// + /// Calculates the total scale of the laser. By default uses a clamped sine of time. + /// public virtual void DetermineScale() { projectile.scale = (float)Math.Sin(Time / Lifetime * MathHelper.Pi) * 6f * MaxScale; @@ -69,14 +85,49 @@ namespace CalamityMod.Projectiles.BaseProjectiles projectile.scale = MaxScale; } } - public virtual void AttachToSomething() { } // Does nothing by default. - public virtual float DetermineLaserLength() => MaxLaserLength; // Go with the default length and ignore any obstacles by default. + + /// + /// Handles direct attachment to things. The projectile.ai[1] array index is reserved for this. Does nothing by default. + /// + public virtual void AttachToSomething() { } + + /// + /// Calculates the current laser's length. By default does not collide with tiles. is a generic laser collision method if you want to do that. + /// + /// The laser length as a float. + public virtual float DetermineLaserLength() => MaxLaserLength; + + /// + /// An extra, empty by default method that exists so that a developer can add custom code after all typical AI logic is done. Think of it like PostAI. + /// public virtual void ExtraBehavior() { } + #endregion + + #region Helper Methods + + /// + /// Calculates the laser length while taking tiles into account. + /// + /// The amount of samples the ray uses. The higher this is, the more precision, but also more calculations done. + public float DetermineLaserLength_CollideWithTiles(int samplePointCount) + { + float[] laserLengthSamplePoints = new float[samplePointCount]; + Collision.LaserScan(projectile.Center, projectile.velocity, projectile.scale, MaxLaserLength, laserLengthSamplePoints); + return laserLengthSamplePoints.Average(); + } + #endregion + + #region Hook Overrides public override void AI() { Behavior(); ExtraBehavior(); } + public override void CutTiles() + { + DelegateMethods.tilecut_0 = TileCuttingContext.AttackMelee; + Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * LaserLength, projectile.Size.Length() * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { // This should never happen, but just in case- @@ -84,13 +135,13 @@ namespace CalamityMod.Projectiles.BaseProjectiles return false; // Start texture drawing. - spriteBatch.Draw(LaserBeginTexture, - projectile.Center - Main.screenPosition, + spriteBatch.Draw(LaserBeginTexture, + projectile.Center - Main.screenPosition, null, LaserOverlayColor, projectile.rotation, LaserBeginTexture.Size() / 2f, - projectile.scale, + projectile.scale, SpriteEffects.None, 0f); @@ -107,13 +158,13 @@ namespace CalamityMod.Projectiles.BaseProjectiles float incrementalBodyLength = 0f; while (incrementalBodyLength + 1f < laserBodyLength) { - spriteBatch.Draw(LaserMiddleTexture, - centerOnLaser - Main.screenPosition, - null, - LaserOverlayColor, + spriteBatch.Draw(LaserMiddleTexture, + centerOnLaser - Main.screenPosition, + null, + LaserOverlayColor, projectile.rotation, - LaserMiddleTexture.Width * 0.5f * Vector2.UnitX, - projectile.scale, + LaserMiddleTexture.Width * 0.5f * Vector2.UnitX, + projectile.scale, SpriteEffects.None, 0f); incrementalBodyLength += laserOffset; @@ -137,25 +188,16 @@ namespace CalamityMod.Projectiles.BaseProjectiles } return false; } - public override void CutTiles() - { - DelegateMethods.tilecut_0 = TileCuttingContext.AttackMelee; - Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * LaserLength, projectile.Size.Length() * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); - } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { if (projHitbox.Intersects(targetHitbox)) return true; float unused = 69420f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * LaserLength, projectile.Size.Length() * projectile.scale, ref unused)) - { - return true; - } - return false; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * LaserLength, projectile.Size.Length() * projectile.scale, ref unused); } + #endregion - #region Virtual Values + #region Virtual Properties public virtual float Lifetime => 120f; public virtual float MaxScale => 1f; public virtual float MaxLaserLength => 2400f; // Be careful with this. Going too high will cause lag. diff --git a/Projectiles/Boss/BrimstoneMonster.cs b/Projectiles/Boss/BrimstoneMonster.cs index 0bd500e3be..82cf189fc3 100644 --- a/Projectiles/Boss/BrimstoneMonster.cs +++ b/Projectiles/Boss/BrimstoneMonster.cs @@ -9,57 +9,57 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class BrimstoneMonster : ModProjectile - { - private float speedAdd = 0f; - private float speedLimit = 0f; + public class BrimstoneMonster : ModProjectile + { + private float speedAdd = 0f; + private float speedLimit = 0f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Brimstone Monster"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Brimstone Monster"); + } - public override void SetDefaults() - { - projectile.width = 320; - projectile.height = 320; - projectile.hostile = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.timeLeft = 36000; - projectile.Opacity = 0f; - cooldownSlot = 1; - } + public override void SetDefaults() + { + projectile.width = 320; + projectile.height = 320; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.timeLeft = 36000; + projectile.Opacity = 0f; + cooldownSlot = 1; + } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(speedAdd); - writer.Write(projectile.localAI[0]); - writer.Write(speedLimit); - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(speedAdd); + writer.Write(projectile.localAI[0]); + writer.Write(speedLimit); + } - public override void ReceiveExtraAI(BinaryReader reader) - { - speedAdd = reader.ReadSingle(); - projectile.localAI[0] = reader.ReadSingle(); - speedLimit = reader.ReadSingle(); - } + public override void ReceiveExtraAI(BinaryReader reader) + { + speedAdd = reader.ReadSingle(); + projectile.localAI[0] = reader.ReadSingle(); + speedLimit = reader.ReadSingle(); + } - public override void AI() - { - if (!CalamityPlayer.areThereAnyDamnBosses) - { - projectile.active = false; - projectile.netUpdate = true; - return; - } + public override void AI() + { + if (!CalamityPlayer.areThereAnyDamnBosses) + { + projectile.active = false; + projectile.netUpdate = true; + return; + } int choice = (int)projectile.ai[1]; if (projectile.localAI[0] == 0f) { projectile.soundDelay = 1125 - (choice * 225); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/BrimstoneMonsterSpawn"), (int)projectile.Center.X, (int)projectile.Center.Y); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/BrimstoneMonsterSpawn"), projectile.Center); projectile.localAI[0] += 1f; switch (choice) { @@ -86,21 +86,21 @@ namespace CalamityMod.Projectiles.Boss if (projectile.soundDelay <= 0 && (choice == 0 || choice == 2)) { projectile.soundDelay = 420; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/BrimstoneMonsterDrone"), (int)projectile.Center.X, (int)projectile.Center.Y); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/BrimstoneMonsterDrone"), projectile.Center); } - bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; + bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; - Lighting.AddLight(projectile.Center, 3f, 0f, 0f); + Lighting.AddLight(projectile.Center, 3f, 0f, 0f); - float num953 = (revenge ? 5f : 4.5f) + speedAdd; //100 - float scaleFactor12 = (revenge ? 1.5f : 1.35f) + (speedAdd * 0.25f); //5 - float num954 = 160f; + float inertia = (revenge ? 5f : 4.5f) + speedAdd; //100 + float speed = (revenge ? 1.5f : 1.35f) + (speedAdd * 0.25f); //5 + float minDist = 160f; if (NPC.AnyNPCs(ModContent.NPCType())) { - num953 *= 0.5f; - scaleFactor12 *= 0.5f; + inertia *= 0.5f; + speed *= 0.5f; } if (projectile.timeLeft < 90) @@ -108,92 +108,94 @@ namespace CalamityMod.Projectiles.Boss else projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 35910) / 90f), 0f, 1f); - int num959 = (int)projectile.ai[0]; - if (num959 >= 0 && Main.player[num959].active && !Main.player[num959].dead) - { - if (projectile.Distance(Main.player[num959].Center) > num954) - { - Vector2 vector102 = projectile.DirectionTo(Main.player[num959].Center); - if (vector102.HasNaNs()) - vector102 = Vector2.UnitY; + int target = (int)projectile.ai[0]; + if (target >= 0 && Main.player[target].active && !Main.player[target].dead) + { + if (projectile.Distance(Main.player[target].Center) > minDist) + { + Vector2 targetVec = projectile.DirectionTo(Main.player[target].Center); + if (targetVec.HasNaNs()) + targetVec = Vector2.UnitY; - projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953; - } - } - else - { - if (projectile.ai[0] != -1f) - { - projectile.ai[0] = -1f; - projectile.netUpdate = true; - } - } + projectile.velocity = (projectile.velocity * (inertia - 1f) + targetVec * speed) / inertia; + } + } + else + { + if (projectile.ai[0] != -1f) + { + projectile.ai[0] = -1f; + projectile.netUpdate = true; + } + } // Fly away from other brimstone monsters - float velocity = 0.05f; - for (int i = 0; i < Main.maxProjectiles; i++) + float pushForce = 0.05f; + for (int k = 0; k < Main.maxProjectiles; k++) { - if (Main.projectile[i].active) - { - if (i != projectile.whoAmI && Main.projectile[i].type == projectile.type) - { - if (Vector2.Distance(projectile.Center, Main.projectile[i].Center) < 320f) - { - if (projectile.position.X < Main.projectile[i].position.X) - projectile.velocity.X -= velocity; - else - projectile.velocity.X += velocity; + Projectile otherProj = Main.projectile[k]; + // Short circuits to make the loop as fast as possible + if (!otherProj.active || k == projectile.whoAmI) + continue; - if (projectile.position.Y < Main.projectile[i].position.Y) - projectile.velocity.Y -= velocity; - else - projectile.velocity.Y += velocity; - } - } + // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away. + bool sameProjType = otherProj.type == projectile.type; + float taxicabDist = Vector2.Distance(projectile.Center, otherProj.Center); + if (sameProjType && taxicabDist < 320f) + { + if (projectile.position.X < otherProj.position.X) + projectile.velocity.X -= pushForce; + else + projectile.velocity.X += pushForce; + + if (projectile.position.Y < otherProj.position.Y) + projectile.velocity.Y -= pushForce; + else + projectile.velocity.Y += pushForce; } } } - 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()); + 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 minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; - return minDist <= 170f; - } + return minDist <= 170f; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D tex = Main.projectileTexture[projectile.type]; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D tex = Main.projectileTexture[projectile.type]; lightColor.R = (byte)(255 * projectile.Opacity); spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); - return false; - } + return false; + } public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; public override void OnHitPlayer(Player target, int damage, bool crit) - { + { if (projectile.Opacity != 1f) return; target.AddBuff(ModContent.BuffType(), 900); - target.AddBuff(ModContent.BuffType(), 300, true); - } + target.AddBuff(ModContent.BuffType(), 300, true); + } - public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) - { + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { target.Calamity().lastProjectileHit = projectile; } - } + } } diff --git a/Projectiles/Boss/FlareBomb.cs b/Projectiles/Boss/FlareBomb.cs index 678ce0689a..00b8164505 100644 --- a/Projectiles/Boss/FlareBomb.cs +++ b/Projectiles/Boss/FlareBomb.cs @@ -144,7 +144,7 @@ namespace CalamityMod.Projectiles.Boss projectile.Damage(); for (int num621 = 0; num621 < 3; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -154,13 +154,13 @@ namespace CalamityMod.Projectiles.Boss } for (int num623 = 0; num623 < 5; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitPlayer(Player target, int damage, bool crit) diff --git a/Projectiles/Boss/FlareDust.cs b/Projectiles/Boss/FlareDust.cs index 8f5553b635..ef1fb85b8e 100644 --- a/Projectiles/Boss/FlareDust.cs +++ b/Projectiles/Boss/FlareDust.cs @@ -127,7 +127,7 @@ namespace CalamityMod.Projectiles.Boss projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); for (int num621 = 0; num621 < 2; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -137,13 +137,13 @@ namespace CalamityMod.Projectiles.Boss } for (int num623 = 0; num623 < 4; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); projectile.damage = Main.expertMode ? 75 : 90; projectile.Damage(); } diff --git a/Projectiles/Boss/FlareDust2.cs b/Projectiles/Boss/FlareDust2.cs index 2443e6de78..ff2ed24cc2 100644 --- a/Projectiles/Boss/FlareDust2.cs +++ b/Projectiles/Boss/FlareDust2.cs @@ -137,7 +137,7 @@ namespace CalamityMod.Projectiles.Boss projectile.Damage(); for (int num621 = 0; num621 < 2; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -147,13 +147,13 @@ namespace CalamityMod.Projectiles.Boss } for (int num623 = 0; num623 < 4; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitPlayer(Player target, int damage, bool crit) diff --git a/Projectiles/Boss/HiveBombGoliath.cs b/Projectiles/Boss/HiveBombGoliath.cs index 706050c1d3..383f5dfa4a 100644 --- a/Projectiles/Boss/HiveBombGoliath.cs +++ b/Projectiles/Boss/HiveBombGoliath.cs @@ -62,13 +62,13 @@ namespace CalamityMod.Projectiles.Boss } else if (Main.rand.NextBool(4)) { - int num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 0.5f); + int num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 0.5f); Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].noGravity = true; Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default) * 1.1f; Main.rand.Next(2); - num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); + num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].noGravity = true; Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default) * 1.1f; @@ -97,7 +97,7 @@ namespace CalamityMod.Projectiles.Boss Main.PlaySound(SoundID.Item14, projectile.position); for (int num621 = 0; num621 < 8; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -107,13 +107,13 @@ namespace CalamityMod.Projectiles.Boss } for (int num623 = 0; num623 < 10; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 89, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitPlayer(Player target, int damage, bool crit) diff --git a/Projectiles/Boss/MoltenBlast.cs b/Projectiles/Boss/MoltenBlast.cs index c22cb912a6..b79d1986e2 100644 --- a/Projectiles/Boss/MoltenBlast.cs +++ b/Projectiles/Boss/MoltenBlast.cs @@ -57,9 +57,9 @@ namespace CalamityMod.Projectiles.Boss int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; if (projectile.ai[1] == 0f) { - for (int num621 = 0; num621 < 10; num621++) + for (int d = 0; d < 10; d++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -106,19 +106,13 @@ namespace CalamityMod.Projectiles.Boss public override void Kill(int timeLeft) { - int num251 = Main.rand.Next(5, 10); + int blobAmt = Main.rand.Next(5, 10); if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < num251; num252++) + for (int b = 0; b < blobAmt; b++) { - Vector2 value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= Main.rand.Next(70, 121) * 0.1f; //70 101 - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 0f, 0f); } } Main.PlaySound(SoundID.Item20, projectile.Center); @@ -126,14 +120,14 @@ namespace CalamityMod.Projectiles.Boss int dustType = Main.dayTime ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; for (int num193 = 0; num193 < 3; num193++) { - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 50, default, 1.5f); + Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 50, default, 1.5f); } for (int num194 = 0; num194 < 30; num194++) { - int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 2.5f); + int num195 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 0, default, 2.5f); Main.dust[num195].noGravity = true; Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 50, default, 1.5f); + num195 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 50, default, 1.5f); Main.dust[num195].velocity *= 2f; Main.dust[num195].noGravity = true; } diff --git a/Projectiles/Boss/ScavengerNuke.cs b/Projectiles/Boss/ScavengerNuke.cs index 9b78527422..7eb944406a 100644 --- a/Projectiles/Boss/ScavengerNuke.cs +++ b/Projectiles/Boss/ScavengerNuke.cs @@ -104,7 +104,7 @@ namespace CalamityMod.Projectiles.Boss projectile.Damage(); for (int num621 = 0; num621 < 30; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -114,13 +114,13 @@ namespace CalamityMod.Projectiles.Boss } for (int num623 = 0; num623 < 40; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } } diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index eeb0eb52bf..860127a9d0 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -9,6 +9,7 @@ using CalamityMod.Projectiles.Hybrid; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Melee.Yoyos; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; @@ -78,13 +79,13 @@ namespace CalamityMod.Projectiles public bool overridesMinionDamagePrevention = false; #region SetDefaults - public override void SetDefaults(Projectile projectile) - { + public override void SetDefaults(Projectile projectile) + { if (CalamityMod.trueMeleeProjectileList.Contains(projectile.type)) trueMelee = true; - switch (projectile.type) - { + switch (projectile.type) + { case ProjectileID.ShadowBeamHostile: projectile.timeLeft = 60; break; @@ -97,23 +98,24 @@ namespace CalamityMod.Projectiles projectile.extraUpdates = 1; break; - case ProjectileID.StarWrath: - projectile.penetrate = projectile.maxPenetrate = 1; - break; + case ProjectileID.StarWrath: + projectile.penetrate = projectile.maxPenetrate = 1; + break; - case ProjectileID.Spazmamini: - case ProjectileID.Retanimini: - case ProjectileID.MiniRetinaLaser: - projectile.localNPCHitCooldown = 10; - projectile.usesLocalNPCImmunity = true; - break; - default: - break; - } + case ProjectileID.Spazmamini: + case ProjectileID.Retanimini: + case ProjectileID.MiniRetinaLaser: + projectile.localNPCHitCooldown = 10; + projectile.usesLocalNPCImmunity = true; + projectile.usesIDStaticNPCImmunity = false; + break; + default: + break; + } - // Disable Lunatic Cultist's homing resistance globally - ProjectileID.Sets.Homing[projectile.type] = false; - } + // Disable Lunatic Cultist's homing resistance globally + ProjectileID.Sets.Homing[projectile.type] = false; + } #endregion #region PreAI @@ -841,16 +843,10 @@ namespace CalamityMod.Projectiles { if (projectile.owner == Main.myPlayer && Main.player[projectile.owner].ownedProjectileCounts[90] < 30) { - for (int num252 = 0; num252 < 2; num252++) + for (int i = 0; i < 2; i++) { - Vector2 value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= Main.rand.Next(70, 101) * 0.1f; - int shard = Projectile.NewProjectile(projectile.oldPosition + projectile.Size * 0.5f, value15, ProjectileID.CrystalShard, (int)(projectile.damage * 0.25), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int shard = Projectile.NewProjectile(projectile.Center, velocity, ProjectileID.CrystalShard, (int)(projectile.damage * 0.25), 0f, projectile.owner, 0f, 0f); Main.projectile[shard].ranged = false; } } @@ -1095,12 +1091,33 @@ namespace CalamityMod.Projectiles crit = Main.rand.NextBool(6); } - //Needs to be done in here. If done in the projectile file, it's overridden by the thing above + if (rogue && stealthStrike && modPlayer.stealthStrikeAlwaysCrits) + crit = true; + + //Following things need to be done in here. If done in the projectile file, it's overridden by the thing above if (projectile.type == ProjectileType() && projectile.ai[0] == 1f) crit = true; - if (rogue && stealthStrike && modPlayer.stealthStrikeAlwaysCrits) - crit = true; + if (projectile.type == ProjectileType()) + { + double damageMult = 1D; + if (crit) + { + damageMult += 0.25; + } + if (target.Inorganic()) + { + damageMult += 0.1; + } + damage = (int)(damage * damageMult); + } + + if (projectile.type == ProjectileType()) + { + damage = (int)(damage * 1.2); + if (!crit) + crit = Main.rand.NextBool(10); + } } } #endregion @@ -1120,7 +1137,7 @@ namespace CalamityMod.Projectiles //flask of party affects all types of weapons, !projectile.melee is to prevent double flask effects if (!projectile.melee && player.meleeEnchant == 7) - Projectile.NewProjectile(target.Center.X, target.Center.Y, target.velocity.X, target.velocity.Y, ProjectileID.ConfettiMelee, 0, 0f, projectile.owner, 0f, 0f); + Projectile.NewProjectile(target.Center, target.velocity, ProjectileID.ConfettiMelee, 0, 0f, projectile.owner, 0f, 0f); if (rogue && stealthStrike && modPlayer.dragonScales && CalamityUtils.CountProjectiles(ProjectileType()) < 2) { @@ -1163,7 +1180,7 @@ namespace CalamityMod.Projectiles { if (player.ghostHurt) { - projectile.ghostHurt(damage, new Vector2(target.Center.X, target.Center.Y)); + projectile.ghostHurt(damage, target.Center); } if (player.setNebula && player.nebulaCD == 0 && Main.rand.Next(3) == 0) @@ -1175,7 +1192,7 @@ namespace CalamityMod.Projectiles ItemID.NebulaPickup2, ItemID.NebulaPickup3 }); - int nebulaBooster = Item.NewItem((int)target.position.X, (int)target.position.Y, target.width, target.height, boosterType, 1, false, 0, false, false); + int nebulaBooster = Item.NewItem(target.Center, target.Size, boosterType, 1, false, 0, false, false); Main.item[nebulaBooster].velocity.Y = Main.rand.Next(-20, 1) * 0.2f; Main.item[nebulaBooster].velocity.X = Main.rand.Next(10, 31) * 0.2f * projectile.direction; if (Main.netMode == NetmodeID.MultiplayerClient) @@ -1190,23 +1207,23 @@ namespace CalamityMod.Projectiles // Increases the degree to which Spectre Healing set contributes to the lifesteal cap if (player.ghostHeal) { - float num = 0.1f; - num -= projectile.numHits * 0.025f; - if (num < 0f) - num = 0f; + float cooldownMult = 0.1f; + cooldownMult -= projectile.numHits * 0.025f; + if (cooldownMult < 0f) + cooldownMult = 0f; - float num2 = damage * num; - Main.player[Main.myPlayer].lifeSteal -= num2; + float cooldown = damage * cooldownMult; + Main.player[Main.myPlayer].lifeSteal -= cooldown; } // Increases the degree to which Vampire Knives contribute to the lifesteal cap if (projectile.type == ProjectileID.VampireKnife) { - float num = damage * 0.075f; - if (num < 0f) - num = 0f; + float cooldown = damage * 0.075f; + if (cooldown < 0f) + cooldown = 0f; - Main.player[Main.myPlayer].lifeSteal -= num; + Main.player[Main.myPlayer].lifeSteal -= cooldown; } if (modPlayer.vampiricTalisman && rogue && crit) @@ -1224,6 +1241,30 @@ namespace CalamityMod.Projectiles player.HealEffect(1); } + bool otherHealTypes = modPlayer.auricSet || modPlayer.silvaSet || modPlayer.godSlayerMage || modPlayer.tarraMage || modPlayer.ataxiaMage; + + if (projectile.magic && player.ActiveItem().magic) + { + if (modPlayer.manaOverloader && otherHealTypes) + { + if (Main.rand.NextBool(2)) + { + float healMult = 0.2f; + healMult -= projectile.numHits * 0.05f; + float heal = projectile.damage * healMult * (player.statMana / (float)player.statManaMax2); + + if (heal > 50) + heal = 50; + + if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) + goto OTHEREFFECTS; + + SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 2f); + goto OTHEREFFECTS; + } + } + } + if (modPlayer.auricSet) { float healMult = 0.05f; @@ -1252,8 +1293,22 @@ namespace CalamityMod.Projectiles SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 3f); } - else if (projectile.magic) + else if (projectile.magic && player.ActiveItem().magic) { + if (modPlayer.manaOverloader) + { + float healMult = 0.2f; + healMult -= projectile.numHits * 0.05f; + float heal = projectile.damage * healMult * (player.statMana / (float)player.statManaMax2); + + if (heal > 50) + heal = 50; + + if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) + goto OTHEREFFECTS; + + SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 2f); + } if (modPlayer.godSlayerMage) { float healMult = 0.06f; @@ -1307,7 +1362,7 @@ namespace CalamityMod.Projectiles SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 2f); } - else if (modPlayer.manaOverloader && player.inventory[player.selectedItem].magic) + else if (modPlayer.manaOverloader) { float healMult = 0.2f; healMult -= projectile.numHits * 0.05f; @@ -1330,13 +1385,13 @@ namespace CalamityMod.Projectiles (projectile.magic || rogue || projectile.melee || projectile.IsSummon() || projectile.ranged) && player.ownedProjectileCounts[ProjectileType()] < 6) { - int plague = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.25, 30), 0f, projectile.owner, 0f, 0f); - Main.projectile[plague].Calamity().forceTypeless = false; + int plague = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.25, 30), 0f, projectile.owner, 0f, 0f); + Main.projectile[plague].Calamity().forceTypeless = true; } if (modPlayer.reaverBlast && projectile.melee) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.2, 30), 0f, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.2, 30), 0f, projectile.owner, 0f, 0f); } if (projectile.magic) @@ -1344,23 +1399,20 @@ namespace CalamityMod.Projectiles if (modPlayer.silvaMage && projectile.penetrate == 1 && Main.rand.Next(0, 100) >= 97) { Main.PlaySound(SoundID.Zombie, (int)projectile.position.X, (int)projectile.position.Y, 103); - projectile.position = projectile.Center; - projectile.width = projectile.height = 96; - projectile.position.X -= projectile.width / 2; - projectile.position.Y -= projectile.height / 2; - for (int num193 = 0; num193 < 3; num193++) - { - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 157, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.5f); - } - for (int num194 = 0; num194 < 30; num194++) - { - int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 157, 0f, 0f, 0, new Color(Main.DiscoR, 203, 103), 2.5f); - Main.dust[num195].noGravity = true; - Main.dust[num195].velocity *= 3f; - num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 157, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; - } + ExpandHitboxBy(projectile, 96); + for (int d = 0; d < 3; d++) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, 157, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.5f); + } + for (int d = 0; d < 30; d++) + { + int explode = Dust.NewDust(projectile.position, projectile.width, projectile.height, 157, 0f, 0f, 0, new Color(Main.DiscoR, 203, 103), 2.5f); + Main.dust[explode].noGravity = true; + Main.dust[explode].velocity *= 3f; + explode = Dust.NewDust(projectile.position, projectile.width, projectile.height, 157, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.5f); + Main.dust[explode].velocity *= 2f; + Main.dust[explode].noGravity = true; + } projectile.damage *= modPlayer.auricSet ? 7 : 4; projectile.localNPCHitCooldown = 10; projectile.usesLocalNPCImmunity = true; @@ -1369,60 +1421,53 @@ namespace CalamityMod.Projectiles if (modPlayer.reaverBurst) { - int num251 = Main.rand.Next(2, 5); - for (int num252 = 0; num252 < num251; num252++) + int projAmt = Main.rand.Next(2, 5); + for (int i = 0; i < projAmt; i++) { - Vector2 value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= Main.rand.Next(70, 101) * 0.1f; - int proj = Projectile.NewProjectile(projectile.oldPosition.X + (projectile.width / 2), projectile.oldPosition.Y + (projectile.height / 2), value15.X, value15.Y, 569 + Main.rand.Next(3), CalamityUtils.DamageSoftCap(projectile.damage * 0.15, 15), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int proj = Projectile.NewProjectile(projectile.Center, velocity, ProjectileID.SporeGas + Main.rand.Next(3), CalamityUtils.DamageSoftCap(projectile.damage * 0.15, 15), 0f, projectile.owner, 0f, 0f); Main.projectile[proj].usesLocalNPCImmunity = true; Main.projectile[proj].localNPCHitCooldown = 30; } } else if (modPlayer.ataxiaMage && modPlayer.ataxiaDmg <= 0) { - SpawnOrb(projectile, 1.25f, ProjectileType(), 800f, 20f); - int num = (int)(projectile.damage * 0.5f); - modPlayer.ataxiaDmg += num; + SpawnOrb(projectile, (int)(projectile.damage * 0.625), ProjectileType(), 800f, 20f); + int cooldown = (int)(projectile.damage * 0.5f); + modPlayer.ataxiaDmg += cooldown; } else if (modPlayer.godSlayerMage && modPlayer.godSlayerDmg <= 0) { - SpawnOrb(projectile, modPlayer.auricSet ? 2f : 1.5f, ProjectileType(), 800f, 20f); - int num = (int)(projectile.damage * 0.5f); - modPlayer.godSlayerDmg += num; + SpawnOrb(projectile, (int)(projectile.damage * (modPlayer.auricSet ? 1 : 0.75)), ProjectileType(), 800f, 20f); + int cooldown = (int)(projectile.damage * 0.5f); + modPlayer.godSlayerDmg += cooldown; } } if (projectile.melee) { if (modPlayer.ataxiaGeyser && player.ownedProjectileCounts[ProjectileType()] < 3) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.15, 35), 0f, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.15, 35), 0f, projectile.owner, 0f, 0f); } } if (rogue) { if (modPlayer.xerocSet && modPlayer.xerocDmg <= 0 && player.ownedProjectileCounts[ProjectileType()] < 3 && player.ownedProjectileCounts[ProjectileType()] < 3) { + int cooldown = (int)(projectile.damage * 0.5f); switch (Main.rand.Next(5)) { case 0: - SpawnOrb(projectile, 1.6f, ProjectileType(), 800f, Main.rand.Next(15, 30)); - int num = (int)(projectile.damage * 0.5f); - modPlayer.xerocDmg += num; + SpawnOrb(projectile, (int)(projectile.damage * 0.8), ProjectileType(), 800f, Main.rand.Next(15, 30)); + modPlayer.xerocDmg += cooldown; break; case 1: - SpawnOrb(projectile, 1.25f, ProjectileType(), 800f, 30f); - int num2 = (int)(projectile.damage * 0.5f); - modPlayer.xerocDmg += num2; + SpawnOrb(projectile, (int)(projectile.damage * 0.625), ProjectileType(), 800f, 30f); + modPlayer.xerocDmg += cooldown; if (target.canGhostHeal && Main.player[Main.myPlayer].lifeSteal > 0f) { @@ -1440,21 +1485,20 @@ namespace CalamityMod.Projectiles case 2: - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.15, 40), 0f, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.15, 40), 0f, projectile.owner, 0f, 0f); break; case 3: - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.2, 40), 0f, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.2, 40), 0f, projectile.owner, 0f, 0f); break; case 4: - SpawnOrb(projectile, 1.2f, ProjectileType(), 800f, 15f); - int num3 = (int)(projectile.damage * 0.5f); - modPlayer.xerocDmg += num3; + SpawnOrb(projectile, (int)(projectile.damage * 0.6), ProjectileType(), 800f, 15f); + modPlayer.xerocDmg += cooldown; break; @@ -1469,11 +1513,12 @@ namespace CalamityMod.Projectiles { for (int i = 0; i < 6; i++) { - Vector2 pos = new Vector2(target.Center.X + target.width * 0.5f + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); - float speedX = (target.Center.X - pos.X) / 30f; - float speedY = (target.Center.Y - pos.Y) * 8; + Vector2 source = new Vector2(target.Center.X + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + float speedX = (target.Center.X - source.X) / 30f; + float speedY = (target.Center.Y - source.Y) * 8; + Vector2 velocity = new Vector2(speedX, speedY); int dmg = (int)(15 + (projectile.damage * 0.05f)); - int feather = Projectile.NewProjectile(pos.X, pos.Y, speedX, speedY, ProjectileType(), dmg, 3, projectile.owner, 0f, Main.rand.Next(15)); + int feather = Projectile.NewProjectile(source, velocity, ProjectileType(), dmg, 3f, projectile.owner); Main.projectile[feather].Calamity().forceRogue = true; modPlayer.featherCrownCooldown = 15; } @@ -1483,11 +1528,10 @@ namespace CalamityMod.Projectiles { for (int i = 0; i < 6; i++) { - Vector2 pos = new Vector2(target.Center.X + target.width * 0.5f + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); - Vector2 velocity = (target.Center - pos) / 10f; - float AI1 = Main.rand.Next(3); + Vector2 source = new Vector2(target.Center.X + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + Vector2 velocity = (target.Center - source) / 10f; int dmg = (int)(150 + (projectile.damage * 0.05f)); - int flare = Projectile.NewProjectile(pos, velocity, ProjectileID.LunarFlare, dmg, 3, projectile.owner, 0f, AI1); + int flare = Projectile.NewProjectile(source, velocity, ProjectileID.LunarFlare, dmg, 3, projectile.owner); Main.projectile[flare].Calamity().forceRogue = true; modPlayer.moonCrownCooldown = 15; } @@ -1497,10 +1541,10 @@ namespace CalamityMod.Projectiles { for (int i = 0; i < 6; i++) { - Vector2 pos = new Vector2(target.Center.X + target.width * 0.5f + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); - Vector2 velocity = (target.Center - pos) / 40f; + Vector2 source = new Vector2(target.Center.X + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + Vector2 velocity = (target.Center - source) / 40f; int dmg = (int)(1000 + (projectile.damage * 0.05f)); - int flare = Projectile.NewProjectile(pos, velocity, ProjectileType(),dmg, 3f, projectile.owner, 0f, 0f); + int flare = Projectile.NewProjectile(source, velocity, ProjectileType(),dmg, 3f, projectile.owner); Main.projectile[flare].Calamity().rogue = true; modPlayer.nanoFlareCooldown = 15; } @@ -1596,42 +1640,9 @@ namespace CalamityMod.Projectiles if (CalamityMod.boomerangProjList.Contains(projectile.type)) { int spiritDamage = CalamityUtils.DamageSoftCap(projectile.damage * 0.2, 60); - int[] numArray1 = new int[Main.maxNPCs]; - int maxValue1 = 0; - int maxValue2 = 0; - for (int index = 0; index < Main.maxNPCs; ++index) - { - if (Main.npc[index].CanBeChasedBy((object)projectile, false)) - { - float num2 = Math.Abs(Main.npc[index].Center.X - projectile.Center.X) + Math.Abs(Main.npc[index].Center.Y - projectile.Center.Y); - if (num2 < 800f) - { - if (Collision.CanHit(projectile.position, 1, 1, Main.npc[index].position, Main.npc[index].width, Main.npc[index].height) && num2 > 50f) - { - numArray1[maxValue2] = index; - ++maxValue2; - } - else if (maxValue2 == 0) - { - numArray1[maxValue1] = index; - ++maxValue1; - } - } - } - } - if (maxValue1 == 0 && maxValue2 == 0) - return; - int num3 = maxValue2 <= 0 ? numArray1[Main.rand.Next(maxValue1)] : numArray1[Main.rand.Next(maxValue2)]; - double num4 = 4.0; - float num5 = (float)Main.rand.Next(-100, 101); - float num6 = (float)Main.rand.Next(-100, 101); - double num7 = Math.Sqrt((double)num5 * (double)num5 + (double)num6 * (double)num6); - float num8 = (float)(num4 / num7); - float SpeedX = num5 * num8; - float SpeedY = num6 * num8; - int ghost = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, SpeedX, SpeedY, ProjectileID.SpectreWrath, spiritDamage, 0f, projectile.owner, (float)num3, 0f); - Main.projectile[ghost].Calamity().forceRogue = true; - Main.projectile[ghost].penetrate = 1; + Projectile ghost = SpawnOrb(projectile, spiritDamage, ProjectileID.SpectreWrath, 800f, 4f); + ghost.Calamity().forceRogue = true; + ghost.penetrate = 1; modPlayer.shadowPotCooldown = 30; } if (CalamityMod.flaskBombProjList.Contains(projectile.type)) @@ -1685,9 +1696,9 @@ namespace CalamityMod.Projectiles if (modPlayer.godSlayerSummon && modPlayer.godSlayerDmg <= 0) { - SpawnOrb(projectile, 2f, ProjectileType(), 800f, 15f, true); - int num = (int)(projectile.damage * 0.5f); - modPlayer.godSlayerDmg += num; + SpawnOrb(projectile, projectile.damage, ProjectileType(), 800f, 15f, true); + int cooldown = (int)(projectile.damage * 0.5f); + modPlayer.godSlayerDmg += cooldown; } //Priorities: Nucleogenesis => Starbuster Core => Nuclear Rod => Jelly-Charged Battery @@ -1733,9 +1744,9 @@ namespace CalamityMod.Projectiles } else if (modPlayer.jellyChargedBattery) { - SpawnOrb(projectile, 1.05f, ProjectileType(), 800f, 15f); - int num = (int)(projectile.damage * 0.5f); - modPlayer.jellyDmg += num; + SpawnOrb(projectile, (int)(projectile.damage * 0.525), ProjectileType(), 800f, 15f); + int cooldown = (int)(projectile.damage * 0.5f); + modPlayer.jellyDmg += cooldown; } } @@ -1757,17 +1768,11 @@ namespace CalamityMod.Projectiles { if (modPlayer.tarraRanged && Main.rand.Next(0, 100) >= 88 && player.ownedProjectileCounts[ProjectileType()] <= 20 && (projectile.timeLeft <= 2 || projectile.penetrate <= 1)) { - int num251 = Main.rand.Next(2, 4); - for (int num252 = 0; num252 < num251; num252++) + int projAmt = Main.rand.Next(2, 4); + for (int projCount = 0; projCount < projAmt; projCount++) { - Vector2 value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.33, 65), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.33, 65), 0f, projectile.owner, 0f, 0f); } } } @@ -1865,7 +1870,7 @@ namespace CalamityMod.Projectiles public static void DrawCenteredAndAfterimage(Projectile projectile, Color lightColor, int trailingMode, int afterimageCounter, Texture2D texture = null, bool drawCentered = true) { - if (texture == null) + if (texture is null) texture = Main.projectileTexture[projectile.type]; int frameHeight = texture.Height / Main.projFrames[projectile.type]; @@ -1928,11 +1933,11 @@ namespace CalamityMod.Projectiles { if (modPlayer.providenceLore && projectile.friendly && projectile.damage > 0 && (projectile.melee || projectile.ranged || projectile.magic || rogue)) { - Main.PlaySound(SoundID.Item20, (int)projectile.position.X, (int)projectile.position.Y); + Main.PlaySound(SoundID.Item20, projectile.Center); for (int dustIndex = 0; dustIndex < 3; dustIndex++) { - int dust = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, (int)CalamityDusts.ProfanedFire, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f, 0, default, 1f); - Main.dust[dust].noGravity = true; + int fire = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, (int)CalamityDusts.ProfanedFire, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f, 0, default, 1f); + Main.dust[fire].noGravity = true; } } @@ -1940,16 +1945,10 @@ namespace CalamityMod.Projectiles { if (modPlayer.etherealExtorter && Main.rand.Next(0, 100) >= 95) { - for (int num252 = 0; num252 < 3; num252++) + for (int i = 0; i < 3; i++) { - Vector2 value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= Main.rand.Next(70, 101) * 0.1f; - int soul = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.33), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int soul = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.33), 0f, projectile.owner, 0f, 0f); Main.projectile[soul].tileCollide = false; } } @@ -2005,78 +2004,66 @@ namespace CalamityMod.Projectiles if (Main.player[Main.myPlayer].moonLeech) return; Main.player[Main.myPlayer].lifeSteal -= healAmount * cooldownMultiplier; - float num13 = 0f; - int num14 = projectile.owner; + float lowestHealthCheck = 0f; + int healTarget = projectile.owner; for (int i = 0; i < Main.maxPlayers; i++) { - if (Main.player[i].active && !Main.player[i].dead && ((!player.hostile && !Main.player[i].hostile) || player.team == Main.player[i].team)) + Player otherPlayer = Main.player[i]; + if (otherPlayer.active && !otherPlayer.dead && ((!player.hostile && !otherPlayer.hostile) || player.team == otherPlayer.team)) { - float num15 = Math.Abs(Main.player[i].position.X + (Main.player[i].width / 2) - projectile.position.X + (projectile.width / 2)) + Math.Abs(Main.player[i].position.Y + (Main.player[i].height / 2) - projectile.position.Y + (projectile.height / 2)); - if (num15 < distanceRequired && (Main.player[i].statLifeMax2 - Main.player[i].statLife) > num13) + float playerDist = Vector2.Distance(projectile.Center, otherPlayer.Center); + if (playerDist < distanceRequired && (otherPlayer.statLifeMax2 - otherPlayer.statLife) > lowestHealthCheck) { - num13 = Main.player[i].statLifeMax2 - Main.player[i].statLife; - num14 = i; + lowestHealthCheck = otherPlayer.statLifeMax2 - otherPlayer.statLife; + healTarget = i; } } } - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, healProjectileType, 0, 0f, projectile.owner, num14, healAmount); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, healProjectileType, 0, 0f, projectile.owner, healTarget, healAmount); } #endregion #region AI Shortcuts - public void SpawnOrb(Projectile projectile, float dmgMult, int projType, float distanceRequired, float N, bool gsPhantom = false) + public static Projectile SpawnOrb(Projectile projectile, int damage, int projType, float distanceRequired, float speedMult, bool gsPhantom = false) { Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - int num = (int)(projectile.damage * 0.5f); float ai1 = Main.rand.NextFloat() + 0.5f; int[] array = new int[Main.maxNPCs]; - int num3 = 0; - int num4 = 0; + int targetArrayA = 0; + int targetArrayB = 0; for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[i].CanBeChasedBy(projectile, false)) + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) { - float num5 = Math.Abs(Main.npc[i].position.X + (Main.npc[i].width / 2) - projectile.position.X + (projectile.width / 2)) + Math.Abs(Main.npc[i].position.Y + (Main.npc[i].height / 2) - projectile.position.Y + (projectile.height / 2)); - if (num5 < distanceRequired) + float enemyDist = Vector2.Distance(projectile.Center, npc.Center); + if (enemyDist < distanceRequired) { - if (Collision.CanHit(projectile.position, 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height) && num5 > 50f) + if (Collision.CanHit(projectile.position, 1, 1, npc.position, npc.width, npc.height) && enemyDist > 50f) { - array[num4] = i; - num4++; + array[targetArrayB] = i; + targetArrayB++; } - else if (num4 == 0) + else if (targetArrayB == 0) { - array[num3] = i; - num3++; + array[targetArrayA] = i; + targetArrayA++; } } } } - if (num3 == 0 && num4 == 0) + if (targetArrayA == 0 && targetArrayB == 0) { - return; + return Projectile.NewProjectileDirect(projectile.Center, Vector2.Zero, ProjectileType(), 0, 0f, projectile.owner); } - int num6; - if (num4 > 0) - { - num6 = array[Main.rand.Next(num4)]; - } - else - { - num6 = array[Main.rand.Next(num3)]; - } - float num7 = N; - float num8 = Main.rand.Next(-100, 101); - float num9 = Main.rand.Next(-100, 101); - float num10 = (float)Math.Sqrt(num8 * num8 + num9 * num9); - num10 = num7 / num10; - num8 *= num10; - num9 *= num10; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, num8, num9, projType, (int)(num * dmgMult), 0f, projectile.owner, gsPhantom ? 0f : num6, gsPhantom ? ai1 : 0f); + int target = targetArrayB <= 0 ? array[Main.rand.Next(targetArrayA)] : array[Main.rand.Next(targetArrayB)]; + Vector2 velocity = CalamityUtils.RandomVelocity(100f, speedMult, speedMult, 1f); + Projectile orb = Projectile.NewProjectileDirect(projectile.Center, velocity, projType, damage, 0f, projectile.owner, gsPhantom ? 0f : target, gsPhantom ? ai1 : 0f); + return orb; } - + public static void HomeInOnNPC(Projectile projectile, bool ignoreTiles, float distanceRequired, float homingVelocity, float N) { Vector2 center = projectile.Center; diff --git a/Projectiles/DraedonsArsenal/GatlingLaserProj.cs b/Projectiles/DraedonsArsenal/GatlingLaserProj.cs index ff64a9d489..f466fd633b 100644 --- a/Projectiles/DraedonsArsenal/GatlingLaserProj.cs +++ b/Projectiles/DraedonsArsenal/GatlingLaserProj.cs @@ -109,8 +109,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal velocity2.Normalize(); velocity2 *= 5f; } - float SpeedX = velocity2.X + Main.rand.Next(-1, 2) * 0.01f; - float SpeedY = velocity2.Y + Main.rand.Next(-1, 2) * 0.01f; + float SpeedX = velocity2.X + Main.rand.Next(-1, 2) * 0.005f; + float SpeedY = velocity2.Y + Main.rand.Next(-1, 2) * 0.005f; float ai0 = projectile.ai[0] - 2f; // 0, 1, or 2 Projectile.NewProjectile(value2.X, value2.Y, SpeedX, SpeedY, type, weaponDamage2, projectile.knockBack, projectile.owner, ai0, 0f); } diff --git a/Projectiles/DraedonsArsenal/LaserRifleShot.cs b/Projectiles/DraedonsArsenal/LaserRifleShot.cs index b52dffebbf..a4e23a5fdf 100644 --- a/Projectiles/DraedonsArsenal/LaserRifleShot.cs +++ b/Projectiles/DraedonsArsenal/LaserRifleShot.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal for (int i = 0; i < 2; i++) { - int num41 = Dust.NewDust(projectile.Center, 0, 0, dust, 0f, 0f, 160, default, 2f); + int num41 = Dust.NewDust(projectile.Center, 0, 0, dust, 0f, 0f, 160, projectile.ai[0] == 0f ? default : new Color(255, 255, 0), 2f); Main.dust[num41].noGravity = true; Main.dust[num41].position = projectile.Center; Main.dust[num41].velocity = projectile.velocity; @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void Kill(int timeLeft) { - int height = 40; + int height = 60; projectile.position = projectile.Center; projectile.width = projectile.height = height; projectile.Center = projectile.position; @@ -74,8 +74,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal LaserBurst(2.4f, 4.2f); // 60 dusts - int num3; - for (int num640 = 0; num640 < 100; num640 = num3 + 1) + for (int num640 = 0; num640 < 100; num640++) { float num641 = 4f; @@ -96,8 +95,6 @@ namespace CalamityMod.Projectiles.DraedonsArsenal dust2.velocity.X = dust2.velocity.X + num644; dust2.velocity.Y = dust2.velocity.Y + num645; dust2.noGravity = true; - - num3 = num640; } } @@ -105,8 +102,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { float angleRandom = 0.05f; - int num3; - for (int num53 = 0; num53 < 20; num53 = num3 + 1) + for (int num53 = 0; num53 < 20; num53++) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); @@ -132,10 +128,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Main.dust[num54].color = Color.Orange * 0.5f; dust2 = Main.dust[num54]; - - num3 = num53; } - for (int num55 = 0; num55 < 10; num55 = num3 + 1) + for (int num55 = 0; num55 < 10; num55++) { float dustSpeed = Main.rand.NextFloat(speed1, speed2); Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); @@ -149,8 +143,6 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Dust dust2 = Main.dust[num56]; dust2.velocity *= 0.5f; dust2 = Main.dust[num56]; - - num3 = num55; } } } diff --git a/Projectiles/DraedonsArsenal/PlasmaGrenadeProjectile.cs b/Projectiles/DraedonsArsenal/PlasmaGrenadeProjectile.cs index e2a3bdc19b..5c4f2eeaee 100644 --- a/Projectiles/DraedonsArsenal/PlasmaGrenadeProjectile.cs +++ b/Projectiles/DraedonsArsenal/PlasmaGrenadeProjectile.cs @@ -74,6 +74,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal else { CalamityGlobalProjectile.ExpandHitboxBy(projectile, 240); + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; projectile.Damage(); if (!Main.dedServ) { diff --git a/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs b/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs index 37048d129c..845249ad2f 100644 --- a/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs +++ b/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs @@ -240,7 +240,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { Vector2 spawnPosition = projectile.Center + Vector2.UnitX * 8f * projectile.spriteDirection; - float shootSpeed = 11f; + float shootSpeed = 14f; float gravity = -StarSwallowerAcid.Gravity; float distance = Vector2.Distance(spawnPosition, potentialTarget.Center); float angle = 0.5f * (float)Math.Asin(MathHelper.Clamp(gravity * distance / (float)Math.Pow(shootSpeed, 2), -1f, 1f)); diff --git a/Projectiles/Enemy/EarthRockBig.cs b/Projectiles/Enemy/EarthRockBig.cs index 5da084e7a8..d1d35e7c7f 100644 --- a/Projectiles/Enemy/EarthRockBig.cs +++ b/Projectiles/Enemy/EarthRockBig.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Enemy projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); for (int num621 = 0; num621 < 15; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 8, 0f, 0f, 100, default, 1.2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 8, 0f, 0f, 100, default, 1.2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -71,13 +71,13 @@ namespace CalamityMod.Projectiles.Enemy } for (int num623 = 0; num623 < 30; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 1, 0f, 0f, 100, default, 1.7f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 1, 0f, 0f, 100, default, 1.7f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 8, 0f, 0f, 100, default, 1f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 8, 0f, 0f, 100, default, 1f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitPlayer(Player target, int damage, bool crit) diff --git a/Projectiles/Enemy/EarthRockSmall.cs b/Projectiles/Enemy/EarthRockSmall.cs index 98e51b084c..23f4b6378d 100644 --- a/Projectiles/Enemy/EarthRockSmall.cs +++ b/Projectiles/Enemy/EarthRockSmall.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Enemy projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); for (int num621 = 0; num621 < 10; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 8, 0f, 0f, 100, default, 1.2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 8, 0f, 0f, 100, default, 1.2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -50,13 +50,13 @@ namespace CalamityMod.Projectiles.Enemy } for (int num623 = 0; num623 < 20; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 1, 0f, 0f, 100, default, 1.7f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 1, 0f, 0f, 100, default, 1.7f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 8, 0f, 0f, 100, default, 1f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 8, 0f, 0f, 100, default, 1f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitPlayer(Player target, int damage, bool crit) diff --git a/Projectiles/Magic/AuroraAustralis.cs b/Projectiles/Magic/AuroraAustralis.cs index cd166051f1..38887a0bda 100644 --- a/Projectiles/Magic/AuroraAustralis.cs +++ b/Projectiles/Magic/AuroraAustralis.cs @@ -7,115 +7,105 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { public class AuroraAustralis : ModProjectile - { - private static float CosFrequency = 0.05f; - private static float CosAmplitude = 0.008f; + { + private static float CosFrequency = 0.05f; + private static float CosAmplitude = 0.008f; public int[] dustTypes = new int[] { ModContent.DustType(), ModContent.DustType() }; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Aurora Australis"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Aurora Australis"); + } - public override void SetDefaults() - { - projectile.width = 10; - projectile.height = 10; - projectile.friendly = true; - projectile.penetrate = 1; - projectile.tileCollide = false; - projectile.timeLeft = 300; - projectile.magic = true; + public override void SetDefaults() + { + projectile.width = 10; + projectile.height = 10; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.timeLeft = 300; + projectile.magic = true; projectile.alpha = 255; - CosFrequency = 0.15f; - CosAmplitude = 0.06f; - } + CosFrequency = 0.15f; + CosAmplitude = 0.06f; + } - public override void AI() - { - // On-spawn effects - if (projectile.ai[0] == 0) - { - // Store the X and Y of the spawn velocity so it can be used for trig calculations - projectile.localAI[0] = projectile.velocity.X; - projectile.localAI[1] = projectile.velocity.Y; - } + public override void AI() + { + // On-spawn effects + if (projectile.ai[0] == 0) + { + // Store the X and Y of the spawn velocity so it can be used for trig calculations + projectile.localAI[0] = projectile.velocity.X; + projectile.localAI[1] = projectile.velocity.Y; + } - // Doesn't collide with tiles for the first 2 frames - projectile.tileCollide = projectile.ai[0] > 2f; + // Doesn't collide with tiles for the first 2 frames + projectile.tileCollide = projectile.ai[0] > 2f; - // Apply fancy cosine movement, then slight gravity, then cap velocity. - // Original velocity is reconstructed so that it can be used in the calculation - Vector2 originalVelocity = new Vector2(projectile.localAI[0], projectile.localAI[1]); - ApplyCosVelocity(originalVelocity); - float currentSpeed = projectile.velocity.Length(); - float maxSpeed = 1.4f * originalVelocity.Length(); - if (currentSpeed > maxSpeed) - projectile.velocity *= maxSpeed / currentSpeed; + // Apply fancy cosine movement, then slight gravity, then cap velocity. + // Original velocity is reconstructed so that it can be used in the calculation + Vector2 originalVelocity = new Vector2(projectile.localAI[0], projectile.localAI[1]); + ApplyCosVelocity(originalVelocity); + float currentSpeed = projectile.velocity.Length(); + float maxSpeed = 1.4f * originalVelocity.Length(); + if (currentSpeed > maxSpeed) + projectile.velocity *= maxSpeed / currentSpeed; - // spawn dust - if (Main.rand.NextBool(5)) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, Main.rand.Next(dustTypes), projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - } - int rainbow = Dust.NewDust(projectile.Center, projectile.width, projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Dust dust = Main.dust[rainbow]; - dust.velocity *= 0.1f; - dust.velocity += projectile.velocity * 0.2f; - dust.position.X = projectile.Center.X + 4f + Main.rand.Next(-2, 3); - dust.position.Y = projectile.Center.Y + Main.rand.Next(-2, 3); - dust.noGravity = true; + // spawn dust + if (Main.rand.NextBool(5)) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, Main.rand.Next(dustTypes), projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + } + int rainbow = Dust.NewDust(projectile.Center, projectile.width, projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Dust dust = Main.dust[rainbow]; + dust.velocity *= 0.1f; + dust.velocity += projectile.velocity * 0.2f; + dust.position.X = projectile.Center.X + 4f + Main.rand.Next(-2, 3); + dust.position.Y = projectile.Center.Y + Main.rand.Next(-2, 3); + dust.noGravity = true; - if (projectile.timeLeft % 10 == 0 && Main.myPlayer == projectile.owner) //spawn stars every 10 ticks - { - if (Main.player[projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] < 30) - { + if (projectile.timeLeft % 10 == 0 && Main.myPlayer == projectile.owner) //spawn stars every 10 ticks + { + if (Main.player[projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] < 30) + { float dmgKBMult = Main.rand.NextFloat(0.25f, 0.75f); - float xStart = projectile.Center.X + projectile.velocity.X; - float yStart = projectile.Center.Y - Main.rand.Next(500, 800); - Vector2 startPos = new Vector2(xStart, yStart); - Vector2 velocity = projectile.Center - startPos; - velocity.X += (float)Main.rand.Next(-100, 101); - float travelDist = velocity.Length(); - float starSpeed = Main.rand.NextFloat(10f, 20f); - travelDist = starSpeed / travelDist; - velocity.X *= travelDist; - velocity.Y *= travelDist; - int star = Projectile.NewProjectile(startPos, velocity, ModContent.ProjectileType(), (int)(projectile.damage * dmgKBMult), projectile.knockBack * dmgKBMult, projectile.owner, 0f, 0f); - Main.projectile[star].timeLeft = 120; - } - } + Projectile star = CalamityUtils.ProjectileRain(projectile.Center, projectile.velocity.X, 100f, 500f, 800f, Main.rand.NextFloat(10f, 20f), ModContent.ProjectileType(), (int)(projectile.damage * dmgKBMult), projectile.knockBack * dmgKBMult, projectile.owner); + star.timeLeft = 120; + } + } - projectile.ai[0]++; - } + projectile.ai[0]++; + } - private void ApplyCosVelocity(Vector2 baseVelocity) - { - float radians = -(-MathHelper.PiOver2 + CosFrequency * projectile.ai[0]); - projectile.velocity += CosAmplitude * baseVelocity.RotatedBy(radians); - } + private void ApplyCosVelocity(Vector2 baseVelocity) + { + float radians = -(-MathHelper.PiOver2 + CosFrequency * projectile.ai[0]); + projectile.velocity += CosAmplitude * baseVelocity.RotatedBy(radians); + } - public override void Kill(int timeLeft) - { - for (int i = 0; i <= 5; i++) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, Main.rand.Next(dustTypes), projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); - } - } + public override void Kill(int timeLeft) + { + for (int i = 0; i <= 5; i++) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, Main.rand.Next(dustTypes), projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); + } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } + } } diff --git a/Projectiles/Magic/IceBarrageMain.cs b/Projectiles/Magic/IceBarrageMain.cs index c8b926209a..016ab4e72c 100644 --- a/Projectiles/Magic/IceBarrageMain.cs +++ b/Projectiles/Magic/IceBarrageMain.cs @@ -32,58 +32,37 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - float maxDistance = 500f; - bool bossFound = false; - - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC npc = Main.npc[i]; - if (!npc.active || npc.type == NPCID.TargetDummy) - continue; - - // If we've found a valid boss target, ignore ALL targets which aren't bosses. - if (bossFound && !npc.boss) - continue; - - if (npc.CanBeChasedBy(projectile, false)) - { - float extraDistance = (float)(npc.width / 2) + (float)(npc.height / 2); - - if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) - { - if (npc.boss) - bossFound = true; - projectile.Center = npc.Center; - break; - } - } - } + NPC closestTarget = projectile.Center.ClosestNPCAt(500f, true, true); + if (closestTarget != null) + { + projectile.Center = closestTarget.Center; + } projectile.ai[0]++; projectile.ai[1]++; for (int j = 0; j < 3; j++) { - int num297 = Main.rand.NextBool(2) ? 68 : 67; + int dustType = Main.rand.NextBool(2) ? 68 : 67; if (Main.rand.NextBool(4)) { - num297 = 80; + dustType = 80; } if (projectile.ai[0] < 140f) { Vector2 direction = new Vector2(Main.rand.NextFloat(-4f, 4f), Main.rand.NextFloat(-4f, 4f)); - int dust = Dust.NewDust(projectile.Center, 1, 1, num297, direction.X, direction.Y, 50, default, 1.3f); + int dust = Dust.NewDust(projectile.Center, 1, 1, dustType, direction.X, direction.Y, 50, default, 1.3f); Main.dust[dust].noGravity = true; } else { int direct = Main.rand.NextBool(2) ? 1 : -1; Vector2 dir1 = new Vector2(0f, 10f) * direct; - int dust1 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num297, dir1.X, dir1.Y, 50, default, 1.3f); + int dust1 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, dir1.X, dir1.Y, 50, default, 1.3f); Main.dust[dust1].noGravity = true; Main.dust[dust1].velocity = dir1; int direct2 = Main.rand.NextBool(2) ? 1 : -1; Vector2 dir2 = new Vector2(10f, 0f) * direct2; - int dust2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num297, dir2.X, dir2.Y, 50, default, 1.3f); + int dust2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, dir2.X, dir2.Y, 50, default, 1.3f); Main.dust[dust2].noGravity = true; Main.dust[dust2].velocity = dir2; } diff --git a/Projectiles/Magic/InfernalBlade.cs b/Projectiles/Magic/InfernalBlade.cs index ae4b69cf78..da9fd69275 100644 --- a/Projectiles/Magic/InfernalBlade.cs +++ b/Projectiles/Magic/InfernalBlade.cs @@ -59,24 +59,21 @@ namespace CalamityMod.Projectiles.Magic { Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height); Main.PlaySound(SoundID.Item10, projectile.position); - int num487 = Main.rand.Next(4, 10); - for (int num488 = 0; num488 < num487; num488++) + int dustAmt = Main.rand.Next(4, 10); + for (int d = 0; d < dustAmt; d++) { - int num489 = Dust.NewDust(projectile.Center, 0, 0, 182, 0f, 0f, 100, default, 1f); - Main.dust[num489].velocity *= 1.6f; - Dust expr_FEDF_cp_0 = Main.dust[num489]; - expr_FEDF_cp_0.velocity.Y -= 1f; - Main.dust[num489].velocity += -projectile.velocity * (Main.rand.NextFloat() * 2f - 1f) * 0.5f; - Main.dust[num489].scale = 2f; - Main.dust[num489].fadeIn = 0.5f; - Main.dust[num489].noGravity = true; + int fire = Dust.NewDust(projectile.Center, 0, 0, 182, 0f, 0f, 100, default, 1f); + Dust dust = Main.dust[fire]; + dust.velocity *= 1.6f; + dust.velocity.Y -= 1f; + dust.velocity += -projectile.velocity * (Main.rand.NextFloat() * 2f - 1f) * 0.5f; + dust.scale = 2f; + dust.fadeIn = 0.5f; + dust.noGravity = true; } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(255, 50, 50, 0); - } + public override Color? GetAlpha(Color lightColor) => new Color(255, 50, 50, 0); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -119,20 +116,22 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - float xPos = projectile.Center.X + 800 * Main.rand.NextBool(2).ToDirectionInt(); - float yPos = projectile.Center.Y + Main.rand.Next(-800, 801); - Vector2 spawnPosition = new Vector2(xPos, yPos); - Vector2 velocity = target.Center - spawnPosition; - float dir = 10 / spawnPosition.X; - velocity.X *= dir * 150; - velocity.Y *= dir * 150; - velocity.X = MathHelper.Clamp(velocity.X, -15f, 15f); - velocity.Y = MathHelper.Clamp(velocity.Y, -15f, 15f); - if (projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(spawnPosition, velocity, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.75), 1f, projectile.owner); - } + OnHitEffects(target.Center); target.AddBuff(ModContent.BuffType(), 240); } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(target.Center); + target.AddBuff(ModContent.BuffType(), 240); + } + + private void OnHitEffects(Vector2 targetPos) + { + if (projectile.owner == Main.myPlayer) + { + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), 1f, projectile.owner, true); + } + } } } diff --git a/Projectiles/Magic/LightBead.cs b/Projectiles/Magic/LightBead.cs index 237effaa0b..19dc99e163 100644 --- a/Projectiles/Magic/LightBead.cs +++ b/Projectiles/Magic/LightBead.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Magic projectile.ai[1] += 1f; if (Main.rand.NextBool(3)) { - int num300 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 0, default, 1f); + int num300 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 0, default, 1f); Main.dust[num300].noGravity = true; Main.dust[num300].velocity *= 0.5f; Main.dust[num300].scale *= 0.9f; @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Magic if (projectile.ai[1] > 300f) { projectile.scale -= 0.05f; - if ((double)projectile.scale <= 0.2) + if (projectile.scale <= 0.2f) { projectile.scale = 0.2f; projectile.Kill(); @@ -58,19 +58,13 @@ namespace CalamityMod.Projectiles.Magic { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 244, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); } - int num251 = Main.rand.Next(2, 3); + int beadAmt = Main.rand.Next(2, 3); if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < num251; num252++) + for (int b = 0; b < beadAmt; b++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.oldPosition.X + (float)(projectile.width / 2), projectile.oldPosition.Y + (float)(projectile.height / 2), value15.X, value15.Y, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.5), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Magic/LiquidBlade.cs b/Projectiles/Magic/LiquidBlade.cs index 7ff3f82483..bcc8f79caa 100644 --- a/Projectiles/Magic/LiquidBlade.cs +++ b/Projectiles/Magic/LiquidBlade.cs @@ -120,23 +120,28 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - float xPos = projectile.Center.X + 800 * Main.rand.NextBool(2).ToDirectionInt(); - float yPos = projectile.Center.Y + Main.rand.Next(-800, 801); - Vector2 spawnPosition = new Vector2(xPos, yPos); - Vector2 velocity = target.Center - spawnPosition; - float dir = 10 / spawnPosition.X; - velocity.X *= dir * 150; - velocity.Y *= dir * 150; - velocity.X = MathHelper.Clamp(velocity.X, -15f, 15f); - velocity.Y = MathHelper.Clamp(velocity.Y, -15f, 15f); - if (projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(spawnPosition, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), 1f, projectile.owner); - } + OnHitEffects(target.Center); target.AddBuff(BuffID.Ichor, 240); target.AddBuff(BuffID.Frostburn, 240); target.AddBuff(BuffID.OnFire, 240); target.AddBuff(BuffID.CursedInferno, 120); } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(target.Center); + target.AddBuff(BuffID.Ichor, 240); + target.AddBuff(BuffID.Frostburn, 240); + target.AddBuff(BuffID.OnFire, 240); + target.AddBuff(BuffID.CursedInferno, 120); + } + + private void OnHitEffects(Vector2 targetPos) + { + if (projectile.owner == Main.myPlayer) + { + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), 1f, projectile.owner, true); + } + } } } diff --git a/Projectiles/Magic/MadAlchemistsCocktailGasCloud.cs b/Projectiles/Magic/MadAlchemistsCocktailGasCloud.cs index d4d16ef5e5..7e75163b43 100644 --- a/Projectiles/Magic/MadAlchemistsCocktailGasCloud.cs +++ b/Projectiles/Magic/MadAlchemistsCocktailGasCloud.cs @@ -39,37 +39,40 @@ namespace CalamityMod.Projectiles.Magic projectile.rotation += projectile.velocity.X * 0.1f; projectile.rotation += (float)projectile.direction * 0.003f; projectile.velocity *= 0.96f; - Rectangle rectangle5 = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); - int num3; - for (int num894 = 0; num894 < 1000; num894 = num3 + 1) + + Rectangle cloudHitbox = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); + for (int i = 0; i < Main.maxProjectiles; i++) { - if (num894 != projectile.whoAmI && Main.projectile[num894].active) + Projectile otherProj = Main.projectile[i]; + // Short circuits to make the loop as fast as possible + if (!otherProj.active || otherProj.owner != projectile.owner || !otherProj.minion || i == projectile.whoAmI) + continue; + + if (otherProj.type == projectile.type) { - Rectangle value43 = new Rectangle((int)Main.projectile[num894].position.X, (int)Main.projectile[num894].position.Y, Main.projectile[num894].width, Main.projectile[num894].height); - if (rectangle5.Intersects(value43)) + Rectangle otherProjHitbox = new Rectangle((int)otherProj.position.X, (int)otherProj.position.Y, otherProj.width, otherProj.height); + if (cloudHitbox.Intersects(otherProjHitbox)) { - Vector2 vector105 = Main.projectile[num894].Center - projectile.Center; - if (vector105.X == 0f && vector105.Y == 0f) + Vector2 projDistance = otherProj.Center - projectile.Center; + if (projDistance.X == 0f && projDistance.Y == 0f) { - if (num894 < projectile.whoAmI) + if (i < projectile.whoAmI) { - vector105.X = -1f; - vector105.Y = 1f; + projDistance.X = -1f; + projDistance.Y = 1f; } else { - vector105.X = 1f; - vector105.Y = -1f; + projDistance.X = 1f; + projDistance.Y = -1f; } } - vector105.Normalize(); - vector105 *= 0.005f; - projectile.velocity -= vector105; - Projectile projectile2 = Main.projectile[num894]; - projectile2.velocity += vector105; + projDistance.Normalize(); + projDistance *= 0.005f; + projectile.velocity -= projDistance; + otherProj.velocity += projDistance; } } - num3 = num894; } } } diff --git a/Projectiles/Magic/MagicNebulaShot.cs b/Projectiles/Magic/MagicNebulaShot.cs index 43293cf1d2..1c8431dcac 100644 --- a/Projectiles/Magic/MagicNebulaShot.cs +++ b/Projectiles/Magic/MagicNebulaShot.cs @@ -1,64 +1,62 @@ +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class MagicNebulaShot : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Shot"); - } + public class MagicNebulaShot : BaseLaserbeamProjectile + { + private Color startingColor = new Color(119, 210, 255); + private Color secondColor = new Color(247, 119, 255); + public override float MaxScale => 0.7f; + public override float MaxLaserLength => 1599.999999f; + public override float Lifetime => 20f; + public override Color LaserOverlayColor => CalamityUtils.ColorSwap(startingColor, secondColor, 0.9f); + public override Color LightCastColor => LaserOverlayColor; + public override Texture2D LaserBeginTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UltimaRayStart"); + public override Texture2D LaserMiddleTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UltimaRayMid"); + public override Texture2D LaserEndTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UltimaRayEnd"); - public override void SetDefaults() - { - projectile.width = 4; - projectile.height = 4; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.magic = true; - projectile.tileCollide = false; - projectile.alpha = 255; - projectile.penetrate = -1; - projectile.extraUpdates = 5; - projectile.timeLeft = 200; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 2; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Nebula Shot"); + } - public override void AI() - { - if (projectile.ai[1] == 0f) - { - projectile.ai[1] = 1f; - Main.PlaySound(SoundID.Item12, projectile.position); - } - if (projectile.alpha > 0) - { - projectile.alpha -= 15; - } - if (projectile.alpha < 0) - { - projectile.alpha = 0; - } - Lighting.AddLight(projectile.Center, 0.4f, 0.2f, 0.4f); - for (int num121 = 0; num121 < 5; num121++) - { - Dust dust4 = Main.dust[Dust.NewDust(projectile.position, projectile.width, projectile.height, Main.rand.NextBool(3) ? 56 : 242, projectile.velocity.X, projectile.velocity.Y, 100, default, 1f)]; - dust4.velocity = Vector2.Zero; - dust4.position -= projectile.velocity / 5f * (float)num121; - dust4.noGravity = true; - dust4.scale = 0.8f; - dust4.noLight = true; - } - } + public override void SetDefaults() + { + projectile.width = projectile.height = 22; + projectile.friendly = true; + projectile.magic = true; + projectile.penetrate = -1; + projectile.alpha = 255; + projectile.localNPCHitCooldown = 2; + projectile.usesLocalNPCImmunity = true; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.OnFire, 600); - target.AddBuff(BuffID.Frostburn, 600); - } - } + public override bool PreAI() + { + // Initialization. Using the AI hook would override the base laser's code, and we don't want that. + if (projectile.localAI[0] == 0f) + { + if (Main.rand.NextBool()) + { + secondColor = new Color(119, 210, 255); + startingColor = new Color(247, 119, 255); + } + } + return true; + } + + public override bool ShouldUpdatePosition() => false; + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.OnFire, 600); + target.AddBuff(BuffID.Frostburn, 600); + } + } } diff --git a/Projectiles/Magic/MagnusBeam.cs b/Projectiles/Magic/MagnusBeam.cs index d3a4e48a0d..91a963a290 100644 --- a/Projectiles/Magic/MagnusBeam.cs +++ b/Projectiles/Magic/MagnusBeam.cs @@ -23,6 +23,7 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = 1; projectile.extraUpdates = 2; projectile.alpha = 0; + projectile.magic = true; } public override void AI() diff --git a/Projectiles/Magic/ShiftingSandsProj.cs b/Projectiles/Magic/ShiftingSandsProj.cs index 9e729a55f0..2b842424c7 100644 --- a/Projectiles/Magic/ShiftingSandsProj.cs +++ b/Projectiles/Magic/ShiftingSandsProj.cs @@ -7,158 +7,158 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class ShiftingSandsProj : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Shifting Sands"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public class ShiftingSandsProj : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Shifting Sands"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 18; - projectile.height = 18; - projectile.friendly = true; - projectile.penetrate = 5; - projectile.magic = true; + public override void SetDefaults() + { + projectile.width = 18; + projectile.height = 18; + projectile.friendly = true; + projectile.penetrate = 5; + projectile.magic = true; projectile.extraUpdates = 2; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - } + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } - public override void AI() - { - if (projectile.soundDelay == 0 && Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) > 2f) - { - projectile.soundDelay = 10; - Main.PlaySound(SoundID.Item20, projectile.position); - } - int num114 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 85, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[num114]; - dust.velocity *= 0.3f; - Main.dust[num114].position.X = projectile.position.X + (float)(projectile.width / 2) + 4f + (float)Main.rand.Next(-4, 5); - Main.dust[num114].position.Y = projectile.position.Y + (float)(projectile.height / 2) + (float)Main.rand.Next(-4, 5); - Main.dust[num114].noGravity = true; - if (Main.myPlayer == projectile.owner && projectile.ai[0] <= 0f) - { - if (Main.player[projectile.owner].channel) - { - float num115 = 18f; - Vector2 vector10 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num116 = (float)Main.mouseX + Main.screenPosition.X - vector10.X; - float num117 = (float)Main.mouseY + Main.screenPosition.Y - vector10.Y; - if (Main.player[projectile.owner].gravDir == -1f) - { - num117 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector10.Y; - } - float num118 = (float)Math.Sqrt((double)(num116 * num116 + num117 * num117)); - num118 = (float)Math.Sqrt((double)(num116 * num116 + num117 * num117)); - if (projectile.ai[0] < 0f) - { - projectile.ai[0] += 1f; - } - if (num118 > num115) - { - num118 = num115 / num118; - num116 *= num118; - num117 *= num118; - int num119 = (int)(num116 * 1000f); - int num120 = (int)(projectile.velocity.X * 1000f); - int num121 = (int)(num117 * 1000f); - int num122 = (int)(projectile.velocity.Y * 1000f); - if (num119 != num120 || num121 != num122) - { - projectile.netUpdate = true; - } - projectile.velocity.X = num116; - projectile.velocity.Y = num117; - } - else - { - int num123 = (int)(num116 * 1000f); - int num124 = (int)(projectile.velocity.X * 1000f); - int num125 = (int)(num117 * 1000f); - int num126 = (int)(projectile.velocity.Y * 1000f); - if (num123 != num124 || num125 != num126) - { - projectile.netUpdate = true; - } - projectile.velocity.X = num116; - projectile.velocity.Y = num117; - } - } - else if (projectile.ai[0] <= 0f) - { - projectile.netUpdate = true; - float num127 = 12f; - Vector2 vector11 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num128 = (float)Main.mouseX + Main.screenPosition.X - vector11.X; - float num129 = (float)Main.mouseY + Main.screenPosition.Y - vector11.Y; - if (Main.player[projectile.owner].gravDir == -1f) - { - num129 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector11.Y; - } - float num130 = (float)Math.Sqrt((double)(num128 * num128 + num129 * num129)); - if (num130 == 0f || projectile.ai[0] < 0f) - { - vector11 = new Vector2(Main.player[projectile.owner].position.X + (float)(Main.player[projectile.owner].width / 2), Main.player[projectile.owner].position.Y + (float)(Main.player[projectile.owner].height / 2)); - num128 = projectile.position.X + (float)projectile.width * 0.5f - vector11.X; - num129 = projectile.position.Y + (float)projectile.height * 0.5f - vector11.Y; - num130 = (float)Math.Sqrt((double)(num128 * num128 + num129 * num129)); - } - num130 = num127 / num130; - num128 *= num130; - num129 *= num130; - projectile.velocity.X = num128; - projectile.velocity.Y = num129; - if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) - { - projectile.Kill(); - } - projectile.ai[0] = 1f; - } - } - if (projectile.velocity.X != 0f || projectile.velocity.Y != 0f) - { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; - } - if (projectile.velocity.Y > 16f) - { - projectile.velocity.Y = 16f; - } - } + public override void AI() + { + if (projectile.soundDelay == 0 && Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) > 2f) + { + projectile.soundDelay = 10; + Main.PlaySound(SoundID.Item20, projectile.Center); + } + int sand = Dust.NewDust(projectile.position, projectile.width, projectile.height, 85, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[sand]; + dust.velocity *= 0.3f; + dust.position.X = projectile.Center.X + 4f + (float)Main.rand.Next(-4, 5); + dust.position.Y = projectile.Center.Y + (float)Main.rand.Next(-4, 5); + dust.noGravity = true; - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); - return false; - } + if (Main.myPlayer == projectile.owner && projectile.ai[0] <= 0f) + { + Player player = Main.player[projectile.owner]; + if (player.channel) + { + float speed = 18f; + float mouseDistX = (float)Main.mouseX + Main.screenPosition.X - projectile.Center.X; + float mouseDistY = (float)Main.mouseY + Main.screenPosition.Y - projectile.Center.Y; + if (player.gravDir == -1f) + { + mouseDistY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projectile.Center.Y; + } + Vector2 mouseVec = new Vector2(mouseDistX, mouseDistY); + float mouseDist = mouseVec.Length(); + if (projectile.ai[0] < 0f) + { + projectile.ai[0] += 1f; + } + if (mouseDist > speed) + { + mouseDist = speed / mouseDist; + mouseVec.X *= mouseDist; + mouseVec.Y *= mouseDist; + int mouseSpeedX = (int)(mouseVec.X * 1000f); + int projSpeedX = (int)(projectile.velocity.X * 1000f); + int mouseSpeedY = (int)(mouseVec.Y * 1000f); + int projSpeedY = (int)(projectile.velocity.Y * 1000f); + if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) + { + projectile.netUpdate = true; + } + projectile.velocity.X = mouseVec.X; + projectile.velocity.Y = mouseVec.Y; + } + else + { + int mouseSpeedX = (int)(mouseVec.X * 1000f); + int projSpeedX = (int)(projectile.velocity.X * 1000f); + int mouseSpeedY = (int)(mouseVec.Y * 1000f); + int projSpeedY = (int)(projectile.velocity.Y * 1000f); + if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) + { + projectile.netUpdate = true; + } + projectile.velocity.X = mouseVec.X; + projectile.velocity.Y = mouseVec.Y; + } + } + else if (projectile.ai[0] <= 0f) + { + projectile.netUpdate = true; + float speed = 12f; + Vector2 projCenter = projectile.Center; + float mouseDistX = (float)Main.mouseX + Main.screenPosition.X - projCenter.X; + float mouseDistY = (float)Main.mouseY + Main.screenPosition.Y - projCenter.Y; + if (player.gravDir == -1f) + { + mouseDistY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projCenter.Y; + } + Vector2 mouseVec = new Vector2(mouseDistX, mouseDistY); + float mouseDist = mouseVec.Length(); + if (mouseDist == 0f || projectile.ai[0] < 0f) + { + projCenter = player.Center; + mouseVec = projectile.Center - projCenter; + mouseDist = mouseVec.Length(); + } + mouseDist = speed / mouseDist; + mouseVec.X *= mouseDist; + mouseVec.Y *= mouseDist; + projectile.velocity.X = mouseVec.X; + projectile.velocity.Y = mouseVec.Y; + if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) + { + projectile.Kill(); + } + projectile.ai[0] = 1f; + } + } + if (projectile.velocity.X != 0f || projectile.velocity.Y != 0f) + { + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + if (projectile.velocity.Y > 16f) + { + projectile.velocity.Y = 16f; + } + } - public override void Kill(int timeLeft) - { - projectile.position = projectile.Center; - projectile.width = projectile.height = 64; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - projectile.maxPenetrate = -1; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); - Main.PlaySound(SoundID.Item14, projectile.position); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) - { - Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + projectile.Center; - Vector2 vector7 = vector6 - projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 85, vector7.X * 1.5f, vector7.Y * 1.5f, 100, default, 1.2f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; - } - } - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); + return false; + } + + public override void Kill(int timeLeft) + { + projectile.position = projectile.Center; + projectile.width = projectile.height = 64; + projectile.Center = projectile.position; + projectile.maxPenetrate = -1; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); + Main.PlaySound(SoundID.Item14, projectile.Center); + int dustAmt = 36; + for (int index = 0; index < dustAmt; index++) + { + Vector2 dustPos = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; + dustPos = dustPos.RotatedBy((double)((float)(index - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + projectile.Center; + Vector2 dustVel = dustPos - projectile.Center; + int sand = Dust.NewDust(dustPos + dustVel, 0, 0, 85, dustVel.X * 1.5f, dustVel.Y * 1.5f, 100, default, 1.2f); + Main.dust[sand].noGravity = true; + Main.dust[sand].noLight = true; + Main.dust[sand].velocity = dustVel; + } + } + } } diff --git a/Projectiles/Magic/SparklingBeam.cs b/Projectiles/Magic/SparklingBeam.cs index 5d0d1a0383..cd46efefb5 100644 --- a/Projectiles/Magic/SparklingBeam.cs +++ b/Projectiles/Magic/SparklingBeam.cs @@ -111,20 +111,14 @@ namespace CalamityMod.Projectiles.Magic if (target.life <= 0) { Player player = Main.player[projectile.owner]; - int shardDamage = (int)((SparklingEmpress.BaseDamage / 5) * (player.allDamage + player.magicDamage - 1f)); - int num251 = Main.rand.Next(2, 4); + int shardDamage = (int)((SparklingEmpress.BaseDamage / 5) * player.MagicDamage()); + int shardAmt = Main.rand.Next(2, 4); if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < num251; num252++) + for (int s = 0; s < shardAmt; s++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int shard = Projectile.NewProjectile(target.Center.X, target.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), shardDamage, 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int shard = Projectile.NewProjectile(target.Center, velocity, ModContent.ProjectileType(), shardDamage, 0f, projectile.owner, 0f, 0f); Main.projectile[shard].Calamity().forceMagic = true; } } diff --git a/Projectiles/Magic/SubsumingTentacle.cs b/Projectiles/Magic/SubsumingTentacle.cs index e6ab77c645..3374d189ea 100644 --- a/Projectiles/Magic/SubsumingTentacle.cs +++ b/Projectiles/Magic/SubsumingTentacle.cs @@ -111,8 +111,8 @@ namespace CalamityMod.Projectiles.Magic } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); if (projectile.scale < 1f) { @@ -136,8 +136,8 @@ namespace CalamityMod.Projectiles.Magic } public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) { - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.TransformationMatrix); + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) diff --git a/Projectiles/Magic/VividBeam.cs b/Projectiles/Magic/VividBeam.cs index 834975c128..f58366c6eb 100644 --- a/Projectiles/Magic/VividBeam.cs +++ b/Projectiles/Magic/VividBeam.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using System; @@ -98,15 +96,16 @@ namespace CalamityMod.Projectiles.Magic { SummonLasers(); } - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + if (projectile.owner == Main.myPlayer) + { + SummonLasers(); + } + target.ExoDebuffs(); } private void SummonLasers() diff --git a/Projectiles/Magic/VividBolt.cs b/Projectiles/Magic/VividBolt.cs index a0443dcca5..1fa5ae52b2 100644 --- a/Projectiles/Magic/VividBolt.cs +++ b/Projectiles/Magic/VividBolt.cs @@ -65,15 +65,12 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); } } } diff --git a/Projectiles/Magic/VividClarityBeam.cs b/Projectiles/Magic/VividClarityBeam.cs index 59d149066b..614d4279b8 100644 --- a/Projectiles/Magic/VividClarityBeam.cs +++ b/Projectiles/Magic/VividClarityBeam.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -97,20 +95,18 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); if (target.type == NPCID.TargetDummy) { return; } - projectile.damage = (int)((double)projectile.damage * 1.1); + projectile.damage = (int)(projectile.damage * 1.1); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); + projectile.damage = (int)(projectile.damage * 1.1); } } } diff --git a/Projectiles/Magic/VividLaser2.cs b/Projectiles/Magic/VividLaser2.cs index b8f9e7ac1d..3db215c1c7 100644 --- a/Projectiles/Magic/VividLaser2.cs +++ b/Projectiles/Magic/VividLaser2.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -62,16 +60,13 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); - } + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); + } // Cannot deal damage for the first several frames of existence. public override bool? CanHitNPC(NPC target) diff --git a/Projectiles/Magic/Vortex.cs b/Projectiles/Magic/Vortex.cs index 390bd05184..b78aa9ace8 100644 --- a/Projectiles/Magic/Vortex.cs +++ b/Projectiles/Magic/Vortex.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -149,15 +147,12 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/AegisBeam.cs b/Projectiles/Melee/AegisBeam.cs index 079d99c4c8..0be8a8f07b 100644 --- a/Projectiles/Melee/AegisBeam.cs +++ b/Projectiles/Melee/AegisBeam.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Melee Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 73); projectile.localAI[0] += 1f; } - int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 246, 0f, 0f, 100, new Color(255, Main.DiscoG, 53), 0.8f); + int num458 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 246, 0f, 0f, 100, new Color(255, Main.DiscoG, 53), 0.8f); Main.dust[num458].noGravity = true; Main.dust[num458].velocity *= 0.5f; Main.dust[num458].velocity += projectile.velocity * 0.1f; @@ -56,39 +56,32 @@ namespace CalamityMod.Projectiles.Melee projectile.localNPCHitCooldown = 10; projectile.Damage(); Main.PlaySound(SoundID.Item20, projectile.Center); - for (int dust = 0; dust <= 30; dust++) + for (int d = 0; d <= 30; d++) { float num463 = (float)Main.rand.Next(-10, 11); float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); + float speed = (float)Main.rand.Next(3, 9); float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; + num466 = speed / num466; num463 *= num466; num464 *= num466; int num467 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 246, 0f, 0f, 100, new Color(255, Main.DiscoG, 53), 1.2f); - Main.dust[num467].noGravity = true; - Main.dust[num467].position.X = projectile.Center.X; - Main.dust[num467].position.Y = projectile.Center.Y; - Dust expr_149DF_cp_0 = Main.dust[num467]; - expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11); - Dust expr_14A09_cp_0 = Main.dust[num467]; - expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11); - Main.dust[num467].velocity.X = num463; - Main.dust[num467].velocity.Y = num464; + Dust dust = Main.dust[num467]; + dust.noGravity = true; + dust.position.X = projectile.Center.X; + dust.position.Y = projectile.Center.Y; + dust.position.X += (float)Main.rand.Next(-10, 11); + dust.position.Y += (float)Main.rand.Next(-10, 11); + dust.velocity.X = num463; + dust.velocity.Y = num464; } - int num251 = Main.rand.Next(2, 4); + int flameAmt = Main.rand.Next(2, 4); if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < num251; num252++) + for (int i = 0; i < flameAmt; i++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.75), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), 0f, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Melee/BonebreakerProjectile.cs b/Projectiles/Melee/BonebreakerProjectile.cs index cdafa10941..704f138600 100644 --- a/Projectiles/Melee/BonebreakerProjectile.cs +++ b/Projectiles/Melee/BonebreakerProjectile.cs @@ -31,10 +31,9 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - int num982 = 25; if (projectile.alpha > 0) { - projectile.alpha -= num982; + projectile.alpha -= 25; } if (projectile.alpha < 0) { @@ -42,16 +41,13 @@ namespace CalamityMod.Projectiles.Melee } if (projectile.ai[0] == 0f) { - projectile.ai[1] += 1f; - if (projectile.ai[1] >= 45f) + projectile.localAI[1] += 1f; + if (projectile.localAI[1] >= 45f) { - float num986 = 0.98f; - float num987 = 0.35f; - projectile.ai[1] = 45f; - projectile.velocity.X = projectile.velocity.X * num986; - projectile.velocity.Y = projectile.velocity.Y + num987; + projectile.velocity.X *= 0.98f; + projectile.velocity.Y += 0.35f; } - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; } //Sticky Behaviour projectile.StickyProjAI(15); @@ -59,7 +55,7 @@ namespace CalamityMod.Projectiles.Melee public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - projectile.ModifyHitNPCSticky(6, false); + projectile.ModifyHitNPCSticky(6, true); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) @@ -86,16 +82,16 @@ namespace CalamityMod.Projectiles.Melee } if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < Main.rand.Next(2,5); num252++) + for (int s = 0; s < Main.rand.Next(2,5); s++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) + Vector2 velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + while (velocity.X == 0f && velocity.Y == 0f) { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int shard = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)((float)Bonebreaker.BaseDamage * 0.5f), projectile.knockBack * 0.5f, projectile.owner, Main.rand.Next(0,4), 0f); + velocity.Normalize(); + velocity *= (float)Main.rand.Next(70, 101) * 0.1f; + int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5f), projectile.knockBack * 0.5f, projectile.owner, Main.rand.Next(0,4), 0f); } } } @@ -113,5 +109,16 @@ namespace CalamityMod.Projectiles.Melee target.AddBuff(BuffID.Venom, 240); target.AddBuff(ModContent.BuffType(), 240); } + + public override bool? CanHitNPC(NPC target) + { + if (projectile.ai[0] == 1f) + { + return false; + } + return null; + } + + public override bool CanHitPvp(Player target) => projectile.ai[0] != 1f; } } diff --git a/Projectiles/Melee/ClamCrusherFlail.cs b/Projectiles/Melee/ClamCrusherFlail.cs index 654d461866..9d9fe2dc87 100644 --- a/Projectiles/Melee/ClamCrusherFlail.cs +++ b/Projectiles/Melee/ClamCrusherFlail.cs @@ -127,14 +127,8 @@ namespace CalamityMod.Projectiles.Melee Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/ClamImpact"), (int)projectile.position.X, (int)projectile.position.Y); for (int num105 = 0; num105 < 50; num105++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int waterDust = Dust.NewDust(new Vector2(projectile.Center.X, projectile.Center.Y), projectile.width / 2, projectile.height / 2, 33, value15.X, value15.Y, 0, new Color(0, 142, 255), 1.5f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int waterDust = Dust.NewDust(new Vector2(projectile.Center.X, projectile.Center.Y), projectile.width / 2, projectile.height / 2, 33, velocity.X, velocity.Y, 0, new Color(0, 142, 255), 1.5f); Main.dust[waterDust].velocity *= 2f; } } diff --git a/Projectiles/Melee/DepthOrb.cs b/Projectiles/Melee/DepthOrb.cs index 820ef425cf..84fd73405c 100644 --- a/Projectiles/Melee/DepthOrb.cs +++ b/Projectiles/Melee/DepthOrb.cs @@ -55,8 +55,7 @@ namespace CalamityMod.Projectiles.Melee Main.PlaySound(SoundID.Item10, projectile.position); projectile.position = projectile.Center; projectile.width = projectile.height = 64; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + projectile.Center = projectile.position; for (int dustIndex = 0; dustIndex < 30; dustIndex++) { float num463 = (float)Main.rand.Next(-10, 11); @@ -80,6 +79,7 @@ namespace CalamityMod.Projectiles.Melee projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; + projectile.damage /= 2; projectile.Damage(); } diff --git a/Projectiles/Melee/DragonPowFlail.cs b/Projectiles/Melee/DragonPowFlail.cs index 706d707863..a335681163 100644 --- a/Projectiles/Melee/DragonPowFlail.cs +++ b/Projectiles/Melee/DragonPowFlail.cs @@ -150,61 +150,57 @@ namespace CalamityMod.Projectiles.Melee if (target.type == NPCID.TargetDummy) return; - PetalStorm(target, damage, knockback, crit); - Waterfalls(target, damage, knockback, crit); + PetalStorm(target.Center); + Waterfalls(target.Center); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + // Inflicts Abyssal Flames and Holy Flames for 8 seconds on-hit + target.AddBuff(ModContent.BuffType(), 480); + target.AddBuff(ModContent.BuffType(), 480); + + projectile.ai[0] = 1f; + projectile.netUpdate = true; + + PetalStorm(target.Center); + Waterfalls(target.Center); } // Spawns a storm of flower petals on-hit. - private void PetalStorm(NPC target, int damage, float knockback, bool crit) + private void PetalStorm(Vector2 targetPos) { - Main.PlaySound(SoundID.Item105, target.Center); + Main.PlaySound(SoundID.Item105, targetPos); int type = ProjectileID.FlowerPetal; int numPetals = 12; int petalDamage = projectile.damage / 8; float petalKB = 0f; - Player owner = Main.player[projectile.owner]; for (int i = 0; i < numPetals; ++i) { - float startOffsetX = Main.rand.NextFloat(1000f, 1400f) * (Main.rand.NextBool() ? -1f : 1f); - float startOffsetY = Main.rand.NextFloat(80f, 900f) * (Main.rand.NextBool() ? -1f : 1f); - Vector2 startPos = new Vector2(target.Center.X + startOffsetX, target.Center.Y + startOffsetY); - float dx = target.Center.X - startPos.X; - float dy = target.Center.Y - startPos.Y; - - // Add some randomness / inaccuracy to the petal target location - dx += Main.rand.NextFloat(-5f, 5f); - dy += Main.rand.NextFloat(-5f, 5f); - float speed = Main.rand.NextFloat(DragonPow.MinPetalSpeed, DragonPow.MaxPetalSpeed); - float dist = (float)Math.Sqrt((double)(dx * dx + dy * dy)); - dist = speed / dist; - dx *= dist; - dy *= dist; - Vector2 petalVel = new Vector2(dx, dy); - float angle = Main.rand.NextFloat(MathHelper.TwoPi); - if (projectile.owner == Main.myPlayer) - { - int idx = Projectile.NewProjectile(startPos, petalVel, type, petalDamage, petalKB, projectile.owner, 0f, 0f); - Main.projectile[idx].rotation = angle; - Main.projectile[idx].melee = true; - Main.projectile[idx].usesLocalNPCImmunity = true; - Main.projectile[idx].localNPCHitCooldown = -1; - } + if (projectile.owner == Main.myPlayer) + { + float angle = Main.rand.NextFloat(MathHelper.TwoPi); + Projectile petal = CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(DragonPow.MinPetalSpeed, DragonPow.MaxPetalSpeed), type, petalDamage, petalKB, projectile.owner); + petal.rotation = angle; + petal.Calamity().forceMelee = true; + petal.usesLocalNPCImmunity = true; + petal.localNPCHitCooldown = -1; + } } } - private void Waterfalls(NPC target, int damage, float knockback, bool crit) + private void Waterfalls(Vector2 targetPos) { int type = ModContent.ProjectileType(); int numWaterfalls = 12; int waterfallDamage = projectile.damage / 6; float waterfallKB = 0f; - Player owner = Main.player[projectile.owner]; for (int i = 0; i < numWaterfalls; ++i) { float startOffsetX = Main.rand.NextFloat(-120f, 120f); float startOffsetY = Main.rand.NextFloat(-740f, -700f); - Vector2 startPos = new Vector2(target.Center.X + startOffsetX, target.Center.Y + startOffsetY); + Vector2 startPos = new Vector2(targetPos.X + startOffsetX, targetPos.Y + startOffsetY); float fallSpeed = Main.rand.NextFloat(DragonPow.MinWaterfallSpeed, DragonPow.MaxWaterfallSpeed); Vector2 fallVec = new Vector2(0f, fallSpeed); fallVec = fallVec.RotatedBy(Main.rand.NextFloat(-0.08f, 0.08f)); diff --git a/Projectiles/Melee/DragonRageProj.cs b/Projectiles/Melee/DragonRageProj.cs index 671018b52f..b38af4fda1 100644 --- a/Projectiles/Melee/DragonRageProj.cs +++ b/Projectiles/Melee/DragonRageProj.cs @@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.Melee projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); for (int num621 = 0; num621 < 6; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -84,13 +84,13 @@ namespace CalamityMod.Projectiles.Melee } for (int num623 = 0; num623 < 9; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } } diff --git a/Projectiles/Melee/Earth3.cs b/Projectiles/Melee/Earth3.cs index 5cadbb8afb..c80c727a88 100644 --- a/Projectiles/Melee/Earth3.cs +++ b/Projectiles/Melee/Earth3.cs @@ -95,7 +95,7 @@ namespace CalamityMod.Projectiles.Melee projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); for (int num621 = 0; num621 < 20; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -105,13 +105,13 @@ namespace CalamityMod.Projectiles.Melee } for (int num623 = 0; num623 < 35; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Melee/ElementBallShiv.cs b/Projectiles/Melee/ElementBallShiv.cs index 687772a7b8..f808dd0b00 100644 --- a/Projectiles/Melee/ElementBallShiv.cs +++ b/Projectiles/Melee/ElementBallShiv.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Projectiles.Melee public override void SetDefaults() { - projectile.width = 10; - projectile.height = 10; + projectile.width = 20; + projectile.height = 20; projectile.friendly = true; projectile.melee = true; projectile.penetrate = 1; @@ -29,9 +29,9 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - int num250 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 66, (float)(projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); - Main.dust[num250].noGravity = true; - Main.dust[num250].velocity *= 0f; + int rainbow = Dust.NewDust(projectile.position, projectile.width, projectile.height, 66, (float)(projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); + Main.dust[rainbow].noGravity = true; + Main.dust[rainbow].velocity = Vector2.Zero; CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 36f, 20f); } @@ -48,35 +48,38 @@ namespace CalamityMod.Projectiles.Melee { for (int k = 0; k < 4; k++) { - int num = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 66, (float)(projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[num].noGravity = true; + int rainbow = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 66, (float)(projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[rainbow].noGravity = true; } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < 4; i++) - { - float xPos = i < 2 ? projectile.Center.X + 800 : projectile.Center.X - 800; - Vector2 source = new Vector2(xPos, projectile.Center.Y + Main.rand.Next(-800, 801)); - - float xStart = xPos; - Vector2 speed = target.Center - source; - float dir = speed.Length(); - dir = 10 / xStart; - float random = (float)Main.rand.Next(1, 150); - - speed.X *= dir * random; - speed.Y *= dir * random; - Projectile.NewProjectile(source, speed, ModContent.ProjectileType(), projectile.damage, 1f, projectile.owner); - } - } + OnHitEffects(target.Center); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(target.Center); + target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 120); + } + + private void OnHitEffects(Vector2 targetPos) + { + for (int x = 0; x < 4; x++) + { + if (projectile.owner == Main.myPlayer) + { + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, x > 2, 800f, 800f, 0f, 800f, 1f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, false, 50f); + } + } + } } } diff --git a/Projectiles/Melee/ElementalExcaliburBeam.cs b/Projectiles/Melee/ElementalExcaliburBeam.cs index 9df00e4032..660a368351 100644 --- a/Projectiles/Melee/ElementalExcaliburBeam.cs +++ b/Projectiles/Melee/ElementalExcaliburBeam.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -245,15 +243,21 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 60); - target.AddBuff(ModContent.BuffType(), 240); - target.AddBuff(ModContent.BuffType(), 240); - target.AddBuff(ModContent.BuffType(), 240); - target.AddBuff(ModContent.BuffType(), 240); - target.AddBuff(BuffID.CursedInferno, 240); - target.AddBuff(BuffID.Frostburn, 240); - target.AddBuff(BuffID.OnFire, 240); - target.AddBuff(BuffID.Ichor, 240); + target.ExoDebuffs(2f); + + if (projectile.ai[0] == 7f) + { + projectile.velocity *= 0.25f; + } + else if (projectile.ai[0] == 8f) + { + projectile.velocity *= -1f; + } + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(2f); if (projectile.ai[0] == 7f) { diff --git a/Projectiles/Melee/ExoGladComet.cs b/Projectiles/Melee/ExoGladComet.cs index ede9497a67..7ae372dc51 100644 --- a/Projectiles/Melee/ExoGladComet.cs +++ b/Projectiles/Melee/ExoGladComet.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -70,15 +68,12 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/ExoGladProj.cs b/Projectiles/Melee/ExoGladProj.cs index ae2b717f7e..558ddc2dc6 100644 --- a/Projectiles/Melee/ExoGladProj.cs +++ b/Projectiles/Melee/ExoGladProj.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using System; using Terraria; @@ -38,58 +36,26 @@ namespace CalamityMod.Projectiles.Melee } else { - for (int num41 = 0; num41 < 2; num41++) + for (int i = 0; i < 2; i++) { - int dustType = num41 == 0 ? 107 : 234; + int dustType = i == 0 ? 107 : 234; if (Main.rand.NextBool(4)) { dustType = 269; } - Vector2 value8 = Vector2.UnitX * -12f; - value8 = -Vector2.UnitY.RotatedBy((double)(counter * 0.1308997f + (float)num41 * 3.14159274f), default) * value7; - int num42 = Dust.NewDust(projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1.5f); - Main.dust[num42].noGravity = true; - Main.dust[num42].position = projectile.Center + value8; - Main.dust[num42].velocity = projectile.velocity; - int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 0.8f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0f; + Vector2 offset = Vector2.UnitX * -12f; + offset = -Vector2.UnitY.RotatedBy((double)(counter * 0.1308997f + (float)i * MathHelper.Pi), default) * value7; + int exo = Dust.NewDust(projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1.5f); + Main.dust[exo].noGravity = true; + Main.dust[exo].position = projectile.Center + offset; + Main.dust[exo].velocity = projectile.velocity; + int dusters = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 0.8f); + Main.dust[dusters].noGravity = true; + Main.dust[dusters].velocity *= 0f; } } - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 1000f; - bool flag17 = false; - for (int num475 = 0; num475 < Main.npc.Length; num475++) - { - if (Main.npc[num475].CanBeChasedBy(projectile, false)) - { - float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2); - float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); - if (num478 < num474) - { - num474 = num478; - num472 = num476; - num473 = num477; - flag17 = true; - } - } - } - if (flag17) - { - float num483 = 36f; - Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num484 = num472 - vector35.X; - float num485 = num473 - vector35.Y; - float num486 = (float)Math.Sqrt((double)(num484 * num484 + num485 * num485)); - num486 = num483 / num486; - num484 *= num486; - num485 *= num486; - projectile.velocity.X = (projectile.velocity.X * 20f + num484) / 21f; - projectile.velocity.Y = (projectile.velocity.Y * 20f + num485) / 21f; - } + CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 1000f, 36f, 20f); } public override void Kill(int timeLeft) @@ -102,66 +68,41 @@ namespace CalamityMod.Projectiles.Melee }); for (int k = 0; k < 4; k++) { - int num = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, dustType, (float)(projectile.direction * 2), 0f, 150, default, 1f); - Main.dust[num].noGravity = true; + int exo = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, dustType, (float)(projectile.direction * 2), 0f, 150, default, 1f); + Main.dust[exo].noGravity = true; } } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - int type = ModContent.ProjectileType(); - int numSwords = Main.rand.Next(1,4); + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + OnHitEffects(target.Center); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(target.Center); + target.ExoDebuffs(); + } + + private void OnHitEffects(Vector2 targetPos) + { float swordKB = projectile.knockBack; - for (int i = 0; i < numSwords; ++i) - { - float startOffsetX = Main.rand.NextFloat(1000f, 1400f) * (Main.rand.NextBool() ? -1f : 1f); - float startOffsetY = Main.rand.NextFloat(80f, 900f) * (Main.rand.NextBool() ? -1f : 1f); - Vector2 startPos = new Vector2(target.Center.X + startOffsetX, target.Center.Y + startOffsetY); - float dx = target.Center.X - startPos.X; - float dy = target.Center.Y - startPos.Y; - - dx += Main.rand.NextFloat(-5f, 5f); - dy += Main.rand.NextFloat(-5f, 5f); - float speed = Main.rand.NextFloat(24f, 30f); - float dist = (float)Math.Sqrt((double)(dx * dx + dy * dy)); - dist = speed / dist; - dx *= dist; - dy *= dist; - Vector2 swordVel = new Vector2(dx, dy); - float angle = Main.rand.NextFloat(MathHelper.TwoPi); - if (projectile.owner == Main.myPlayer) - { - int idx = Projectile.NewProjectile(startPos, swordVel, type, (int)((double)projectile.damage * 0.25), swordKB, projectile.owner, 0f, 0f); - Main.projectile[idx].rotation = angle; - } - } - + int swordDmg = (int)(projectile.damage * 0.25); + int numSwords = Main.rand.Next(1,4); int spearAmt = Main.rand.Next(1,4); - for (int n = 0; n < spearAmt; n++) + if (projectile.owner == Main.myPlayer) { - float x = projectile.position.X + (float)Main.rand.Next(-400, 400); - float y = projectile.position.Y + (float)Main.rand.Next(800, 1000); - Vector2 vector = new Vector2(x, y); - float num13 = projectile.position.X + (float)(projectile.width / 2) - vector.X; - float num14 = projectile.position.Y + (float)(projectile.height / 2) - vector.Y; - num13 += (float)Main.rand.Next(-100, 101); - int num15 = 29; - float num16 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14)); - num16 = (float)num15 / num16; - num13 *= num16; - num14 *= num16; - int num17 = Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.5), swordKB, projectile.owner, 0f, 0f); - } + for (int i = 0; i < numSwords; ++i) + { + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(24f, 30f), ModContent.ProjectileType(), swordDmg, swordKB, projectile.owner); + } - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + for (int n = 0; n < spearAmt; n++) + { + CalamityUtils.ProjectileRain(targetPos, 400f, 100f, -1000f, -800f, 29f, ModContent.ProjectileType(), swordDmg, swordKB, projectile.owner); + } + } } } } diff --git a/Projectiles/Melee/ExoGladSpears.cs b/Projectiles/Melee/ExoGladSpears.cs index 8b1a20bf84..489d2eea50 100644 --- a/Projectiles/Melee/ExoGladSpears.cs +++ b/Projectiles/Melee/ExoGladSpears.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -166,15 +164,12 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); } } } diff --git a/Projectiles/Melee/ExoGladiusBeam.cs b/Projectiles/Melee/ExoGladiusBeam.cs index e0b562e115..bebcea157f 100644 --- a/Projectiles/Melee/ExoGladiusBeam.cs +++ b/Projectiles/Melee/ExoGladiusBeam.cs @@ -118,15 +118,15 @@ namespace CalamityMod.Projectiles.Melee projectile.scale += (maxScale - 1) / (float)penetrationAmt; projectile.ai[1] = 5 + Main.rand.Next(-2, 3); - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + projectile.scale += (maxScale - 1) / (float)penetrationAmt; + projectile.ai[1] = 5 + Main.rand.Next(-2, 3); + + target.ExoDebuffs(); } } } diff --git a/Projectiles/Melee/Exobeam.cs b/Projectiles/Melee/Exobeam.cs index 77884b6d39..382ada426d 100644 --- a/Projectiles/Melee/Exobeam.cs +++ b/Projectiles/Melee/Exobeam.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -137,15 +135,12 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Melee/Exoboom.cs b/Projectiles/Melee/Exoboom.cs index 8b5b528c9e..802afbb5f6 100644 --- a/Projectiles/Melee/Exoboom.cs +++ b/Projectiles/Melee/Exoboom.cs @@ -81,30 +81,26 @@ namespace CalamityMod.Projectiles.Melee num463 *= num466; num464 *= num466; int num467 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); - Main.dust[num467].noGravity = true; - Main.dust[num467].position.X = projectile.Center.X; - Main.dust[num467].position.Y = projectile.Center.Y; - Dust expr_149DF_cp_0 = Main.dust[num467]; - expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11); - Dust expr_14A09_cp_0 = Main.dust[num467]; - expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11); - Main.dust[num467].velocity.X = num463; - Main.dust[num467].velocity.Y = num464; + Dust dust = Main.dust[num467]; + dust.noGravity = true; + dust.position.X = projectile.Center.X; + dust.position.Y = projectile.Center.Y; + dust.position.X += (float)Main.rand.Next(-10, 11); + dust.position.Y += (float)Main.rand.Next(-10, 11); + dust.velocity.X = num463; + dust.velocity.Y = num464; num462++; } } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); + } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); } } } diff --git a/Projectiles/Melee/Exocomet.cs b/Projectiles/Melee/Exocomet.cs index 4efc5a5ed2..400ab230b9 100644 --- a/Projectiles/Melee/Exocomet.cs +++ b/Projectiles/Melee/Exocomet.cs @@ -90,15 +90,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); if (target.type == NPCID.TargetDummy) { return; @@ -115,6 +107,21 @@ namespace CalamityMod.Projectiles.Melee CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 1f); } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); + float healAmt = (float)damage * 0.01f; + if ((int)healAmt == 0) + { + return; + } + if (Main.player[Main.myPlayer].lifeSteal <= 0f) + { + return; + } + CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 1f); + } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); diff --git a/Projectiles/Melee/GalileosPlanet.cs b/Projectiles/Melee/GalileosPlanet.cs index 800ba661f9..3853e7760b 100644 --- a/Projectiles/Melee/GalileosPlanet.cs +++ b/Projectiles/Melee/GalileosPlanet.cs @@ -130,7 +130,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[num21].velocity *= 2; } } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Melee/GreenBall.cs b/Projectiles/Melee/GreenBall.cs index 5ca2cbf060..f7c99668db 100644 --- a/Projectiles/Melee/GreenBall.cs +++ b/Projectiles/Melee/GreenBall.cs @@ -7,8 +7,6 @@ namespace CalamityMod.Projectiles.Melee { public class GreenBall : ModProjectile { - private int projTime = 15; - public override void SetStaticDefaults() { DisplayName.SetDefault("Green Bag"); @@ -36,14 +34,12 @@ namespace CalamityMod.Projectiles.Melee projectile.alpha = 0; } projectile.rotation = projectile.velocity.X * 0.04f; - projTime--; - if (projTime == 0) + if (projectile.timeLeft % 15 == 0) { if (projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.35f, projectile.velocity.Y * 0.35f, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.35f, projectile.velocity.Y * 0.35f, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 0f); } - projTime = 15; } } diff --git a/Projectiles/Melee/HellionSpike.cs b/Projectiles/Melee/HellionSpike.cs index 2e7c6bc864..64c2de990b 100644 --- a/Projectiles/Melee/HellionSpike.cs +++ b/Projectiles/Melee/HellionSpike.cs @@ -56,25 +56,27 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.immune[projectile.owner] = 8; + OnHitEffects(target.Center, crit); target.AddBuff(BuffID.Venom, 300); - if (crit) - { - float xPos = projectile.Center.X + 800 * Main.rand.NextBool(2).ToDirectionInt(); - float yPos = projectile.Center.Y + Main.rand.Next(-800, 801); - Vector2 spawnPosition = new Vector2(xPos, yPos); - Vector2 velocity = target.Center - spawnPosition; - float dir = 10 / spawnPosition.X; - velocity.X *= dir * 150; - velocity.Y *= dir * 150; - velocity.X = MathHelper.Clamp(velocity.X, -15f, 15f); - velocity.Y = MathHelper.Clamp(velocity.Y, -15f, 15f); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(target.Center, crit); + target.AddBuff(BuffID.Venom, 300); + } + + private void OnHitEffects(Vector2 targetPos, bool crit) + { + if (crit) + { if (projectile.owner == Main.myPlayer) { - int petal = Projectile.NewProjectile(spawnPosition, velocity, ProjectileID.FlowerPetal, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner); - Main.projectile[petal].Calamity().forceMelee = true; - Main.projectile[petal].localNPCHitCooldown = -1; + Projectile petal = CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ProjectileID.FlowerPetal, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, true); + petal.Calamity().forceMelee = true; + petal.localNPCHitCooldown = -1; } - } - } + } + } } } diff --git a/Projectiles/Melee/RedBall.cs b/Projectiles/Melee/RedBall.cs index a489dc1a20..b3da2a6d7f 100644 --- a/Projectiles/Melee/RedBall.cs +++ b/Projectiles/Melee/RedBall.cs @@ -7,8 +7,6 @@ namespace CalamityMod.Projectiles.Melee { public class RedBall : ModProjectile { - private int projTime = 15; - public override void SetStaticDefaults() { DisplayName.SetDefault("Red Bag"); @@ -36,14 +34,12 @@ namespace CalamityMod.Projectiles.Melee projectile.alpha = 0; } projectile.rotation = projectile.velocity.X * 0.04f; - projTime--; - if (projTime == 0) + if (projectile.timeLeft % 15 == 0) { if (projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.35f, projectile.velocity.Y * 0.35f, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.35f, projectile.velocity.Y * 0.35f, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 0f); } - projTime = 15; } } diff --git a/Projectiles/Melee/RedtideWhirlpool.cs b/Projectiles/Melee/RedtideWhirlpool.cs index 6dfcb4d07f..3e80bfc60c 100644 --- a/Projectiles/Melee/RedtideWhirlpool.cs +++ b/Projectiles/Melee/RedtideWhirlpool.cs @@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Melee { projectile.frame = 0; } - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/RoxSlam.cs b/Projectiles/Melee/RoxSlam.cs index feecfb4671..c41919ffb6 100644 --- a/Projectiles/Melee/RoxSlam.cs +++ b/Projectiles/Melee/RoxSlam.cs @@ -19,15 +19,25 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - Player player = Main.player[Main.myPlayer]; + Player player = Main.player[projectile.owner]; //Kills the projectile if the alt attack ended if (player.itemAnimation == 0) { projectile.Kill(); } - //Makes the projectiles follow the player - projectile.velocity.X = player.velocity.X; - projectile.velocity.Y = player.velocity.Y; + //Makes the projectiles track the player + float posX; + float posY = player.Center.Y + 63; + // Makes the projectile follow the proper position on the X axis + if (player.direction == 1) + { + posX = player.Center.X + 6; + } + else + { + posX = player.Center.X - 8; + } + projectile.Center = new Vector2(posX, posY - (player.height / 10f)); } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Melee/SHIV.cs b/Projectiles/Melee/SHIV.cs index 1072dba0d2..40091aee13 100644 --- a/Projectiles/Melee/SHIV.cs +++ b/Projectiles/Melee/SHIV.cs @@ -18,29 +18,31 @@ namespace CalamityMod.Projectiles.Melee public override void SetDefaults() { - projectile.width = 10; - projectile.height = 10; + projectile.width = 20; + projectile.height = 20; projectile.friendly = true; projectile.melee = true; projectile.penetrate = 1; projectile.tileCollide = false; projectile.timeLeft = 600; projectile.aiStyle = 27; + projectile.extraUpdates = 1; } public override void AI() { - projectile.velocity.X *= 1.075f; - projectile.velocity.Y *= 1.075f; - int num250 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 66, (float)(projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); - Main.dust[num250].noGravity = true; - Main.dust[num250].velocity *= 0f; + if (projectile.velocity.Length() < 25f && projectile.timeLeft % 2 == 0) + projectile.velocity *= 1.04f; + + int rainbow = Dust.NewDust(projectile.position, projectile.width, projectile.height, 66, (float)(projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); + Main.dust[rainbow].noGravity = true; + Main.dust[rainbow].velocity = Vector2.Zero; } public override void Kill(int timeLeft) { - int num = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 66, (float)(projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[num].noGravity = true; + int rainbow = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 66, (float)(projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + Main.dust[rainbow].noGravity = true; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Melee/ShortBeam.cs b/Projectiles/Melee/ShortBeam.cs index a97d2516d8..df133f307b 100644 --- a/Projectiles/Melee/ShortBeam.cs +++ b/Projectiles/Melee/ShortBeam.cs @@ -27,7 +27,6 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.2f / 255f, 0f, (255 - projectile.alpha) * 0.2f / 255f); - projectile.velocity.Y += projectile.ai[0]; if (Main.rand.NextBool(5)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 73, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); diff --git a/Projectiles/Melee/ShortNightBeam.cs b/Projectiles/Melee/ShortNightBeam.cs index 8d71bb8209..b289cca935 100644 --- a/Projectiles/Melee/ShortNightBeam.cs +++ b/Projectiles/Melee/ShortNightBeam.cs @@ -27,7 +27,6 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Lighting.AddLight(projectile.Center, 0f, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.1f / 255f); - projectile.velocity.Y += projectile.ai[0]; if (Main.rand.NextBool(5)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 21, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); diff --git a/Projectiles/Melee/ShortTerraBeam.cs b/Projectiles/Melee/ShortTerraBeam.cs index 846387995b..d959cc1355 100644 --- a/Projectiles/Melee/ShortTerraBeam.cs +++ b/Projectiles/Melee/ShortTerraBeam.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Projectiles.Melee public override void SetDefaults() { projectile.width = 20; - projectile.height = 6; + projectile.height = 20; projectile.aiStyle = 27; projectile.friendly = true; projectile.melee = true; diff --git a/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs b/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs index e98f738239..47f5399f4e 100644 --- a/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs +++ b/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs @@ -38,17 +38,29 @@ namespace CalamityMod.Projectiles.Melee.Spears if (Main.rand.NextBool(5)) Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, Main.rand.NextBool(3) ? 16 : 127, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - Vector2 goreVec = new Vector2(projectile.position.X + (float)(projectile.width / 2) + projectile.velocity.X, projectile.position.Y + (float)(projectile.height / 2) + projectile.velocity.Y); + Vector2 goreVec = projectile.Center + projectile.velocity; if (Main.rand.NextBool(8)) { int smoke = Gore.NewGore(goreVec, default, Main.rand.Next(375, 378), 1f); Main.gore[smoke].behindTiles = true; } } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.immune[projectile.owner] = 6; + OnHitEffects(target.Center, crit); target.AddBuff(BuffID.OnFire, 300); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(target.Center, crit); + target.AddBuff(BuffID.OnFire, 300); + } + + private void OnHitEffects(Vector2 targetPos, bool crit) + { if (projectile.owner == Main.myPlayer) { int boom = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); @@ -58,20 +70,12 @@ namespace CalamityMod.Projectiles.Melee.Spears { for (int i = 0; i < 2; i++) { - float xPos = projectile.position.X + 800f * Main.rand.NextBool(2).ToDirectionInt(); - Vector2 spawnPosition = new Vector2(xPos, projectile.position.Y - Main.rand.Next(-800, 801)); - float speedX = target.position.X - spawnPosition.X; - float speedY = target.position.Y - spawnPosition.Y; - float magnitude = (float)Math.Sqrt(speedX * speedX + speedY * speedY); - magnitude = 10f / xPos; - speedX *= magnitude * 150; - speedY *= magnitude * 150; - speedX = MathHelper.Clamp(speedX, -15f, 15f); - speedY = MathHelper.Clamp(speedY, -15f, 15f); - if (projectile.owner == Main.myPlayer) - Projectile.NewProjectile(spawnPosition.X, spawnPosition.Y, speedX, speedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 2f, projectile.owner); - } - } + if (projectile.owner == Main.myPlayer) + { + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 2f, projectile.owner, true); + } + } + } } } } diff --git a/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs b/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs index 4fc87924f3..f4970d16a2 100644 --- a/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs +++ b/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs @@ -37,27 +37,29 @@ namespace CalamityMod.Projectiles.Melee.Spears { Projectile.NewProjectile(projectile.Center.X + projectile.velocity.X, projectile.Center.Y + projectile.velocity.Y, projectile.velocity.X * 2.4f, projectile.velocity.Y * 2.4f, ModContent.ProjectileType(), (int)(projectile.damage * 0.65), projectile.knockBack * 0.85f, projectile.owner, 0f, 0f); }; - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 8; - target.AddBuff(BuffID.Venom, 300); + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.immune[projectile.owner] = 8; + OnHitEffects(target.Center, crit); + target.AddBuff(BuffID.Venom, 300); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(target.Center, crit); + target.AddBuff(BuffID.Venom, 300); + } + + private void OnHitEffects(Vector2 targetPos, bool crit) + { if (crit) { - float xPos = projectile.position.X + 800f * Main.rand.NextBool(2).ToDirectionInt(); - Vector2 spawnPosition = new Vector2(xPos, projectile.position.Y - Main.rand.Next(-800, 801)); - float speedX = target.position.X - spawnPosition.X; - float speedY = target.position.Y - spawnPosition.Y; - float magnitude = (float)Math.Sqrt(speedX * speedX + speedY * speedY); - magnitude = 10f / xPos; - speedX *= magnitude * 150; - speedY *= magnitude * 150; - speedX = MathHelper.Clamp(speedX, -15f, 15f); - speedY = MathHelper.Clamp(speedY, -15f, 15f); - if (projectile.owner == Main.myPlayer) + if (projectile.owner == Main.myPlayer) { - int petal = Projectile.NewProjectile(spawnPosition.X, spawnPosition.Y, speedX, speedY, ProjectileID.FlowerPetal, (int)(projectile.damage * 0.5), 2f, projectile.owner); - Main.projectile[petal].Calamity().forceMelee = true; - Main.projectile[petal].localNPCHitCooldown = -1; + Projectile petal = CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ProjectileID.FlowerPetal, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, true); + petal.Calamity().forceMelee = true; + petal.localNPCHitCooldown = -1; } } } diff --git a/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs b/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs index d228b7851f..755b3b173d 100644 --- a/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs +++ b/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs @@ -64,22 +64,9 @@ namespace CalamityMod.Projectiles.Melee.Spears for (int i = 0; i < projAmt; ++i) { int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); - float startOffsetX = Main.rand.NextFloat(1000f, 1400f) * (Main.rand.NextBool() ? -1f : 1f); - float startOffsetY = Main.rand.NextFloat(80f, 900f) * (Main.rand.NextBool() ? -1f : 1f); - Vector2 startPos = new Vector2(targetPos.X + startOffsetX, targetPos.Y + startOffsetY); - Vector2 projVel = targetPos - startPos; - - // Add some randomness / inaccuracy to the projectile target location - projVel.X += Main.rand.NextFloat(-5f, 5f); - projVel.Y += Main.rand.NextFloat(-5f, 5f); - float speed = Main.rand.NextFloat(25f, 35f); - float dist = projVel.Length(); - dist = speed / dist; - projVel.X *= dist; - projVel.Y *= dist; if (projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(startPos, projVel, type, projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner, 0f, 0f); + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(25f, 35f), type, projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner); } } } diff --git a/Projectiles/Melee/TenebreusTidesWaterProjectile.cs b/Projectiles/Melee/TenebreusTidesWaterProjectile.cs index 9860c3de00..7970a0aa6a 100644 --- a/Projectiles/Melee/TenebreusTidesWaterProjectile.cs +++ b/Projectiles/Melee/TenebreusTidesWaterProjectile.cs @@ -98,22 +98,9 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < projAmt; ++i) { int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); - float startOffsetX = Main.rand.NextFloat(1000f, 1400f) * (Main.rand.NextBool() ? -1f : 1f); - float startOffsetY = Main.rand.NextFloat(80f, 900f) * (Main.rand.NextBool() ? -1f : 1f); - Vector2 startPos = new Vector2(targetPos.X + startOffsetX, targetPos.Y + startOffsetY); - Vector2 projVel = targetPos - startPos; - - // Add some randomness / inaccuracy to the projectile target location - projVel.X += Main.rand.NextFloat(-5f, 5f); - projVel.Y += Main.rand.NextFloat(-5f, 5f); - float speed = Main.rand.NextFloat(25f, 35f); - float dist = projVel.Length(); - dist = speed / dist; - projVel.X *= dist; - projVel.Y *= dist; if (projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(startPos, projVel, type, projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner, 0f, 0f); + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(25f, 35f), type, projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner); } } } diff --git a/Projectiles/Melee/TyphonsGreedStaff.cs b/Projectiles/Melee/TyphonsGreedStaff.cs index 1ff3b8b1a3..2b213b2620 100644 --- a/Projectiles/Melee/TyphonsGreedStaff.cs +++ b/Projectiles/Melee/TyphonsGreedStaff.cs @@ -142,19 +142,10 @@ namespace CalamityMod.Projectiles.Melee projectile.localAI[0] += 1f; if (projectile.localAI[0] % 12f == 0f) { - float xPos = projectile.Center.X + 800 * Main.rand.NextBool(2).ToDirectionInt(); - float yPos = projectile.Center.Y + Main.rand.Next(-800, 801); - Vector2 spawnPosition = new Vector2(xPos, yPos); - Vector2 velocity = player.Center - spawnPosition; - float dir = 10 / spawnPosition.X; - velocity.X *= dir * 150; - velocity.Y *= dir * 150; - velocity.X = MathHelper.Clamp(velocity.X, -15f, 15f); - velocity.Y = MathHelper.Clamp(velocity.Y, -15f, 15f); if (projectile.owner == Main.myPlayer) { - float ai1 = Main.rand.NextFloat() + 0.5f; - Projectile.NewProjectile(spawnPosition, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, 0f, ai1); + Projectile bubble = CalamityUtils.ProjectileBarrage(projectile.Center, player.Center, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, true); + bubble.ai[1] = Main.rand.NextFloat() + 0.5f; } } } @@ -164,10 +155,10 @@ namespace CalamityMod.Projectiles.Melee Rectangle myRect = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); if (projectile.owner == Main.myPlayer) { - for (int i = 0; i < 200; i++) + for (int i = 0; i < Main.maxNPCs; i++) { if (Main.npc[i].active && !Main.npc[i].dontTakeDamage && - ((projectile.friendly && (!Main.npc[i].friendly || projectile.type == 318 || (Main.npc[i].type == NPCID.Guide && projectile.owner < 255 && Main.player[projectile.owner].killGuide) || (Main.npc[i].type == NPCID.Clothier && projectile.owner < 255 && Main.player[projectile.owner].killClothier))) || + ((projectile.friendly && (!Main.npc[i].friendly || (Main.npc[i].type == NPCID.Guide && projectile.owner < 255 && Main.player[projectile.owner].killGuide) || (Main.npc[i].type == NPCID.Clothier && projectile.owner < 255 && Main.player[projectile.owner].killClothier))) || (projectile.hostile && Main.npc[i].friendly && !Main.npc[i].dontTakeDamageFromHostiles)) && (projectile.owner < 0 || Main.npc[i].immune[projectile.owner] == 0 || projectile.maxPenetrate == 1)) { if (Main.npc[i].noTileCollide || !projectile.ownerHitCheck || projectile.CanHit(Main.npc[i])) diff --git a/Projectiles/Pets/RotomPet.cs b/Projectiles/Pets/RotomPet.cs index 241890e028..c9c30336f8 100644 --- a/Projectiles/Pets/RotomPet.cs +++ b/Projectiles/Pets/RotomPet.cs @@ -6,138 +6,168 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Pets { public class RotomPet : ModProjectile - { - private int biome = 0; - private float dust = 0f; + { + private bool initialized = false; + private int form = 0; + private const int Normal = 0; + private const int Dex = 1; + private const int Wash = 2; + private const int Heat = 3; + private const int Frost = 4; + private const int Mow = 5; + private const int Fan = 6; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Rotom"); - Main.projFrames[projectile.type] = 4; - Main.projPet[projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rotom"); + Main.projFrames[projectile.type] = 4; + Main.projPet[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.netImportant = true; - projectile.width = 30; - projectile.height = 30; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.timeLeft *= 5; - } + public override void SetDefaults() + { + projectile.netImportant = true; + projectile.width = projectile.height = 30; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft *= 5; + } - public override void AI() - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); + public override void AI() + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); - if (CalamityPlayer.areThereAnyDamnBosses) - biome = 1; //dex - else if (player.ZoneBeach || player.Calamity().ZoneSunkenSea || player.Calamity().ZoneSulphur || player.Calamity().ZoneAbyss) - biome = 2; //wash - else if (player.ZoneTowerSolar || player.ZoneDesert || player.ZoneUndergroundDesert || player.ZoneUnderworldHeight || player.Calamity().ZoneCalamity) - biome = 3; //heat - else if (player.ZoneSnow || Main.snowMoon) - biome = 4; //frost - else if (player.ZoneJungle) - biome = 5; //mow - else if (player.ZoneSkyHeight || player.ZoneMeteor || player.Calamity().ZoneAstral) - biome = 6; //fan - else - biome = 0; //anything else + if (!player.active) + { + projectile.active = false; + return; + } + if (player.dead) + { + modPlayer.rotomPet = false; + } + if (modPlayer.rotomPet) + { + projectile.timeLeft = 2; + } - if (!player.active) - { - projectile.active = false; - return; - } - if (player.dead) - { - modPlayer.rotomPet = false; - } - if (modPlayer.rotomPet) - { - projectile.timeLeft = 2; - } + if (!initialized) + { + DustEffects(); + initialized = true; + } - if (dust == 0f) - { - int num501 = 25; - for (int num502 = 0; num502 < num501; num502++) - { - int num503 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 16f), projectile.width, projectile.height - 16, 132, 0f, 0f, 0, default, 1f); - Main.dust[num503].velocity *= 2f; - Main.dust[num503].scale *= 1.15f; - } - dust += 1f; - } + UpdateForm(player); + UpdateFrames(); projectile.FloatingPetAI(true, 0.05f); + } - projectile.frameCounter++; + private void UpdateForm(Player player) + { + if (CalamityPlayer.areThereAnyDamnBosses) + form = Dex; + else if (player.ZoneBeach || player.InSunkenSea() || player.InSulphur() || player.InAbyss()) + form = Wash; + else if (player.ZoneTowerSolar || player.ZoneDesert || player.ZoneUndergroundDesert || player.ZoneUnderworldHeight || player.InCalamity()) + form = Heat; + else if (player.ZoneSnow || Main.snowMoon) + form = Frost; + else if (player.ZoneJungle) + form = Mow; + else if (player.ZoneSkyHeight || player.ZoneMeteor || player.InAstral()) + form = Fan; + else + form = Normal; + } + + private void DustEffects() + { + int dustAmt = 25; + for (int i = 0; i < dustAmt; i++) + { + int electric = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 16f), projectile.width, projectile.height - 16, 132, 0f, 0f, 0, default, 1f); + Main.dust[electric].velocity *= 2f; + Main.dust[electric].scale *= 1.15f; + } + } + + private void UpdateFrames() + { + projectile.frameCounter++; if (projectile.frameCounter > 6) { projectile.frame++; - projectile.frameCounter = 0; + projectile.frameCounter = 0; } - if (projectile.frame >= 4) - { - projectile.frame = 0; - } - } + if (projectile.frame >= 4) + { + projectile.frame = 0; + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture = Main.projectileTexture[projectile.type]; - if (biome == 1) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomDex"); - if (biome == 2) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomWash"); - if (biome == 3) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomHeat"); - if (biome == 4) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFrost"); - if (biome == 5) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomMow"); - if (biome == 6) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFan"); - int height = texture.Height / Main.projFrames[projectile.type]; - int frameHeight = height * projectile.frame; - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; - Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, spriteEffects, 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Drawing(spriteBatch, lightColor, + Main.projectileTexture[projectile.type], + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomDex"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomWash"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomHeat"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFrost"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomMow"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFan")); + return false; + } public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomPetGlow"); - if (biome == 1) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomDexGlow"); - if (biome == 2) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomWashGlow"); - if (biome == 3) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomHeatGlow"); - if (biome == 4) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFrostGlow"); - if (biome == 5) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomMowGlow"); - if (biome == 6) - texture = ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFanGlow"); - int num214 = texture.Height / Main.projFrames[projectile.type]; - int y6 = num214 * projectile.frame; + Drawing(spriteBatch, Color.White, + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomPetGlow"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomDexGlow"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomWashGlow"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomHeatGlow"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFrostGlow"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomMowGlow"), + ModContent.GetTexture("CalamityMod/Projectiles/Pets/RotomFanGlow")); + } + + private void Drawing(SpriteBatch spriteBatch, Color color, Texture2D normal, Texture2D dex, Texture2D wash, Texture2D heat, Texture2D frost, Texture2D mow, Texture2D fan) + { + Texture2D texture = normal; + switch (form) + { + case Dex: + texture = dex; + break; + case Wash: + texture = wash; + break; + case Heat: + texture = heat; + break; + case Frost: + texture = frost; + break; + case Mow: + texture = mow; + break; + case Fan: + texture = fan; + break; + default: + break; + } + + int height = texture.Height / Main.projFrames[projectile.type]; + int frameHeight = height * projectile.frame; SpriteEffects spriteEffects = SpriteEffects.None; if (projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, num214)), Color.White, projectile.rotation, new Vector2((float)texture.Width / 2f, (float)num214 / 2f), projectile.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), color, projectile.rotation, new Vector2(texture.Width / 2f, height / 2f), projectile.scale, spriteEffects, 0f); } - public override bool CanDamage() - { - return false; - } - } + public override bool CanDamage() => false; + } } diff --git a/Projectiles/Ranged/AMRShot.cs b/Projectiles/Ranged/AMRShot.cs index c7d8403d73..b6a2b523e2 100644 --- a/Projectiles/Ranged/AMRShot.cs +++ b/Projectiles/Ranged/AMRShot.cs @@ -40,29 +40,32 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (crit) - { - for (int x = 0; x < 8; x++) - { - float xPos = x > 4 ? projectile.Center.X + 500 : projectile.Center.X - 500; - float yPos = projectile.Center.Y + Main.rand.Next(-500, 501); - Vector2 spawnPosition = new Vector2(xPos, yPos); - Vector2 velocity = target.Center - spawnPosition; - float dir = velocity.Length(); - dir = 10 / spawnPosition.X; - velocity.X *= dir * 150; - velocity.Y *= dir * 150; - if (projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(spawnPosition, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.1), 1f, projectile.owner); - } - } - } + OnHitEffects(target.Center, crit); target.AddBuff(ModContent.BuffType(), 600); if (target.defense > 50) { target.defense -= 50; } + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(target.Center, crit); + target.AddBuff(ModContent.BuffType(), 600); + } + + private void OnHitEffects(Vector2 targetPos, bool crit) + { + if (crit) + { + for (int x = 0; x < 8; x++) + { + if (projectile.owner == Main.myPlayer) + { + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, x > 4, 500f, 500f, 0f, 500f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.1), 1f, projectile.owner); + } + } + } } } } diff --git a/Projectiles/Ranged/Aquashard.cs b/Projectiles/Ranged/Aquashard.cs index 5faf5234ff..0b9f8b7705 100644 --- a/Projectiles/Ranged/Aquashard.cs +++ b/Projectiles/Ranged/Aquashard.cs @@ -26,24 +26,18 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { projectile.velocity.X *= 0.9995f; - projectile.velocity.Y = projectile.velocity.Y + 0.01f; + projectile.velocity.Y += 0.01f; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - int num251 = Main.rand.Next(2, 4); + int projAmt = Main.rand.Next(2, 4); if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < num251; num252++) + for (int i = 0; i < projAmt; i++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.5), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Ranged/BeeRPG.cs b/Projectiles/Ranged/BeeRPG.cs index a5d6284419..715177685a 100644 --- a/Projectiles/Ranged/BeeRPG.cs +++ b/Projectiles/Ranged/BeeRPG.cs @@ -52,13 +52,13 @@ namespace CalamityMod.Projectiles.Ranged } else if (Main.rand.NextBool(2)) { - int num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); + int num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].noGravity = true; Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default) * 1.1f; Main.rand.Next(2); - num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); + num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].noGravity = true; Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default) * 1.1f; @@ -124,7 +124,7 @@ namespace CalamityMod.Projectiles.Ranged Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 14); for (int num621 = 0; num621 < 5; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -134,13 +134,13 @@ namespace CalamityMod.Projectiles.Ranged } for (int num623 = 0; num623 < 10; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Ranged/BigNuke.cs b/Projectiles/Ranged/BigNuke.cs index 616e02a28b..ded24101f6 100644 --- a/Projectiles/Ranged/BigNuke.cs +++ b/Projectiles/Ranged/BigNuke.cs @@ -71,7 +71,7 @@ namespace CalamityMod.Projectiles.Ranged Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 14); for (int num621 = 0; num621 < 90; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -81,13 +81,13 @@ namespace CalamityMod.Projectiles.Ranged } for (int num623 = 0; num623 < 180; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(9); + CalamityUtils.ExplosionGores(projectile.Center, 9); } } } diff --git a/Projectiles/Ranged/BlueExoArrow.cs b/Projectiles/Ranged/BlueExoArrow.cs index b38cfbcacc..2a9210321b 100644 --- a/Projectiles/Ranged/BlueExoArrow.cs +++ b/Projectiles/Ranged/BlueExoArrow.cs @@ -96,17 +96,30 @@ namespace CalamityMod.Projectiles.Ranged return false; } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); + for (int x = 0; x < 3; x++) + { + float xPos = projectile.ai[0] > 0 ? projectile.position.X + 500 : projectile.position.X - 500; + Vector2 vector2 = new Vector2(xPos, projectile.position.Y + Main.rand.Next(-500, 501)); + float num80 = xPos; + float speedX = (float)target.position.X - vector2.X; + float speedY = (float)target.position.Y - vector2.Y; + float dir = (float)Math.Sqrt((double)(speedX * speedX + speedY * speedY)); + dir = 10 / num80; + speedX *= dir * 150; + speedY *= dir * 150; + if (projectile.owner == Main.myPlayer) + { + Projectile.NewProjectile(vector2.X, vector2.Y, speedX, speedY, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.7), 1f, projectile.owner); + } + } + } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); for (int x = 0; x < 3; x++) { float xPos = projectile.ai[0] > 0 ? projectile.position.X + 500 : projectile.position.X - 500; diff --git a/Projectiles/Ranged/CardDiamond.cs b/Projectiles/Ranged/CardDiamond.cs index 2fdbf43907..ccc514c942 100644 --- a/Projectiles/Ranged/CardDiamond.cs +++ b/Projectiles/Ranged/CardDiamond.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.spriteDirection = projectile.direction; if (Main.rand.NextBool(2)) { - int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, 30, 0f, 0f, 0, default, 0.5f); + int num137 = Dust.NewDust(projectile.position, 1, 1, 30, 0f, 0f, 0, default, 0.5f); Main.dust[num137].velocity *= 0f; Main.dust[num137].noGravity = true; } @@ -53,33 +53,31 @@ namespace CalamityMod.Projectiles.Ranged { projectile.position = projectile.Center; projectile.width = projectile.height = 50; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - projectile.maxPenetrate = -1; - projectile.penetrate = -1; + projectile.Center = projectile.position; + projectile.maxPenetrate = projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.Damage(); - Main.PlaySound(SoundID.Item14, (int)projectile.Center.X, (int)projectile.Center.Y); - for (int num621 = 0; num621 < 10; num621++) + Main.PlaySound(SoundID.Item14, projectile.Center); + for (int d = 0; d < 10; d++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 30, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int paper = Dust.NewDust(projectile.position, projectile.width, projectile.height, 30, 0f, 0f, 100, default, 2f); + Main.dust[paper].velocity *= 3f; if (Main.rand.NextBool(2)) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[paper].scale = 0.5f; + Main.dust[paper].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 15; num623++) + for (int d = 0; d < 15; d++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 30, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 30, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int paper = Dust.NewDust(projectile.position, projectile.width, projectile.height, 30, 0f, 0f, 100, default, 3f); + Main.dust[paper].noGravity = true; + Main.dust[paper].velocity *= 5f; + paper = Dust.NewDust(projectile.position, projectile.width, projectile.height, 30, 0f, 0f, 100, default, 2f); + Main.dust[paper].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Ranged/ClamorRifleProj.cs b/Projectiles/Ranged/ClamorRifleProj.cs index b356c3be83..9b5430bd60 100644 --- a/Projectiles/Ranged/ClamorRifleProj.cs +++ b/Projectiles/Ranged/ClamorRifleProj.cs @@ -49,19 +49,13 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - int num251 = Main.rand.Next(2, 3); + int bulletAmt = 2; if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < num251; num252++) + for (int b = 0; b < bulletAmt; b++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.45), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.45), 0f, projectile.owner, 0f, 0f); } } Main.PlaySound(SoundID.Item118, projectile.Center); diff --git a/Projectiles/Ranged/CosmicFire.cs b/Projectiles/Ranged/CosmicFire.cs index fc45b2f130..5b3dccc63a 100644 --- a/Projectiles/Ranged/CosmicFire.cs +++ b/Projectiles/Ranged/CosmicFire.cs @@ -37,47 +37,44 @@ namespace CalamityMod.Projectiles.Ranged } if (projectile.ai[0] > 7f) { - float num296 = 1f; + float scalar = 1f; if (projectile.ai[0] == 8f) { - num296 = 0.25f; + scalar = 0.25f; } else if (projectile.ai[0] == 9f) { - num296 = 0.5f; + scalar = 0.5f; } else if (projectile.ai[0] == 10f) { - num296 = 0.75f; + scalar = 0.75f; } projectile.ai[0] += 1f; int dustType = 62; if (Main.rand.NextBool(2)) { - for (int num298 = 0; num298 < 1; num298++) - { - int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 3f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 1.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.velocity += projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } - } + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); + Dust dust = Main.dust[fire]; + if (Main.rand.NextBool(3)) + { + dust.noGravity = true; + dust.scale *= 3f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + else + { + dust.scale *= 1.5f; + } + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= scalar; + dust.velocity += projectile.velocity; + if (!dust.noGravity) + { + dust.velocity *= 0.5f; + } } } else diff --git a/Projectiles/Ranged/DrataliornusExoArrow.cs b/Projectiles/Ranged/DrataliornusExoArrow.cs index c032573a6e..d57837122d 100644 --- a/Projectiles/Ranged/DrataliornusExoArrow.cs +++ b/Projectiles/Ranged/DrataliornusExoArrow.cs @@ -60,10 +60,11 @@ namespace CalamityMod.Projectiles.Ranged } } - public override void OnHitPlayer(Player target, int damage, bool crit) + public override void OnHitPvp(Player target, int damage, bool crit) { - target.AddBuff(BuffID.Ichor, 540); target.AddBuff(ModContent.BuffType(), 540); + target.AddBuff(BuffID.Ichor, 540); + target.ExoDebuffs(); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) @@ -72,14 +73,7 @@ namespace CalamityMod.Projectiles.Ranged target.AddBuff(BuffID.Daybreak, 540); target.AddBuff(ModContent.BuffType(), 540); - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Ranged/ElysianArrowProj.cs b/Projectiles/Ranged/ElysianArrowProj.cs index c1549dff6d..484e84d68c 100644 --- a/Projectiles/Ranged/ElysianArrowProj.cs +++ b/Projectiles/Ranged/ElysianArrowProj.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.Damage(); for (int num621 = 0; num621 < 2; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -67,13 +67,13 @@ namespace CalamityMod.Projectiles.Ranged } for (int num623 = 0; num623 < 6; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); float x = projectile.position.X + (float)Main.rand.Next(-400, 400); float y = projectile.position.Y - (float)Main.rand.Next(500, 800); Vector2 vector = new Vector2(x, y); diff --git a/Projectiles/Ranged/EnhancedNanoRoundProj.cs b/Projectiles/Ranged/EnhancedNanoRoundProj.cs index c360fdb514..2e3f3e5e69 100644 --- a/Projectiles/Ranged/EnhancedNanoRoundProj.cs +++ b/Projectiles/Ranged/EnhancedNanoRoundProj.cs @@ -61,16 +61,10 @@ namespace CalamityMod.Projectiles.Ranged { if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < 2; num252++) + for (int i = 0; i < 2; i++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.oldPosition.X + (float)(projectile.width / 2), projectile.oldPosition.Y + (float)(projectile.height / 2), value15.X, value15.Y, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.3), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 0f, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Ranged/ExoFire.cs b/Projectiles/Ranged/ExoFire.cs index 8058226979..455f3739a8 100644 --- a/Projectiles/Ranged/ExoFire.cs +++ b/Projectiles/Ranged/ExoFire.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using System.Collections.Generic; using Terraria; @@ -96,15 +94,12 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); } } } diff --git a/Projectiles/Ranged/ExoLight.cs b/Projectiles/Ranged/ExoLight.cs index a87ba62638..3572009064 100644 --- a/Projectiles/Ranged/ExoLight.cs +++ b/Projectiles/Ranged/ExoLight.cs @@ -1,6 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.IO; @@ -86,15 +84,11 @@ namespace CalamityMod.Projectiles.Ranged } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 60); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(BuffID.CursedInferno, 180); - target.AddBuff(BuffID.Frostburn, 180); - target.AddBuff(BuffID.OnFire, 180); - target.AddBuff(BuffID.Ichor, 180); + target.ExoDebuffs(2f); + } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(2f); } } } diff --git a/Projectiles/Ranged/ExoLightBurst.cs b/Projectiles/Ranged/ExoLightBurst.cs index dc68a71e89..1a6a497922 100644 --- a/Projectiles/Ranged/ExoLightBurst.cs +++ b/Projectiles/Ranged/ExoLightBurst.cs @@ -1,6 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ID; @@ -75,17 +73,15 @@ namespace CalamityMod.Projectiles.Ranged CalamityGlobalProjectile.ExpandHitboxBy(projectile, width, height); return null; } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 60); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(BuffID.CursedInferno, 180); - target.AddBuff(BuffID.Frostburn, 180); - target.AddBuff(BuffID.OnFire, 180); - target.AddBuff(BuffID.Ichor, 180); + target.ExoDebuffs(2f); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(2f); } } } diff --git a/Projectiles/Ranged/FungiOrb.cs b/Projectiles/Ranged/FungiOrb.cs index eb951a4840..5515739c10 100644 --- a/Projectiles/Ranged/FungiOrb.cs +++ b/Projectiles/Ranged/FungiOrb.cs @@ -44,19 +44,13 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - int num251 = Main.rand.Next(2, 5); + int fungiAmt = Main.rand.Next(2, 5); if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < num251; num252++) + for (int f = 0; f < fungiAmt; f++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.25), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), 0f, projectile.owner, 0f, 0f); } } Main.PlaySound(SoundID.NPCDeath1, projectile.position); diff --git a/Projectiles/Ranged/GoliathRocket.cs b/Projectiles/Ranged/GoliathRocket.cs index ec81057cfc..1d7a314a2e 100644 --- a/Projectiles/Ranged/GoliathRocket.cs +++ b/Projectiles/Ranged/GoliathRocket.cs @@ -67,13 +67,13 @@ namespace CalamityMod.Projectiles.Ranged } else if (Main.rand.NextBool(2)) { - int num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); + int num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].noGravity = true; Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default) * 1.1f; Main.rand.Next(2); - num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); + num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].noGravity = true; Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default) * 1.1f; @@ -140,7 +140,7 @@ namespace CalamityMod.Projectiles.Ranged Main.PlaySound(SoundID.Item14, projectile.position); for (int num621 = 0; num621 < 20; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -150,13 +150,13 @@ namespace CalamityMod.Projectiles.Ranged } for (int num623 = 0; num623 < 30; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Ranged/GreenExoArrow.cs b/Projectiles/Ranged/GreenExoArrow.cs index 14dbd90676..966670abc7 100644 --- a/Projectiles/Ranged/GreenExoArrow.cs +++ b/Projectiles/Ranged/GreenExoArrow.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -59,15 +57,12 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Ranged/HalleysComet.cs b/Projectiles/Ranged/HalleysComet.cs index fa16faba6b..791ce568d8 100644 --- a/Projectiles/Ranged/HalleysComet.cs +++ b/Projectiles/Ranged/HalleysComet.cs @@ -13,8 +13,7 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - projectile.width = 12; - projectile.height = 12; + projectile.width = projectile.height = 12; projectile.friendly = true; projectile.ignoreWater = true; projectile.ranged = true; @@ -29,32 +28,30 @@ namespace CalamityMod.Projectiles.Ranged { projectile.scale *= 1.01f; } + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.35f / 255f, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.45f / 255f); - if (projectile.timeLeft > 600) + + if (projectile.ai[0]++ > 5f) { - projectile.timeLeft = 600; - } - if (projectile.ai[0] > 5f) - { - float num296 = 1f; + float dustScaleSize = 1f; if (projectile.ai[0] == 6f) { - num296 = 0.25f; + dustScaleSize = 0.25f; } else if (projectile.ai[0] == 7f) { - num296 = 0.5f; + dustScaleSize = 0.5f; } else if (projectile.ai[0] == 8f) { - num296 = 0.75f; + dustScaleSize = 0.75f; } projectile.ai[0] += 1f; - int num297 = 176; - for (int num298 = 0; num298 < 3; num298++) + int dustType = 176; + for (int i = 0; i < 3; i++) { - int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 1, default, 1f); - Dust dust = Main.dust[num299]; + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 1, default, 1f); + Dust dust = Main.dust[fire]; if (Main.rand.NextBool(3)) { dust.noGravity = true; @@ -68,7 +65,7 @@ namespace CalamityMod.Projectiles.Ranged } dust.velocity.X *= 1.2f; dust.velocity.Y *= 1.2f; - dust.scale *= num296; + dust.scale *= dustScaleSize; dust.velocity += projectile.velocity; if (!dust.noGravity) { @@ -76,16 +73,18 @@ namespace CalamityMod.Projectiles.Ranged } } } - else - { - projectile.ai[0] += 1f; - } + projectile.rotation += 0.3f * (float)projectile.direction; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 300); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); } } } diff --git a/Projectiles/Ranged/HandheldTankShell.cs b/Projectiles/Ranged/HandheldTankShell.cs index 45df4038f5..428e03643e 100644 --- a/Projectiles/Ranged/HandheldTankShell.cs +++ b/Projectiles/Ranged/HandheldTankShell.cs @@ -106,7 +106,7 @@ namespace CalamityMod.Projectiles.Ranged void SpawnExplosionDust() { // Sparks and such - Vector2 corner = new Vector2(projectile.position.X, projectile.position.Y); + Vector2 corner = projectile.position; for (int i = 0; i < 40; i++) { int idx = Dust.NewDust(corner, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); @@ -127,7 +127,7 @@ namespace CalamityMod.Projectiles.Ranged } // Smoke, which counts as a Gore - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } } diff --git a/Projectiles/Ranged/HiveBomb.cs b/Projectiles/Ranged/HiveBomb.cs index 5505a6dfe6..40452af1b9 100644 --- a/Projectiles/Ranged/HiveBomb.cs +++ b/Projectiles/Ranged/HiveBomb.cs @@ -67,13 +67,13 @@ namespace CalamityMod.Projectiles.Ranged } else if (Main.rand.NextBool(2)) { - int num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); + int num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].noGravity = true; Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default) * 1.1f; Main.rand.Next(2); - num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); + num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].noGravity = true; Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default) * 1.1f; @@ -140,7 +140,7 @@ namespace CalamityMod.Projectiles.Ranged Main.PlaySound(SoundID.Item14, projectile.position); for (int num621 = 0; num621 < 20; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -150,13 +150,13 @@ namespace CalamityMod.Projectiles.Ranged } for (int num623 = 0; num623 < 30; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 89, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Ranged/HiveMissile.cs b/Projectiles/Ranged/HiveMissile.cs index d906d4be11..f765cf2c87 100644 --- a/Projectiles/Ranged/HiveMissile.cs +++ b/Projectiles/Ranged/HiveMissile.cs @@ -67,13 +67,13 @@ namespace CalamityMod.Projectiles.Ranged } else if (Main.rand.NextBool(2)) { - int num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); + int num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1f); Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].noGravity = true; Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default) * 1.1f; Main.rand.Next(2); - num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); + num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].noGravity = true; Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default) * 1.1f; @@ -140,7 +140,7 @@ namespace CalamityMod.Projectiles.Ranged Main.PlaySound(SoundID.Item14, projectile.position); for (int num621 = 0; num621 < 20; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 90, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 90, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -150,13 +150,13 @@ namespace CalamityMod.Projectiles.Ranged } for (int num623 = 0; num623 < 30; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 90, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 90, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 90, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 90, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } } diff --git a/Projectiles/Ranged/HyperiusBulletProj.cs b/Projectiles/Ranged/HyperiusBulletProj.cs index f580d96470..2f0713c0b3 100644 --- a/Projectiles/Ranged/HyperiusBulletProj.cs +++ b/Projectiles/Ranged/HyperiusBulletProj.cs @@ -75,21 +75,20 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - float xPos = projectile.Center.X + 800 * Main.rand.NextBool(2).ToDirectionInt(); - float yPos = projectile.Center.Y + Main.rand.Next(-800, 801); - Vector2 spawnPosition = new Vector2(xPos, yPos); - Vector2 velocity = target.Center - spawnPosition; - float dir = 10 / spawnPosition.X; - velocity.X *= dir * 150; - velocity.Y *= dir * 150; - velocity.X = MathHelper.Clamp(velocity.X, -15f, 15f); - velocity.Y = MathHelper.Clamp(velocity.Y, -15f, 15f); - if (projectile.owner == Main.myPlayer) - { - int splitDamage = (int)(projectile.damage * 0.6f); - float splitKB = 1f; - Projectile.NewProjectile(spawnPosition, velocity, ModContent.ProjectileType(), splitDamage, splitKB, projectile.owner); - } + OnHitEffects(target.Center); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(target.Center); + } + + private void OnHitEffects(Vector2 targetPos) + { + if (projectile.owner == Main.myPlayer) + { + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.6), 1f, projectile.owner, true); + } } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/HyperiusSplit.cs b/Projectiles/Ranged/HyperiusSplit.cs index 83c1c3f3c9..60719f0a07 100644 --- a/Projectiles/Ranged/HyperiusSplit.cs +++ b/Projectiles/Ranged/HyperiusSplit.cs @@ -50,6 +50,8 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { + if (projectile.timeLeft == 360) + return false; CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); return false; } diff --git a/Projectiles/Ranged/ImpactRound.cs b/Projectiles/Ranged/ImpactRound.cs index c471d98944..77be1dd621 100644 --- a/Projectiles/Ranged/ImpactRound.cs +++ b/Projectiles/Ranged/ImpactRound.cs @@ -43,19 +43,5 @@ namespace CalamityMod.Projectiles.Ranged } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => projectile.timeLeft < 600; - - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - double damageMult = 1D; - if (crit) - { - damageMult += 0.25; - } - if (target.Inorganic()) - { - damageMult += 0.1; - } - damage = (int)(damage * damageMult); - } } } diff --git a/Projectiles/Ranged/MagnomalyBeam.cs b/Projectiles/Ranged/MagnomalyBeam.cs index c89a3e15ca..6814cdcebe 100644 --- a/Projectiles/Ranged/MagnomalyBeam.cs +++ b/Projectiles/Ranged/MagnomalyBeam.cs @@ -103,15 +103,12 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); } } } diff --git a/Projectiles/Ranged/MagnomalyExplosion.cs b/Projectiles/Ranged/MagnomalyExplosion.cs index 5f6e9859f2..eaa19849a5 100644 --- a/Projectiles/Ranged/MagnomalyExplosion.cs +++ b/Projectiles/Ranged/MagnomalyExplosion.cs @@ -1,8 +1,6 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; namespace CalamityMod.Projectiles.Ranged { public class MagnomalyExplosion : ModProjectile @@ -29,15 +27,12 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); } } } diff --git a/Projectiles/Ranged/MagnomalyRocket.cs b/Projectiles/Ranged/MagnomalyRocket.cs index 358748903c..767866cf0e 100644 --- a/Projectiles/Ranged/MagnomalyRocket.cs +++ b/Projectiles/Ranged/MagnomalyRocket.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -21,10 +19,8 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - projectile.width = 22; - projectile.height = 22; + projectile.width = projectile.height = 22; projectile.friendly = true; - projectile.penetrate = 1; projectile.timeLeft = 300; projectile.ranged = true; projectile.tileCollide = false; @@ -42,7 +38,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.frame++; projectile.frameCounter = 0; } - if (projectile.frame >= 4) + if (projectile.frame >= Main.projFrames[projectile.type]) { projectile.frame = 0; } @@ -51,33 +47,33 @@ namespace CalamityMod.Projectiles.Ranged projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) + MathHelper.ToRadians(90) * projectile.direction; - int num297 = Main.rand.NextBool(2) ? 107 : 234; + int dustType = Main.rand.NextBool(2) ? 107 : 234; if (Main.rand.NextBool(4)) { - num297 = 269; + dustType = 269; } if (projectile.owner == Main.myPlayer && !spawnedAura) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5f), projectile.knockBack * 0.5f, projectile.owner, projectile.identity, 0f); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.5f), projectile.knockBack * 0.5f, projectile.owner, projectile.identity, 0f); spawnedAura = true; } - float num247 = projectile.velocity.X * 0.5f; - float num248 = projectile.velocity.Y * 0.5f; + float dustOffsetX = projectile.velocity.X * 0.5f; + float dustOffsetY = projectile.velocity.Y * 0.5f; if (Main.rand.NextBool(2)) { - int num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, num297, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].scale *= (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - Main.dust[num249].noLight = true; + int exo = Dust.NewDust(new Vector2(projectile.position.X + 3f + dustOffsetX, projectile.position.Y + 3f + dustOffsetY) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, dustType, 0f, 0f, 100, default, 0.5f); + Main.dust[exo].scale *= (float)Main.rand.Next(10) * 0.1f; + Main.dust[exo].velocity *= 0.2f; + Main.dust[exo].noGravity = true; + Main.dust[exo].noLight = true; } else { - int dust2 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, num297, 0f, 0f, 100, default, 0.25f); - Main.dust[dust2].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[dust2].velocity *= 0.05f; - Main.dust[dust2].noGravity = true; - Main.dust[dust2].noLight = true; + int exo = Dust.NewDust(new Vector2(projectile.position.X + 3f + dustOffsetX, projectile.position.Y + 3f + dustOffsetY) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, dustType, 0f, 0f, 100, default, 0.25f); + Main.dust[exo].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; + Main.dust[exo].velocity *= 0.05f; + Main.dust[exo].noGravity = true; + Main.dust[exo].noLight = true; } CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 16f, 20f); } @@ -88,39 +84,38 @@ namespace CalamityMod.Projectiles.Ranged { projectile.position = projectile.Center; projectile.width = projectile.height = 192; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + projectile.Center = projectile.position; Main.PlaySound(SoundID.Item14, projectile.position); //DO NOT REMOVE THIS PROJECTILE - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - int num298 = Main.rand.NextBool(2) ? 107 : 234; + int dustType = Main.rand.NextBool(2) ? 107 : 234; if (Main.rand.NextBool(4)) { - num298 = 269; + dustType = 269; } - for (int num621 = 0; num621 < 30; num621++) + for (int d = 0; d < 30; d++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num298, 0f, 0f, 100, default, 1f); - Main.dust[num622].velocity *= 3f; - Main.dust[num622].noGravity = true; - Main.dust[num622].noLight = true; + int exo = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 1f); + Main.dust[exo].velocity *= 3f; + Main.dust[exo].noGravity = true; + Main.dust[exo].noLight = true; if (Main.rand.NextBool(2)) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[exo].scale = 0.5f; + Main.dust[exo].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 40; num623++) + for (int d = 0; d < 40; d++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num298, 0f, 0f, 100, default, 0.5f); - Main.dust[num624].noGravity = true; - Main.dust[num624].noLight = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num298, 0f, 0f, 100, default, 0.75f); - Main.dust[num624].velocity *= 2f; + int exo = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 0.5f); + Main.dust[exo].noGravity = true; + Main.dust[exo].noLight = true; + Main.dust[exo].velocity *= 5f; + exo = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 0.75f); + Main.dust[exo].velocity *= 2f; } - projectile.ExplosionGores(10); + CalamityUtils.ExplosionGores(projectile.Center, 9); } } @@ -131,6 +126,18 @@ namespace CalamityMod.Projectiles.Ranged } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + OnHitEffects(); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(); + target.ExoDebuffs(); + } + + private void OnHitEffects() { if (projectile.owner == Main.myPlayer) { @@ -145,15 +152,6 @@ namespace CalamityMod.Projectiles.Ranged int proj2 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), projectile.damage / 4, projectile.knockBack / 4, projectile.owner, 0f, 1f); } } - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); } } } diff --git a/Projectiles/Ranged/MiniRocket.cs b/Projectiles/Ranged/MiniRocket.cs index a627006b3f..4f328eebd1 100644 --- a/Projectiles/Ranged/MiniRocket.cs +++ b/Projectiles/Ranged/MiniRocket.cs @@ -78,7 +78,7 @@ namespace CalamityMod.Projectiles.Ranged Main.PlaySound(SoundID.Item14, projectile.position); for (int num621 = 0; num621 < 20; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -88,13 +88,13 @@ namespace CalamityMod.Projectiles.Ranged } for (int num623 = 0; num623 < 30; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } } diff --git a/Projectiles/Ranged/MortarRoundProj.cs b/Projectiles/Ranged/MortarRoundProj.cs index e5c727f691..6c6ff512d8 100644 --- a/Projectiles/Ranged/MortarRoundProj.cs +++ b/Projectiles/Ranged/MortarRoundProj.cs @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Ranged Main.PlaySound(SoundID.Item14, projectile.position); for (int num621 = 0; num621 < 40; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -99,13 +99,13 @@ namespace CalamityMod.Projectiles.Ranged } for (int num623 = 0; num623 < 70; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); if (projectile.owner == Main.myPlayer) { int num814 = 5; diff --git a/Projectiles/Ranged/NapalmArrowProj.cs b/Projectiles/Ranged/NapalmArrowProj.cs index 61d1a7012e..c9bed216bd 100644 --- a/Projectiles/Ranged/NapalmArrowProj.cs +++ b/Projectiles/Ranged/NapalmArrowProj.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Ranged fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 2f); Main.dust[fire].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); if (projectile.owner == Main.myPlayer) { for (int i = 0; i < 3; i++) diff --git a/Projectiles/Ranged/Nuke.cs b/Projectiles/Ranged/Nuke.cs index d29d635ad9..304f24dcad 100644 --- a/Projectiles/Ranged/Nuke.cs +++ b/Projectiles/Ranged/Nuke.cs @@ -103,7 +103,7 @@ namespace CalamityMod.Projectiles.Ranged Main.PlaySound(SoundID.Item14, projectile.position); for (int num621 = 0; num621 < 40; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -113,13 +113,13 @@ namespace CalamityMod.Projectiles.Ranged } for (int num623 = 0; num623 < 60; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(10); + CalamityUtils.ExplosionGores(projectile.Center, 10); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Ranged/OrangeExoArrow.cs b/Projectiles/Ranged/OrangeExoArrow.cs index 085e80af95..275bbc4e0a 100644 --- a/Projectiles/Ranged/OrangeExoArrow.cs +++ b/Projectiles/Ranged/OrangeExoArrow.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -97,15 +95,12 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/PiercingBullet.cs b/Projectiles/Ranged/PiercingBullet.cs index 29d5803af7..05416b3556 100644 --- a/Projectiles/Ranged/PiercingBullet.cs +++ b/Projectiles/Ranged/PiercingBullet.cs @@ -54,48 +54,29 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (crit) - { - int bulletCount = 10; - for (int x = 0; x < bulletCount; x++) - { - float speed = 12f; - float xPos = projectile.Center.X + (x < bulletCount / 2 ? 500f : -500f); - float yPos = projectile.Center.Y + Main.rand.Next(-500, 501); - Vector2 origin = new Vector2(xPos, yPos); - Vector2 velocity = new Vector2(target.Center.X - origin.X, target.Center.Y - origin.Y); - velocity.Normalize(); - velocity *= speed; - if (projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(origin, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.2), projectile.knockBack, projectile.owner); - } - } - } + OnHitEffects(target.Center, crit); target.AddBuff(ModContent.BuffType(), 900); } public override void OnHitPvp(Player target, int damage, bool crit) { + OnHitEffects(target.Center, crit); + target.AddBuff(ModContent.BuffType(), 900); + } + + private void OnHitEffects(Vector2 targetPos, bool crit) + { if (crit) { int bulletCount = 10; for (int x = 0; x < bulletCount; x++) { - float speed = 12f; - float xPos = projectile.Center.X + (x < bulletCount / 2 ? 500f : -500f); - float yPos = projectile.Center.Y + Main.rand.Next(-500, 501); - Vector2 origin = new Vector2(xPos, yPos); - Vector2 velocity = new Vector2(target.Center.X - origin.X, target.Center.Y - origin.Y); - velocity.Normalize(); - velocity *= speed; if (projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(origin, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.2), projectile.knockBack, projectile.owner); - } + CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, x < bulletCount / 2, 500f, 500f, 0f, 500f, 12f, ModContent.ProjectileType(), (int)(projectile.damage * 0.2), projectile.knockBack, projectile.owner); + } } } - target.AddBuff(ModContent.BuffType(), 900); } } } diff --git a/Projectiles/Ranged/RubberMortarRoundProj.cs b/Projectiles/Ranged/RubberMortarRoundProj.cs index 0ed94ee191..644d747b8b 100644 --- a/Projectiles/Ranged/RubberMortarRoundProj.cs +++ b/Projectiles/Ranged/RubberMortarRoundProj.cs @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Ranged Main.PlaySound(SoundID.Item14, projectile.position); for (int num621 = 0; num621 < 40; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -99,13 +99,13 @@ namespace CalamityMod.Projectiles.Ranged } for (int num623 = 0; num623 < 70; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); if (projectile.owner == Main.myPlayer) { int num814 = 5; @@ -229,7 +229,7 @@ namespace CalamityMod.Projectiles.Ranged Main.PlaySound(SoundID.Item14, projectile.position); for (int num621 = 0; num621 < 40; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -239,10 +239,10 @@ namespace CalamityMod.Projectiles.Ranged } for (int num623 = 0; num623 < 70; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } for (int num625 = 0; num625 < 3; num625++) diff --git a/Projectiles/Ranged/SeasSearingBubble.cs b/Projectiles/Ranged/SeasSearingBubble.cs index 40baf7cdb3..56554d93b7 100644 --- a/Projectiles/Ranged/SeasSearingBubble.cs +++ b/Projectiles/Ranged/SeasSearingBubble.cs @@ -88,42 +88,33 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - Main.PlaySound(SoundID.Item96, projectile.position); + OnHitEffects(target.Center); target.AddBuff(BuffID.Wet, 240); target.AddBuff(ModContent.BuffType(), 240); + } - int type = ModContent.ProjectileType(); + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(target.Center); + target.AddBuff(BuffID.Wet, 240); + target.AddBuff(ModContent.BuffType(), 240); + } + + private void OnHitEffects(Vector2 targetPos) + { + Main.PlaySound(SoundID.Item96, projectile.Center); if (projectile.ai[0] == 1f) { - int numWaterBlasts = 2; - int waterDamage = SeasSearing.BaseDamage / 2; - float waterKB = 1f; - Player owner = Main.player[projectile.owner]; - for (int i = 0; i < numWaterBlasts; ++i) + for (int x = 0; x < 2; x++) { - float startOffsetX = Main.rand.NextFloat(1000f, 1400f) * (Main.rand.NextBool() ? -1f : 1f); - float startOffsetY = Main.rand.NextFloat(80f, 900f) * (Main.rand.NextBool() ? -1f : 1f); - Vector2 startPos = new Vector2(target.Center.X + startOffsetX, target.Center.Y + startOffsetY); - float dx = target.Center.X - startPos.X; - float dy = target.Center.Y - startPos.Y; - - // Add some randomness / inaccuracy - dx += Main.rand.NextFloat(-5f, 5f); - dy += Main.rand.NextFloat(-5f, 5f); - float speed = Main.rand.NextFloat(20f, 25f); - float dist = (float)Math.Sqrt((double)(dx * dx + dy * dy)); - dist = speed / dist; - dx *= dist; - dy *= dist; - Vector2 waterVel = new Vector2(dx, dy); - float angle = Main.rand.NextFloat(MathHelper.TwoPi); if (projectile.owner == Main.myPlayer) { - int idx = Projectile.NewProjectile(startPos, waterVel, type, waterDamage, waterKB, projectile.owner, 0f, 0f); - Main.projectile[idx].rotation = angle; - Main.projectile[idx].tileCollide = false; - Main.projectile[idx].usesLocalNPCImmunity = true; - Main.projectile[idx].localNPCHitCooldown = -1; + float angle = Main.rand.NextFloat(MathHelper.TwoPi); + Projectile bubble = CalamityUtils.ProjectileBarrage(projectile.Center, targetPos, Main.rand.NextBool(), 1000f, 1400f, 80f, 900f, Main.rand.NextFloat(20f, 25f), ModContent.ProjectileType(), projectile.damage / 2, 1f, projectile.owner); + bubble.rotation = angle; + bubble.tileCollide = false; + bubble.usesLocalNPCImmunity = true; + bubble.localNPCHitCooldown = -1; } } } diff --git a/Projectiles/Ranged/SparkSpreaderFire.cs b/Projectiles/Ranged/SparkSpreaderFire.cs index 4fede1d4eb..97f9a05507 100644 --- a/Projectiles/Ranged/SparkSpreaderFire.cs +++ b/Projectiles/Ranged/SparkSpreaderFire.cs @@ -14,8 +14,7 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - projectile.width = 12; - projectile.height = 12; + projectile.width = projectile.height = 12; projectile.friendly = true; projectile.ranged = true; projectile.penetrate = 3; @@ -28,71 +27,69 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.05f / 255f, (255 - projectile.alpha) * 0.45f / 255f, (255 - projectile.alpha) * 0.05f / 255f); - if (projectile.timeLeft > 60) - { - projectile.timeLeft = 60; - } + if (projectile.wet && !projectile.lavaWet) { projectile.Kill(); } - if (Main.rand.Next(3) == 0) + + if (Main.rand.NextBool(3)) { - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 35, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 80, default, 0.75f); - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 55, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 50, default, 0.75f); + Dust.NewDust(projectile.position, projectile.width, projectile.height, 35, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 80, default, 0.75f); + Dust.NewDust(projectile.position, projectile.width, projectile.height, 55, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 50, default, 0.75f); } - if (projectile.ai[0] > 7f) + + if (projectile.ai[0]++ > 7f) { - float num296 = 1f; + float dustScaleSize = 1f; if (projectile.ai[0] == 8f) { - num296 = 0.25f; + dustScaleSize = 0.25f; } else if (projectile.ai[0] == 9f) { - num296 = 0.5f; + dustScaleSize = 0.5f; } else if (projectile.ai[0] == 10f) { - num296 = 0.75f; + dustScaleSize = 0.75f; } projectile.ai[0] += 1f; - int num297 = 6; - if (Main.rand.Next(1) == 0) - { - for (int num298 = 0; num298 < 2; num298++) - { - int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 10, default, 0.75f); - Dust dust = Main.dust[num299]; - if (Main.rand.Next(3) == 0) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.noGravity = true; - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.velocity += projectile.velocity; - } + int dustType = DustID.Fire; + for (int i = 0; i < 2; i++) + { + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 10, default, 0.75f); + Dust dust = Main.dust[fire]; + if (Main.rand.Next(3) == 0) + { + dust.noGravity = true; + dust.scale *= 1.75f; + dust.velocity.X *= 2f; + dust.velocity.Y *= 2f; + } + else + { + dust.noGravity = true; + dust.scale *= 0.5f; + } + dust.velocity.X *= 1.2f; + dust.velocity.Y *= 1.2f; + dust.scale *= dustScaleSize; + dust.velocity += projectile.velocity; } } - else - { - projectile.ai[0] += 1f; - } + projectile.rotation += 0.3f * (float)projectile.direction; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(1, 4)); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(1, 4)); } } } diff --git a/Projectiles/Ranged/SporeBomb.cs b/Projectiles/Ranged/SporeBomb.cs index 035b88d0cb..c05d251d6a 100644 --- a/Projectiles/Ranged/SporeBomb.cs +++ b/Projectiles/Ranged/SporeBomb.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Ranged if (projectile.localAI[0] == 0f) { projectile.scale += 0.05f; - if ((double)projectile.scale > 1.2) + if (projectile.scale > 1.2f) { projectile.localAI[0] = 1f; } @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Ranged else { projectile.scale -= 0.05f; - if ((double)projectile.scale < 0.8) + if (projectile.scale < 0.8f) { projectile.localAI[0] = 0f; } @@ -72,26 +72,20 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item14, projectile.position); - for (int num407 = 0; num407 < 25; num407++) + for (int d = 0; d < 25; d++) { - int num408 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 157, 0f, 0f, 0, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num408].noGravity = true; - Main.dust[num408].velocity *= 1.5f; - Main.dust[num408].scale = 1.5f; + int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, 157, 0f, 0f, 0, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[index].noGravity = true; + Main.dust[index].velocity *= 1.5f; + Main.dust[index].scale = 1.5f; } - int num251 = Main.rand.Next(3, 7); + int sporeAmt = Main.rand.Next(3, 7); if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < num251; num252++) + for (int s = 0; s < sporeAmt; s++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ProjectileID.SporeGas + Main.rand.Next(3), (int)((double)projectile.damage * 0.25), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int proj = Projectile.NewProjectile(projectile.Center, velocity, ProjectileID.SporeGas + Main.rand.Next(3), (int)(projectile.damage * 0.25), 0f, projectile.owner, 0f, 0f); Main.projectile[proj].Calamity().forceRanged = true; Main.projectile[proj].usesLocalNPCImmunity = true; Main.projectile[proj].localNPCHitCooldown = 30; diff --git a/Projectiles/Ranged/SpykerProj.cs b/Projectiles/Ranged/SpykerProj.cs index 259b2d3042..9abaee61b8 100644 --- a/Projectiles/Ranged/SpykerProj.cs +++ b/Projectiles/Ranged/SpykerProj.cs @@ -66,24 +66,18 @@ namespace CalamityMod.Projectiles.Ranged projectile.width = projectile.height = 32; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - int num251 = Main.rand.Next(3, 6); + int projAmt = Main.rand.Next(3, 6); if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < num251; num252++) + for (int p = 0; p < projAmt; p++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.65), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.65), 0f, projectile.owner, 0f, 0f); } } for (int num621 = 0; num621 < 3; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 46, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 46, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -93,10 +87,10 @@ namespace CalamityMod.Projectiles.Ranged } for (int num623 = 0; num623 < 5; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 39, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 39, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 44, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 44, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); Main.dust[num624].velocity *= 2f; } } diff --git a/Projectiles/Ranged/TealExoArrow.cs b/Projectiles/Ranged/TealExoArrow.cs index 4a9e00a9f9..0704497d31 100644 --- a/Projectiles/Ranged/TealExoArrow.cs +++ b/Projectiles/Ranged/TealExoArrow.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -61,15 +59,12 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Ranged/TerraArrowMain.cs b/Projectiles/Ranged/TerraArrowMain.cs index 1e93a8e051..7af1f17a05 100644 --- a/Projectiles/Ranged/TerraArrowMain.cs +++ b/Projectiles/Ranged/TerraArrowMain.cs @@ -27,42 +27,36 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { projectile.velocity *= 1.005f; - if (projectile.velocity.X >= 20f || projectile.velocity.Y >= 20f || projectile.velocity.X <= -20f || projectile.velocity.Y <= -20f) + if (projectile.velocity.Length() >= 20f) { projectile.Kill(); } - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; } public override void Kill(int timeLeft) { projectile.position = projectile.Center; projectile.width = projectile.height = 32; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + projectile.position.X -= (float)(projectile.width / 2); + projectile.position.Y -= (float)(projectile.height / 2); Main.PlaySound(SoundID.Item60, projectile.position); - for (int num621 = 0; num621 < 3; num621++) + for (int d = 0; d < 3; d++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 1.2f; + int terra = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 100, default, 2f); + Main.dust[terra].velocity *= 1.2f; if (Main.rand.NextBool(2)) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[terra].scale = 0.5f; + Main.dust[terra].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < 2; num252++) + for (int a = 0; a < 2; a++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), 0f, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Ranged/TerraBulletMain.cs b/Projectiles/Ranged/TerraBulletMain.cs index 28bb65c8e0..db3ce4ef4a 100644 --- a/Projectiles/Ranged/TerraBulletMain.cs +++ b/Projectiles/Ranged/TerraBulletMain.cs @@ -71,16 +71,10 @@ namespace CalamityMod.Projectiles.Ranged { if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < 2; num252++) + for (int b = 0; b < 2; b++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 0f, projectile.owner, 0f, 0f); } } Main.PlaySound(SoundID.Item118, projectile.position); diff --git a/Projectiles/Ranged/ToxicannonDrop.cs b/Projectiles/Ranged/ToxicannonDrop.cs index 689a8b0d3e..c17c8d455e 100644 --- a/Projectiles/Ranged/ToxicannonDrop.cs +++ b/Projectiles/Ranged/ToxicannonDrop.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.tileCollide = true; projectile.ignoreWater = false; projectile.timeLeft = 420; - projectile.Calamity().rogue = true; + projectile.ranged = true; } public override void AI() { diff --git a/Projectiles/Ranged/UltimaBowProjectile.cs b/Projectiles/Ranged/UltimaBowProjectile.cs index c5f44980fe..a5b20419e8 100644 --- a/Projectiles/Ranged/UltimaBowProjectile.cs +++ b/Projectiles/Ranged/UltimaBowProjectile.cs @@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.Ranged { type = ModContent.ProjectileType(); shotVelocity = shotVelocity.RotatedByRandom(0.03f); - damage *= 2; + damage = (int)(damage * 1.5); } // Sometimes fire little sparks if the bow is fully charged. if (Time >= Ultima.FullChargeTime * 0.7f && Main.rand.NextBool(6)) diff --git a/Projectiles/Ranged/UltimaRay.cs b/Projectiles/Ranged/UltimaRay.cs index 43742db73f..5f2b6287d4 100644 --- a/Projectiles/Ranged/UltimaRay.cs +++ b/Projectiles/Ranged/UltimaRay.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Projectiles.Ranged set => projectile.ai[1] = value; } public override float MaxScale => 0.7f; - public override float MaxLaserLength => 1599.999999f; + public override float MaxLaserLength => 2400f; public override float Lifetime => 50f; public override Color LaserOverlayColor => Main.hslToRgb((float)Math.Sin(Main.GlobalTime * 2.3f + HueOffset) * 0.5f + 0.5f, 1f, 0.775f) * Utils.InverseLerp(Lifetime, 0f, Time, true); public override Color LightCastColor => LaserOverlayColor; @@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.arrow = true; projectile.penetrate = -1; projectile.alpha = 255; - projectile.localNPCHitCooldown = 8; + projectile.localNPCHitCooldown = 10; projectile.usesLocalNPCImmunity = true; } public override bool PreAI() diff --git a/Projectiles/Rogue/XerocPitchforkProjectile.cs b/Projectiles/Rogue/AntumbraShardProjectile.cs similarity index 96% rename from Projectiles/Rogue/XerocPitchforkProjectile.cs rename to Projectiles/Rogue/AntumbraShardProjectile.cs index 38d1edc8b2..fb9821e918 100644 --- a/Projectiles/Rogue/XerocPitchforkProjectile.cs +++ b/Projectiles/Rogue/AntumbraShardProjectile.cs @@ -8,11 +8,11 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class XerocPitchforkProjectile : ModProjectile + public class AntumbraShardProjectile : ModProjectile { public override void SetStaticDefaults() { - DisplayName.SetDefault("Pitchfork"); + DisplayName.SetDefault("Antumbra Shard"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; ProjectileID.Sets.TrailingMode[projectile.type] = 0; } @@ -33,13 +33,13 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(135f); - if (Main.rand.NextBool(3)) - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 62, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - } if (projectile.spriteDirection == -1) { projectile.rotation -= 1.57f; + } + if (Main.rand.NextBool(3)) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 62, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } if (projectile.timeLeft % 12 == 0) { diff --git a/Projectiles/Rogue/XerocPitchforkProjectile.png b/Projectiles/Rogue/AntumbraShardProjectile.png similarity index 100% rename from Projectiles/Rogue/XerocPitchforkProjectile.png rename to Projectiles/Rogue/AntumbraShardProjectile.png diff --git a/Projectiles/Rogue/AuroradicalStar.cs b/Projectiles/Rogue/AuroradicalStar.cs index f7468a41c1..5af928b27e 100644 --- a/Projectiles/Rogue/AuroradicalStar.cs +++ b/Projectiles/Rogue/AuroradicalStar.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.soundDelay = 20 + Main.rand.Next(40); if (Main.rand.NextBool(5)) { - Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 9); + Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 9); } } @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.ai[0] += 1f; if (projectile.ai[0] > 15f) { - int astral = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.Next(dustTypes), 0f, 0f, 100, default, 0.8f); + int astral = Dust.NewDust(projectile.position, projectile.width, projectile.height, Main.rand.Next(dustTypes), 0f, 0f, 100, default, 0.8f); Main.dust[astral].noGravity = true; Main.dust[astral].velocity *= 0f; } @@ -133,7 +133,7 @@ namespace CalamityMod.Projectiles.Rogue int dmg = projectile.damage / 2; int comet = Projectile.NewProjectile(pos, velocity, ModContent.ProjectileType(), dmg, projectile.knockBack, projectile.owner, 0f, 0f); Main.projectile[comet].Calamity().forceRogue = true; - Main.projectile[comet].Calamity().lineColor = Main.rand.Next(3);; + Main.projectile[comet].Calamity().lineColor = Main.rand.Next(3); } } @@ -147,30 +147,27 @@ namespace CalamityMod.Projectiles.Rogue int dmg = projectile.damage / 2; int comet = Projectile.NewProjectile(pos, velocity, ModContent.ProjectileType(), dmg, projectile.knockBack, projectile.owner, 0f, 0f); Main.projectile[comet].Calamity().forceRogue = true; - Main.projectile[comet].Calamity().lineColor = Main.rand.Next(3);; + Main.projectile[comet].Calamity().lineColor = Main.rand.Next(3); } } public override void Kill(int timeLeft) { - Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 9, 1f, 0f); - projectile.position = projectile.Center; - projectile.width = projectile.height = 96; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 9, 1f, 0f); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 96); projectile.localNPCHitCooldown = 10; projectile.usesLocalNPCImmunity = true; projectile.Damage(); for (int d = 0; d < 2; d++) { - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.Next(dustTypes), 0f, 0f, 50, default, 1f); + Dust.NewDust(projectile.position, projectile.width, projectile.height, Main.rand.Next(dustTypes), 0f, 0f, 50, default, 1f); } for (int d = 0; d < 20; d++) { - int astral = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.Next(dustTypes), 0f, 0f, 0, default, 1.5f); + int astral = Dust.NewDust(projectile.position, projectile.width, projectile.height, Main.rand.Next(dustTypes), 0f, 0f, 0, default, 1.5f); Main.dust[astral].noGravity = true; Main.dust[astral].velocity *= 3f; - astral = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 173, 0f, 0f, 50, default, 1f); + astral = Dust.NewDust(projectile.position, projectile.width, projectile.height, 173, 0f, 0f, 50, default, 1f); Main.dust[astral].velocity *= 2f; Main.dust[astral].noGravity = true; } diff --git a/Projectiles/Rogue/BallisticPoisonBombProj.cs b/Projectiles/Rogue/BallisticPoisonBombProj.cs index 2cd7f8ad45..9e5f0b8ab0 100644 --- a/Projectiles/Rogue/BallisticPoisonBombProj.cs +++ b/Projectiles/Rogue/BallisticPoisonBombProj.cs @@ -1,5 +1,6 @@ using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -30,59 +31,13 @@ namespace CalamityMod.Projectiles.Rogue { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 14, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - try - { - int num223 = (int)(projectile.position.X / 16f) - 1; - int num224 = (int)((projectile.position.X + (float)projectile.width) / 16f) + 2; - int num225 = (int)(projectile.position.Y / 16f) - 1; - int num226 = (int)((projectile.position.Y + (float)projectile.height) / 16f) + 2; - if (num223 < 0) - { - num223 = 0; - } - if (num224 > Main.maxTilesX) - { - num224 = Main.maxTilesX; - } - if (num225 < 0) - { - num225 = 0; - } - if (num226 > Main.maxTilesY) - { - num226 = Main.maxTilesY; - } - for (int num227 = num223; num227 < num224; num227++) - { - for (int num228 = num225; num228 < num226; num228++) - { - if (Main.tile[num227, num228] != null && !TileID.Sets.Platforms[Main.tile[num227, num228].type] && Main.tile[num227, num228].nactive() && (Main.tileSolid[(int)Main.tile[num227, num228].type] || (Main.tileSolidTop[(int)Main.tile[num227, num228].type] && Main.tile[num227, num228].frameY == 0))) - { - Vector2 vector19; - vector19.X = (float)(num227 * 16); - vector19.Y = (float)(num228 * 16); - if (projectile.position.X + (float)projectile.width - 4f > vector19.X && projectile.position.X + 4f < vector19.X + 16f && projectile.position.Y + (float)projectile.height - 4f > vector19.Y && projectile.position.Y + 4f < vector19.Y + 16f) - { - projectile.velocity.X = 0f; - projectile.velocity.Y = -0.2f; - } - } - } - } - } catch - { - } + projectile.StickToTiles(); if (projectile.owner == Main.myPlayer && projectile.timeLeft <= 3) { projectile.tileCollide = false; projectile.ai[1] = 0f; projectile.alpha = 255; - projectile.position.X = projectile.position.X + (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); - projectile.width = 128; - projectile.height = 128; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 128); } projectile.ai[0] += 1f; if (projectile.ai[0] > 10f) @@ -90,8 +45,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.ai[0] = 10f; if (projectile.velocity.Y == 0f && projectile.velocity.X != 0f) { - projectile.velocity.X = projectile.velocity.X * 0.97f; - if (projectile.velocity.X > -0.01f && projectile.velocity.X < 0.01f) + projectile.velocity.X *= 0.97f; + if (Math.Abs(projectile.velocity.X) < 0.01f) { projectile.velocity.X = 0f; projectile.netUpdate = true; @@ -104,55 +59,42 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - projectile.position = projectile.Center; - projectile.width = projectile.height = 128; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 14); - int num251 = Main.rand.Next(3, 5); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 128); + Main.PlaySound(SoundID.Item14, projectile.Center); + int projAmt = Main.rand.Next(3, 5); if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < num251; num252++) + for (int s = 0; s < projAmt; s++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, projectile.owner, 0f, 0f); } - int num320 = Main.rand.Next(8, 13); - int num3; - for (int num321 = 0; num321 < num320; num321 = num3 + 1) + int cloudAmt = Main.rand.Next(8, 13); + for (int c = 0; c < cloudAmt; c++) { - Vector2 vector15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - vector15.Normalize(); - vector15 *= (float)Main.rand.Next(10, 201) * 0.01f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, vector15.X, vector15.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), 1f, projectile.owner, 0f, (float)Main.rand.Next(-45, 1)); - num3 = num321; + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 200f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), 1f, projectile.owner, 0f, (float)Main.rand.Next(-45, 1)); } } - for (int num621 = 0; num621 < 5; num621++) + for (int d = 0; d < 5; d++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 14, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int boom = Dust.NewDust(projectile.position, projectile.width, projectile.height, 14, 0f, 0f, 100, default, 2f); + Main.dust[boom].velocity *= 3f; if (Main.rand.NextBool(2)) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[boom].scale = 0.5f; + Main.dust[boom].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 9; num623++) + for (int d = 0; d < 9; d++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 3f); + Main.dust[fire].noGravity = true; + Main.dust[fire].velocity *= 5f; + fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 2f); + Main.dust[fire].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Rogue/BettyExplosion.cs b/Projectiles/Rogue/BettyExplosion.cs index d0d71d8722..29f5e8bfc3 100644 --- a/Projectiles/Rogue/BettyExplosion.cs +++ b/Projectiles/Rogue/BettyExplosion.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Rogue void SpawnExplosionDust() { // Sparks and such - Vector2 corner = new Vector2(projectile.position.X, projectile.position.Y); + Vector2 corner = projectile.position; for (int i = 0; i < 15; i++) { int idx = Dust.NewDust(corner, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Rogue } // Smoke, which counts as a Gore - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } diff --git a/Projectiles/Rogue/BloodsoakedCrashax.cs b/Projectiles/Rogue/BloodsoakedCrashax.cs index 802f3d0811..d871f158a9 100644 --- a/Projectiles/Rogue/BloodsoakedCrashax.cs +++ b/Projectiles/Rogue/BloodsoakedCrashax.cs @@ -7,133 +7,122 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class BloodsoakedCrashax : ModProjectile - { - private int bounce = 3; //number of times it bounces - private int grind = 0; //used to know when to slow down + public class BloodsoakedCrashax : ModProjectile + { + private int bounce = 3; //number of times it bounces + private int grind = 0; //used to know when to slow down - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bloodsoaked Crasher"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bloodsoaked Crasher"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 30; - projectile.height = 30; - projectile.friendly = true; - projectile.penetrate = 10; - projectile.aiStyle = 2; - projectile.timeLeft = 600; //10 seconds and counting - aiType = ProjectileID.ThrowingKnife; //Throwing Knife AI - projectile.Calamity().rogue = true; - projectile.usesIDStaticNPCImmunity = true; - projectile.idStaticNPCHitCooldown = 5; - projectile.extraUpdates = 1; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 30; + projectile.friendly = true; + projectile.penetrate = 10; + projectile.timeLeft = 600; //10 seconds and counting + projectile.aiStyle = 2; + aiType = ProjectileID.ThrowingKnife; //Throwing Knife AI + projectile.Calamity().rogue = true; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 5; + projectile.extraUpdates = 1; + } - public override void AI() - { - grind--; - if (grind <= 0) - { - grind = 0; - } - if (grind >= 1) - { - projectile.extraUpdates = 0; //stop, you're touching an enemy - projectile.velocity.X *= 0.75f; - projectile.velocity.Y *= 0.75f; - } - else - { - projectile.velocity.X *= 1.005f; //you broke up, time to yeet yourself out - projectile.velocity.Y *= 1.005f; - if (projectile.velocity.X > 16f) - { - projectile.velocity.X = 16f; - } - if (projectile.velocity.Y > 16f) - { - projectile.velocity.Y = 16f; - } - projectile.extraUpdates = 1; - } - } + public override void AI() + { + if (grind > 0) + { + grind--; + } + if (grind >= 1) + { + projectile.extraUpdates = 0; //stop, you're touching an enemy + projectile.velocity.X *= 0.75f; + projectile.velocity.Y *= 0.75f; + } + else + { + projectile.velocity.X *= 1.005f; //you broke up, time to yeet yourself out + projectile.velocity.Y *= 1.005f; + if (projectile.velocity.X > 16f) + { + projectile.velocity.X = 16f; + } + if (projectile.velocity.Y > 16f) + { + projectile.velocity.Y = 16f; + } + projectile.extraUpdates = 1; + } + } - public override bool OnTileCollide(Vector2 oldVelocity) - { - bounce--; - if (bounce <= 0) - { - projectile.Kill(); //you can only bounce so much 'til death - } - else - { - if (projectile.velocity.X != oldVelocity.X) - { - projectile.velocity.X = -oldVelocity.X; - } - if (projectile.velocity.Y != oldVelocity.Y) - { - projectile.velocity.Y = -oldVelocity.Y; - } - } - return false; - } + public override bool OnTileCollide(Vector2 oldVelocity) + { + bounce--; + if (bounce <= 0) + { + projectile.Kill(); //you can only bounce so much 'til death + } + else + { + if (projectile.velocity.X != oldVelocity.X) + { + projectile.velocity.X = -oldVelocity.X; + } + if (projectile.velocity.Y != oldVelocity.Y) + { + projectile.velocity.Y = -oldVelocity.Y; + } + } + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - grind += 5; //THE GRIND NEVER STOPS - if (grind >= 10) - { - grind = 10; - } - Player player = Main.player[projectile.owner]; - target.AddBuff(ModContent.BuffType(), 300); - if (projectile.ai[1] == 1f && projectile.owner == Main.myPlayer && grind >= 1) //stealth strike attack - { - int stealth = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - Main.projectile[stealth].Calamity().forceRogue = true; - } - if (!target.canGhostHeal || player.moonLeech) //canGhostHeal be like lol - { - return; - } - if (Main.rand.NextBool(2)) - { - player.statLife += 1; //Trello said 2 hp per hit. Sounds like a fat balancing problem. - player.HealEffect(1); - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + OnHitEffects(!target.canGhostHeal || Main.player[projectile.owner].moonLeech); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - grind += 5; //THE GRIND NEVER STOPS - if (grind >= 10) - { - grind = 10; - } - Player player = Main.player[projectile.owner]; - target.AddBuff(ModContent.BuffType(), 300); - if (projectile.ai[1] == 1f && projectile.owner == Main.myPlayer && grind >= 1) //stealth strike attack - { - int stealth = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - Main.projectile[stealth].Calamity().forceRogue = true; - } - if (Main.rand.NextBool(2)) - { - player.statLife += 1; //Trello said 2 hp per hit. Sounds like a fat balancing problem. - player.HealEffect(1); - } - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + OnHitEffects(Main.player[projectile.owner].moonLeech); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) //afterimages - { - CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); - return false; - } - } + private void OnHitEffects(bool cannotLifesteal) + { + if (grind < 10) + { + grind += 5; //THE GRIND NEVER STOPS + } + + if (projectile.Calamity().stealthStrike && projectile.owner == Main.myPlayer) //stealth strike attack + { + int stealth = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + Main.projectile[stealth].Calamity().forceRogue = true; + } + + Player player = Main.player[projectile.owner]; + if (cannotLifesteal) //canGhostHeal be like lol + { + return; + } + if (Main.rand.NextBool(2)) + { + player.statLife += 1; //Trello said 2 hp per hit. Sounds like a fat balancing problem. + player.HealEffect(1); + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) //afterimages + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); + return false; + } + } } diff --git a/Projectiles/Rogue/Celestus2.cs b/Projectiles/Rogue/Celestus2.cs index 7f9d070323..825b8d27e4 100644 --- a/Projectiles/Rogue/Celestus2.cs +++ b/Projectiles/Rogue/Celestus2.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -52,28 +50,12 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/CelestusBoomerang.cs b/Projectiles/Rogue/CelestusBoomerang.cs index 5ccaed09b3..08a6c98a18 100644 --- a/Projectiles/Rogue/CelestusBoomerang.cs +++ b/Projectiles/Rogue/CelestusBoomerang.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -116,15 +114,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); if (projectile.owner == Main.myPlayer) { float spread = 45f * 0.0174f; @@ -143,15 +133,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitPvp(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); if (projectile.owner == Main.myPlayer) { float spread = 45f * 0.0174f; diff --git a/Projectiles/Rogue/CircletTornado.cs b/Projectiles/Rogue/CircletTornado.cs index 54af35c75c..f3dba7b2d1 100644 --- a/Projectiles/Rogue/CircletTornado.cs +++ b/Projectiles/Rogue/CircletTornado.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = -1; projectile.timeLeft = 1200; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 20; + projectile.localNPCHitCooldown = 30; } public override void AI() diff --git a/Projectiles/Rogue/CraniumSMASH.cs b/Projectiles/Rogue/CraniumSMASH.cs index 33c2da5aa8..7da9b66221 100644 --- a/Projectiles/Rogue/CraniumSMASH.cs +++ b/Projectiles/Rogue/CraniumSMASH.cs @@ -36,10 +36,10 @@ namespace CalamityMod.Projectiles.Rogue void SpawnExplosionDust() { Main.PlaySound(2, (int)projectile.Center.X, (int)projectile.Center.Y, 14); - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); for (int num194 = 0; num194 < 25; num194++) { - int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 135, 0f, 0f, 100, default, 2f); + int num195 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, 0f, 0f, 100, default, 2f); Main.dust[num195].noGravity = true; Main.dust[num195].velocity *= 0f; } diff --git a/Projectiles/Rogue/CraniumSmasherExplosive.cs b/Projectiles/Rogue/CraniumSmasherExplosive.cs index 98e1f41f97..41d1d816d9 100644 --- a/Projectiles/Rogue/CraniumSmasherExplosive.cs +++ b/Projectiles/Rogue/CraniumSmasherExplosive.cs @@ -47,10 +47,10 @@ namespace CalamityMod.Projectiles.Rogue projectile.localNPCHitCooldown = 10; projectile.Damage(); Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); for (int num194 = 0; num194 < 25; num194++) { - int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 135, 0f, 0f, 100, default, 2f); + int num195 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, 0f, 0f, 100, default, 2f); Main.dust[num195].noGravity = true; Main.dust[num195].velocity *= 0f; } diff --git a/Projectiles/Rogue/CraniumSmasherStealth.cs b/Projectiles/Rogue/CraniumSmasherStealth.cs index 6b68e13ac9..7e616a124d 100644 --- a/Projectiles/Rogue/CraniumSmasherStealth.cs +++ b/Projectiles/Rogue/CraniumSmasherStealth.cs @@ -68,10 +68,10 @@ namespace CalamityMod.Projectiles.Rogue projectile.localNPCHitCooldown = 10; projectile.Damage(); Main.PlaySound(2, (int)projectile.Center.X, (int)projectile.Center.Y, 14); - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); for (int num194 = 0; num194 < 25; num194++) { - int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 135, 0f, 0f, 100, default, 2f); + int num195 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, 0f, 0f, 100, default, 2f); Main.dust[num195].noGravity = true; Main.dust[num195].velocity *= 0f; } diff --git a/Projectiles/Rogue/Crystalline2.cs b/Projectiles/Rogue/Crystalline2.cs index 6aaabebe15..993bca11aa 100644 --- a/Projectiles/Rogue/Crystalline2.cs +++ b/Projectiles/Rogue/Crystalline2.cs @@ -28,10 +28,10 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { projectile.localAI[0]++; - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 2.355f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(135f); if (projectile.spriteDirection == -1) { - projectile.rotation -= 1.57f; + projectile.rotation -= MathHelper.PiOver2; } if (projectile.localAI[0] == 10f && projectile.ai[1] == 1f) { @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i < numProj + 1; i++) { Vector2 perturbedSpeed = new Vector2(projectile.velocity.X * 0.8f, projectile.velocity.Y * 0.8f).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.5f), projectile.knockBack, projectile.owner, 0f, 2f); + int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.5f), projectile.knockBack, projectile.owner, 0f, 2f); Main.projectile[proj].timeLeft = 20; } } @@ -51,6 +51,8 @@ namespace CalamityMod.Projectiles.Rogue public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { + if (projectile.timeLeft == (projectile.ai[1] == 2f ? 20 : 30)) + return false; Texture2D tex = Main.projectileTexture[projectile.type]; spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); return false; diff --git a/Projectiles/Rogue/CrystallineProj.cs b/Projectiles/Rogue/CrystallineProj.cs index d5e35bf284..14b3066e8b 100644 --- a/Projectiles/Rogue/CrystallineProj.cs +++ b/Projectiles/Rogue/CrystallineProj.cs @@ -27,10 +27,10 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 2.355f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(135f); if (projectile.spriteDirection == -1) { - projectile.rotation -= 1.57f; + projectile.rotation -= MathHelper.PiOver2; } projectile.ai[1] += 1f; if (projectile.ai[1] == 30f) @@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.Rogue { float AI1 = projectile.Calamity().stealthStrike ? 1f : 0f; Vector2 perturbedSpeed = new Vector2(projectile.velocity.X, projectile.velocity.Y).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.5f), projectile.knockBack, projectile.owner, 0f, AI1); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.5f), projectile.knockBack, projectile.owner, 0f, AI1); } } } diff --git a/Projectiles/Rogue/DestructionBolt.cs b/Projectiles/Rogue/DestructionBolt.cs index e0fd35b20f..f90577c3fa 100644 --- a/Projectiles/Rogue/DestructionBolt.cs +++ b/Projectiles/Rogue/DestructionBolt.cs @@ -151,7 +151,7 @@ namespace CalamityMod.Projectiles.Rogue Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); for (int num621 = 0; num621 < 20; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -161,13 +161,13 @@ namespace CalamityMod.Projectiles.Rogue } for (int num623 = 0; num623 < 45; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(9); + CalamityUtils.ExplosionGores(projectile.Center, 9); } } } diff --git a/Projectiles/Rogue/DestructionStar.cs b/Projectiles/Rogue/DestructionStar.cs index 8faa224bca..2018a0a830 100644 --- a/Projectiles/Rogue/DestructionStar.cs +++ b/Projectiles/Rogue/DestructionStar.cs @@ -33,12 +33,12 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - if (Main.rand.Next(8) == 0) + if (Main.rand.NextBool(8)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 191, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } projectile.rotation += Math.Sign(projectile.velocity.X) * MathHelper.ToRadians(8f); - if (projectile.Calamity().stealthStrike == true || hitCount > 16) + if (projectile.Calamity().stealthStrike || hitCount > 16) hitCount = 16; } @@ -91,14 +91,8 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i < hitCount; i++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, Main.myPlayer, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, Main.myPlayer, 0f, 0f); } } } diff --git a/Projectiles/Rogue/DragonShit.cs b/Projectiles/Rogue/DragonShit.cs index 9786df44db..1c098b42a1 100644 --- a/Projectiles/Rogue/DragonShit.cs +++ b/Projectiles/Rogue/DragonShit.cs @@ -87,7 +87,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); for (int num621 = 0; num621 < 5; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -97,13 +97,13 @@ namespace CalamityMod.Projectiles.Rogue } for (int num623 = 0; num623 < 8; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.Damage(); diff --git a/Projectiles/Rogue/EclipsesFallMain.cs b/Projectiles/Rogue/EclipsesFallMain.cs index 5969e11d6e..bbe31e0aee 100644 --- a/Projectiles/Rogue/EclipsesFallMain.cs +++ b/Projectiles/Rogue/EclipsesFallMain.cs @@ -33,50 +33,32 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - if (Main.rand.Next(8) == 0) + if (Main.rand.NextBool(8)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 138, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - for (int n = 0; n < Main.rand.Next(3, 6); n++) //3 to 5 spears - { - float x = target.position.X + (float)Main.rand.Next(-400, 400); - float y = target.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num13 = target.position.X + (float)(target.width / 2) - vector.X; - float num14 = target.position.Y + (float)(target.height / 2) - vector.Y; - num13 += (float)Main.rand.Next(-100, 101); - int num15 = 29; - float num16 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14)); - num16 = (float)num15 / num16; - num13 *= num16; - num14 *= num16; - Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType(), (int)(projectile.damage * 0.08f * Main.rand.NextFloat(4f, 7f)), (int)(projectile.knockBack * 0.1f * Main.rand.NextFloat(7f, 10f)), projectile.owner, 0f, 0f); - } + SpawnSpears(target.Center); } public override void OnHitPvp(Player target, int damage, bool crit) { + SpawnSpears(target.Center); + } + + private void SpawnSpears(Vector2 targetPos) + { for (int n = 0; n < Main.rand.Next(3, 6); n++) //3 to 5 spears { - float x = target.position.X + (float)Main.rand.Next(-400, 400); - float y = target.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num13 = target.position.X + (float)(target.width / 2) - vector.X; - float num14 = target.position.Y + (float)(target.height / 2) - vector.Y; - num13 += (float)Main.rand.Next(-100, 101); - int num15 = 29; - float num16 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14)); - num16 = (float)num15 / num16; - num13 *= num16; - num14 *= num16; - Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType(), (int)(projectile.damage * 0.08f * Main.rand.NextFloat(4f, 7f)), (int)(projectile.knockBack * 0.1f * Main.rand.NextFloat(7f, 10f)), projectile.owner, 0f, 0f); + float dmgMult = 0.08f * Main.rand.NextFloat(4f, 7f); + float kBMult = 0.1f * Main.rand.NextFloat(7f, 10f); + CalamityUtils.ProjectileRain(targetPos, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), (int)(projectile.damage * dmgMult), projectile.knockBack * kBMult, projectile.owner); } - } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Rogue/EclipsesSmol.cs b/Projectiles/Rogue/EclipsesSmol.cs index fa9ad85291..0da5447707 100644 --- a/Projectiles/Rogue/EclipsesSmol.cs +++ b/Projectiles/Rogue/EclipsesSmol.cs @@ -18,7 +18,6 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.penetrate = 1; projectile.tileCollide = false; projectile.ignoreWater = true; projectile.timeLeft = 150; @@ -28,36 +27,30 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 400f, 24f, 20f); } public override void Kill(int timeLeft) { - Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); - for (int num621 = 0; num621 < 20; num621++) + Main.PlaySound(SoundID.Item14, projectile.Center); + for (int i = 0; i < 2; i++) { - if (Main.rand.NextBool(10)) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 138, 0f, 0f, 100, default, 1.2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } + int dustInt = Dust.NewDust(projectile.position, projectile.width, projectile.height, 138, 0f, 0f, 100, default, 1.2f); + Main.dust[dustInt].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[dustInt].scale = 0.5f; + Main.dust[dustInt].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } } - for (int num623 = 0; num623 < 35; num623++) + for (int j = 0; j < 3; j++) { - if (Main.rand.NextBool(10)) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 138, 0f, 0f, 100, default, 1.7f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 138, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; - } + int moreDust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 138, 0f, 0f, 100, default, 1.7f); + Main.dust[moreDust].noGravity = true; + Main.dust[moreDust].velocity *= 5f; + moreDust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 138, 0f, 0f, 100, default, 1f); + Main.dust[moreDust].velocity *= 2f; } } diff --git a/Projectiles/Rogue/EclipsesStealth.cs b/Projectiles/Rogue/EclipsesStealth.cs index 748254fc39..4dfec90536 100644 --- a/Projectiles/Rogue/EclipsesStealth.cs +++ b/Projectiles/Rogue/EclipsesStealth.cs @@ -7,90 +7,96 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class EclipsesStealth : ModProjectile - { + public class EclipsesStealth : ModProjectile + { private bool changedTimeLeft = false; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Eclipse's Stealth"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Eclipse's Stealth"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 25; - projectile.height = 25; - projectile.friendly = true; - projectile.penetrate = -1; - projectile.timeLeft = 300; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 30; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = 25; + projectile.height = 25; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft = 300; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -1; + projectile.Calamity().rogue = true; + } - public override void AI() - { - if (projectile.timeLeft % 5 == 0) //congrats Pinkie... every 5 ticks - { - if (Main.rand.NextBool(2) && Main.myPlayer == projectile.owner) - { - float dmgKBMult = Main.rand.NextFloat(0.32f, 0.56f); - int spearAmt = Main.rand.Next(1, 4); //1 to 3 spears - for (int n = 0; n < spearAmt; n++) - { - float xStart = projectile.position.X + Main.rand.Next(-400, 400); - float yStart = projectile.position.Y - Main.rand.Next(500, 800); - Vector2 startPos = new Vector2(xStart, yStart); - Vector2 velocity = projectile.Center - startPos; - velocity.X += (float)Main.rand.Next(-100, 101); - float travelDist = velocity.Length(); - float spearSpeed = 29f; - travelDist = spearSpeed / travelDist; - velocity.X *= travelDist; - velocity.Y *= travelDist; - Projectile.NewProjectile(startPos, velocity, ModContent.ProjectileType(), (int)(projectile.damage * dmgKBMult), projectile.knockBack * dmgKBMult, projectile.owner, 0f, 0f); - } - } - } - if (projectile.ai[0] == 0f) - { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f; - if (Main.rand.NextBool(8)) //dust - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 138, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - } - } + public override void AI() + { + if (projectile.timeLeft % 5 == 0) //congrats Pinkie... every 5 ticks + { + if (Main.rand.NextBool(2) && Main.myPlayer == projectile.owner) + { + float dmgKBMult = Main.rand.NextFloat(0.4f, 0.6f); + int spearAmt = Main.rand.Next(1, 3); //1 to 2 spears + for (int n = 0; n < spearAmt; n++) + { + CalamityUtils.ProjectileRain(projectile.Center, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), (int)(projectile.damage * dmgKBMult), projectile.knockBack * dmgKBMult, projectile.owner); + } + } + } + + //Behavior when not sticking to anything + if (projectile.ai[0] == 0f) + { + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; + if (Main.rand.NextBool(8)) //dust + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 138, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); + } + } + + //Ensures that a spear will last 10 seconds after it hits something if (projectile.ai[0] == 1f && !changedTimeLeft) { - projectile.timeLeft = 900; + projectile.timeLeft = 600; changedTimeLeft = true; } - //Sticky Behaviour - projectile.StickyProjAI(15); - } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - projectile.ModifyHitNPCSticky(1, true); - } + //Sticky Behaviour + projectile.StickyProjAI(10); + } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - if (targetHitbox.Width > 8 && targetHitbox.Height > 8) - { - targetHitbox.Inflate(-targetHitbox.Width / 8, -targetHitbox.Height / 8); - } - return null; - } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + projectile.ModifyHitNPCSticky(1, true); + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); - return false; - } - } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (targetHitbox.Width > 8 && targetHitbox.Height > 8) + { + targetHitbox.Inflate(-targetHitbox.Width / 8, -targetHitbox.Height / 8); + } + return null; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); + return false; + } + + public override bool? CanHitNPC(NPC target) + { + if (projectile.ai[0] == 1f) + { + return false; + } + return null; + } + + public override bool CanHitPvp(Player target) => projectile.ai[0] != 1f; + } } diff --git a/Projectiles/Rogue/FantasyTalismanProj.cs b/Projectiles/Rogue/FantasyTalismanProj.cs index 568106cfd1..744533b7e7 100644 --- a/Projectiles/Rogue/FantasyTalismanProj.cs +++ b/Projectiles/Rogue/FantasyTalismanProj.cs @@ -35,11 +35,11 @@ namespace CalamityMod.Projectiles.Rogue { projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - if (Main.rand.Next(3) == 0) + if (Main.rand.NextBool(3)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 175, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - projectile.StickyProjAI(15); + projectile.StickyProjAI(4); if (projectile.ai[0] == 1f) { if (projectile.timeLeft % 10 == 0) @@ -47,42 +47,9 @@ namespace CalamityMod.Projectiles.Rogue if (Main.rand.NextBool(2)) { int spiritDamage = projectile.damage / 2; - int[] numArray1 = new int[Main.maxNPCs]; - int maxValue1 = 0; - int maxValue2 = 0; - for (int index = 0; index < Main.maxNPCs; ++index) - { - if (Main.npc[index].CanBeChasedBy((object) projectile, false)) - { - float num2 = Math.Abs(Main.npc[index].Center.X - projectile.Center.X) + Math.Abs(Main.npc[index].Center.Y - projectile.Center.Y); - if (num2 < 800f) - { - if (Collision.CanHit(projectile.position, 1, 1, Main.npc[index].position, Main.npc[index].width, Main.npc[index].height) && num2 > 50f) - { - numArray1[maxValue2] = index; - ++maxValue2; - } - else if (maxValue2 == 0) - { - numArray1[maxValue1] = index; - ++maxValue1; - } - } - } - } - if (maxValue1 == 0 && maxValue2 == 0) - return; - int num3 = maxValue2 <= 0 ? numArray1[Main.rand.Next(maxValue1)] : numArray1[Main.rand.Next(maxValue2)]; - double num4 = 4.0; - float num5 = (float) Main.rand.Next(-100, 101); - float num6 = (float) Main.rand.Next(-100, 101); - double num7 = Math.Sqrt((double) num5 * (double) num5 + (double) num6 * (double) num6); - float num8 = (float) (num4 / num7); - float SpeedX = num5 * num8; - float SpeedY = num6 * num8; - int ghost = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, SpeedX, SpeedY, ProjectileID.SpectreWrath, spiritDamage, 0.0f, projectile.owner, (float)num3, 0f); - Main.projectile[ghost].Calamity().forceRogue = true; - Main.projectile[ghost].penetrate = 1; + Projectile ghost = CalamityGlobalProjectile.SpawnOrb(projectile, spiritDamage, ProjectileID.SpectreWrath, 800f, 4f); + ghost.Calamity().forceRogue = true; + ghost.penetrate = 1; } } } @@ -107,13 +74,5 @@ namespace CalamityMod.Projectiles.Rogue } return null; } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (projectile.timeLeft > 240) - { - projectile.timeLeft = 240; - } - } } } diff --git a/Projectiles/Rogue/FantasyTalismanStealth.cs b/Projectiles/Rogue/FantasyTalismanStealth.cs index fb1ddd368f..fb27738123 100644 --- a/Projectiles/Rogue/FantasyTalismanStealth.cs +++ b/Projectiles/Rogue/FantasyTalismanStealth.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Projectiles.Rogue { projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - if (Main.rand.Next(3) == 0) + if (Main.rand.NextBool(3)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 175, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } @@ -45,11 +45,11 @@ namespace CalamityMod.Projectiles.Rogue { if (projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); } } } - projectile.StickyProjAI(15); + projectile.StickyProjAI(4); if (projectile.ai[0] == 1f) { if (projectile.timeLeft % 4 == 0) @@ -57,42 +57,9 @@ namespace CalamityMod.Projectiles.Rogue if (Main.rand.NextBool(2)) { int spiritDamage = projectile.damage / 2; - int[] numArray1 = new int[Main.maxNPCs]; - int maxValue1 = 0; - int maxValue2 = 0; - for (int index = 0; index < Main.maxNPCs; ++index) - { - if (Main.npc[index].CanBeChasedBy((object) projectile, false)) - { - float num2 = Math.Abs(Main.npc[index].Center.X - projectile.Center.X) + Math.Abs(Main.npc[index].Center.Y - projectile.Center.Y); - if (num2 < 800f) - { - if (Collision.CanHit(projectile.position, 1, 1, Main.npc[index].position, Main.npc[index].width, Main.npc[index].height) && num2 > 50f) - { - numArray1[maxValue2] = index; - ++maxValue2; - } - else if (maxValue2 == 0) - { - numArray1[maxValue1] = index; - ++maxValue1; - } - } - } - } - if (maxValue1 == 0 && maxValue2 == 0) - return; - int num3 = maxValue2 <= 0 ? numArray1[Main.rand.Next(maxValue1)] : numArray1[Main.rand.Next(maxValue2)]; - double num4 = 4.0; - float num5 = (float) Main.rand.Next(-100, 101); - float num6 = (float) Main.rand.Next(-100, 101); - double num7 = Math.Sqrt((double) num5 * (double) num5 + (double) num6 * (double) num6); - float num8 = (float) (num4 / num7); - float SpeedX = num5 * num8; - float SpeedY = num6 * num8; - int ghost = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, SpeedX, SpeedY, ProjectileID.SpectreWrath, spiritDamage, 0.0f, projectile.owner, (float)num3, 0f); - Main.projectile[ghost].Calamity().forceRogue = true; - Main.projectile[ghost].penetrate = 1; + Projectile ghost = CalamityGlobalProjectile.SpawnOrb(projectile, spiritDamage, ProjectileID.SpectreWrath, 800f, 4f); + ghost.Calamity().forceRogue = true; + ghost.penetrate = 1; } } } @@ -117,13 +84,5 @@ namespace CalamityMod.Projectiles.Rogue } return null; } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (projectile.timeLeft > 240) - { - projectile.timeLeft = 240; - } - } } } diff --git a/Projectiles/Rogue/FinalDawnFireSlash.cs b/Projectiles/Rogue/FinalDawnFireSlash.cs index 18e059abb4..ff28601aa3 100644 --- a/Projectiles/Rogue/FinalDawnFireSlash.cs +++ b/Projectiles/Rogue/FinalDawnFireSlash.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.Rogue { Player player = Main.player[projectile.owner]; - if (player.dead || player is null || Main.myPlayer != projectile.owner) + if (player.dead || player is null) projectile.Kill(); player.direction = projectile.direction; diff --git a/Projectiles/Rogue/FinalDawnHorizontalSlash.cs b/Projectiles/Rogue/FinalDawnHorizontalSlash.cs index 5ed9d58eea..63e04254e4 100644 --- a/Projectiles/Rogue/FinalDawnHorizontalSlash.cs +++ b/Projectiles/Rogue/FinalDawnHorizontalSlash.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Rogue { Player player = Main.player[projectile.owner]; - if (player.dead || player is null || Main.myPlayer != projectile.owner) + if (player.dead || player is null) projectile.Kill(); projectile.Center = player.Center; @@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.friendly = true; Main.PlaySound(SoundID.Item71, projectile.position); - if(projectile.owner == Main.myPlayer) + if (projectile.owner == Main.myPlayer) { Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner); } diff --git a/Projectiles/Rogue/FinalDawnProjectile.cs b/Projectiles/Rogue/FinalDawnProjectile.cs index a7e799af8d..36e42761d0 100644 --- a/Projectiles/Rogue/FinalDawnProjectile.cs +++ b/Projectiles/Rogue/FinalDawnProjectile.cs @@ -7,169 +7,173 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class FinalDawnProjectile : ModProjectile - { - public const float MaxChargeTime = 20f; - public override void SetStaticDefaults() + public class FinalDawnProjectile : ModProjectile + { + public const float MaxChargeTime = 20f; + public override void SetStaticDefaults() { DisplayName.SetDefault("The Final Dawn"); + Main.projFrames[projectile.type] = 2; } - public override void SetDefaults() - { - projectile.width = 16; - projectile.height = 16; - projectile.friendly = false; - projectile.Calamity().rogue = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - Main.projFrames[projectile.type] = 2; - //projectile.extraUpdates = 2; - } - public override bool ShouldUpdatePosition() => false; - public override void AI() + public override void SetDefaults() { - Player player = Main.player[projectile.owner]; + projectile.width = 16; + projectile.height = 16; + projectile.friendly = false; + projectile.Calamity().rogue = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + //projectile.extraUpdates = 2; + } + public override bool ShouldUpdatePosition() => false; + public override void AI() + { + Player player = Main.player[projectile.owner]; - if (player.dead || player is null || Main.myPlayer != projectile.owner) + if (player.dead || player is null) projectile.Kill(); - if (Main.myPlayer == player.whoAmI) - { - projectile.velocity = Main.MouseWorld - player.Center; - projectile.velocity.Normalize(); - } - player.direction = projectile.direction; - player.heldProj = projectile.whoAmI; - projectile.Center = player.Center; - projectile.position.Y -= 44; - projectile.position.X -= 46 * player.direction; - player.bodyFrame.Y = player.bodyFrame.Height; + if (Main.myPlayer == player.whoAmI) + { + projectile.velocity = Main.MouseWorld - player.Center; + projectile.velocity.Normalize(); + } + player.direction = projectile.direction; + player.heldProj = projectile.whoAmI; + projectile.Center = player.Center; + projectile.position.Y -= 44; + projectile.position.X -= 46 * player.direction; + player.bodyFrame.Y = player.bodyFrame.Height; - if (projectile.ai[0] < MaxChargeTime) - { - // Charging dust - Vector2 dustCenter = new Vector2(projectile.Center.X, projectile.Center.Y - 40); - int flame = Dust.NewDust(dustCenter, projectile.width, projectile.height, ModContent.DustType(), 0, 0, 100, default, 2f); - Main.dust[flame].noGravity = true; - Main.dust[flame].fadeIn = 1.5f; - Main.dust[flame].scale = 1.4f; - Vector2 offsetVector = Utils.NextVector2CircularEdge(Main.rand, 100f, 100f); - Main.dust[flame].position = dustCenter - offsetVector; - Vector2 newVelocity = dustCenter - Main.dust[flame].position; - Main.dust[flame].velocity = newVelocity * 0.1f; - } - if (projectile.ai[0] == MaxChargeTime) - { - int dustCount = 36; - for (int i = 0; i < dustCount; i++) - { - Vector2 startingPosition = projectile.Center + new Vector2(0, -40); - Vector2 offset = Vector2.UnitX * projectile.width * 0.1875f; - offset = offset.RotatedBy((i - (dustCount / 2 - 1)) * MathHelper.TwoPi / dustCount); - int dustIdx = Dust.NewDust(startingPosition + offset, 0, 0, ModContent.DustType(), offset.X * 2f, offset.Y * 2f, 100, default, 3.4f); - Main.dust[dustIdx].noGravity = true; - Main.dust[dustIdx].noLight = true; - Main.dust[dustIdx].velocity = Vector2.Normalize(offset) * 5f; - } - projectile.frame = 1; - } - projectile.ai[0]++; + if (projectile.ai[0] < MaxChargeTime) + { + // Charging dust + Vector2 dustCenter = new Vector2(projectile.Center.X, projectile.Center.Y - 40); + int flame = Dust.NewDust(dustCenter, projectile.width, projectile.height, ModContent.DustType(), 0, 0, 100, default, 2f); + Main.dust[flame].noGravity = true; + Main.dust[flame].fadeIn = 1.5f; + Main.dust[flame].scale = 1.4f; + Vector2 offsetVector = Utils.NextVector2CircularEdge(Main.rand, 100f, 100f); + Main.dust[flame].position = dustCenter - offsetVector; + Vector2 newVelocity = dustCenter - Main.dust[flame].position; + Main.dust[flame].velocity = newVelocity * 0.1f; + } + if (projectile.ai[0] == MaxChargeTime) + { + int dustCount = 36; + for (int i = 0; i < dustCount; i++) + { + Vector2 startingPosition = projectile.Center + new Vector2(0, -40); + Vector2 offset = Vector2.UnitX * projectile.width * 0.1875f; + offset = offset.RotatedBy((i - (dustCount / 2 - 1)) * MathHelper.TwoPi / dustCount); + int dustIdx = Dust.NewDust(startingPosition + offset, 0, 0, ModContent.DustType(), offset.X * 2f, offset.Y * 2f, 100, default, 3.4f); + Main.dust[dustIdx].noGravity = true; + Main.dust[dustIdx].noLight = true; + Main.dust[dustIdx].velocity = Vector2.Normalize(offset) * 5f; + } + projectile.frame = 1; + } + projectile.ai[0]++; - projectile.spriteDirection = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.spriteDirection = (projectile.velocity.X > 0).ToDirectionInt(); - if (Main.myPlayer == projectile.owner) - { - if (!player.channel || player.noItems || player.CCed) - { - AttemptExecuteAttacks(player); - projectile.Kill(); - } - } - } + if (Main.myPlayer == projectile.owner) + { + if (!player.channel || player.noItems || player.CCed) + { + AttemptExecuteAttacks(player); + projectile.Kill(); + } + } + } - public void AttemptExecuteAttacks(Player player) - { - if (projectile.ai[0] >= MaxChargeTime && !player.noItems && !player.CCed) - { - // Far range attack - if (player.controlUp) - { - // Stealth Strike - if (player.Calamity().StealthStrikeAvailable()) - { - Projectile.NewProjectile(player.Center, - player.DirectionTo(Main.MouseWorld) * 38f, - ModContent.ProjectileType(), - (int)(projectile.damage * 2.5f), - projectile.knockBack, - projectile.owner); - player.Calamity().ConsumeStealthByAttacking(); - } - else - { - Projectile.NewProjectile(projectile.Center, - projectile.DirectionTo(Main.MouseWorld) * 38f, - ModContent.ProjectileType(), projectile.damage, - projectile.knockBack, projectile.owner); - } - } - // Close range attack - else - { - // Stealth - if (player.Calamity().StealthStrikeAvailable()) - { - Projectile.NewProjectile(projectile.Center, - projectile.velocity, - ModContent.ProjectileType(), - (int)(projectile.damage * 2.5f), - projectile.knockBack, - projectile.owner); - player.Calamity().ConsumeStealthByAttacking(); - } - else - { - Projectile.NewProjectile(projectile.Center, - projectile.velocity, - ModContent.ProjectileType(), - (int)(projectile.damage * 1.5f), - projectile.knockBack, - projectile.owner); - } - } - } - } + public void AttemptExecuteAttacks(Player player) + { + //projectile.ai[1] == 1f if spawned via Venerated Locket + if (projectile.ai[0] >= MaxChargeTime && !player.noItems && !player.CCed) + { + // Far range attack + if (player.controlUp) + { + // Stealth Strike + if (player.Calamity().StealthStrikeAvailable() && projectile.ai[1] != 1f) + { + Projectile.NewProjectile(player.Center, + player.DirectionTo(Main.MouseWorld) * 38f, + ModContent.ProjectileType(), + (int)(projectile.damage * 1.5f), + projectile.knockBack, + projectile.owner); + player.Calamity().ConsumeStealthByAttacking(); + } + else + { + Projectile.NewProjectile(projectile.Center, + projectile.DirectionTo(Main.MouseWorld) * 38f, + ModContent.ProjectileType(), projectile.damage, + projectile.knockBack, projectile.owner); + if (projectile.ai[1] != 1f) + player.Calamity().ConsumeStealthByAttacking(); + } + } + // Close range attack + else + { + // Stealth + if (player.Calamity().StealthStrikeAvailable() && projectile.ai[1] != 1f) + { + Projectile.NewProjectile(projectile.Center, + projectile.velocity, + ModContent.ProjectileType(), + (int)(projectile.damage * 1.5f), + projectile.knockBack, + projectile.owner); + player.Calamity().ConsumeStealthByAttacking(); + } + else + { + //This one doesn't consume stealth since it replenishes stealth on hits + Projectile.NewProjectile(projectile.Center, + projectile.velocity, + ModContent.ProjectileType(), + projectile.damage, + projectile.knockBack, + projectile.owner); + } + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D scytheTexture = Main.projectileTexture[projectile.type]; - Texture2D glowmask = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/FinalDawnProjectile_Glow"); - int height = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; - int yStart = height * projectile.frame; - Main.spriteBatch.Draw(scytheTexture, - projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY, - new Rectangle?(new Rectangle(0, yStart, scytheTexture.Width, height)), - projectile.GetAlpha(lightColor), - projectile.rotation, - new Vector2(scytheTexture.Width / 2f, height / 2f), - projectile.scale, - projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, - 0f); - Main.spriteBatch.Draw(glowmask, - projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY, - new Rectangle?(new Rectangle(0, yStart, scytheTexture.Width, height)), - projectile.GetAlpha(Color.White), - projectile.rotation, - new Vector2(scytheTexture.Width / 2f, height / 2f), - projectile.scale, - projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, - 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D scytheTexture = Main.projectileTexture[projectile.type]; + Texture2D glowmask = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/FinalDawnProjectile_Glow"); + int height = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int yStart = height * projectile.frame; + Main.spriteBatch.Draw(scytheTexture, + projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY, + new Rectangle?(new Rectangle(0, yStart, scytheTexture.Width, height)), + projectile.GetAlpha(lightColor), + projectile.rotation, + new Vector2(scytheTexture.Width / 2f, height / 2f), + projectile.scale, + projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, + 0f); + Main.spriteBatch.Draw(glowmask, + projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY, + new Rectangle?(new Rectangle(0, yStart, scytheTexture.Width, height)), + projectile.GetAlpha(Color.White), + projectile.rotation, + new Vector2(scytheTexture.Width / 2f, height / 2f), + projectile.scale, + projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, + 0f); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 600); - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 600); + } + } } \ No newline at end of file diff --git a/Projectiles/Rogue/FinalDawnThrow.cs b/Projectiles/Rogue/FinalDawnThrow.cs index 9151e544a7..d09dc8400f 100644 --- a/Projectiles/Rogue/FinalDawnThrow.cs +++ b/Projectiles/Rogue/FinalDawnThrow.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Projectiles.Rogue { Player player = Main.player[projectile.owner]; - if (player.dead || player is null || Main.myPlayer != projectile.owner) + if (player.dead || player is null) projectile.Kill(); if (projectile.localAI[0] == 0) diff --git a/Projectiles/Rogue/FinalDawnThrow2.cs b/Projectiles/Rogue/FinalDawnThrow2.cs index 80aa357634..6bb8d51475 100644 --- a/Projectiles/Rogue/FinalDawnThrow2.cs +++ b/Projectiles/Rogue/FinalDawnThrow2.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Rogue Vector2 velocity = Utils.NextVector2Circular(Main.rand, 7.2f, 7.2f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), - (int)(projectile.damage * 0.8), projectile.knockBack, projectile.owner, 0f, + (int)(projectile.damage * 0.3), projectile.knockBack, projectile.owner, 0f, target.whoAmI); } HasHitEnemy = true; @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Rogue { Player player = Main.player[projectile.owner]; - if (player.dead || player is null || Main.myPlayer != projectile.owner) + if (player.dead || player is null) projectile.Kill(); if (projectile.localAI[0] == 0) diff --git a/Projectiles/Rogue/GlaiveProj.cs b/Projectiles/Rogue/GlaiveProj.cs index e2a3d4a386..f8af833e7e 100644 --- a/Projectiles/Rogue/GlaiveProj.cs +++ b/Projectiles/Rogue/GlaiveProj.cs @@ -82,25 +82,25 @@ namespace CalamityMod.Projectiles.Rogue // Home back in on the player. if (projectile.velocity.X < xDist) { - projectile.velocity.X = projectile.velocity.X + acceleration; + projectile.velocity.X += acceleration; if (projectile.velocity.X < 0f && xDist > 0f) projectile.velocity.X += acceleration; } else if (projectile.velocity.X > xDist) { - projectile.velocity.X = projectile.velocity.X - acceleration; + projectile.velocity.X -= acceleration; if (projectile.velocity.X > 0f && xDist < 0f) projectile.velocity.X -= acceleration; } if (projectile.velocity.Y < yDist) { - projectile.velocity.Y = projectile.velocity.Y + acceleration; + projectile.velocity.Y += acceleration; if (projectile.velocity.Y < 0f && yDist > 0f) projectile.velocity.Y += acceleration; } else if (projectile.velocity.Y > yDist) { - projectile.velocity.Y = projectile.velocity.Y - acceleration; + projectile.velocity.Y -= acceleration; if (projectile.velocity.Y > 0f && yDist < 0f) projectile.velocity.Y -= acceleration; } diff --git a/Projectiles/Rogue/HypothermiaChunk.cs b/Projectiles/Rogue/HypothermiaChunk.cs index f52bc2a2b0..05d18001a9 100644 --- a/Projectiles/Rogue/HypothermiaChunk.cs +++ b/Projectiles/Rogue/HypothermiaChunk.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.tileCollide = true; } - if (Main.rand.Next(10) == 0) + if (Main.rand.NextBool(10)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 191, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f, 0, default, 0.8f); } @@ -58,16 +58,10 @@ namespace CalamityMod.Projectiles.Rogue } if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < Main.rand.Next(1,4); num252++) + for (int i = 0; i < Main.rand.Next(1,4); i++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int shard = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)((float)projectile.damage * 0.33f), projectile.knockBack * 0.75f, Main.myPlayer, Main.rand.Next(0,4), 1f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.33f), projectile.knockBack * 0.75f, Main.myPlayer, Main.rand.Next(4), 1f); } } } diff --git a/Projectiles/Rogue/HypothermiaShard.cs b/Projectiles/Rogue/HypothermiaShard.cs index 583d5f1aca..8c9b3d1ae5 100644 --- a/Projectiles/Rogue/HypothermiaShard.cs +++ b/Projectiles/Rogue/HypothermiaShard.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Rogue counter += 0.25f; if (Main.rand.NextBool(10)) { - int num300 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 191, 0f, 0f, 0, default, 0.8f); + int num300 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 191, 0f, 0f, 0, default, 0.8f); Main.dust[num300].noGravity = true; Main.dust[num300].velocity *= 0.2f; } diff --git a/Projectiles/Rogue/NastyChollaBol.cs b/Projectiles/Rogue/NastyChollaBol.cs index 8b201fe22f..4602066ee9 100644 --- a/Projectiles/Rogue/NastyChollaBol.cs +++ b/Projectiles/Rogue/NastyChollaBol.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Weapons.Rogue; using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ModLoader; @@ -33,65 +34,24 @@ namespace CalamityMod.Projectiles.Rogue projectile.StickyProjAI(15); if (projectile.ai[0] != 1f) { - try - { - int num223 = (int)(projectile.position.X / 16f) - 1; - int num224 = (int)((projectile.position.X + (float)projectile.width) / 16f) + 2; - int num225 = (int)(projectile.position.Y / 16f) - 1; - int num226 = (int)((projectile.position.Y + (float)projectile.height) / 16f) + 2; - if (num223 < 0) - { - num223 = 0; - } - if (num224 > Main.maxTilesX) - { - num224 = Main.maxTilesX; - } - if (num225 < 0) - { - num225 = 0; - } - if (num226 > Main.maxTilesY) - { - num226 = Main.maxTilesY; - } - for (int num227 = num223; num227 < num224; num227++) - { - for (int num228 = num225; num228 < num226; num228++) - { - if (Main.tile[num227, num228] != null && Main.tile[num227, num228].nactive() && (Main.tileSolid[(int)Main.tile[num227, num228].type] || (Main.tileSolidTop[(int)Main.tile[num227, num228].type] && Main.tile[num227, num228].frameY == 0))) - { - Vector2 vector19; - vector19.X = (float)(num227 * 16); - vector19.Y = (float)(num228 * 16); - if (projectile.position.X + (float)projectile.width - 4f > vector19.X && projectile.position.X + 4f < vector19.X + 16f && projectile.position.Y + (float)projectile.height - 4f > vector19.Y && projectile.position.Y + 4f < vector19.Y + 16f) - { - projectile.velocity.X = 0f; - projectile.velocity.Y = -0.2f; - } - } - } - } - } catch - { - } + projectile.StickToTiles(); projectile.localAI[1] += 1f; if (projectile.localAI[1] > 10f) { projectile.localAI[1] = 10f; if (projectile.velocity.Y == 0f && projectile.velocity.X != 0f) { - projectile.velocity.X = projectile.velocity.X * 0.97f; - if ((double)projectile.velocity.X > -0.01 && (double)projectile.velocity.X < 0.01) + projectile.velocity.X *= 0.97f; + if (Math.Abs(projectile.velocity.X) < 0.01f) { projectile.velocity.X = 0f; projectile.netUpdate = true; } } - projectile.velocity.Y = projectile.velocity.Y + 0.2f; + projectile.velocity.Y += 0.2f; } projectile.rotation += projectile.velocity.X * 0.1f; - } + } } public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) @@ -121,19 +81,13 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { Player player = Main.player[projectile.owner]; - int num251 = Main.rand.Next(2, 4); + int needleAmt = Main.rand.Next(2, 4); if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < num251; num252++) + for (int n = 0; n < needleAmt; n++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int shard = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)((NastyCholla.BaseDamage/4) * (player.allDamage + player.meleeDamage - 1f)), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)((NastyCholla.BaseDamage/4) * player.RogueDamage()), 0f, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Rogue/PlaguenadeProj.cs b/Projectiles/Rogue/PlaguenadeProj.cs index 99e82b2e9e..3ff3bbec5e 100644 --- a/Projectiles/Rogue/PlaguenadeProj.cs +++ b/Projectiles/Rogue/PlaguenadeProj.cs @@ -95,7 +95,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.Damage(); for (int i = 0; i < 10; i++) { - int smoke = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); + int smoke = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); Main.dust[smoke].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -105,13 +105,13 @@ namespace CalamityMod.Projectiles.Rogue } for (int j = 0; j < 15; j++) { - int plague = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 89, 0f, 0f, 100, default, 3f); + int plague = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 3f); Main.dust[plague].noGravity = true; Main.dust[plague].velocity *= 5f; - int fire = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 2f); + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 2f); Main.dust[fire].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } diff --git a/Projectiles/Rogue/Prismalline3.cs b/Projectiles/Rogue/Prismalline3.cs index 1c4eeb32e2..5fc4d6946c 100644 --- a/Projectiles/Rogue/Prismalline3.cs +++ b/Projectiles/Rogue/Prismalline3.cs @@ -25,10 +25,10 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 2.355f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(135f); if (projectile.spriteDirection == -1) { - projectile.rotation -= 1.57f; + projectile.rotation -= MathHelper.PiOver2; } CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 300f, 25f, 20f); } @@ -49,16 +49,10 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.ai[0] == 1f) { int shardCount = Main.rand.Next(1,4); - for (int num252 = 0; num252 < shardCount; num252++) + for (int s = 0; s < shardCount; s++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int shard = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner, 0f, 0f); Main.projectile[shard].Calamity().forceRogue = true; Main.projectile[shard].penetrate = 1; } diff --git a/Projectiles/Rogue/PrismallineProj.cs b/Projectiles/Rogue/PrismallineProj.cs index 280539286c..a1fab9f455 100644 --- a/Projectiles/Rogue/PrismallineProj.cs +++ b/Projectiles/Rogue/PrismallineProj.cs @@ -48,21 +48,15 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i < numProj + 1; i++) { - Vector2 speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - while (speed.X == 0f && speed.Y == 0f) - { - speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - } - speed.Normalize(); - speed *= (float)Main.rand.Next(30, 61) * 0.1f * 2f; + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f, 0.2f); if (numSpecProj < 2 && !hitEnemy) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 1.25), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 1.1), projectile.knockBack, projectile.owner, 0f, 0f); ++numSpecProj; } else { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 0f); } } } @@ -71,28 +65,16 @@ namespace CalamityMod.Projectiles.Rogue int shardCount = Main.rand.Next(2,5); for (int num252 = 0; num252 < shardCount; num252++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int shard = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner, 0f, 0f); Main.projectile[shard].Calamity().forceRogue = true; Main.projectile[shard].usesLocalNPCImmunity = true; Main.projectile[shard].localNPCHitCooldown = 10; } for (int i = 0; i < numProj + 1; i++) { - Vector2 speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - while (speed.X == 0f && speed.Y == 0f) - { - speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); - } - speed.Normalize(); - speed *= (float)Main.rand.Next(30, 61) * 0.1f * 2f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 1.25), projectile.knockBack, projectile.owner, 1f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f, 0.2f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 1.15), projectile.knockBack, projectile.owner, 1f, 0f); } } } @@ -116,16 +98,10 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.Calamity().stealthStrike) { int shardCount = Main.rand.Next(1,4); - for (int num252 = 0; num252 < shardCount; num252++) + for (int s = 0; s < shardCount; s++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int shard = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner, 0f, 0f); Main.projectile[shard].Calamity().forceRogue = true; Main.projectile[shard].penetrate = 1; } diff --git a/Projectiles/Rogue/ProfanedPartisanproj.cs b/Projectiles/Rogue/ProfanedPartisanproj.cs index 992f348aa5..f5f60cf019 100644 --- a/Projectiles/Rogue/ProfanedPartisanproj.cs +++ b/Projectiles/Rogue/ProfanedPartisanproj.cs @@ -1,16 +1,15 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Rogue { public class ProfanedPartisanproj : ModProjectile { - public int stealthStrikeTimer = 0; - public override void SetStaticDefaults() { DisplayName.SetDefault("Profaned Partisan"); @@ -64,9 +63,9 @@ namespace CalamityMod.Projectiles.Rogue drawOriginOffsetY = 2; } - if (Main.rand.Next(3) == 0) + if (Main.rand.NextBool(3)) { - int d = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, projectile.velocity.X, projectile.velocity.Y, 100, default(Color), 1.1f); + int d = Dust.NewDust(projectile.position, projectile.width, projectile.height, (int)CalamityDusts.ProfanedFire, projectile.velocity.X, projectile.velocity.Y, 100, default(Color), 1.1f); Main.dust[d].position = projectile.Center; Main.dust[d].velocity *= 0.3f; Main.dust[d].velocity += projectile.velocity * 0.85f; @@ -75,13 +74,11 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.Calamity().stealthStrike) //Stealth strike { - Vector2 spearposition = new Vector2(projectile.Center.X + Main.rand.NextFloat(-15f, 15f), projectile.Center.Y + Main.rand.NextFloat(-15f, 15f)); - Vector2 spearspeed = new Vector2(projectile.velocity.X, projectile.velocity.Y); - stealthStrikeTimer++; - if (stealthStrikeTimer >= 18) + Vector2 spearPosition = new Vector2(projectile.Center.X + Main.rand.NextFloat(-15f, 15f), projectile.Center.Y + Main.rand.NextFloat(-15f, 15f)); + Vector2 spearSpeed = projectile.velocity; + if (projectile.timeLeft % 18 == 0) { - Projectile.NewProjectile(spearposition, spearspeed, ModContent.ProjectileType(), projectile.damage/10, projectile.knockBack, projectile.owner, 0f, 0f); - stealthStrikeTimer = 0; + Projectile.NewProjectile(spearPosition, spearSpeed, ModContent.ProjectileType(), projectile.damage / 10, projectile.knockBack * 0.1f, projectile.owner); } } } @@ -90,11 +87,10 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i < 20; i++) { - Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 50, default(Color), 2.6f); + Dust.NewDust(projectile.position, projectile.width, projectile.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 50, default(Color), 2.6f); } Main.PlaySound(SoundID.Item45, projectile.position); - Vector2 explode = new Vector2(0f, 0f); - Projectile.NewProjectile(projectile.Center, explode, ModContent.ProjectileType(), projectile.damage/2, projectile.knockBack * 1.3f, projectile.owner); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/ProfanedPartisanspear.cs b/Projectiles/Rogue/ProfanedPartisanspear.cs index d69ca6b7e3..79c8b1d30d 100644 --- a/Projectiles/Rogue/ProfanedPartisanspear.cs +++ b/Projectiles/Rogue/ProfanedPartisanspear.cs @@ -53,32 +53,28 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - if (projectile.ai[1] != 1f) - { - projectile.velocity.X = -projectile.velocity.X; - projectile.velocity.Y = -projectile.velocity.Y; - projectile.ai[1] = 1f; - projectile.ai[0] = 1f; - projectile.extraUpdates = 2; - if (projectile.timeLeft > 280) - projectile.timeLeft = 280; - } + OnHitEffects(); } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 120); + OnHitEffects(); + } + + private void OnHitEffects() + { if (projectile.ai[1] != 1f) { - projectile.velocity.X = -projectile.velocity.X; - projectile.velocity.Y = -projectile.velocity.Y; + projectile.velocity.X *= -1f; + projectile.velocity.Y *= -1f; projectile.ai[1] = 1f; projectile.ai[0] = 1f; projectile.extraUpdates = 2; if (projectile.timeLeft > 280) projectile.timeLeft = 280; } - } + } public override void AI() { @@ -88,8 +84,6 @@ namespace CalamityMod.Projectiles.Rogue timer++; if (timer >= 5) projectile.penetrate = 1; - float pcx = projectile.Center.X; - float pcy = projectile.Center.Y; if (timer >= 10) { CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 800f, 7f, 20f); diff --git a/Projectiles/Rogue/SandDollarStealth.cs b/Projectiles/Rogue/SandDollarStealth.cs index d92e588b1d..4986c1cac4 100644 --- a/Projectiles/Rogue/SandDollarStealth.cs +++ b/Projectiles/Rogue/SandDollarStealth.cs @@ -28,44 +28,28 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { + OnHitEffects(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(); + } + + private void OnHitEffects() + { int coralAmt = Main.rand.Next(1, 4); if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) { for (int coralCount = 0; coralCount < coralAmt; coralCount++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int coral = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int coral = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner, 0f, 0f); Main.projectile[coral].Calamity().forceRogue = true; } } } - public override void OnHitPvp(Player target, int damage, bool crit) - { - int coralAmt = Main.rand.Next(1, 4); - if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) - { - for (int coralCount = 0; coralCount < coralAmt; coralCount++) - { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int coral = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner, 0f, 0f); - Main.projectile[coral].Calamity().forceRogue = true; - } - } - } - public override bool OnTileCollide(Vector2 oldVelocity) { projectile.ai[0] += 0.1f; diff --git a/Projectiles/Rogue/SeafoamBombProj.cs b/Projectiles/Rogue/SeafoamBombProj.cs index 7bfc7c6cab..f2b34c0c49 100644 --- a/Projectiles/Rogue/SeafoamBombProj.cs +++ b/Projectiles/Rogue/SeafoamBombProj.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.NewProjectile(posX, posY, 0f, 0f, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.4), 0f, projectile.owner, 0f, 0f); } - projectile.ExplosionGores((projectile.Calamity().stealthStrike ? 6 : 3)); + CalamityUtils.ExplosionGores(projectile.Center, (projectile.Calamity().stealthStrike ? 6 : 3)); } } } diff --git a/Projectiles/Rogue/ShatteredSunScorchedBlade.cs b/Projectiles/Rogue/ShatteredSunScorchedBlade.cs index 0493a92685..2120ecd134 100644 --- a/Projectiles/Rogue/ShatteredSunScorchedBlade.cs +++ b/Projectiles/Rogue/ShatteredSunScorchedBlade.cs @@ -62,10 +62,10 @@ namespace CalamityMod.Projectiles.Rogue int timesToSpawnDust = projectile.Calamity().stealthStrike ? 2 : 1; for (int i = 0; i < timesToSpawnDust; i++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 127, 0f, 0f, 100, default, projectile.Calamity().stealthStrike ? 1.8f : 1.3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 127, 0f, 0f, 100, default, projectile.Calamity().stealthStrike ? 1.8f : 1.3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 127, 0f, 0f, 100, default, projectile.Calamity().stealthStrike ? 1.8f : 1.3f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 127, 0f, 0f, 100, default, projectile.Calamity().stealthStrike ? 1.8f : 1.3f); Main.dust[num624].velocity *= 2f; } } @@ -191,7 +191,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); for (int num621 = 0; num621 < 4; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -201,14 +201,14 @@ namespace CalamityMod.Projectiles.Rogue } for (int num623 = 0; num623 < 12; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } } diff --git a/Projectiles/Rogue/StellarKnifeProj.cs b/Projectiles/Rogue/StellarKnifeProj.cs index 23ee2f5efa..6bc326dd0d 100644 --- a/Projectiles/Rogue/StellarKnifeProj.cs +++ b/Projectiles/Rogue/StellarKnifeProj.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.ai[0] == 1f) { projectile.ai[0] = 0f; - projectile.damage = (int)((double) projectile.damage * (projectile.ai[1] == 1f ? 0.9f : 0.75f)); + projectile.damage = (int)(projectile.damage * (projectile.ai[1] == 1f ? 0.9f : 0.75f)); projectile.ai[1] = 0f; } projectile.ai[1] += 0.75f; diff --git a/Projectiles/Rogue/StickyBol.cs b/Projectiles/Rogue/StickyBol.cs index b2a4316afa..e3a95f9cba 100644 --- a/Projectiles/Rogue/StickyBol.cs +++ b/Projectiles/Rogue/StickyBol.cs @@ -1,4 +1,5 @@ using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -27,74 +28,30 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - int Alpha = 175; - Color newColor = new Color(0, 80, (int) byte.MaxValue, 100); + Color color = new Color(0, 80, 255, 100); if (Main.rand.NextBool(12)) { - Vector2 vector2 = projectile.velocity * (float) Main.rand.Next(6) / 6f; - int num = 6; - Dust.NewDust(projectile.position + Vector2.One * 6f, projectile.width - num * 2, projectile.height - num * 2, 4, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, Alpha, newColor, 1.2f); + Dust.NewDust(projectile.position + Vector2.One * 6f, projectile.width - 12, projectile.height - 12, 4, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, 175, color, 1.2f); } //Sticky Behaviour projectile.StickyProjAI(10); if (projectile.ai[0] != 1f) { - try - { - int num223 = (int)(projectile.position.X / 16f) - 1; - int num224 = (int)((projectile.position.X + (float)projectile.width) / 16f) + 2; - int num225 = (int)(projectile.position.Y / 16f) - 1; - int num226 = (int)((projectile.position.Y + (float)projectile.height) / 16f) + 2; - if (num223 < 0) - { - num223 = 0; - } - if (num224 > Main.maxTilesX) - { - num224 = Main.maxTilesX; - } - if (num225 < 0) - { - num225 = 0; - } - if (num226 > Main.maxTilesY) - { - num226 = Main.maxTilesY; - } - for (int num227 = num223; num227 < num224; num227++) - { - for (int num228 = num225; num228 < num226; num228++) - { - if (Main.tile[num227, num228] != null && Main.tile[num227, num228].nactive() && (Main.tileSolid[(int)Main.tile[num227, num228].type] || (Main.tileSolidTop[(int)Main.tile[num227, num228].type] && Main.tile[num227, num228].frameY == 0))) - { - Vector2 vector19; - vector19.X = (float)(num227 * 16); - vector19.Y = (float)(num228 * 16); - if (projectile.position.X + (float)projectile.width - 4f > vector19.X && projectile.position.X + 4f < vector19.X + 16f && projectile.position.Y + (float)projectile.height - 4f > vector19.Y && projectile.position.Y + 4f < vector19.Y + 16f) - { - projectile.velocity.X = 0f; - projectile.velocity.Y = -0.2f; - } - } - } - } - } catch - { - } + projectile.StickToTiles(); projectile.localAI[1] += 1f; if (projectile.localAI[1] > 10f) { projectile.localAI[1] = 10f; if (projectile.velocity.Y == 0f && projectile.velocity.X != 0f) { - projectile.velocity.X = projectile.velocity.X * 0.97f; - if ((double)projectile.velocity.X > -0.01 && (double)projectile.velocity.X < 0.01) + projectile.velocity.X *= 0.97f; + if (Math.Abs(projectile.velocity.X) < 0.01f) { projectile.velocity.X = 0f; projectile.netUpdate = true; } } - projectile.velocity.Y = projectile.velocity.Y + 0.2f; + projectile.velocity.Y += 0.2f; } projectile.rotation += projectile.velocity.X * 0.1f; } diff --git a/Projectiles/Rogue/SupernovaBomb.cs b/Projectiles/Rogue/SupernovaBomb.cs index 8895f911ff..6d0552505d 100644 --- a/Projectiles/Rogue/SupernovaBomb.cs +++ b/Projectiles/Rogue/SupernovaBomb.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -50,14 +48,14 @@ namespace CalamityMod.Projectiles.Rogue projectile.ai[0] = 10f; if (projectile.velocity.Y == 0f && projectile.velocity.X != 0f) { - projectile.velocity.X = projectile.velocity.X * 0.97f; - if ((double)projectile.velocity.X > -0.01 && (double)projectile.velocity.X < 0.01) + projectile.velocity.X *= 0.97f; + if (Math.Abs(projectile.velocity.X) < 0.01f) { projectile.velocity.X = 0f; projectile.netUpdate = true; } } - projectile.velocity.Y = projectile.velocity.Y + 0.2f; + projectile.velocity.Y += 0.2f; } //rotation @@ -70,7 +68,7 @@ namespace CalamityMod.Projectiles.Rogue { if (projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0f, 2f, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.8), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0f, 2f, ModContent.ProjectileType(), (int)(projectile.damage * 0.8), projectile.knockBack, projectile.owner, 0f, 0f); } } } @@ -85,87 +83,64 @@ namespace CalamityMod.Projectiles.Rogue Main.PlaySound(SoundID.Item14, projectile.position); //spawn projectiles - int num251 = Main.rand.Next(3, 5); + int projAmt = Main.rand.Next(3, 5); if (projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - for (int num252 = 0; num252 < num251; num252++) + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + for (int i = 0; i < projAmt; i++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.6), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.6), 0f, projectile.owner, 0f, 0f); } - float spread = 60f * 0.0174f; + float spread = MathHelper.Pi / 3f; double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; double deltaAngle = spread / 6f; double offsetAngle; - int i; - for (i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 2f), (float)(Math.Cos(offsetAngle) * 2f), ModContent.ProjectileType(), (int)((double)projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 2f), (float)(-Math.Cos(offsetAngle) * 2f), ModContent.ProjectileType(), (int)((double)projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 2f), (float)(Math.Cos(offsetAngle) * 2f), ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 2f), (float)(-Math.Cos(offsetAngle) * 2f), ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); } } //dust effects - int num298 = Main.rand.NextBool(2) ? 107 : 234; + int dustType = Main.rand.NextBool(2) ? 107 : 234; if (Main.rand.NextBool(4)) { - num298 = 269; + dustType = 269; } - for (int num621 = 0; num621 < 5; num621++) + for (int d = 0; d < 5; d++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num298, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int exo = Dust.NewDust(projectile.position, projectile.width, projectile.height, dustType, 0f, 0f, 100, default, 2f); + Main.dust[exo].velocity *= 3f; if (Main.rand.NextBool(2)) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[exo].scale = 0.5f; + Main.dust[exo].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 9; num623++) + for (int d = 0; d < 9; d++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 3f); + Main.dust[fire].noGravity = true; + Main.dust[fire].velocity *= 5f; + fire = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 2f); + Main.dust[fire].velocity *= 2f; } //gore cloud effects - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/SupernovaBoom.cs b/Projectiles/Rogue/SupernovaBoom.cs index 6af43f0920..6cbb60b03d 100644 --- a/Projectiles/Rogue/SupernovaBoom.cs +++ b/Projectiles/Rogue/SupernovaBoom.cs @@ -3,8 +3,6 @@ using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; namespace CalamityMod.Projectiles.Rogue { public class SupernovaBoom : ModProjectile @@ -98,28 +96,12 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); } } } diff --git a/Projectiles/Rogue/SupernovaHoming.cs b/Projectiles/Rogue/SupernovaHoming.cs index 98c15fc61a..b1631a0873 100644 --- a/Projectiles/Rogue/SupernovaHoming.cs +++ b/Projectiles/Rogue/SupernovaHoming.cs @@ -2,8 +2,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Rogue { @@ -107,28 +105,12 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); } } } diff --git a/Projectiles/Rogue/SupernovaSpike.cs b/Projectiles/Rogue/SupernovaSpike.cs index 512e8781ab..e6d3859eb4 100644 --- a/Projectiles/Rogue/SupernovaSpike.cs +++ b/Projectiles/Rogue/SupernovaSpike.cs @@ -2,8 +2,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Rogue { @@ -63,28 +61,12 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); } public override void OnHitPvp(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); } internal static void Visuals(Projectile projectile, ref Color c) diff --git a/Projectiles/Rogue/TheSyringeProj.cs b/Projectiles/Rogue/TheSyringeProj.cs index 0db04433ed..1694cd1276 100644 --- a/Projectiles/Rogue/TheSyringeProj.cs +++ b/Projectiles/Rogue/TheSyringeProj.cs @@ -70,21 +70,15 @@ namespace CalamityMod.Projectiles.Rogue { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 89, projectile.oldVelocity.X, projectile.oldVelocity.Y); } - int num251 = Main.rand.Next(1, 3); + int fireAmt = Main.rand.Next(1, 3); if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < num251; num252++) + for (int f = 0; f < fireAmt; f++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, Main.myPlayer, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, Main.myPlayer, 0f, 0f); } - for (int index = 0; index < 2; ++index) + for (int s = 0; s < 2; ++s) { float SpeedX = -projectile.velocity.X * Main.rand.Next(40, 70) * 0.01f + Main.rand.Next(-20, 21) * 0.4f; float SpeedY = -projectile.velocity.Y * Main.rand.Next(40, 70) * 0.01f + Main.rand.Next(-20, 21) * 0.4f; @@ -93,12 +87,12 @@ namespace CalamityMod.Projectiles.Rogue } if (projectile.owner == Main.myPlayer && projectile.ai[1] == 1) { - for (int num639 = 0; num639 < 5; num639++) + for (int b = 0; b < 5; b++) { float speedX = (float)Main.rand.Next(-35, 36) * 0.02f; float speedY = (float)Main.rand.Next(-35, 36) * 0.02f; - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speedX, speedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, Main.myPlayer, 0f, 0f); - Main.projectile[proj].penetrate = 1; + int bee = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speedX, speedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, Main.myPlayer, 0f, 0f); + Main.projectile[bee].penetrate = 1; } } } diff --git a/Projectiles/Rogue/TotalityFlask.cs b/Projectiles/Rogue/TotalityFlask.cs index 6336f8aac1..c78562fb18 100644 --- a/Projectiles/Rogue/TotalityFlask.cs +++ b/Projectiles/Rogue/TotalityFlask.cs @@ -25,13 +25,13 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - if (projectile.Calamity().stealthStrike == true) + if (projectile.Calamity().stealthStrike) { if (projectile.timeLeft % 10 == 0) { if (projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0f, projectile.velocity.Y * 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.6), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.6), projectile.knockBack, projectile.owner, 0f, 0f); } } } @@ -62,35 +62,29 @@ namespace CalamityMod.Projectiles.Rogue Main.projectile[meltdown].Center = projectile.Center; //makes it centered because it's not without this Vector2 vector2 = new Vector2(20f, 20f); - for (int index = 0; index < 5; ++index) + for (int d = 0; d < 5; ++d) Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 191, 0.0f, 0.0f, 0, Color.Red, 1f); - for (int index1 = 0; index1 < 10; ++index1) + for (int d = 0; d < 10; ++d) { int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 31, 0.0f, 0.0f, 100, new Color(), 1.5f); Dust dust = Main.dust[index2]; dust.velocity *= 1.4f; } - for (int index1 = 0; index1 < 20; ++index1) + for (int d = 0; d < 20; ++d) { - int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 6, 0.0f, 0.0f, 100, new Color(), 2.5f); + int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 2.5f); Dust dust1 = Main.dust[index2]; dust1.noGravity = true; dust1.velocity *= 5f; - int index3 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 6, 0.0f, 0.0f, 100, new Color(), 1.5f); + int index3 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 1.5f); Dust dust2 = Main.dust[index3]; dust2.velocity *= 3f; } - int num251 = Main.rand.Next(2, 4); - for (int num252 = 0; num252 < num251; num252++) + int tarAmt = Main.rand.Next(2, 4); + for (int t = 0; t < tarAmt; t++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 0f, Main.myPlayer, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 0f, Main.myPlayer, 0f, 0f); } } } diff --git a/Projectiles/Rogue/TotalityTar.cs b/Projectiles/Rogue/TotalityTar.cs index 6ea14ec9df..6e6d7fa30d 100644 --- a/Projectiles/Rogue/TotalityTar.cs +++ b/Projectiles/Rogue/TotalityTar.cs @@ -1,4 +1,5 @@ using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -28,15 +29,15 @@ namespace CalamityMod.Projectiles.Rogue { if (projectile.velocity.X != projectile.velocity.X) { - projectile.velocity.X = projectile.velocity.X * -0.1f; + projectile.velocity.X *= -0.1f; } if (projectile.velocity.X != projectile.velocity.X) { - projectile.velocity.X = projectile.velocity.X * -0.5f; + projectile.velocity.X *= -0.5f; } if (projectile.velocity.Y != projectile.velocity.Y && projectile.velocity.Y > 1f) { - projectile.velocity.Y = projectile.velocity.Y * -0.5f; + projectile.velocity.Y *= -0.5f; } projectile.ai[0] += 1f; if (projectile.ai[0] > 5f) @@ -44,19 +45,19 @@ namespace CalamityMod.Projectiles.Rogue projectile.ai[0] = 5f; if (projectile.velocity.Y == 0f && projectile.velocity.X != 0f) { - projectile.velocity.X = projectile.velocity.X * 0.97f; - if ((double)projectile.velocity.X > -0.01 && (double)projectile.velocity.X < 0.01) + projectile.velocity.X *= 0.97f; + if (Math.Abs(projectile.velocity.X) < 0.01f) { projectile.velocity.X = 0f; projectile.netUpdate = true; } } - projectile.velocity.Y = projectile.velocity.Y + 0.2f; + projectile.velocity.Y += 0.2f; } projectile.rotation += projectile.velocity.X * 0.1f; - if ((double)projectile.velocity.Y < 0.25 && (double)projectile.velocity.Y > 0.15) + if (projectile.velocity.Y < 0.25f && projectile.velocity.Y > 0.15f) { - projectile.velocity.X = projectile.velocity.X * 0.8f; + projectile.velocity.X *= 0.8f; } projectile.rotation = -projectile.velocity.X * 0.05f; if (projectile.velocity.Y > 16f) @@ -90,31 +91,25 @@ namespace CalamityMod.Projectiles.Rogue { int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 31, 0.0f, 0.0f, 100, new Color(), 1.5f); Dust dust = Main.dust[index2]; - dust.velocity = dust.velocity * 1.4f; + dust.velocity *= 1.4f; } for (int index1 = 0; index1 < 10; ++index1) { - int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 6, 0.0f, 0.0f, 100, new Color(), 2.5f); - Main.dust[index2].noGravity = true; + int index2 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 2.5f); Dust dust1 = Main.dust[index2]; - dust1.velocity = dust1.velocity * 5f; - int index3 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 6, 0.0f, 0.0f, 100, new Color(), 1.5f); + dust1.noGravity = true; + dust1.velocity *= 5f; + int index3 = Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 1.5f); Dust dust2 = Main.dust[index3]; - dust2.velocity = dust2.velocity * 3f; + dust2.velocity *= 3f; } - int num251 = Main.rand.Next(2, 4); + int fireAmt = Main.rand.Next(2, 4); if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < num251; num252++) + for (int f = 0; f < fireAmt; f++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int fire = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), projectile.damage, 1f, Main.myPlayer, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage, 1f, Main.myPlayer, 0f, 0f); } } } diff --git a/Projectiles/Rogue/ToxicantTwisterTwoPointZero.cs b/Projectiles/Rogue/ToxicantTwisterTwoPointZero.cs index e49e7434ed..b7535085c7 100644 --- a/Projectiles/Rogue/ToxicantTwisterTwoPointZero.cs +++ b/Projectiles/Rogue/ToxicantTwisterTwoPointZero.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Projectiles.Rogue public class ToxicantTwisterTwoPointZero : ModProjectile { private int lifeTime = 300; + private int targetIndex = -1; public override void SetStaticDefaults() { @@ -23,10 +24,9 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 46; projectile.friendly = true; projectile.tileCollide = false; - projectile.penetrate = 5; + projectile.penetrate = -1; projectile.timeLeft = lifeTime; projectile.Calamity().rogue = true; - projectile.extraUpdates = 1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 12; } @@ -35,7 +35,7 @@ namespace CalamityMod.Projectiles.Rogue { if (projectile.Calamity().stealthStrike) { - if (projectile.timeLeft % 50f == 0f) + if (projectile.timeLeft % 20 == 0) { for (int i = 0; i < 2; i++) { @@ -57,10 +57,7 @@ namespace CalamityMod.Projectiles.Rogue Main.PlaySound(SoundID.Item7, projectile.position); } - // Returns after 2.5 seconds in the air - if (projectile.timeLeft < lifeTime - 150) - projectile.ai[0] = 1f; - + projectile.ai[1]++; if (projectile.ai[0] != 0f) { float returnSpeed = 30f; @@ -109,16 +106,41 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.Hitbox.Intersects(owner.Hitbox)) projectile.Kill(); } + else if (projectile.ai[1] > 40f) + { + NPC closestTarget = projectile.Center.ClosestNPCAt(1769f, true, true); + if (closestTarget != null) + { + projectile.extraUpdates = 1; + targetIndex = closestTarget.whoAmI; + float inertia = 20f; + float homingVelocity = projectile.Calamity().stealthStrike ? 30f : 20f; + Vector2 homeInVector = projectile.DirectionTo(closestTarget.Center); + if (homeInVector.HasNaNs()) + homeInVector = Vector2.UnitY; + + projectile.velocity = (projectile.velocity * inertia + homeInVector * homingVelocity) / (inertia + 1f); + } + } else { - CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 600f, 20f, 20f); + projectile.velocity *= 0.985f; } } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + if (projectile.ai[1] <= 40f && projectile.ai[0] != 1f) + { + damage /= 3; + } + } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.penetrate < 3) + if (targetIndex == target.whoAmI) projectile.ai[0] = 1f; + target.AddBuff(ModContent.BuffType(), 180); Main.PlaySound(SoundID.Item20, projectile.position); for (int k = 0; k < 10; k++) @@ -131,8 +153,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitPvp(Player target, int damage, bool crit) { - if (projectile.penetrate < 3) - projectile.ai[0] = 1f; + projectile.ai[0] = 1f; target.AddBuff(ModContent.BuffType(), 180); Main.PlaySound(SoundID.Item20, projectile.position); for (int k = 0; k < 10; k++) diff --git a/Projectiles/Rogue/TurbulanceProjectile.cs b/Projectiles/Rogue/TurbulanceProjectile.cs index 91a3065856..a4bf1741d7 100644 --- a/Projectiles/Rogue/TurbulanceProjectile.cs +++ b/Projectiles/Rogue/TurbulanceProjectile.cs @@ -9,8 +9,6 @@ namespace CalamityMod.Projectiles.Rogue { public class TurbulanceProjectile : ModProjectile { - public int stealthStrikeTimer = 0; - public override void SetStaticDefaults() { DisplayName.SetDefault("Turbulance"); @@ -20,10 +18,8 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { - projectile.width = 20; - projectile.height = 20; + projectile.width = projectile.height = 20; projectile.friendly = true; - projectile.penetrate = 1; projectile.timeLeft = 600; projectile.extraUpdates = 2; projectile.ignoreWater = true; @@ -33,37 +29,29 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - if (projectile.ai[0] < 0.2f) - { - projectile.ai[0] += 0.1f; - } - else - { - projectile.tileCollide = true; - } + projectile.ai[0]++; + projectile.tileCollide = projectile.ai[0] < 2f; - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 2.355f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(135f); if (projectile.spriteDirection == -1) { - projectile.rotation -= 1.57f; + projectile.rotation -= MathHelper.PiOver2; } - if (Main.rand.Next(5) == 0) + if (Main.rand.NextBool(5)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 187, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, 100, new Color(53, Main.DiscoG, 255)); } - if (Main.rand.Next(5) == 0) + if (Main.rand.NextBool(5)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 16, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } if (projectile.Calamity().stealthStrike) //Stealth strike { - stealthStrikeTimer++; - if (stealthStrikeTimer >= 14) + if (projectile.timeLeft % 14 == 0) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack / 2, projectile.owner, 1f, 1f); - stealthStrikeTimer = 0; + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack / 2, projectile.owner, 1f, 1f); } } } @@ -78,57 +66,30 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.owner == Main.myPlayer) - { - for (int num252 = 0; num252 < 4; num252++) - { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), projectile.damage / 3, projectile.knockBack / 3, Main.myPlayer, 0f, (crit ? 1f /*homing*/: 0f/*not homing*/)); - } - } + OnHitEffects(crit); } public override void OnHitPvp(Player target, int damage, bool crit) { - if (projectile.owner == Main.myPlayer) - { - for (int num252 = 0; num252 < 4; num252++) - { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), projectile.damage / 3, projectile.knockBack / 3, Main.myPlayer, 0f, (crit ? 1f /*homing*/: 0f/*not homing*/)); - } - } + OnHitEffects(crit); } public override bool OnTileCollide(Vector2 oldVelocity) { + OnHitEffects(false); + return true; + } + + private void OnHitEffects(bool homeIn) + { if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < 4; num252++) - { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), projectile.damage / 3, projectile.knockBack / 3, Main.myPlayer, 0f, 0f); - } + for (int w = 0; w < 4; w++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 3, projectile.knockBack / 3, Main.myPlayer, 0f, (homeIn ? 1f : 0f)); + } } - return true; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/ValariBoomerang.cs b/Projectiles/Rogue/ValariBoomerang.cs index c112d88487..4e0e029242 100644 --- a/Projectiles/Rogue/ValariBoomerang.cs +++ b/Projectiles/Rogue/ValariBoomerang.cs @@ -94,25 +94,25 @@ namespace CalamityMod.Projectiles.Rogue // Home back in on the player. if (projectile.velocity.X < xDist) { - projectile.velocity.X = projectile.velocity.X + acceleration; + projectile.velocity.X += acceleration; if (projectile.velocity.X < 0f && xDist > 0f) projectile.velocity.X += acceleration; } else if (projectile.velocity.X > xDist) { - projectile.velocity.X = projectile.velocity.X - acceleration; + projectile.velocity.X -= acceleration; if (projectile.velocity.X > 0f && xDist < 0f) projectile.velocity.X -= acceleration; } if (projectile.velocity.Y < yDist) { - projectile.velocity.Y = projectile.velocity.Y + acceleration; + projectile.velocity.Y += acceleration; if (projectile.velocity.Y < 0f && yDist > 0f) projectile.velocity.Y += acceleration; } else if (projectile.velocity.Y > yDist) { - projectile.velocity.Y = projectile.velocity.Y - acceleration; + projectile.velocity.Y -= acceleration; if (projectile.velocity.Y > 0f && yDist < 0f) projectile.velocity.Y -= acceleration; } @@ -125,27 +125,26 @@ namespace CalamityMod.Projectiles.Rogue } } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + private void OnHitEffects() { //Start homing at player if you hit an enemy projectile.ai[0] = 1; - int num251 = Main.rand.Next(2, 4); + int icicleAmt = Main.rand.Next(2, 4); if (projectile.owner == Main.myPlayer) { - for (int num252 = 0; num252 < num251; num252++) + for (int i = 0; i < icicleAmt; i++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int shard = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, (Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType()), projectile.damage / 3, 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int shard = Projectile.NewProjectile(projectile.Center, velocity, (Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType()), projectile.damage / 3, 0f, projectile.owner, 0f, 0f); } } + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + OnHitEffects(); target.AddBuff(BuffID.Frostburn, 240); target.AddBuff(ModContent.BuffType(), 240); if (Main.rand.NextBool(5)) @@ -154,25 +153,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitPvp(Player target, int damage, bool crit) { - //Start homing at player if you hit someone - projectile.ai[0] = 1; - - int num251 = Main.rand.Next(2, 4); - if (projectile.owner == Main.myPlayer) - { - for (int num252 = 0; num252 < num251; num252++) - { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int shard = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, (Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType()), projectile.damage / 3, 0f, projectile.owner, 0f, 0f); - } - } - + OnHitEffects(); target.AddBuff(BuffID.Frostburn, 240); target.AddBuff(ModContent.BuffType(), 240); if (Main.rand.NextBool(5)) diff --git a/Projectiles/Rogue/ValedictionBoomerang.cs b/Projectiles/Rogue/ValedictionBoomerang.cs index 1e2e86dba7..c4d6044ff8 100644 --- a/Projectiles/Rogue/ValedictionBoomerang.cs +++ b/Projectiles/Rogue/ValedictionBoomerang.cs @@ -9,191 +9,172 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class ValedictionBoomerang : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Scythe"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + public class ValedictionBoomerang : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Valediction"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } - public override void SetDefaults() - { - projectile.width = 70; - projectile.height = 70; - projectile.friendly = true; - projectile.tileCollide = false; - projectile.penetrate = -1; - projectile.extraUpdates = 3; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 15; - projectile.Calamity().rogue = true; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 70; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.extraUpdates = 3; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 15; + projectile.Calamity().rogue = true; + } - public override void AI() - { + public override void AI() + { Player player = Main.player[projectile.owner]; - if (projectile.soundDelay == 0) - { - projectile.soundDelay = 8; - Main.PlaySound(SoundID.Item7, projectile.position); - } - if (projectile.ai[0] == 0f) - { - projectile.ai[1] += 1f; - if (projectile.ai[1] >= 60f) - { - projectile.ai[0] = 1f; - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - else - { + if (projectile.soundDelay == 0) + { + projectile.soundDelay = 8; + Main.PlaySound(SoundID.Item7, projectile.position); + } + if (projectile.ai[0] == 0f) + { + projectile.ai[1] += 1f; + if (projectile.ai[1] >= 60f) + { + projectile.ai[0] = 1f; + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } + else + { CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 400f, 20f, 20f); - } - } - else - { - float returnSpeed = 30f; - float num43 = 5f; - Vector2 projPos = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float xDist = player.position.X + (float)(player.width / 2) - projPos.X; - float yDist = player.position.Y + (float)(player.height / 2) - projPos.Y; - float playerDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); - if (playerDist > 3000f) - { - projectile.Kill(); - } - playerDist = returnSpeed / playerDist; - xDist *= playerDist; - yDist *= playerDist; - if (projectile.velocity.X < xDist) - { - projectile.velocity.X = projectile.velocity.X + num43; - if (projectile.velocity.X < 0f && xDist > 0f) - { - projectile.velocity.X = projectile.velocity.X + num43; - } - } - else if (projectile.velocity.X > xDist) - { - projectile.velocity.X = projectile.velocity.X - num43; - if (projectile.velocity.X > 0f && xDist < 0f) - { - projectile.velocity.X = projectile.velocity.X - num43; - } - } - if (projectile.velocity.Y < yDist) - { - projectile.velocity.Y = projectile.velocity.Y + num43; - if (projectile.velocity.Y < 0f && yDist > 0f) - { - projectile.velocity.Y = projectile.velocity.Y + num43; - } - } - else if (projectile.velocity.Y > yDist) - { - projectile.velocity.Y = projectile.velocity.Y - num43; - if (projectile.velocity.Y > 0f && yDist < 0f) - { - projectile.velocity.Y = projectile.velocity.Y - num43; - } - } - if (Main.myPlayer == projectile.owner) - { - Rectangle projHitbox = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); - Rectangle playerHitbox = new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height); - if (projHitbox.Intersects(playerHitbox)) - { - projectile.Kill(); - } - } - } - projectile.rotation += 0.5f; - } + } + } + else + { + float returnSpeed = 30f; + float acceleration = 5f; + Vector2 projVector = player.Center - projectile.Center; + float playerDist = projVector.Length(); + if (playerDist > 3000f) + { + projectile.Kill(); + } + playerDist = returnSpeed / playerDist; + projVector.X *= playerDist; + projVector.Y *= playerDist; + if (projectile.velocity.X < projVector.X) + { + projectile.velocity.X += acceleration; + if (projectile.velocity.X < 0f && projVector.X > 0f) + { + projectile.velocity.X += acceleration; + } + } + else if (projectile.velocity.X > projVector.X) + { + projectile.velocity.X -= acceleration; + if (projectile.velocity.X > 0f && projVector.X < 0f) + { + projectile.velocity.X -= acceleration; + } + } + if (projectile.velocity.Y < projVector.Y) + { + projectile.velocity.Y += acceleration; + if (projectile.velocity.Y < 0f && projVector.Y > 0f) + { + projectile.velocity.Y += acceleration; + } + } + else if (projectile.velocity.Y > projVector.Y) + { + projectile.velocity.Y -= acceleration; + if (projectile.velocity.Y > 0f && projVector.Y < 0f) + { + projectile.velocity.Y -= acceleration; + } + } + if (Main.myPlayer == projectile.owner) + { + Rectangle projHitbox = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height); + Rectangle playerHitbox = new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height); + if (projHitbox.Intersects(playerHitbox)) + { + projectile.Kill(); + } + } + } + projectile.rotation += 0.5f; + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 600); + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 600); + OnHitEffects(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 600); + OnHitEffects(); + } + + private void OnHitEffects() + { int typhoonAmt = 3; if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) { - Main.PlaySound(SoundID.Item84, projectile.position); - for (int typhoonCount = 0; typhoonCount < typhoonAmt; typhoonCount++) + Main.PlaySound(SoundID.Item84, projectile.position); + for (int typhoonCount = 0; typhoonCount < typhoonAmt; typhoonCount++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) + Vector2 velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + while (velocity.X == 0f && velocity.Y == 0f) { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int typhoon = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner, 0f, 0f); - Main.projectile[typhoon].Calamity().forceRogue = true; - Main.projectile[typhoon].usesLocalNPCImmunity = true; - Main.projectile[typhoon].localNPCHitCooldown = 10; + velocity.Normalize(); + velocity *= (float)Main.rand.Next(70, 101) * 0.1f; + Projectile typhoon = Projectile.NewProjectileDirect(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner); + typhoon.Calamity().forceRogue = true; + typhoon.usesLocalNPCImmunity = true; + typhoon.localNPCHitCooldown = 10; } } - } + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 600); - int typhoonAmt = 3; - if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item21, projectile.position); + projectile.position = projectile.Center; + projectile.width = projectile.height = 100; + projectile.Center = projectile.position; + for (int d = 0; d < 5; d++) { - Main.PlaySound(SoundID.Item84, projectile.position); - for (int typhoonCount = 0; typhoonCount < typhoonAmt; typhoonCount++) + int water = Dust.NewDust(projectile.position, projectile.width, projectile.height, 33, 0f, 0f, 100, default, 2f); + Main.dust[water].velocity *= 3f; + if (Main.rand.NextBool(2)) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int typhoon = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner, 0f, 1f); - Main.projectile[typhoon].Calamity().forceRogue = true; - Main.projectile[typhoon].usesLocalNPCImmunity = true; - Main.projectile[typhoon].localNPCHitCooldown = 10; + Main.dust[water].scale = 0.5f; + Main.dust[water].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - } - - public override void Kill(int timeLeft) - { - Main.PlaySound(SoundID.Item21, projectile.position); - projectile.position.X = projectile.position.X + (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); - projectile.width = 100; - projectile.height = 100; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - for (int num621 = 0; num621 < 5; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 8; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 33, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } + for (int d = 0; d < 8; d++) + { + int water = Dust.NewDust(projectile.position, projectile.width, projectile.height, 33, 0f, 0f, 100, default, 3f); + Main.dust[water].noGravity = true; + Main.dust[water].velocity *= 5f; + water = Dust.NewDust(projectile.position, projectile.width, projectile.height, 33, 0f, 0f, 100, default, 2f); + Main.dust[water].velocity *= 2f; + } + } + } } diff --git a/Projectiles/Summon/ApexShark.cs b/Projectiles/Summon/ApexShark.cs index 3a062aa18b..d42ac52fac 100644 --- a/Projectiles/Summon/ApexShark.cs +++ b/Projectiles/Summon/ApexShark.cs @@ -133,7 +133,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag25) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { diff --git a/Projectiles/Summon/AstralProbeRound.cs b/Projectiles/Summon/AstralProbeRound.cs index 85e23d5049..09f08b9890 100644 --- a/Projectiles/Summon/AstralProbeRound.cs +++ b/Projectiles/Summon/AstralProbeRound.cs @@ -35,22 +35,18 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { Lighting.AddLight(projectile.Center, 0.3f, 0.5f, 0.1f); - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; if (Main.rand.NextBool(3)) { - int randomDust = Main.rand.Next(2); - if (randomDust == 0) - { - randomDust = ModContent.DustType(); - } - else - { - randomDust = ModContent.DustType(); - } - int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, randomDust, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].alpha = projectile.alpha; - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; + int randomDust = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.DustType(), + ModContent.DustType() + }); + int astral = Dust.NewDust(projectile.position, 1, 1, randomDust, 0f, 0f, 0, default, 0.5f); + Main.dust[astral].alpha = projectile.alpha; + Main.dust[astral].velocity *= 0f; + Main.dust[astral].noGravity = true; } float num472 = projectile.Center.X; float num473 = projectile.Center.Y; @@ -61,9 +57,9 @@ namespace CalamityMod.Projectiles.Summon NPC npc = Main.npc[Main.player[projectile.owner].MinionAttackTargetNPC]; if (npc.CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1)) { - float num476 = npc.position.X + (float)(npc.width / 2); - float num477 = npc.position.Y + (float)(npc.height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); + float num476 = npc.Center.X; + float num477 = npc.Center.Y; + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); if (num478 < num474) { num474 = num478; @@ -73,7 +69,24 @@ namespace CalamityMod.Projectiles.Summon } } } - else + else if (projectile.ai[0] != -1f && Main.npc[(int)projectile.ai[0]].active) + { + NPC npc = Main.npc[(int)projectile.ai[0]]; + if (npc.CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1)) + { + float num476 = npc.Center.X; + float num477 = npc.Center.Y; + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); + if (num478 < num474) + { + num474 = num478; + num472 = num476; + num473 = num477; + flag17 = true; + } + } + } + if (!flag17) { for (int target = 0; target < Main.npc.Length; target++) { diff --git a/Projectiles/Summon/AstralProbeSummon.cs b/Projectiles/Summon/AstralProbeSummon.cs index dcc163d511..1dc3e65293 100644 --- a/Projectiles/Summon/AstralProbeSummon.cs +++ b/Projectiles/Summon/AstralProbeSummon.cs @@ -79,6 +79,7 @@ namespace CalamityMod.Projectiles.Summon float range = 1000f; Vector2 targetVec = projectile.position; bool foundTarget = false; + int targetIndex = -1; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; @@ -89,10 +90,11 @@ namespace CalamityMod.Projectiles.Summon { targetVec = npc.Center; foundTarget = true; + targetIndex = npc.whoAmI; } } } - else + if (!foundTarget) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { @@ -104,6 +106,7 @@ namespace CalamityMod.Projectiles.Summon { targetVec = npc.Center; foundTarget = true; + targetIndex = num645; } } } @@ -147,7 +150,7 @@ namespace CalamityMod.Projectiles.Summon Vector2 velocity = targetVec - projectile.Center; velocity.Normalize(); velocity *= speedMult; - Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, 0f, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, 0f, projectile.owner, targetIndex, 0f); projectile.netUpdate = true; } } diff --git a/Projectiles/Summon/AureusBomber.cs b/Projectiles/Summon/AureusBomber.cs index a4be169099..1347dfcbc3 100644 --- a/Projectiles/Summon/AureusBomber.cs +++ b/Projectiles/Summon/AureusBomber.cs @@ -82,7 +82,7 @@ namespace CalamityMod.Projectiles.Summon float idleDistance = vectorToIdlePosition.Length(); //dust effects - if (Main.rand.Next(10) == 0) + if (Main.rand.NextBool(10)) { int index = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, dustType, 0.0f, 0.0f, 100, Color.Transparent, 2f); Main.dust[index].velocity *= 0.3f; diff --git a/Projectiles/Summon/BabyPlaguebringer.cs b/Projectiles/Summon/BabyPlaguebringer.cs index 8355493836..24154ac42b 100644 --- a/Projectiles/Summon/BabyPlaguebringer.cs +++ b/Projectiles/Summon/BabyPlaguebringer.cs @@ -101,7 +101,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag25) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { diff --git a/Projectiles/Summon/BlackHawkSummon.cs b/Projectiles/Summon/BlackHawkSummon.cs index 40336956f6..b507f288dd 100644 --- a/Projectiles/Summon/BlackHawkSummon.cs +++ b/Projectiles/Summon/BlackHawkSummon.cs @@ -122,7 +122,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!foundTarget) { for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) { diff --git a/Projectiles/Summon/BloodClotMinion.cs b/Projectiles/Summon/BloodClotMinion.cs index 982d7bd55b..122ab949fa 100644 --- a/Projectiles/Summon/BloodClotMinion.cs +++ b/Projectiles/Summon/BloodClotMinion.cs @@ -121,7 +121,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag19) { for (int num542 = 0; num542 < Main.maxNPCs; num542++) { diff --git a/Projectiles/Summon/BrimstoneElementalMinion.cs b/Projectiles/Summon/BrimstoneElementalMinion.cs index 72b6832176..258574dd22 100644 --- a/Projectiles/Summon/BrimstoneElementalMinion.cs +++ b/Projectiles/Summon/BrimstoneElementalMinion.cs @@ -96,7 +96,7 @@ namespace CalamityMod.Projectiles.Summon float num = (float)Main.rand.Next(90, 111) * 0.01f; num *= Main.essScale; Lighting.AddLight(projectile.Center, 1.25f * num, 0f * num, 0.5f * num); - if ((double)Math.Abs(projectile.velocity.X) > 0.2) + if (Math.Abs(projectile.velocity.X) > 0.2f) { projectile.spriteDirection = -projectile.direction; } @@ -126,7 +126,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag25) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { diff --git a/Projectiles/Summon/CalamariInk.cs b/Projectiles/Summon/CalamariInk.cs index c0c366f779..5ee1bbd833 100644 --- a/Projectiles/Summon/CalamariInk.cs +++ b/Projectiles/Summon/CalamariInk.cs @@ -60,12 +60,26 @@ namespace CalamityMod.Projectiles.Summon } } } - else + else if (Main.npc[(int)projectile.ai[0]].active && projectile.ai[0] != -1f) + { + NPC npc = Main.npc[(int)projectile.ai[0]]; + if (npc.CanBeChasedBy(projectile, false)) + { + float dist = (projectile.Center - npc.Center).Length(); + if (dist < maxHomingRange) + { + targetIdx = (int)projectile.ai[0]; + maxHomingRange = dist; + hasHomingTarget = true; + } + } + } + if (!hasHomingTarget) { for (int i = 0; i < Main.npc.Length; ++i) { NPC npc = Main.npc[i]; - if (npc == null || !npc.active) + if (npc is null || !npc.active) continue; if (npc.CanBeChasedBy(projectile, false)) diff --git a/Projectiles/Summon/CalamariMinion.cs b/Projectiles/Summon/CalamariMinion.cs index e7d201fed8..1dc958cacf 100644 --- a/Projectiles/Summon/CalamariMinion.cs +++ b/Projectiles/Summon/CalamariMinion.cs @@ -141,6 +141,7 @@ namespace CalamityMod.Projectiles.Summon Vector2 center = Main.player[projectile.owner].Center; Vector2 value = new Vector2(0.5f); value.Y = 0f; + int targetIndex = -1; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; @@ -152,11 +153,11 @@ namespace CalamityMod.Projectiles.Summon { vector = vector2; flag = true; - int num11 = npc.whoAmI; + targetIndex = npc.whoAmI; } } } - else + if (!flag) { for (int k = 0; k < Main.maxNPCs; k++) { @@ -170,6 +171,7 @@ namespace CalamityMod.Projectiles.Summon num10 = num13; vector = vector3; flag = true; + targetIndex = k; } } } @@ -321,7 +323,7 @@ namespace CalamityMod.Projectiles.Summon Vector2 vector7 = vector - projectile.Center; vector7.Normalize(); vector7 *= scaleFactor4; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y + 20, vector7.X, vector7.Y, num28, projectile.damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y + 20, vector7.X, vector7.Y, num28, projectile.damage, 0f, Main.myPlayer, targetIndex, 0f); projectile.netUpdate = true; } } diff --git a/Projectiles/Summon/Calamitamini.cs b/Projectiles/Summon/Calamitamini.cs index e4b66fa0da..cf84bd6ab6 100644 --- a/Projectiles/Summon/Calamitamini.cs +++ b/Projectiles/Summon/Calamitamini.cs @@ -114,7 +114,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag25) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { diff --git a/Projectiles/Summon/Cataclymini.cs b/Projectiles/Summon/Cataclymini.cs index d2a9fcd293..dd725c2304 100644 --- a/Projectiles/Summon/Cataclymini.cs +++ b/Projectiles/Summon/Cataclymini.cs @@ -108,7 +108,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag25) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { diff --git a/Projectiles/Summon/ChaosSpirit.cs b/Projectiles/Summon/ChaosSpirit.cs index d166103b26..3f611ea370 100644 --- a/Projectiles/Summon/ChaosSpirit.cs +++ b/Projectiles/Summon/ChaosSpirit.cs @@ -129,7 +129,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!foundTarget) { for (int k = 0; k < Main.maxNPCs; k++) { diff --git a/Projectiles/Summon/CinderBlossom.cs b/Projectiles/Summon/CinderBlossom.cs index 07467a2734..26a9de3aab 100644 --- a/Projectiles/Summon/CinderBlossom.cs +++ b/Projectiles/Summon/CinderBlossom.cs @@ -47,10 +47,10 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - projectile.Center = Main.player[projectile.owner].Center + Vector2.UnitY * (Main.player[projectile.owner].gfxOffY - 60f); - if (Main.player[projectile.owner].gravDir == -1f) + projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); + if (player.gravDir == -1f) { - projectile.position.Y += 140f; + projectile.position.Y += 120f; } projectile.position.X = (int)projectile.position.X; projectile.position.Y = (int)projectile.position.Y; diff --git a/Projectiles/Summon/CloudElementalMinion.cs b/Projectiles/Summon/CloudElementalMinion.cs index 757990b8bf..28ae075ac1 100644 --- a/Projectiles/Summon/CloudElementalMinion.cs +++ b/Projectiles/Summon/CloudElementalMinion.cs @@ -101,7 +101,7 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; } - projectile.ChargingMinionAI(500f, 800f, 1200f, 400f, 0, 30f, 8f, -4f, 40f, 8f, false, true); + projectile.ChargingMinionAI(500f, 800f, 1200f, 400f, 0, 30f, 8f, -4f, 40f, 8f, false, true, 1); } } } diff --git a/Projectiles/Summon/CosmicBlast.cs b/Projectiles/Summon/CosmicBlast.cs index ed589327a3..d648e78b7d 100644 --- a/Projectiles/Summon/CosmicBlast.cs +++ b/Projectiles/Summon/CosmicBlast.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -32,7 +30,8 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; + Player player = Main.player[projectile.owner]; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; projectile.frameCounter++; if (projectile.frameCounter > 4) { @@ -56,11 +55,27 @@ namespace CalamityMod.Projectiles.Summon float num474 = 1200f; bool flag17 = false; int target = (int)projectile.ai[0]; - if (Main.npc[target].CanBeChasedBy(projectile, false)) + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + float num476 = npc.position.X + (float)(npc.width / 2); + float num477 = npc.position.Y + (float)(npc.height / 2); + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); + if (num478 < num474) + { + num472 = num476; + num473 = num477; + flag17 = true; + } + } + } + else if (Main.npc[target].CanBeChasedBy(projectile, false)) { float num476 = Main.npc[target].position.X + (float)(Main.npc[target].width / 2); float num477 = Main.npc[target].position.Y + (float)(Main.npc[target].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); if (num478 < num474) { num472 = num476; @@ -68,6 +83,28 @@ namespace CalamityMod.Projectiles.Summon flag17 = true; } } + if (!flag17) + { + for (int i = 0; i < Main.maxNPCs; ++i) + { + NPC npc = Main.npc[i]; + if (npc is null || !npc.active) + continue; + + if (npc.CanBeChasedBy(projectile, false)) + { + float num476 = npc.position.X + (float)(npc.width / 2); + float num477 = npc.position.Y + (float)(npc.height / 2); + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); + if (num478 < num474) + { + num472 = num476; + num473 = num477; + flag17 = true; + } + } + } + } if (flag17) { float num483 = 40f; @@ -90,15 +127,12 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Summon/CosmicBlastBig.cs b/Projectiles/Summon/CosmicBlastBig.cs index fb140b945c..48f0203e43 100644 --- a/Projectiles/Summon/CosmicBlastBig.cs +++ b/Projectiles/Summon/CosmicBlastBig.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using System; using Terraria; @@ -30,6 +28,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { + Player player = Main.player[projectile.owner]; if (projectile.soundDelay == 0) { projectile.soundDelay = 20 + Main.rand.Next(40); @@ -70,11 +69,27 @@ namespace CalamityMod.Projectiles.Summon float num474 = 600f; bool flag17 = false; int target = (int)projectile.ai[0]; - if (Main.npc[target].CanBeChasedBy(projectile, false)) + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + float num476 = npc.position.X + (float)(npc.width / 2); + float num477 = npc.position.Y + (float)(npc.height / 2); + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); + if (num478 < num474) + { + num472 = num476; + num473 = num477; + flag17 = true; + } + } + } + else if (Main.npc[target].CanBeChasedBy(projectile, false)) { float num476 = Main.npc[target].position.X + (float)(Main.npc[target].width / 2); float num477 = Main.npc[target].position.Y + (float)(Main.npc[target].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); if (num478 < num474) { num472 = num476; @@ -82,6 +97,28 @@ namespace CalamityMod.Projectiles.Summon flag17 = true; } } + if (!flag17) + { + for (int i = 0; i < Main.maxNPCs; ++i) + { + NPC npc = Main.npc[i]; + if (npc is null || !npc.active) + continue; + + if (npc.CanBeChasedBy(projectile, false)) + { + float num476 = npc.position.X + (float)(npc.width / 2); + float num477 = npc.position.Y + (float)(npc.height / 2); + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); + if (num478 < num474) + { + num472 = num476; + num473 = num477; + flag17 = true; + } + } + } + } if (flag17) { float num483 = 45f; @@ -104,15 +141,12 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(BuffID.CursedInferno, 120); - target.AddBuff(BuffID.Frostburn, 120); - target.AddBuff(BuffID.OnFire, 120); - target.AddBuff(BuffID.Ichor, 120); + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); } public override void Kill(int timeLeft) diff --git a/Projectiles/Summon/CosmicEnergySpiral.cs b/Projectiles/Summon/CosmicEnergySpiral.cs index 86851d8c8e..3ee918c8bb 100644 --- a/Projectiles/Summon/CosmicEnergySpiral.cs +++ b/Projectiles/Summon/CosmicEnergySpiral.cs @@ -214,24 +214,17 @@ namespace CalamityMod.Projectiles.Summon if (flag11) { Main.PlaySound(SoundID.Item105, (int)projectile.position.X, (int)projectile.position.Y); - int num251 = Main.rand.Next(5, 8); - for (int num252 = 0; num252 < num251; num252++) + int blastAmt = Main.rand.Next(5, 8); + for (int b = 0; b < blastAmt; b++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 2f, projectile.owner, (float)target, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 2f, projectile.owner, (float)target, 0f); } - float num403 = 15f; - Vector2 vector29 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num404 = num396 - vector29.X; - float num405 = num397 - vector29.Y; + float speed = 15f; + float num404 = num396 - projectile.Center.X; + float num405 = num397 - projectile.Center.Y; float num406 = (float)Math.Sqrt((double)(num404 * num404 + num405 * num405)); - num406 = num403 / num406; + num406 = speed / num406; num404 *= num406; num405 *= num406; Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, num404, num405, ModContent.ProjectileType(), projectile.damage, 3f, projectile.owner, (float)target, 0f); diff --git a/Projectiles/Summon/CosmicViperHomingRocket.cs b/Projectiles/Summon/CosmicViperHomingRocket.cs index 0c7f58939b..31c43114e3 100644 --- a/Projectiles/Summon/CosmicViperHomingRocket.cs +++ b/Projectiles/Summon/CosmicViperHomingRocket.cs @@ -71,7 +71,21 @@ namespace CalamityMod.Projectiles.Summon } } } - else + else if (Main.npc[(int)projectile.ai[0]].active && projectile.ai[0] != -1f) + { + NPC npc = Main.npc[(int)projectile.ai[0]]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(npc.width / 2) + (float)(npc.height / 2); + + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + center = npc.Center; + homeIn = true; + } + } + } + if (!homeIn) { for (int i = 0; i < Main.maxNPCs; i++) { diff --git a/Projectiles/Summon/CosmicViperSplittingRocket.cs b/Projectiles/Summon/CosmicViperSplittingRocket.cs index c02d45b6e2..96eb17d447 100644 --- a/Projectiles/Summon/CosmicViperSplittingRocket.cs +++ b/Projectiles/Summon/CosmicViperSplittingRocket.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.Summon } speed.Normalize(); speed *= (float)Main.rand.Next(30, 61) * 0.1f * 2f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.25), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack, projectile.owner, 0f, 0f); } } Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); @@ -76,7 +76,42 @@ namespace CalamityMod.Projectiles.Summon } } } - else + else if (Main.npc[(int)projectile.ai[0]].active && projectile.ai[0] != -1f) + { + NPC npc = Main.npc[(int)projectile.ai[0]]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(npc.width / 2) + (float)(npc.height / 2); + + if (Vector2.Distance(npc.Center, projectile.Center) < (explode + extraDistance)) + { + int numProj = 4; + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < numProj; i++) + { + Vector2 speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); + while (speed.X == 0f && speed.Y == 0f) + { + speed = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); + } + speed.Normalize(); + speed *= (float)Main.rand.Next(30, 61) * 0.1f * 2f; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack, projectile.owner, 0f, 0f); + } + } + Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); + projectile.Kill(); + return; + } + else if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + center = npc.Center; + homeIn = true; + } + } + } + if (!homeIn) { for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) { diff --git a/Projectiles/Summon/CosmicViperSummon.cs b/Projectiles/Summon/CosmicViperSummon.cs index 48d29995ab..460e7dadfc 100644 --- a/Projectiles/Summon/CosmicViperSummon.cs +++ b/Projectiles/Summon/CosmicViperSummon.cs @@ -97,6 +97,7 @@ namespace CalamityMod.Projectiles.Summon float detectRange = 700f; Vector2 targetVec = projectile.position; bool foundTarget = false; + int targetIndex = -1; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; @@ -108,10 +109,11 @@ namespace CalamityMod.Projectiles.Summon detectRange = targetDist; targetVec = npc.Center; foundTarget = true; + targetIndex = npc.whoAmI; } } } - else + if (!foundTarget) { for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) { @@ -124,6 +126,7 @@ namespace CalamityMod.Projectiles.Summon detectRange = targetDist; targetVec = npc.Center; foundTarget = true; + targetIndex = npcIndex; } } } @@ -261,7 +264,7 @@ namespace CalamityMod.Projectiles.Summon velocity.Y += Main.rand.NextFloat(-30f, 30f) * 0.05f; velocity.X += Main.rand.NextFloat(-30f, 30f) * 0.05f; - Projectile.NewProjectile(projectile.Center, velocity, projType, (int)(projectile.damage * dmgMult), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, velocity, projType, (int)(projectile.damage * dmgMult), projectile.knockBack, projectile.owner, targetIndex, 0f); projectile.netUpdate = true; } } diff --git a/Projectiles/Summon/CosmilampMinion.cs b/Projectiles/Summon/CosmilampMinion.cs index 17203f10dc..acc142b16c 100644 --- a/Projectiles/Summon/CosmilampMinion.cs +++ b/Projectiles/Summon/CosmilampMinion.cs @@ -115,7 +115,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag19) { for (int num542 = 0; num542 < Main.maxNPCs; num542++) { diff --git a/Projectiles/Summon/DaedalusCrystal.cs b/Projectiles/Summon/DaedalusCrystal.cs index fe02d3ce27..7bd5688e0c 100644 --- a/Projectiles/Summon/DaedalusCrystal.cs +++ b/Projectiles/Summon/DaedalusCrystal.cs @@ -75,19 +75,18 @@ namespace CalamityMod.Projectiles.Summon projectile.damage = damage2; } Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.35f / 255f, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.75f / 255f); - projectile.position.X = Main.player[projectile.owner].Center.X - (float)(projectile.width / 2); - projectile.position.Y = Main.player[projectile.owner].Center.Y - (float)(projectile.height / 2) + Main.player[projectile.owner].gfxOffY - 60f; - if (Main.player[projectile.owner].gravDir == -1f) + projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); + if (player.gravDir == -1f) { - projectile.position.Y = projectile.position.Y + 120f; - projectile.rotation = 3.14f; + projectile.position.Y += 120f; + projectile.rotation = MathHelper.Pi; } else { projectile.rotation = 0f; } - projectile.position.X = (float)(int)projectile.position.X; - projectile.position.Y = (float)(int)projectile.position.Y; + projectile.position.X = (int)projectile.position.X; + projectile.position.Y = (int)projectile.position.Y; float num395 = (float)Main.mouseTextColor / 200f - 0.35f; num395 *= 0.2f; projectile.scale = num395 + 0.95f; @@ -118,7 +117,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag18) { for (int num512 = 0; num512 < Main.maxNPCs; num512++) { diff --git a/Projectiles/Summon/DankCreeperMinion.cs b/Projectiles/Summon/DankCreeperMinion.cs index 0b171bea53..e90f537e7e 100644 --- a/Projectiles/Summon/DankCreeperMinion.cs +++ b/Projectiles/Summon/DankCreeperMinion.cs @@ -107,7 +107,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag19) { for (int num542 = 0; num542 < Main.maxNPCs; num542++) { diff --git a/Projectiles/Summon/Dreadmine.cs b/Projectiles/Summon/Dreadmine.cs index dcc5001ecc..3f1566d0e4 100644 --- a/Projectiles/Summon/Dreadmine.cs +++ b/Projectiles/Summon/Dreadmine.cs @@ -140,7 +140,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag49) { for (int num949 = 0; num949 < Main.npc.Length; num949++) { @@ -186,7 +186,7 @@ namespace CalamityMod.Projectiles.Summon Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); for (int num621 = 0; num621 < 20; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -196,13 +196,13 @@ namespace CalamityMod.Projectiles.Summon } for (int num623 = 0; num623 < 30; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } } diff --git a/Projectiles/Summon/DreadmineTurret.cs b/Projectiles/Summon/DreadmineTurret.cs index eac916c79e..efe4bb76c8 100644 --- a/Projectiles/Summon/DreadmineTurret.cs +++ b/Projectiles/Summon/DreadmineTurret.cs @@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Summon if (Main.rand.NextBool(15)) { int num = 0; - for (int i = 0; i < Main.projectile.Length; i++) + for (int i = 0; i < Main.maxProjectiles; i++) { if (Main.projectile[i].active && Main.projectile[i].owner == Main.myPlayer && Main.projectile[i].type == ModContent.ProjectileType()) { @@ -108,7 +108,7 @@ namespace CalamityMod.Projectiles.Summon } if (flag) { - for (int k = 0; k < 1000; k++) + for (int k = 0; k < Main.maxProjectiles; k++) { if (Main.projectile[k].active && Main.projectile[k].owner == Main.myPlayer && Main.projectile[k].type == ModContent.ProjectileType() && (center - Main.projectile[k].Center).Length() < 48f) diff --git a/Projectiles/Summon/EndoCooperBody.cs b/Projectiles/Summon/EndoCooperBody.cs index 17e694bac3..9294fffd71 100644 --- a/Projectiles/Summon/EndoCooperBody.cs +++ b/Projectiles/Summon/EndoCooperBody.cs @@ -179,7 +179,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!gotoenemy) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { diff --git a/Projectiles/Summon/EndoIceShard.cs b/Projectiles/Summon/EndoIceShard.cs index 90f8f87571..965991c921 100644 --- a/Projectiles/Summon/EndoIceShard.cs +++ b/Projectiles/Summon/EndoIceShard.cs @@ -80,7 +80,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!hasHomingTarget) { for (int i = 0; i < Main.npc.Length; ++i) { diff --git a/Projectiles/Summon/EnergyOrb.cs b/Projectiles/Summon/EnergyOrb.cs index 419c224307..8f324ed043 100644 --- a/Projectiles/Summon/EnergyOrb.cs +++ b/Projectiles/Summon/EnergyOrb.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag17) { for (int num475 = 0; num475 < Main.maxNPCs; num475++) { diff --git a/Projectiles/Summon/FlameBlast.cs b/Projectiles/Summon/FlameBlast.cs index 8f2869d03f..3339600f83 100644 --- a/Projectiles/Summon/FlameBlast.cs +++ b/Projectiles/Summon/FlameBlast.cs @@ -29,6 +29,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { + Player player = Main.player[projectile.owner]; if (count == 0f) { Main.PlaySound(SoundID.Item73, projectile.position); @@ -72,11 +73,27 @@ namespace CalamityMod.Projectiles.Summon float num474 = 300f; bool flag17 = false; int target = (int)projectile.ai[0]; - if (Main.npc[target].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[target].Center, 1, 1)) + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + float num476 = npc.position.X + (float)(npc.width / 2); + float num477 = npc.position.Y + (float)(npc.height / 2); + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); + if (num478 < num474) + { + num472 = num476; + num473 = num477; + flag17 = true; + } + } + } + else if (Main.npc[target].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[target].Center, 1, 1)) { float num476 = Main.npc[target].position.X + (float)(Main.npc[target].width / 2); float num477 = Main.npc[target].position.Y + (float)(Main.npc[target].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); if (num478 < num474) { num472 = num476; @@ -84,6 +101,28 @@ namespace CalamityMod.Projectiles.Summon flag17 = true; } } + if (!flag17) + { + for (int i = 0; i < Main.maxNPCs; ++i) + { + NPC npc = Main.npc[i]; + if (npc is null || !npc.active) + continue; + + if (npc.CanBeChasedBy(projectile, false)) + { + float num476 = npc.position.X + (float)(npc.width / 2); + float num477 = npc.position.Y + (float)(npc.height / 2); + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); + if (num478 < num474) + { + num472 = num476; + num473 = num477; + flag17 = true; + } + } + } + } if (flag17) { float num483 = 25f; diff --git a/Projectiles/Summon/FlameBurst.cs b/Projectiles/Summon/FlameBurst.cs index e544b740bf..795bf3520a 100644 --- a/Projectiles/Summon/FlameBurst.cs +++ b/Projectiles/Summon/FlameBurst.cs @@ -29,6 +29,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { + Player player = Main.player[projectile.owner]; if (count == 0f) { Main.PlaySound(SoundID.Item73, projectile.position); @@ -72,11 +73,27 @@ namespace CalamityMod.Projectiles.Summon float num474 = 1200f; bool flag17 = false; int target = (int)projectile.ai[0]; - if (Main.npc[target].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[target].Center, 1, 1)) + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + float num476 = npc.position.X + (float)(npc.width / 2); + float num477 = npc.position.Y + (float)(npc.height / 2); + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); + if (num478 < num474) + { + num472 = num476; + num473 = num477; + flag17 = true; + } + } + } + else if (Main.npc[target].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[target].Center, 1, 1)) { float num476 = Main.npc[target].position.X + (float)(Main.npc[target].width / 2); float num477 = Main.npc[target].position.Y + (float)(Main.npc[target].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); if (num478 < num474) { num472 = num476; @@ -84,6 +101,28 @@ namespace CalamityMod.Projectiles.Summon flag17 = true; } } + if (!flag17) + { + for (int i = 0; i < Main.maxNPCs; ++i) + { + NPC npc = Main.npc[i]; + if (npc is null || !npc.active) + continue; + + if (npc.CanBeChasedBy(projectile, false)) + { + float num476 = npc.position.X + (float)(npc.width / 2); + float num477 = npc.position.Y + (float)(npc.height / 2); + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); + if (num478 < num474) + { + num472 = num476; + num473 = num477; + flag17 = true; + } + } + } + } if (flag17) { float num483 = 20f; diff --git a/Projectiles/Summon/ForbiddenCircletEater.cs b/Projectiles/Summon/ForbiddenCircletEater.cs index dc793f422f..90ef9f9969 100644 --- a/Projectiles/Summon/ForbiddenCircletEater.cs +++ b/Projectiles/Summon/ForbiddenCircletEater.cs @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag10) { for (int num376 = 0; num376 < Main.maxNPCs; num376++) { diff --git a/Projectiles/Summon/FrostBlossom.cs b/Projectiles/Summon/FrostBlossom.cs index 5b560e459e..6f0b771a20 100644 --- a/Projectiles/Summon/FrostBlossom.cs +++ b/Projectiles/Summon/FrostBlossom.cs @@ -49,10 +49,10 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - projectile.Center = Main.player[projectile.owner].Center + Vector2.UnitY * (Main.player[projectile.owner].gfxOffY - 60f); - if (Main.player[projectile.owner].gravDir == -1f) + projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); + if (player.gravDir == -1f) { - projectile.position.Y += 140f; + projectile.position.Y += 120f; projectile.rotation = MathHelper.Pi; } else diff --git a/Projectiles/Summon/FungalClumpMinion.cs b/Projectiles/Summon/FungalClumpMinion.cs index 56c2114325..b48421bd07 100644 --- a/Projectiles/Summon/FungalClumpMinion.cs +++ b/Projectiles/Summon/FungalClumpMinion.cs @@ -142,7 +142,7 @@ namespace CalamityMod.Projectiles.Summon } } //If no npc is specifically targetted, check through the entire array - else + if (!npcFound) { for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) { @@ -260,6 +260,8 @@ namespace CalamityMod.Projectiles.Summon { return; } + if (healAmt > 50f) + healAmt = 50f; CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ModContent.ProjectileType(), 1200f, 1f); } diff --git a/Projectiles/Summon/GastricBelcher.cs b/Projectiles/Summon/GastricBelcher.cs index e189e999c6..cb0bb7b127 100644 --- a/Projectiles/Summon/GastricBelcher.cs +++ b/Projectiles/Summon/GastricBelcher.cs @@ -131,7 +131,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!foundTarget) { for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) { diff --git a/Projectiles/Summon/GiantIbanRobotOfDoom.cs b/Projectiles/Summon/GiantIbanRobotOfDoom.cs index 97bf416ef4..796598232d 100644 --- a/Projectiles/Summon/GiantIbanRobotOfDoom.cs +++ b/Projectiles/Summon/GiantIbanRobotOfDoom.cs @@ -68,7 +68,6 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft *= 5; projectile.tileCollide = false; projectile.alpha = 255; - projectile.Calamity().rogue = true; projectile.usesIDStaticNPCImmunity = true; projectile.idStaticNPCHitCooldown = 11; } diff --git a/Projectiles/Summon/GigaFlareFriendly.cs b/Projectiles/Summon/GigaFlareFriendly.cs index 586b346ed6..3629f9c71b 100644 --- a/Projectiles/Summon/GigaFlareFriendly.cs +++ b/Projectiles/Summon/GigaFlareFriendly.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Summon float num473 = projectile.Center.Y; float num474 = 400f; bool flag17 = false; - for (int num475 = 0; num475 < 200; num475++) + for (int num475 = 0; num475 < Main.maxNPCs; num475++) { if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1)) { @@ -93,10 +93,9 @@ namespace CalamityMod.Projectiles.Summon double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; double offsetAngle; - int i; if (projectile.owner == Main.myPlayer) { - for (i = 0; i < 2; i++) + for (int i = 0; i < 2; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); @@ -112,7 +111,7 @@ namespace CalamityMod.Projectiles.Summon projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); for (int num621 = 0; num621 < 20; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -122,13 +121,13 @@ namespace CalamityMod.Projectiles.Summon } for (int num623 = 0; num623 < 35; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Summon/HauntedDishes.cs b/Projectiles/Summon/HauntedDishes.cs index d02acf13f2..70ffa18b50 100644 --- a/Projectiles/Summon/HauntedDishes.cs +++ b/Projectiles/Summon/HauntedDishes.cs @@ -355,7 +355,7 @@ namespace CalamityMod.Projectiles.Summon { projectile.ai[1] = attackCooldown; double num11 = 12.0; - Vector2 vector2 = new Vector2(projectile.position.X + (float) projectile.width * 0.5f, (float) ((double) projectile.position.Y + (double) (projectile.height / 2) - 8.0)); + Vector2 vector2 = new Vector2(projectile.Center.X, projectile.Center.Y - 8f); float num12 = num5 - vector2.X + (float) Main.rand.Next(-10, 11); float num14 = (float) ((double) (Math.Abs(num12) * 0.1f) * (double) Main.rand.Next(0, 100) * (1.0 / 1000.0)); float num15 = num6 - vector2.Y + (float) Main.rand.Next(-10, 11) - num14; diff --git a/Projectiles/Summon/HermitCrabMinion.cs b/Projectiles/Summon/HermitCrabMinion.cs index 6e7e375163..58aa77bc25 100644 --- a/Projectiles/Summon/HermitCrabMinion.cs +++ b/Projectiles/Summon/HermitCrabMinion.cs @@ -124,7 +124,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!chaseNPC) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { diff --git a/Projectiles/Summon/Hive.cs b/Projectiles/Summon/Hive.cs index a5ef59097b..ee8779e206 100644 --- a/Projectiles/Summon/Hive.cs +++ b/Projectiles/Summon/Hive.cs @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag25) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { diff --git a/Projectiles/Summon/Hiveling.cs b/Projectiles/Summon/Hiveling.cs index 018f06728e..fb4b693fb2 100644 --- a/Projectiles/Summon/Hiveling.cs +++ b/Projectiles/Summon/Hiveling.cs @@ -32,6 +32,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { + Player player = Main.player[projectile.owner]; projectile.frameCounter++; if (projectile.frameCounter > 3) { @@ -50,11 +51,28 @@ namespace CalamityMod.Projectiles.Summon float num474 = 1200f; bool homeIn = false; int target = (int)projectile.ai[0]; - if (Main.npc[target].CanBeChasedBy(projectile, false)) + + if (player.HasMinionAttackTargetNPC) { - float num476 = Main.npc[target].position.X + (float)(Main.npc[target].width / 2); - float num477 = Main.npc[target].position.Y + (float)(Main.npc[target].height / 2); - float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477); + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false)) + { + float num476 = npc.Center.X; + float num477 = npc.Center.Y; + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); + if (num478 < num474) + { + centerX = num476; + centerY = num477; + homeIn = true; + } + } + } + else if (Main.npc[target].CanBeChasedBy(projectile, false)) + { + float num476 = Main.npc[target].Center.X; + float num477 = Main.npc[target].Center.Y; + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); if (num478 < num474) { centerX = num476; @@ -62,6 +80,28 @@ namespace CalamityMod.Projectiles.Summon homeIn = true; } } + if (!homeIn) + { + for (int i = 0; i < Main.maxNPCs; ++i) + { + NPC npc = Main.npc[i]; + if (npc is null || !npc.active) + continue; + + if (npc.CanBeChasedBy(projectile, false)) + { + float num476 = npc.Center.X; + float num477 = npc.Center.Y; + float num478 = Math.Abs(projectile.Center.X - num476) + Math.Abs(projectile.Center.Y - num477); + if (num478 < num474) + { + centerX = num476; + centerY = num477; + homeIn = true; + } + } + } + } if (homeIn) { float num483 = 10f; diff --git a/Projectiles/Summon/HowlsHeartFireball.cs b/Projectiles/Summon/HowlsHeartFireball.cs index 6c640d5fd7..8dc31d65be 100644 --- a/Projectiles/Summon/HowlsHeartFireball.cs +++ b/Projectiles/Summon/HowlsHeartFireball.cs @@ -45,6 +45,7 @@ namespace CalamityMod.Projectiles.Summon Vector2 center = projectile.Center; float maxDistance = 500f; bool homeIn = false; + int target = (int)projectile.ai[0]; if (player.HasMinionAttackTargetNPC) { @@ -64,7 +65,23 @@ namespace CalamityMod.Projectiles.Summon } } } - else + else if (Main.npc[target].CanBeChasedBy(projectile, false)) + { + NPC npc = Main.npc[target]; + + float extraDistance = (npc.width / 2) + (npc.height / 2); + + bool canHit = true; + if (extraDistance < maxDistance) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) + { + center = npc.Center; + homeIn = true; + } + } + if (!homeIn) { for (int i = 0; i < Main.maxNPCs; i++) { diff --git a/Projectiles/Summon/HowlsHeartHowl.cs b/Projectiles/Summon/HowlsHeartHowl.cs index caf409d2de..e1db603533 100644 --- a/Projectiles/Summon/HowlsHeartHowl.cs +++ b/Projectiles/Summon/HowlsHeartHowl.cs @@ -93,6 +93,7 @@ namespace CalamityMod.Projectiles.Summon Vector2 targetPos = projectile.position; float maxRange = 900f; bool foundEnemy = false; + int targetIndex = -1; //If the player has targetted an enemy, choose that one NPC target = projectile.OwnerMinionAttackTargetNPC; if (target != null && target.CanBeChasedBy(projectile, false)) @@ -103,6 +104,7 @@ namespace CalamityMod.Projectiles.Summon maxRange = targetDist; targetPos = target.Center; foundEnemy = true; + targetIndex = target.whoAmI; } } //else, search through all available NPCs @@ -119,6 +121,7 @@ namespace CalamityMod.Projectiles.Summon maxRange = targetDist; targetPos = npc.Center; foundEnemy = true; + targetIndex = index; } } } @@ -272,7 +275,7 @@ namespace CalamityMod.Projectiles.Summon targetVec.Normalize(); targetVec *= speedMult; Main.PlaySound(SoundID.Item20, projectile.position); - int fireball = Projectile.NewProjectile(projectile.Center, targetVec, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + int fireball = Projectile.NewProjectile(projectile.Center, targetVec, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, targetIndex, 0f); Main.projectile[fireball].netUpdate = true; Main.projectile[fireball].frame = Main.rand.Next(4); projectile.netUpdate = true; diff --git a/Projectiles/Summon/LanternFlame.cs b/Projectiles/Summon/LanternFlame.cs index 6605f77c63..4a83651bd5 100644 --- a/Projectiles/Summon/LanternFlame.cs +++ b/Projectiles/Summon/LanternFlame.cs @@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag17) { for (int num475 = 0; num475 < Main.npc.Length; num475++) { diff --git a/Projectiles/Summon/LuxorsGiftSummon.cs b/Projectiles/Summon/LuxorsGiftSummon.cs index 29066770e9..4345c84869 100644 --- a/Projectiles/Summon/LuxorsGiftSummon.cs +++ b/Projectiles/Summon/LuxorsGiftSummon.cs @@ -96,7 +96,7 @@ namespace CalamityMod.Projectiles.Summon projectile.ChargingMinionAI(700f, 1000f, 2200f, 150f, 0, 40f, 9f, -4f, 40f, 9f, true, true); - projectile.rotation = projectile.velocity.ToRotation() + 1.57f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Summon/MagicAxe.cs b/Projectiles/Summon/MagicAxe.cs index c1c75c88fd..1b0a2be506 100644 --- a/Projectiles/Summon/MagicAxe.cs +++ b/Projectiles/Summon/MagicAxe.cs @@ -41,176 +41,22 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - projectile.rotation += 0.075f; projectile.alpha -= 50; - float num634 = 1200f; - float num635 = 2500f; - projectile.MinionAntiClump(); - if (projectile.ai[1] <= 30) + counter++; + if (counter == 30) + { + projectile.netUpdate = true; + } + else if (counter < 30) { - projectile.ai[1]++; return; } - bool flag24 = false; - if (projectile.ai[0] == 2f) - { - counter += 1; - projectile.extraUpdates = 4; - if (counter > 30) - { - counter = 1; - projectile.ai[0] = 0f; - projectile.extraUpdates = 1; - projectile.numUpdates = 0; - projectile.netUpdate = true; - } - else - { - flag24 = true; - } - } - if (flag24) - { - return; - } - Vector2 vector46 = projectile.position; - float homingRange = MagicHat.Range; - bool homeIn = false; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { - float num646 = Vector2.Distance(npc.Center, projectile.Center); - if (!homeIn && num646 < homingRange) - { - homingRange = num646; - vector46 = npc.Center; - homeIn = true; - } - } - } - else - { - for (int num645 = 0; num645 < Main.npc.Length; num645++) - { - NPC nPC2 = Main.npc[num645]; - if (nPC2.CanBeChasedBy(projectile, false)) - { - float num646 = Vector2.Distance(nPC2.Center, projectile.Center); - if (!homeIn && num646 < homingRange) - { - homingRange = num646; - vector46 = nPC2.Center; - homeIn = true; - } - } - } - } - float num647 = num634; - if (homeIn) - { - num647 = num635; - } - if (Vector2.Distance(player.Center, projectile.Center) > num647) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } - if (homeIn && projectile.ai[0] == 0f) - { - Vector2 vector47 = vector46 - projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) - { - float scaleFactor2 = 24f; //8 - vector47 *= scaleFactor2; - projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; - } - else - { - float num649 = 12f; //4 - vector47 *= -num649; - projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; //41 - } - } - else - { - bool flag26 = false; - float num636 = 400f; - if (!flag26) - { - flag26 = projectile.ai[0] == 1f; - } - float num650 = 6f; - if (flag26) - { - num650 = 15f; - } - Vector2 center2 = projectile.Center; - Vector2 vector48 = player.Center - center2 + new Vector2(0f, -60f); - float playerDist = vector48.Length(); - if (playerDist > 200f && num650 < 8f) - { - num650 = 8f; - } - if (playerDist < num636 && flag26 && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); - projectile.netUpdate = true; - } - if (playerDist > 70f) - { - vector48.Normalize(); - vector48 *= num650; - projectile.velocity = (projectile.velocity * 40f + vector48) / 41f; - } - else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) - { - projectile.velocity.X = -0.15f; - projectile.velocity.Y = -0.05f; - } - } - if (counter > 0) - { - counter += Main.rand.Next(1, 4); - } - if (counter > 30) - { - counter = 0; - projectile.netUpdate = true; - } - if (projectile.ai[0] == 0f) - { - if (counter == 0 && homeIn && homingRange < 500f) - { - counter += 1; - if (Main.myPlayer == projectile.owner) - { - projectile.ai[0] = 2f; - Vector2 value20 = vector46 - projectile.Center; - value20.Normalize(); - projectile.velocity = value20 * 16f; //8 - projectile.netUpdate = true; - } - } - } + + projectile.ChargingMinionAI(MagicHat.Range, 1200f, 2500f, 400f, 1, 30f, 24f, -12f, 30f, 16f, true, true, 3); } - public override Color? GetAlpha(Color lightColor) - { - return new Color(0, 255, 111, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(0, 255, 111, projectile.alpha); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Summon/MagicBat.cs b/Projectiles/Summon/MagicBat.cs index ed58a72851..651e618f1d 100644 --- a/Projectiles/Summon/MagicBat.cs +++ b/Projectiles/Summon/MagicBat.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Summon/MagicBird.cs b/Projectiles/Summon/MagicBird.cs index 60d1c89402..64b185c573 100644 --- a/Projectiles/Summon/MagicBird.cs +++ b/Projectiles/Summon/MagicBird.cs @@ -35,29 +35,29 @@ namespace CalamityMod.Projectiles.Summon { projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - projectile.frameCounter++; + + projectile.frameCounter++; if (projectile.frameCounter > 6) { projectile.frame++; - projectile.frameCounter = 0; + projectile.frameCounter = 0; } if (projectile.frame >= 7) { projectile.frame = 0; } - projectile.ai[0]++; - projectile.ai[1]++; - if (projectile.ai[0] >= 20f) + + if (projectile.ai[0]++ % 20f == 0f) { Vector2 dspeed = projectile.velocity * Main.rand.NextFloat(0.3f,0.6f); int dust = Dust.NewDust(projectile.Center, 1, 1, 67, dspeed.X, dspeed.Y, 50, default, 1.2f); Main.dust[dust].noGravity = true; - projectile.ai[0] = 0f; } //Homing - if (projectile.ai[1] > 30f) + if (projectile.ai[1]++ > 30f) HomingAI(); + //Fade in if (projectile.alpha > 0) { @@ -89,12 +89,12 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!hasHomingTarget) { for (int i = 0; i < Main.npc.Length; ++i) { NPC npc = Main.npc[i]; - if (npc == null || !npc.active) + if (npc is null || !npc.active) continue; if (npc.CanBeChasedBy(projectile, false)) @@ -130,10 +130,7 @@ namespace CalamityMod.Projectiles.Summon } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(255, 239, 0, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(255, 239, 0, projectile.alpha); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Summon/MagicHammer.cs b/Projectiles/Summon/MagicHammer.cs index afddf9d1a4..d1740b14db 100644 --- a/Projectiles/Summon/MagicHammer.cs +++ b/Projectiles/Summon/MagicHammer.cs @@ -44,15 +44,22 @@ namespace CalamityMod.Projectiles.Summon projectile.alpha = 50; } } + projectile.rotation += 0.075f; - if (counter <= 30) + + counter++; + if (counter == 30) + { + projectile.netUpdate = true; + } + else if (counter < 30) { - counter++; return; } - int num716 = -1; - Vector2 vector59 = projectile.Center; - float num717 = MagicHat.Range; + + int targetIndex = -1; + Vector2 targetVec = projectile.Center; + float maxDistance = MagicHat.Range; if (projectile.localAI[0] > 0f) { projectile.localAI[0] -= 1f; @@ -63,39 +70,35 @@ namespace CalamityMod.Projectiles.Summon if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false) && (projectile.ai[0] == 0f || projectile.ai[0] == (float)(player.MinionAttackTargetNPC + 1))) + if (npc.CanBeChasedBy(projectile, false) && (projectile.ai[0] == 0f || projectile.ai[0] == player.MinionAttackTargetNPC + 1f)) { - Vector2 center4 = npc.Center; - float num719 = Vector2.Distance(center4, vector59); - if (num719 < num717) + float targetDist = Vector2.Distance(npc.Center, targetVec); + if (targetDist < maxDistance) { - num717 = num719; - vector59 = center4; - num716 = player.MinionAttackTargetNPC; + targetVec = npc.Center; + targetIndex = player.MinionAttackTargetNPC; } } } else { - for (int num718 = 0; num718 < Main.npc.Length; num718++) + for (int i = 0; i < Main.npc.Length; i++) { - NPC nPC6 = Main.npc[num718]; - if (nPC6.CanBeChasedBy(projectile, false) && (projectile.ai[0] == 0f || projectile.ai[0] == (float)(num718 + 1))) + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false) && (projectile.ai[0] == 0f || projectile.ai[0] == i + 1f)) { - Vector2 center4 = nPC6.Center; - float num719 = Vector2.Distance(center4, vector59); - if (num719 < num717) + float targetDist = Vector2.Distance(npc.Center, targetVec); + if (targetDist < maxDistance) { - num717 = num719; - vector59 = center4; - num716 = num718; + targetVec = npc.Center; + targetIndex = i; } } } } - if (num716 >= 0) + if (targetIndex >= 0) { - projectile.ai[0] = (float)(num716 + 1); + projectile.ai[0] = targetIndex + 1f; projectile.netUpdate = true; } } @@ -103,40 +106,39 @@ namespace CalamityMod.Projectiles.Summon { projectile.localAI[0] = 30f; } - bool flag32 = false; + bool canHome = false; if (projectile.ai[0] != 0f) { - int num720 = (int)(projectile.ai[0] - 1f); - if (Main.npc[num720].active && !Main.npc[num720].dontTakeDamage && Main.npc[num720].immune[projectile.owner] == 0) + int target = (int)(projectile.ai[0] - 1f); + NPC npc = Main.npc[target]; + if (npc.CanBeChasedBy(projectile, false) && npc.immune[projectile.owner] == 0) { - float num721 = Main.npc[num720].position.X + (float)(Main.npc[num720].width / 2); - float num722 = Main.npc[num720].position.Y + (float)(Main.npc[num720].height / 2); - float num723 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num721) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num722); - if (num723 < MagicHat.Range * 1.25f) + float targetDist = Vector2.Distance(npc.Center, targetVec); + if (targetDist < maxDistance * 1.25f) { - flag32 = true; - vector59 = Main.npc[num720].Center; + canHome = true; + targetVec = npc.Center; } } else { projectile.ai[0] = 0f; - flag32 = false; + canHome = false; projectile.netUpdate = true; } } - if (flag32) + if (canHome) { - Vector2 v = vector59 - projectile.Center; - float num724 = projectile.velocity.ToRotation(); - float num725 = v.ToRotation(); - float num726 = num725 - num724; - num726 = MathHelper.WrapAngle(num726); - projectile.velocity = projectile.velocity.RotatedBy(num726 * 0.25, default); + Vector2 velocity = targetVec - projectile.Center; + float trajectory = projectile.velocity.ToRotation(); + float target = velocity.ToRotation(); + float rotateAmt = target - trajectory; + rotateAmt = MathHelper.WrapAngle(rotateAmt); + projectile.velocity = projectile.velocity.RotatedBy(rotateAmt * 0.25, default); } - float num727 = projectile.velocity.Length(); + float speed = projectile.velocity.Length(); projectile.velocity.Normalize(); - projectile.velocity *= num727 + 0.0025f; + projectile.velocity *= speed + 0.0025f; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -145,10 +147,7 @@ namespace CalamityMod.Projectiles.Summon return false; } - public override Color? GetAlpha(Color lightColor) - { - return new Color(255, 56, 0, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(255, 56, 0, projectile.alpha); public override void Kill(int timeLeft) { diff --git a/Projectiles/Summon/MagicHat.cs b/Projectiles/Summon/MagicHat.cs index 366cb81758..d9f6ba8ee1 100644 --- a/Projectiles/Summon/MagicHat.cs +++ b/Projectiles/Summon/MagicHat.cs @@ -57,24 +57,23 @@ namespace CalamityMod.Projectiles.Summon } //projectile movement - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2) + player.gfxOffY - 60f; + projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); if (player.gravDir == -1f) { - projectile.position.Y = projectile.position.Y + 150f; + projectile.position.Y += 120f; projectile.rotation = MathHelper.Pi; } else { projectile.rotation = 0f; } - projectile.position.X = (float)(int)projectile.position.X; - projectile.position.Y = (float)(int)projectile.position.Y; + projectile.position.X = (int)projectile.position.X; + projectile.position.Y = (int)projectile.position.Y; //Change the summons scale size a little bit to make it pulse in and out - float num395 = (float)Main.mouseTextColor / 200f - 0.35f; - num395 *= 0.2f; - projectile.scale = num395 + 0.95f; + float scalar = (float)Main.mouseTextColor / 200f - 0.35f; + scalar *= 0.2f; + projectile.scale = scalar + 0.95f; //on summon dust and flexible damage if (projectile.localAI[0] == 0f) @@ -97,54 +96,30 @@ namespace CalamityMod.Projectiles.Summon projectile.damage = damage2; } - //finding an enemy, then shooting projectiles at it + //finding an enemy, then shooting projectiles if it's detected if (projectile.owner == Main.myPlayer) { - float projPosX = projectile.position.X; - float projPosY = projectile.position.Y; float detectionRange = Range; bool enemyDetected = false; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { - float xDist = npc.position.X + (float)(npc.width / 2); - float yDist = npc.position.Y + (float)(npc.height / 2); - float enemyDist = Math.Abs(projPosX + (float)(projectile.width / 2) - xDist) + Math.Abs(projPosY + (float)(projectile.height / 2) - yDist); - if (enemyDist < detectionRange) - { - detectionRange = enemyDist; - projPosX = xDist; - projPosY = yDist; - enemyDetected = true; - } - } - } - else - { - for (int index = 0; index < Main.npc.Length; index++) - { - NPC target = Main.npc[index]; - if (target.CanBeChasedBy(projectile, false)) - { - float xDist = target.position.X + (float)(target.width / 2); - float yDist = target.position.Y + (float)(target.height / 2); - float enemyDist = Math.Abs(projPosX + (float)(projectile.width / 2) - xDist) + Math.Abs(projPosY + (float)(projectile.height / 2) - yDist); - if (enemyDist < detectionRange) - { - detectionRange = enemyDist; - projPosX = xDist; - projPosY = yDist; - enemyDetected = true; - } - } - } - } + + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); + + if (Vector2.Distance(npc.Center, projectile.Center) < (detectionRange + extraDistance)) + { + enemyDetected = true; + break; + } + } + } if (enemyDetected) { projectile.ai[1] += 1f; - if ((projectile.ai[1] % 5f) == 0f) + if (projectile.ai[1] % 5f == 0f) { int amount = Main.rand.Next(1, 2); for (int i = 0; i < amount; i++) @@ -159,7 +134,7 @@ namespace CalamityMod.Projectiles.Summon }); float velocityX = Main.rand.NextFloat(-10f, 10f); float velocityY = Main.rand.NextFloat(-15f, -8f); - Projectile.NewProjectile(projectile.oldPosition.X + (float)(projectile.width / 2), projectile.oldPosition.Y + (float)(projectile.height / 2), velocityX, velocityY, projType, projectile.damage, 0f, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.oldPosition.X + (float)(projectile.width / 2), projectile.oldPosition.Y + (float)(projectile.height / 2), velocityX, velocityY, projType, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Summon/MagicRifle.cs b/Projectiles/Summon/MagicRifle.cs index e59667cb4c..8f20a75ca5 100644 --- a/Projectiles/Summon/MagicRifle.cs +++ b/Projectiles/Summon/MagicRifle.cs @@ -9,7 +9,6 @@ namespace CalamityMod.Projectiles.Summon public class MagicRifle : ModProjectile { private int counter = 0; - private bool canHome = false; public override void SetStaticDefaults() { DisplayName.SetDefault("Rifle"); @@ -39,11 +38,16 @@ namespace CalamityMod.Projectiles.Summon projectile.MinionAntiClump(); //Try not to do anything at first - if (counter <= 30) + counter++; + if (counter == 30) { - counter++; - canHome = true; + projectile.netUpdate = true; } + else if (counter < 30) + { + return; + } + float homingRange = MagicHat.Range; Vector2 targetVec = projectile.position; Vector2 half = new Vector2(0.5f); @@ -52,7 +56,7 @@ namespace CalamityMod.Projectiles.Summon if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false) && canHome) + if (npc.CanBeChasedBy(projectile, false)) { //Adding a check on the NPC's size allows it to target big things like Providence Vector2 sizeCheck = npc.position + npc.Size * half; @@ -66,12 +70,12 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!foundTarget) { for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) { NPC npc = Main.npc[npcIndex]; - if (npc.CanBeChasedBy(projectile, false) && canHome) + if (npc.CanBeChasedBy(projectile, false)) { Vector2 sizeCheck = npc.position + npc.Size * half; float targetDist = Vector2.Distance(npc.Center, projectile.Center); diff --git a/Projectiles/Summon/MagicUmbrella.cs b/Projectiles/Summon/MagicUmbrella.cs index 6ee1a99dbe..71cbd42f06 100644 --- a/Projectiles/Summon/MagicUmbrella.cs +++ b/Projectiles/Summon/MagicUmbrella.cs @@ -10,7 +10,6 @@ namespace CalamityMod.Projectiles.Summon public class MagicUmbrella : ModProjectile { private int counter = 0; - private bool canHome = false; public override void SetStaticDefaults() { DisplayName.SetDefault("Umbrella"); @@ -38,182 +37,22 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Player player = Main.player[projectile.owner]; projectile.rotation += 0.075f; projectile.alpha -= 50; - float num633 = MagicHat.Range; - float num634 = 1600f; - float num635 = 2200f; - float num636 = 150f; - projectile.MinionAntiClump(); - if (counter <= 30) + counter++; + if (counter == 30) { - counter++; - canHome = true; + projectile.netUpdate = true; } - else + else if (counter < 30) { - canHome = true; + return; } - bool flag24 = false; - if (projectile.ai[0] == 2f) - { - projectile.ai[1] += 1f; - projectile.extraUpdates = 1; - if (projectile.ai[1] > 40f) - { - projectile.ai[1] = 1f; - projectile.ai[0] = 0f; - projectile.extraUpdates = 0; - projectile.numUpdates = 0; - projectile.netUpdate = true; - } - else - { - flag24 = true; - } - } - if (flag24) - { - return; - } - if (!canHome) - { - return; - } - Vector2 vector46 = projectile.position; - bool flag25 = false; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false) && canHome) - { - float num646 = Vector2.Distance(npc.Center, projectile.Center); - if (!flag25 && num646 < num633) - { - num633 = num646; - vector46 = npc.Center; - flag25 = true; - } - } - } - else - { - for (int num645 = 0; num645 < Main.npc.Length; num645++) - { - NPC nPC2 = Main.npc[num645]; - if (nPC2.CanBeChasedBy(projectile, false) && canHome) - { - float num646 = Vector2.Distance(nPC2.Center, projectile.Center); - if (!flag25 && num646 < num633) - { - num633 = num646; - vector46 = nPC2.Center; - flag25 = true; - } - } - } - } - float num647 = num634; - if (flag25) - { - num647 = num635; - } - if (Vector2.Distance(player.Center, projectile.Center) > num647) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } - if (flag25 && projectile.ai[0] == 0f) - { - Vector2 vector47 = vector46 - projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) - { - float scaleFactor2 = 9f; //8 - vector47 *= scaleFactor2; - projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; - } - else - { - float num649 = 4f; - vector47 *= -num649; - projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; - } - } - else - { - bool flag26 = false; - if (!flag26) - { - flag26 = projectile.ai[0] == 1f; - } - float num650 = 6f; - if (flag26) - { - num650 = 15f; - } - Vector2 center2 = projectile.Center; - Vector2 vector48 = player.Center - center2 + new Vector2(0f, -60f); - float num651 = vector48.Length(); - if (num651 > 200f && num650 < 8f) - { - num650 = 8f; - } - if (num651 < num636 && flag26 && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - if (num651 > 2000f) - { - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); - projectile.netUpdate = true; - } - if (num651 > 70f) - { - vector48.Normalize(); - vector48 *= num650; - projectile.velocity = (projectile.velocity * 40f + vector48) / 41f; - } - else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) - { - projectile.velocity.X = -0.15f; - projectile.velocity.Y = -0.05f; - } - } - if (projectile.ai[1] > 0f) - { - projectile.ai[1] += (float)Main.rand.Next(1, 4); - } - if (projectile.ai[1] > 40f) - { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - if (projectile.ai[0] == 0f) - { - if (projectile.ai[1] == 0f && flag25 && num633 < 500f) - { - projectile.ai[1] += 1f; - if (Main.myPlayer == projectile.owner) - { - projectile.ai[0] = 2f; - Vector2 value20 = vector46 - projectile.Center; - value20.Normalize(); - projectile.velocity = value20 * 9f; //8 - projectile.netUpdate = true; - } - } - } + + projectile.ChargingMinionAI(MagicHat.Range, 1600f, 2200f, 150f, 0, 40f, 9f, -4f, 40f, 9f, true, true); } - public override Color? GetAlpha(Color lightColor) - { - return new Color(75, 255, 255, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(75, 255, 255, projectile.alpha); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -235,21 +74,7 @@ namespace CalamityMod.Projectiles.Summon { if (Main.rand.NextBool(4)) { - for (int n = 0; n < Main.rand.Next(1, 3); n++) //1 to 2 baseball bats - { - float x = target.position.X + (float)Main.rand.Next(-400, 400); - float y = target.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num13 = target.position.X + (float)(target.width / 2) - vector.X; - float num14 = target.position.Y + (float)(target.height / 2) - vector.Y; - num13 += (float)Main.rand.Next(-100, 101); - int num15 = 29; - float num16 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14)); - num16 = (float)num15 / num16; - num13 *= num16; - num14 *= num16; - Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType(), (int)(projectile.damage * Main.rand.NextFloat(0.3f, 0.6f)), projectile.knockBack * Main.rand.NextFloat(0.7f, 1f), projectile.owner, 0f, 0f); - } + SpawnBaseballBats(target.Center); } } @@ -257,22 +82,26 @@ namespace CalamityMod.Projectiles.Summon { if (Main.rand.NextBool(4)) { - for (int n = 0; n < Main.rand.Next(1, 3); n++) //1 to 2 baseball bats - { - float x = target.position.X + (float)Main.rand.Next(-400, 400); - float y = target.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num13 = target.position.X + (float)(target.width / 2) - vector.X; - float num14 = target.position.Y + (float)(target.height / 2) - vector.Y; - num13 += (float)Main.rand.Next(-100, 101); - int num15 = 29; - float num16 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14)); - num16 = (float)num15 / num16; - num13 *= num16; - num14 *= num16; - Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType(), (int)(projectile.damage * Main.rand.NextFloat(0.3f, 0.6f)), projectile.knockBack * Main.rand.NextFloat(0.7f, 1f), projectile.owner, 0f, 0f); - } + SpawnBaseballBats(target.Center); } } + + private void SpawnBaseballBats(Vector2 targetPos) + { + for (int n = 0; n < Main.rand.Next(1, 3); n++) //1 to 2 baseball bats + { + float x = targetPos.X + Main.rand.Next(-400, 401); + float y = targetPos.Y - Main.rand.Next(500, 801); + Vector2 source = new Vector2(x, y); + Vector2 velocity = targetPos - source; + velocity.X += Main.rand.Next(-100, 101); + float speed = 29f; + float targetDist = velocity.Length(); + targetDist = speed / targetDist; + velocity.X *= targetDist; + velocity.Y *= targetDist; + Projectile.NewProjectile(source, velocity, ModContent.ProjectileType(), (int)(projectile.damage * Main.rand.NextFloat(0.3f, 0.6f)), projectile.knockBack * Main.rand.NextFloat(0.7f, 1f), projectile.owner, 0f, 0f); + } + } } } diff --git a/Projectiles/Summon/MidnightSunBeam.cs b/Projectiles/Summon/MidnightSunBeam.cs index 9bbc978cb7..987dbf137b 100644 --- a/Projectiles/Summon/MidnightSunBeam.cs +++ b/Projectiles/Summon/MidnightSunBeam.cs @@ -30,6 +30,8 @@ namespace CalamityMod.Projectiles.Summon projectile.alpha = 255; projectile.penetrate = -1; projectile.tileCollide = false; + projectile.minion = true; + projectile.minionSlots = 0f; projectile.timeLeft = TrueTimeLeft; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 6; diff --git a/Projectiles/Summon/MidnightSunSkyBeam.cs b/Projectiles/Summon/MidnightSunSkyBeam.cs index 6c3d5b5132..c8f86e8e5a 100644 --- a/Projectiles/Summon/MidnightSunSkyBeam.cs +++ b/Projectiles/Summon/MidnightSunSkyBeam.cs @@ -30,6 +30,8 @@ namespace CalamityMod.Projectiles.Summon projectile.alpha = 255; projectile.penetrate = -1; projectile.tileCollide = false; + projectile.minion = true; + projectile.minionSlots = 0f; projectile.timeLeft = TrueTimeLeft; projectile.usesIDStaticNPCImmunity = true; projectile.idStaticNPCHitCooldown = 30; diff --git a/Projectiles/Summon/MiniGuardianAttack.cs b/Projectiles/Summon/MiniGuardianAttack.cs index 33161fc7c2..047bedfc93 100644 --- a/Projectiles/Summon/MiniGuardianAttack.cs +++ b/Projectiles/Summon/MiniGuardianAttack.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Summon if (projectile.ai[1] == 0f) { float num550 = 24f; //12 - Vector2 vector43 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); + Vector2 vector43 = projectile.Center; float num551 = num535 - vector43.X; float num552 = num536 - vector43.Y; float num553 = (float)Math.Sqrt((double)(num551 * num551 + num552 * num552)); @@ -85,9 +85,9 @@ namespace CalamityMod.Projectiles.Summon float num16 = 0.5f; projectile.tileCollide = false; int num17 = 100; - Vector2 vector3 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num18 = Main.player[projectile.owner].position.X + (float)(Main.player[projectile.owner].width / 2) - vector3.X; - float num19 = Main.player[projectile.owner].position.Y + (float)(Main.player[projectile.owner].height / 2) - vector3.Y; + Vector2 vector3 = projectile.Center; + float num18 = Main.player[projectile.owner].Center.X - vector3.X; + float num19 = Main.player[projectile.owner].Center.Y - vector3.Y; num19 += (float)Main.rand.Next(-10, 21); num18 += (float)Main.rand.Next(-10, 21); num18 += (float)(60 * -(float)Main.player[projectile.owner].direction); diff --git a/Projectiles/Summon/MiniGuardianDefense.cs b/Projectiles/Summon/MiniGuardianDefense.cs index 1adb554fc5..5719d88996 100644 --- a/Projectiles/Summon/MiniGuardianDefense.cs +++ b/Projectiles/Summon/MiniGuardianDefense.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Summon if (projectile.ai[1] == 0f) { float num550 = 24f; //12 - Vector2 vector43 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); + Vector2 vector43 = projectile.Center; float num551 = num535 - vector43.X; float num552 = num536 - vector43.Y; float num553 = (float)Math.Sqrt((double)(num551 * num551 + num552 * num552)); @@ -83,9 +83,9 @@ namespace CalamityMod.Projectiles.Summon float num16 = 0.5f; projectile.tileCollide = false; int num17 = 100; - Vector2 vector3 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num18 = Main.player[projectile.owner].position.X + (float)(Main.player[projectile.owner].width / 2) - vector3.X; - float num19 = Main.player[projectile.owner].position.Y + (float)(Main.player[projectile.owner].height / 2) - vector3.Y; + Vector2 vector3 = projectile.Center; + float num18 = Main.player[projectile.owner].Center.X - vector3.X; + float num19 = Main.player[projectile.owner].Center.Y - vector3.Y; num19 += (float)Main.rand.Next(-10, 21); num18 += (float)Main.rand.Next(-10, 21); num18 += (float)(60 * -(float)Main.player[projectile.owner].direction); diff --git a/Projectiles/Summon/PhantomGuy.cs b/Projectiles/Summon/PhantomGuy.cs index 4f1247aec7..0f8d79935f 100644 --- a/Projectiles/Summon/PhantomGuy.cs +++ b/Projectiles/Summon/PhantomGuy.cs @@ -93,7 +93,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag25) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { diff --git a/Projectiles/Summon/PinkButterfly.cs b/Projectiles/Summon/PinkButterfly.cs index 7f9af97df4..322ec34f58 100644 --- a/Projectiles/Summon/PinkButterfly.cs +++ b/Projectiles/Summon/PinkButterfly.cs @@ -100,6 +100,7 @@ namespace CalamityMod.Projectiles.Summon } Vector2 vector46 = projectile.position; bool flag25 = false; + int targetIndex = -1; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; @@ -110,10 +111,11 @@ namespace CalamityMod.Projectiles.Summon { vector46 = npc.Center; flag25 = true; + targetIndex = npc.whoAmI; } } } - else + if (!flag25) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { @@ -126,6 +128,7 @@ namespace CalamityMod.Projectiles.Summon num633 = num646; vector46 = nPC2.Center; flag25 = true; + targetIndex = num645; } } } @@ -235,7 +238,7 @@ namespace CalamityMod.Projectiles.Summon for (int i = 0; i < numProj + 1; i++) { Vector2 perturbedSpeed = value19.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, projectileType, projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, projectileType, projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner, targetIndex, 0f); } projectile.netUpdate = true; } diff --git a/Projectiles/Summon/PlaguePrincess.cs b/Projectiles/Summon/PlaguePrincess.cs index b8fd4170ea..3217086e3b 100644 --- a/Projectiles/Summon/PlaguePrincess.cs +++ b/Projectiles/Summon/PlaguePrincess.cs @@ -194,7 +194,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!targetFound) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { diff --git a/Projectiles/Summon/PlantSummon.cs b/Projectiles/Summon/PlantSummon.cs index 546481e402..0e2390794d 100644 --- a/Projectiles/Summon/PlantSummon.cs +++ b/Projectiles/Summon/PlantSummon.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ID; @@ -23,6 +24,7 @@ namespace CalamityMod.Projectiles.Summon Main.projFrames[projectile.type] = 8; ProjectileID.Sets.MinionSacrificable[projectile.type] = true; ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + ProjectileID.Sets.NeedsUUID[projectile.type] = true; } public override void SetDefaults() @@ -32,7 +34,7 @@ namespace CalamityMod.Projectiles.Summon projectile.netImportant = true; projectile.friendly = true; projectile.ignoreWater = true; - projectile.minionSlots = 2f; + projectile.minionSlots = 3f; projectile.timeLeft = 18000; projectile.penetrate = -1; projectile.tileCollide = false; @@ -49,7 +51,7 @@ namespace CalamityMod.Projectiles.Summon CalamityPlayer modPlayer = player.Calamity(); CalamityGlobalProjectile modProj = projectile.Calamity(); - if (player.statLife <= (int)((double)player.statLifeMax2 * 0.5)) + if (player.statLife <= (int)(player.statLifeMax2 * 0.75)) { if (Main.myPlayer == projectile.owner) { @@ -69,6 +71,7 @@ namespace CalamityMod.Projectiles.Summon modProj.spawnedPlayerMinionDamageValue = player.MinionDamage(); modProj.spawnedPlayerMinionProjectileDamageValue = projectile.damage; SpawnDust(); + SpawnTentacles(); initialized = true; } if (player.MinionDamage() != modProj.spawnedPlayerMinionDamageValue) @@ -173,10 +176,17 @@ namespace CalamityMod.Projectiles.Summon if (Main.myPlayer == projectile.owner) { Vector2 velocity = targetVec - projectile.Center; - velocity.Normalize(); - velocity *= projSpeed; - velocity *= speedMult; - Projectile.NewProjectile(projectile.Center, velocity, projType, projDmg, projectile.knockBack, projectile.owner, 0f, 0f); + if (projType != thornBall && Main.rand.NextBool(3)) + { + FireShotgun(velocity, 0.7f); + } + else + { + velocity.Normalize(); + velocity *= projSpeed; + velocity *= speedMult; + Projectile.NewProjectile(projectile.Center, velocity, projType, projDmg, projectile.knockBack, projectile.owner, 0f, 0f); + } projectile.netUpdate = true; } } @@ -223,7 +233,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!foundTarget) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { @@ -274,23 +284,7 @@ namespace CalamityMod.Projectiles.Summon } if (Main.rand.NextBool(3)) { - float projSpeedMult = 3f; - if (Main.rand.NextBool(2) && CalamityUtils.CountProjectiles(sporeClouds) < 9) - { - projType = sporeClouds; - projSpeedMult = 10f; - } - else - { - projType = Main.rand.NextBool(2) ? greenSeed : pinkSeed; - } - int projDmg = (int)(projectile.damage * 0.8f); - Vector2 projVelocity = whereIsTarget * projSpeedMult; - for (int i = -8; i <= 8; i += 8) - { - Vector2 perturbedSpeed = projVelocity.RotatedBy(MathHelper.ToRadians(i)); - Projectile.NewProjectile(projectile.Center, perturbedSpeed, projType, projDmg, projectile.knockBack * 0.8f, player.whoAmI, Main.rand.Next(3), 1f); - } + FireShotgun(whereIsTarget, 0.8f); } float chargeSpeed = 8f; projectile.velocity = whereIsTarget * chargeSpeed; @@ -391,6 +385,29 @@ namespace CalamityMod.Projectiles.Summon } } + private void FireShotgun(Vector2 whereIsTarget, float attackMult) + { + whereIsTarget.Normalize(); + float projSpeedMult = 3f; + int projType = pinkSeed; + if (Main.rand.NextBool(2) && CalamityUtils.CountProjectiles(sporeClouds) < 9) + { + projType = sporeClouds; + projSpeedMult = 10f; + } + else + { + projType = Main.rand.NextBool(2) ? greenSeed : pinkSeed; + } + int projDmg = (int)(projectile.damage * attackMult); + Vector2 projVelocity = whereIsTarget * projSpeedMult; + for (int i = -8; i <= 8; i += 8) + { + Vector2 perturbedSpeed = projVelocity.RotatedBy(MathHelper.ToRadians(i)); + Projectile.NewProjectile(projectile.Center, perturbedSpeed, projType, projDmg, projectile.knockBack * attackMult, projectile.owner, Main.rand.Next(3), 1f); + } + } + private void HandleRotation(bool targetFound, Vector2 whereIsTarget) { if (targetFound && !enraged) @@ -401,9 +418,6 @@ namespace CalamityMod.Projectiles.Summon { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi; } - /*if (enraged) - projectile.rotation = (whereIsTarget - projectile.Center).ToRotation() + MathHelper.Pi; - else*/ } private void Framing() @@ -442,6 +456,18 @@ namespace CalamityMod.Projectiles.Summon } } + private void SpawnTentacles() + { + if (projectile.owner == Main.myPlayer) + { + int tentacleAmt = 6; + for (int tentacleIndex = 0; tentacleIndex < tentacleAmt; tentacleIndex++) + { + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, tentacleIndex, Projectile.GetByUUID(projectile.owner, projectile.whoAmI)); + } + } + } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Poisoned, 300); @@ -455,5 +481,18 @@ namespace CalamityMod.Projectiles.Summon } public override bool CanDamage() => enraged; + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + int height = texture.Height / Main.projFrames[projectile.type]; + int frameHeight = height * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), projectile.scale, spriteEffects, 0f); + return false; + } } } diff --git a/Projectiles/Summon/PlantTentacle.cs b/Projectiles/Summon/PlantTentacle.cs new file mode 100644 index 0000000000..7764aeb626 --- /dev/null +++ b/Projectiles/Summon/PlantTentacle.cs @@ -0,0 +1,251 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class PlantTentacle : ModProjectile + { + private bool initialized = false; + private int counter = 0; + private float desiredDistance = 150f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tentacle"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 22; + projectile.height = 24; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 0f; + projectile.timeLeft = 18000; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft *= 5; + projectile.minion = true; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 12; + } + + public override void AI() + { + Player player = Main.player[projectile.owner]; + if (projectile.ai[1] < 0 || projectile.ai[1] >= Main.maxProjectiles) + { + projectile.Kill(); + return; + } + // If something has gone wrong with either the tentacle or the host plant, destroy the proj. + Projectile hostPlant = Main.projectile[(int)projectile.ai[1]]; + if (projectile.type != ModContent.ProjectileType() || !hostPlant.active || hostPlant.type != ModContent.ProjectileType()) + { + projectile.Kill(); + return; + } + + if (projectile.frameCounter++ % 6 == 0) + { + projectile.frame++; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } + + if (!initialized) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + initialized = true; + } + if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / + projectile.Calamity().spawnedPlayerMinionDamageValue * player.MinionDamage()); + projectile.damage = trueDamage; + } + + if (player.Calamity().plantera) + { + projectile.timeLeft = 2; + } + + projectile.rotation = (projectile.Center - hostPlant.Center).ToRotation() + MathHelper.Pi; + + projectile.MinionAntiClump(1f); + + counter++; + if (counter % 30 == 0) //changes every half second + { + desiredDistance = Main.rand.NextFloat(175f, 225f); + } + Vector2 targetPos = hostPlant.Center - projectile.Center; + float targetDist = targetPos.Length(); + targetPos.Normalize(); + if (targetDist > desiredDistance) + { + float speedMult = 10f; + speedMult += (targetDist - desiredDistance) * 0.2f; //+0.2f for every 1f away from the desired distance + targetPos *= speedMult; + projectile.velocity = (projectile.velocity * 40f + targetPos) / 41f; + } + else + { + float reverseSpeedMult = 5f; + targetPos *= -reverseSpeedMult; + projectile.velocity = (projectile.velocity * 40f + targetPos) / 41f; + } + + if (targetDist > 2000f) + { + projectile.position.X = hostPlant.Center.X - (float)(projectile.width / 2); + projectile.position.Y = hostPlant.Center.Y - (float)(projectile.height / 2); + projectile.netUpdate = true; + } + + if (projectile.ai[0] >= 3f) + { + if (hostPlant.Center.X - projectile.Center.X > 0) + { + projectile.velocity.X += 0.05f; + } + } + else + { + if (hostPlant.Center.X - projectile.Center.X < 0) + { + projectile.velocity.X -= 0.05f; + } + } + + if (projectile.ai[0] % 2f == 0f) + { + if (hostPlant.Center.Y - projectile.Center.Y > 0) + { + projectile.velocity.Y += 0.05f; + } + } + else + { + if (hostPlant.Center.Y - projectile.Center.Y < 0) + { + projectile.velocity.Y -= 0.05f; + } + } + } + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 10; i++) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, 107); + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.ai[1] < 0 || projectile.ai[1] >= Main.maxProjectiles) + { + return false; + } + + // If something has gone wrong with either the tentacle or the host plant, return. + Projectile hostPlant = Main.projectile[(int)projectile.ai[1]]; + if (projectile.type != ModContent.ProjectileType() || !hostPlant.active || hostPlant.type != ModContent.ProjectileType()) + { + return false; + } + + Vector2 source = hostPlant.Center; + Color transparent = Microsoft.Xna.Framework.Color.Transparent; + Texture2D chain = ModContent.GetTexture("CalamityMod/ExtraTextures/Chains/PlantationChain"); + Vector2 goal = projectile.Center; + Rectangle? sourceRectangle = null; + float textureHeight = (float)chain.Height; + Vector2 drawVector = source - goal; + float rotation = (float)Math.Atan2((double)drawVector.Y, (double)drawVector.X) - MathHelper.PiOver2; + bool shouldDraw = true; + if (float.IsNaN(goal.X) && float.IsNaN(goal.Y)) + { + shouldDraw = false; + } + if (float.IsNaN(drawVector.X) && float.IsNaN(drawVector.Y)) + { + shouldDraw = false; + } + while (shouldDraw) + { + if (drawVector.Length() < textureHeight + 1f) + { + shouldDraw = false; + } + else + { + Vector2 value2 = drawVector; + value2.Normalize(); + goal += value2 * textureHeight; + drawVector = source - goal; + Color color = Lighting.GetColor((int)goal.X / 16, (int)(goal.Y / 16f)); + Main.spriteBatch.Draw(chain, goal - Main.screenPosition, sourceRectangle, color, rotation, chain.Size() / 2f, 1f, SpriteEffects.None, 0f); + } + } + return true; + } + + //It draws the host plant in here in order to have it draw over the tentacles + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + //Only 1 tentacle needs to draw this, the last one spawned because it's latest in the projectile array. + if (projectile.ai[0] < 5) + { + return; + } + + if (projectile.ai[1] < 0 || projectile.ai[1] >= Main.maxProjectiles) + { + return; + } + + // If something has gone wrong with either the tentacle or the host plant, return. + Projectile hostPlant = Main.projectile[(int)projectile.ai[1]]; + if (projectile.type != ModContent.ProjectileType() || !hostPlant.active || hostPlant.type != ModContent.ProjectileType()) + { + return; + } + + Texture2D texture = Main.projectileTexture[hostPlant.type]; + int height = texture.Height / Main.projFrames[hostPlant.type]; + int frameHeight = height * hostPlant.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + if (hostPlant.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + Color color = Lighting.GetColor((int)hostPlant.Center.X / 16, (int)(hostPlant.Center.Y / 16f)); + + Main.spriteBatch.Draw(texture, hostPlant.Center - Main.screenPosition + new Vector2(0f, hostPlant.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), color, hostPlant.rotation, new Vector2((float)texture.Width / 2f, (float)height / 2f), hostPlant.scale, spriteEffects, 0f); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.Poisoned, 120); + target.AddBuff(BuffID.Venom, 120); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.Poisoned, 120); + target.AddBuff(BuffID.Venom, 120); + } + } +} diff --git a/Projectiles/Summon/PlantTentacle.png b/Projectiles/Summon/PlantTentacle.png new file mode 100644 index 0000000000..78dbdaa9f6 Binary files /dev/null and b/Projectiles/Summon/PlantTentacle.png differ diff --git a/Projectiles/Summon/PlantThornBall.cs b/Projectiles/Summon/PlantThornBall.cs index be0abf75a2..07f4c8293b 100644 --- a/Projectiles/Summon/PlantThornBall.cs +++ b/Projectiles/Summon/PlantThornBall.cs @@ -17,7 +17,6 @@ namespace CalamityMod.Projectiles.Summon { projectile.width = 30; projectile.height = 30; - projectile.scale = 0.75f; projectile.friendly = true; projectile.penetrate = 3; projectile.timeLeft = 300; diff --git a/Projectiles/Summon/PlantThornBall.png b/Projectiles/Summon/PlantThornBall.png index 2b5de4b6ae..b2ea5197ee 100644 Binary files a/Projectiles/Summon/PlantThornBall.png and b/Projectiles/Summon/PlantThornBall.png differ diff --git a/Projectiles/Summon/PrincessMissile.cs b/Projectiles/Summon/PrincessMissile.cs index aa74bc0fb1..ef67769255 100644 --- a/Projectiles/Summon/PrincessMissile.cs +++ b/Projectiles/Summon/PrincessMissile.cs @@ -61,13 +61,13 @@ namespace CalamityMod.Projectiles.Summon } else if (Main.rand.NextBool(4)) { - int num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 0.5f); + int num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 0.5f); Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].noGravity = true; Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default) * 1.1f; Main.rand.Next(2); - num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); + num252 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; Main.dust[num252].noGravity = true; Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default) * 1.1f; @@ -98,7 +98,7 @@ namespace CalamityMod.Projectiles.Summon Main.PlaySound(SoundID.Item14, projectile.position); for (int num621 = 0; num621 < 8; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -108,13 +108,13 @@ namespace CalamityMod.Projectiles.Summon } for (int num623 = 0; num623 < 10; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 89, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 89, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Summon/ProfanedEnergy.cs b/Projectiles/Summon/ProfanedEnergy.cs index 503059565f..a13f89d86e 100644 --- a/Projectiles/Summon/ProfanedEnergy.cs +++ b/Projectiles/Summon/ProfanedEnergy.cs @@ -106,7 +106,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag18) { for (int num512 = 0; num512 < Main.maxNPCs; num512++) { diff --git a/Projectiles/Summon/RadiantResolutionAura.cs b/Projectiles/Summon/RadiantResolutionAura.cs index 4c7a35c685..689d7c6820 100644 --- a/Projectiles/Summon/RadiantResolutionAura.cs +++ b/Projectiles/Summon/RadiantResolutionAura.cs @@ -36,10 +36,10 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { Lighting.AddLight(projectile.Center, 2f, 2f, 2f); - bool isCorrectProjectile = projectile.type == ModContent.ProjectileType(); Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); player.AddBuff(ModContent.BuffType(), 3600); + bool isCorrectProjectile = projectile.type == ModContent.ProjectileType(); if (isCorrectProjectile) { if (player.dead) @@ -72,8 +72,8 @@ namespace CalamityMod.Projectiles.Summon float allocatedSlots = projectile.ai[0]; projectile.rotation += MathHelper.ToRadians(3f) + MathHelper.ToRadians(allocatedSlots * 0.85f); - int radiantOrbDamage = (int)(projectile.damage * Math.Log(allocatedSlots + 1f, 1.75)); - int radiantOrbAppearRate = (int)(124 * Math.Pow(0.9, allocatedSlots)); + int radiantOrbDamage = (int)(projectile.damage * (Math.Log(allocatedSlots, 2.5) + 1f)); + int radiantOrbAppearRate = (int)(130 * Math.Pow(0.9, allocatedSlots)); if (radiantOrbAppearRate < 7) radiantOrbAppearRate = 7; @@ -87,9 +87,9 @@ namespace CalamityMod.Projectiles.Summon { if (projectile.ai[1] % 35 == 34) { - for (int i = 0; i < 3; i++) + for (int i = 0; i < 2; i++) { - float angle = MathHelper.Lerp(-MathHelper.ToRadians(30f), MathHelper.ToRadians(30f), i / 3f); + float angle = MathHelper.Lerp(-MathHelper.ToRadians(20f), MathHelper.ToRadians(20f), i / 2f); Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center).RotatedBy(angle) * 15f, ModContent.ProjectileType(), radiantOrbDamage / 2, projectile.knockBack, projectile.owner); } @@ -98,9 +98,9 @@ namespace CalamityMod.Projectiles.Summon { Projectile.NewProjectile(projectile.Center + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(100f, 360f), projectile.DirectionTo(potentialTarget.Center) * 2f, ModContent.ProjectileType(), radiantOrbDamage, projectile.knockBack * 4f, projectile.owner); - for (int i = 0; i < 4; i++) + for (int i = 0; i < 3; i++) { - float angle = MathHelper.Lerp(-MathHelper.ToRadians(40f), MathHelper.ToRadians(40f), i / 4f); + float angle = MathHelper.Lerp(-MathHelper.ToRadians(30f), MathHelper.ToRadians(30f), i / 3f); Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center).RotatedBy(angle) * 19f, ModContent.ProjectileType(), radiantOrbDamage / 2, projectile.knockBack, projectile.owner); } diff --git a/Projectiles/Summon/RadiantResolutionFire.cs b/Projectiles/Summon/RadiantResolutionFire.cs index e069758014..97f276bef3 100644 --- a/Projectiles/Summon/RadiantResolutionFire.cs +++ b/Projectiles/Summon/RadiantResolutionFire.cs @@ -15,15 +15,12 @@ namespace CalamityMod.Projectiles.Summon public override void SetDefaults() { - projectile.width = 10; - projectile.height = 10; + projectile.width = projectile.height = 10; projectile.friendly = true; - projectile.penetrate = 1; projectile.light = 1f; projectile.timeLeft = 300; projectile.minion = true; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 4; + projectile.tileCollide = false; } public override void AI() @@ -41,15 +38,13 @@ namespace CalamityMod.Projectiles.Summon public override void Kill(int timeLeft) { - projectile.position = projectile.Center; - projectile.width = projectile.height = 60; - projectile.position -= projectile.Size / 2f; - projectile.maxPenetrate = -1; - projectile.penetrate = -1; + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 60); + projectile.maxPenetrate = projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 5; + projectile.localNPCHitCooldown = 10; + projectile.damage /= 3; projectile.Damage(); - Main.PlaySound(SoundID.Item14, projectile.position); + Main.PlaySound(SoundID.Item14, projectile.Center); for (int i = 0; i < 20; i++) { Dust dust = Dust.NewDustPerfect(projectile.Center, (int)CalamityDusts.ProfanedFire); diff --git a/Projectiles/Summon/ReaverOrb.cs b/Projectiles/Summon/ReaverOrb.cs index d803995de9..9a8949e334 100644 --- a/Projectiles/Summon/ReaverOrb.cs +++ b/Projectiles/Summon/ReaverOrb.cs @@ -95,35 +95,28 @@ namespace CalamityMod.Projectiles.Summon projectile.ai[0] -= 1f; return; } - bool flag18 = false; - float num508 = 600f; - for (int num512 = 0; num512 < Main.maxNPCs; num512++) + bool foundTarget = false; + float maxDist = 600f; + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num512].CanBeChasedBy(projectile, false)) + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) { - float num513 = Main.npc[num512].position.X + (float)(Main.npc[num512].width / 2); - float num514 = Main.npc[num512].position.Y + (float)(Main.npc[num512].height / 2); - float num515 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num513) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num514); - if (num515 < num508 && Collision.CanHit(projectile.position, projectile.width, projectile.height, Main.npc[num512].position, Main.npc[num512].width, Main.npc[num512].height)) + if (Vector2.Distance(projectile.Center, npc.Center) < maxDist && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) { - num508 = num515; - flag18 = true; + foundTarget = true; + break; } } } - if (flag18) + if (foundTarget) { - int num251 = Main.rand.Next(4, 9); - for (int num252 = 0; num252 < num251; num252++) + int projAmt = Main.rand.Next(4, 9); + for (int u = 0; u < projAmt; u++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(90, 121) * 0.1f; - int spore = Projectile.NewProjectile(projectile.Center.X - 4f, projectile.Center.Y, value15.X, value15.Y, ProjectileID.SporeGas + Main.rand.Next(3), projectile.damage, 1.5f, projectile.owner, 0f, 0f); + Vector2 source = new Vector2(projectile.Center.X - 4f, projectile.Center.Y); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 90f, 120f); + int spore = Projectile.NewProjectile(source, velocity, ProjectileID.SporeGas + Main.rand.Next(3), projectile.damage, 1.5f, projectile.owner, 0f, 0f); Main.projectile[spore].minionSlots = 0f; Main.projectile[spore].Calamity().forceMinion = true; Main.projectile[spore].usesLocalNPCImmunity = true; diff --git a/Projectiles/Summon/SakuraBullet.cs b/Projectiles/Summon/SakuraBullet.cs index 13a6f07c97..06852ff327 100644 --- a/Projectiles/Summon/SakuraBullet.cs +++ b/Projectiles/Summon/SakuraBullet.cs @@ -51,7 +51,21 @@ namespace CalamityMod.Projectiles.Summon } } } - else + else if (projectile.ai[0] != -1f) + { + NPC npc = Main.npc[(int)projectile.ai[0]]; + if ((npc.CanBeChasedBy(projectile, false) || npc.type == NPCID.DukeFishron) && npc.active) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); + + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + center = npc.Center; + homeIn = true; + } + } + } + if (!homeIn) { for (int i = 0; i < Main.maxNPCs; i++) { diff --git a/Projectiles/Summon/SandElementalMinion.cs b/Projectiles/Summon/SandElementalMinion.cs index 36bc62dd9e..b9793548d7 100644 --- a/Projectiles/Summon/SandElementalMinion.cs +++ b/Projectiles/Summon/SandElementalMinion.cs @@ -117,7 +117,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag25) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { diff --git a/Projectiles/Summon/SandnadoMinion.cs b/Projectiles/Summon/SandnadoMinion.cs index 0e6118b2db..c39f019a34 100644 --- a/Projectiles/Summon/SandnadoMinion.cs +++ b/Projectiles/Summon/SandnadoMinion.cs @@ -115,7 +115,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag) { for (int k = 0; k < Main.maxNPCs; k++) { diff --git a/Projectiles/Summon/Shellfish.cs b/Projectiles/Summon/Shellfish.cs index 8f0f6249e4..06b00ba9bb 100644 --- a/Projectiles/Summon/Shellfish.cs +++ b/Projectiles/Summon/Shellfish.cs @@ -139,7 +139,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!chaseNPC) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { diff --git a/Projectiles/Summon/SilvaCrystal.cs b/Projectiles/Summon/SilvaCrystal.cs index c5282b01c8..b6261124df 100644 --- a/Projectiles/Summon/SilvaCrystal.cs +++ b/Projectiles/Summon/SilvaCrystal.cs @@ -67,19 +67,18 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2) + player.gfxOffY - 60f; + projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); if (player.gravDir == -1f) { - projectile.position.Y = projectile.position.Y + 120f; - projectile.rotation = 3.14f; + projectile.position.Y += 120f; + projectile.rotation = MathHelper.Pi; } else { projectile.rotation = 0f; } - projectile.position.X = (float)(int)projectile.position.X; - projectile.position.Y = (float)(int)projectile.position.Y; + projectile.position.X = (int)projectile.position.X; + projectile.position.Y = (int)projectile.position.Y; float num1072 = 1500f; projectile.velocity = Vector2.Zero; projectile.alpha -= 5; diff --git a/Projectiles/Summon/SiriusMinion.cs b/Projectiles/Summon/SiriusMinion.cs index 44c0368aaf..bbf4898f32 100644 --- a/Projectiles/Summon/SiriusMinion.cs +++ b/Projectiles/Summon/SiriusMinion.cs @@ -33,12 +33,11 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - Lighting.AddLight(projectile.Center, 1f, 0.5f, 5f); - bool flag64 = projectile.type == ModContent.ProjectileType(); Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) + + bool correctMinion = projectile.type == ModContent.ProjectileType(); + if (correctMinion) { if (player.dead) { @@ -49,41 +48,46 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } + player.AddBuff(ModContent.BuffType(), 3600); + projectile.minionSlots = projectile.ai[0]; - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2) + player.gfxOffY - 60f; + Lighting.AddLight(projectile.Center, 1f, 0.5f, 5f); + + projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); if (player.gravDir == -1f) { - projectile.position.Y = projectile.position.Y + 150f; - projectile.rotation = 3.14f; + projectile.position.Y += 120f; + projectile.rotation = MathHelper.Pi; } else { projectile.rotation = 0f; } - projectile.position.X = (float)(int)projectile.position.X; - projectile.position.Y = (float)(int)projectile.position.Y; - float num395 = (float)Main.mouseTextColor / 200f - 0.35f; - num395 *= 0.2f; - projectile.scale = num395 + 0.95f; + projectile.position.X = (int)projectile.position.X; + projectile.position.Y = (int)projectile.position.Y; + + float scalar = (float)Main.mouseTextColor / 200f - 0.35f; + scalar *= 0.2f; + projectile.scale = scalar + 0.95f; + if (projectile.localAI[0] == 0f) { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; - int num501 = 50; - for (int num502 = 0; num502 < num501; num502++) + int dustAmt = 50; + for (int d = 0; d < dustAmt; d++) { - int num503 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 16f), projectile.width, projectile.height - 16, 20, 0f, 0f, 0, default, 1f); - Main.dust[num503].velocity *= 2f; - Main.dust[num503].scale *= 1.15f; + int sirius = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 16f), projectile.width, projectile.height - 16, 20, 0f, 0f, 0, default, 1f); + Main.dust[sirius].velocity *= 2f; + Main.dust[sirius].scale *= 1.15f; } projectile.localAI[0] += 1f; } + if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / - projectile.Calamity().spawnedPlayerMinionDamageValue * - player.MinionDamage()); + projectile.Calamity().spawnedPlayerMinionDamageValue * player.MinionDamage()); projectile.damage = damage2; } if (projectile.owner == Main.myPlayer) @@ -93,57 +97,51 @@ namespace CalamityMod.Projectiles.Summon projectile.ai[1] -= 1f; return; } - float num396 = projectile.position.X; - float num397 = projectile.position.Y; - float minDistance = 7000f; - bool flag11 = false; + Vector2 targetVec = projectile.position; + float maxDistance = 7000f; + bool hasTarget = false; if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(projectile, false)) { - float num539 = npc.position.X + (float)(npc.width / 2); - float num540 = npc.position.Y + (float)(npc.height / 2); - float num541 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num539) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num540); - if (num541 < minDistance) - { - num396 = num539; - num397 = num540; - flag11 = true; + float extraDistance = (npc.width / 2) + (npc.height / 2); + + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + targetVec = npc.Center; + hasTarget = true; } } } - else + if (!hasTarget) { - for (int num399 = 0; num399 < Main.npc.Length; num399++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num399].CanBeChasedBy(projectile, false)) - { - float num400 = Main.npc[num399].position.X + (float)(Main.npc[num399].width / 2); - float num401 = Main.npc[num399].position.Y + (float)(Main.npc[num399].height / 2); - float num402 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num400) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num401); - if (num402 < minDistance) - { - minDistance = num402; - num396 = num400; - num397 = num401; - flag11 = true; - } - } + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) + { + float extraDistance = (npc.width / 2) + (npc.height / 2); + + if (Vector2.Distance(npc.Center, projectile.Center) < (maxDistance + extraDistance)) + { + targetVec = npc.Center; + hasTarget = true; + } + } } } - if (flag11) + if (hasTarget) { - float num403 = 15f; - Vector2 vector29 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num404 = num396 - vector29.X; - float num405 = num397 - vector29.Y; - float num406 = (float)Math.Sqrt((double)(num404 * num404 + num405 * num405)); - num406 = num403 / num406; - num404 *= num406; - num405 *= num406; + float projSpeed = 15f; + Vector2 source = new Vector2(projectile.Center.X - 4f, projectile.Center.Y); + Vector2 velocity = targetVec - projectile.Center; + float targetDist = velocity.Length(); + targetDist = projSpeed / targetDist; + velocity.X *= targetDist; + velocity.Y *= targetDist; float damageMult = ((float)Math.Log(projectile.ai[0], MathHelper.E)) + 1f; - int beam = Projectile.NewProjectile(projectile.Center.X - 4f, projectile.Center.Y, num404, num405, ModContent.ProjectileType(), (int)(projectile.damage * damageMult), projectile.knockBack, projectile.owner); + int beam = Projectile.NewProjectile(source, velocity, ModContent.ProjectileType(), (int)(projectile.damage * damageMult), projectile.knockBack, projectile.owner); Main.projectile[beam].penetrate = (int)projectile.ai[0]; projectile.ai[1] = 30f; } diff --git a/Projectiles/Summon/SolarGod.cs b/Projectiles/Summon/SolarGod.cs index f8ae893fd7..25edbb53b3 100644 --- a/Projectiles/Summon/SolarGod.cs +++ b/Projectiles/Summon/SolarGod.cs @@ -49,19 +49,18 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2) + player.gfxOffY - 60f; + projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); if (player.gravDir == -1f) { - projectile.position.Y = projectile.position.Y + 150f; - projectile.rotation = 3.14f; + projectile.position.Y += 120f; + projectile.rotation = MathHelper.Pi; } else { projectile.rotation = 0f; } - projectile.position.X = (float)(int)projectile.position.X; - projectile.position.Y = (float)(int)projectile.position.Y; + projectile.position.X = (int)projectile.position.X; + projectile.position.Y = (int)projectile.position.Y; float num395 = (float)Main.mouseTextColor / 200f - 0.35f; num395 *= 0.2f; projectile.scale = num395 + 0.95f; @@ -112,7 +111,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag11) { for (int num399 = 0; num399 < Main.maxNPCs; num399++) { diff --git a/Projectiles/Summon/SolarPixie.cs b/Projectiles/Summon/SolarPixie.cs index 307d0f1830..4a2288c4e2 100644 --- a/Projectiles/Summon/SolarPixie.cs +++ b/Projectiles/Summon/SolarPixie.cs @@ -49,19 +49,18 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2) + player.gfxOffY - 60f; + projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); if (player.gravDir == -1f) { - projectile.position.Y = projectile.position.Y + 140f; - projectile.rotation = 3.14f; + projectile.position.Y += 120f; + projectile.rotation = MathHelper.Pi; } else { projectile.rotation = 0f; } - projectile.position.X = (float)(int)projectile.position.X; - projectile.position.Y = (float)(int)projectile.position.Y; + projectile.position.X = (int)projectile.position.X; + projectile.position.Y = (int)projectile.position.Y; float num395 = (float)Main.mouseTextColor / 200f - 0.35f; num395 *= 0.2f; projectile.scale = num395 + 0.95f; @@ -112,7 +111,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag11) { for (int num399 = 0; num399 < Main.maxNPCs; num399++) { diff --git a/Projectiles/Summon/Spikecrag.cs b/Projectiles/Summon/Spikecrag.cs index c047fb1e4f..c211265560 100644 --- a/Projectiles/Summon/Spikecrag.cs +++ b/Projectiles/Summon/Spikecrag.cs @@ -78,6 +78,7 @@ namespace CalamityMod.Projectiles.Summon if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance)) { homeIn = true; + break; } } } diff --git a/Projectiles/Summon/Urchin.cs b/Projectiles/Summon/Urchin.cs index 225bfe34ea..930f055101 100644 --- a/Projectiles/Summon/Urchin.cs +++ b/Projectiles/Summon/Urchin.cs @@ -34,7 +34,6 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { - bool flag64 = projectile.type == ModContent.ProjectileType(); Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); if (!modPlayer.urchin) @@ -42,7 +41,8 @@ namespace CalamityMod.Projectiles.Summon projectile.active = false; return; } - if (flag64) + bool correctMinion = projectile.type == ModContent.ProjectileType(); + if (correctMinion) { if (player.dead) { @@ -58,12 +58,12 @@ namespace CalamityMod.Projectiles.Summon { projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; - int num501 = 50; - for (int num502 = 0; num502 < num501; num502++) + int dustAmt = 50; + for (int d = 0; d < dustAmt; d++) { - int num503 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 16f), projectile.width, projectile.height - 16, 179, 0f, 0f, 0, default, 1f); - Main.dust[num503].velocity *= 2f; - Main.dust[num503].scale *= 1.15f; + int index = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 16f), projectile.width, projectile.height - 16, 179, 0f, 0f, 0, default, 1f); + Main.dust[index].velocity *= 2f; + Main.dust[index].scale *= 1.15f; } } if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) @@ -73,22 +73,21 @@ namespace CalamityMod.Projectiles.Summon player.MinionDamage()); projectile.damage = damage2; } - float num395 = (float)Main.mouseTextColor / 200f - 0.35f; - num395 *= 0.2f; - projectile.scale = num395 + 0.95f; - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2) + player.gfxOffY - 60f; + float scalar = (float)Main.mouseTextColor / 200f - 0.35f; + scalar *= 0.2f; + projectile.scale = scalar + 0.95f; + projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); if (player.gravDir == -1f) { - projectile.position.Y = projectile.position.Y + 120f; - projectile.rotation = 3.14f; + projectile.position.Y += 120f; + projectile.rotation = MathHelper.Pi; } else { projectile.rotation = 0f; } - projectile.position.X = (float)(int)projectile.position.X; - projectile.position.Y = (float)(int)projectile.position.Y; + projectile.position.X = (int)projectile.position.X; + projectile.position.Y = (int)projectile.position.Y; if (projectile.owner == Main.myPlayer) { if (projectile.ai[0] != 0f) @@ -96,35 +95,28 @@ namespace CalamityMod.Projectiles.Summon projectile.ai[0] -= 1f; return; } - bool flag18 = false; - float num508 = 300f; - for (int num512 = 0; num512 < Main.maxNPCs; num512++) + bool foundTarget = false; + float maxDist = 300f; + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[num512].CanBeChasedBy(projectile, false)) + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) { - float num513 = Main.npc[num512].position.X + (float)(Main.npc[num512].width / 2); - float num514 = Main.npc[num512].position.Y + (float)(Main.npc[num512].height / 2); - float num515 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num513) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num514); - if (num515 < num508 && Collision.CanHit(projectile.position, projectile.width, projectile.height, Main.npc[num512].position, Main.npc[num512].width, Main.npc[num512].height)) + if (Vector2.Distance(projectile.Center, npc.Center) < maxDist && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) { - num508 = num515; - flag18 = true; + foundTarget = true; + break; } } } - if (flag18) + if (foundTarget) { - int num251 = Main.rand.Next(3, 7); - for (int num252 = 0; num252 < num251; num252++) + int projAmt = Main.rand.Next(3, 7); + for (int u = 0; u < projAmt; u++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - int spore = Projectile.NewProjectile(projectile.Center.X - 4f, projectile.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), projectile.damage, 1f, projectile.owner, 0f, 0f); + Vector2 source = new Vector2(projectile.Center.X - 4f, projectile.Center.Y); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int spore = Projectile.NewProjectile(source, velocity, ModContent.ProjectileType(), projectile.damage, 1f, projectile.owner, 0f, 0f); Main.projectile[spore].minion = true; Main.projectile[spore].minionSlots = 0f; } diff --git a/Projectiles/Summon/VileFeederProjectile.cs b/Projectiles/Summon/VileFeederProjectile.cs index 1cc1503570..320bb5d722 100644 --- a/Projectiles/Summon/VileFeederProjectile.cs +++ b/Projectiles/Summon/VileFeederProjectile.cs @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag10) { for (int num376 = 0; num376 < Main.maxNPCs; num376++) { diff --git a/Projectiles/Summon/VileFeederSummon.cs b/Projectiles/Summon/VileFeederSummon.cs index f226988dca..01428ee118 100644 --- a/Projectiles/Summon/VileFeederSummon.cs +++ b/Projectiles/Summon/VileFeederSummon.cs @@ -143,7 +143,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!targetFound) { for (int num645 = 0; num645 < Main.maxNPCs; num645++) { diff --git a/Projectiles/Summon/WaterElementalMinion.cs b/Projectiles/Summon/WaterElementalMinion.cs index dae844025d..eb5b6d05b0 100644 --- a/Projectiles/Summon/WaterElementalMinion.cs +++ b/Projectiles/Summon/WaterElementalMinion.cs @@ -128,7 +128,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else + if (!flag18) { for (int num512 = 0; num512 < Main.maxNPCs; num512++) { diff --git a/Projectiles/Typeless/GodSlayerShrapnelRound.cs b/Projectiles/Typeless/GodSlayerShrapnelRound.cs index c5384e4247..622dcfeb94 100644 --- a/Projectiles/Typeless/GodSlayerShrapnelRound.cs +++ b/Projectiles/Typeless/GodSlayerShrapnelRound.cs @@ -28,12 +28,12 @@ namespace CalamityMod.Projectiles.Typeless Main.PlaySound(SoundID.Item73, projectile.position); projectile.localAI[0] += 1f; } - for (int num457 = 0; num457 < 3; num457++) + for (int d = 0; d < 3; d++) { - int num458 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 173, 0f, 0f, 100, default, 1.2f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += projectile.velocity * 0.1f; + int cosmilite = Dust.NewDust(projectile.position, projectile.width, projectile.height, 173, 0f, 0f, 100, default, 1.2f); + Main.dust[cosmilite].noGravity = true; + Main.dust[cosmilite].velocity *= 0.5f; + Main.dust[cosmilite].velocity += projectile.velocity * 0.1f; } } @@ -41,17 +41,11 @@ namespace CalamityMod.Projectiles.Typeless { if (projectile.owner == Main.myPlayer) { - int num251 = Main.rand.Next(4, 7); - for (int num252 = 0; num252 < num251; num252++) + int shrapnelAmt = Main.rand.Next(4, 7); + for (int s = 0; s < shrapnelAmt; s++) { - Vector2 value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (value15.X == 0f && value15.Y == 0f) - { - value15 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - value15.Normalize(); - value15 *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(projectile.oldPosition.X + (float)(projectile.width / 2), projectile.oldPosition.Y + (float)(projectile.height / 2), value15.X, value15.Y, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.3), 0f, projectile.owner, 0f, 0f); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 0f, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Typeless/NebulaStar.cs b/Projectiles/Typeless/NebulaStar.cs index a2d726d91e..a21ec81a21 100644 --- a/Projectiles/Typeless/NebulaStar.cs +++ b/Projectiles/Typeless/NebulaStar.cs @@ -5,188 +5,42 @@ using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class NebulaStar : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Star"); - } + public class NebulaStar : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Star"); + } - public override void SetDefaults() - { - projectile.width = 34; - projectile.height = 34; - projectile.friendly = true; - projectile.alpha = 255; - projectile.penetrate = 1; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.timeLeft = 3600; - } + public override void SetDefaults() + { + projectile.width = projectile.height = 34; + projectile.friendly = true; + projectile.alpha = 255; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 3600; + } - public override void AI() - { - float num944 = 1f - (float)projectile.alpha / 255f; - num944 *= projectile.scale; - Lighting.AddLight(projectile.Center, 0.25f * num944, 0.025f * num944, 0.275f * num944); - projectile.localAI[0] += 1f; - if (projectile.localAI[0] >= 90f) - { - projectile.localAI[0] *= -1f; - } - if (projectile.localAI[0] >= 0f) - { - projectile.scale += 0.003f; - } - else - { - projectile.scale -= 0.003f; - } - projectile.rotation += 0.0025f * projectile.scale; - float num945 = 1f; - float num946 = 1f; - if (projectile.identity % 6 == 0) - { - num946 *= -1f; - } - if (projectile.identity % 6 == 1) - { - num945 *= -1f; - } - if (projectile.identity % 6 == 2) - { - num946 *= -1f; - num945 *= -1f; - } - if (projectile.identity % 6 == 3) - { - num946 = 0f; - } - if (projectile.identity % 6 == 4) - { - num945 = 0f; - } - projectile.localAI[1] += 1f; - if (projectile.localAI[1] > 60f) - { - projectile.localAI[1] = -180f; - } - if (projectile.localAI[1] >= -60f) - { - projectile.velocity.X = projectile.velocity.X + 0.002f * num946; - projectile.velocity.Y = projectile.velocity.Y + 0.002f * num945; - } - else - { - projectile.velocity.X = projectile.velocity.X - 0.002f * num946; - projectile.velocity.Y = projectile.velocity.Y - 0.002f * num945; - } - projectile.ai[0] += 1f; - if (projectile.ai[0] > 5400f) - { - projectile.damage = 0; - projectile.ai[1] = 1f; - if (projectile.alpha < 255) - { - projectile.alpha += 5; - if (projectile.alpha > 255) - { - projectile.alpha = 255; - } - } - else if (projectile.owner == Main.myPlayer) - { - projectile.Kill(); - } - } - else - { - float num947 = (projectile.Center - Main.player[projectile.owner].Center).Length() / 100f; - if (num947 > 4f) - { - num947 *= 1.1f; - } - if (num947 > 5f) - { - num947 *= 1.2f; - } - if (num947 > 6f) - { - num947 *= 1.3f; - } - if (num947 > 7f) - { - num947 *= 1.4f; - } - if (num947 > 8f) - { - num947 *= 1.5f; - } - if (num947 > 9f) - { - num947 *= 1.6f; - } - if (num947 > 10f) - { - num947 *= 1.7f; - } - projectile.ai[0] += num947; - if (projectile.alpha > 50) - { - projectile.alpha -= 10; - if (projectile.alpha < 50) - { - projectile.alpha = 50; - } - } - } - bool flag49 = false; - Vector2 center12 = new Vector2(0f, 0f); - float num948 = 600f; - for (int num949 = 0; num949 < Main.maxNPCs; num949++) - { - if (Main.npc[num949].CanBeChasedBy(projectile, false)) - { - float num950 = Main.npc[num949].position.X + (float)(Main.npc[num949].width / 2); - float num951 = Main.npc[num949].position.Y + (float)(Main.npc[num949].height / 2); - float num952 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num950) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num951); - if (num952 < num948) - { - num948 = num952; - center12 = Main.npc[num949].Center; - flag49 = true; - } - } - } - if (flag49) - { - Vector2 vector101 = center12 - projectile.Center; - vector101.Normalize(); - vector101 *= 0.75f; - projectile.velocity = (projectile.velocity * 10f + vector101) / 11f; - return; - } - if ((double)projectile.velocity.Length() > 0.2) - { - projectile.velocity *= 0.98f; - } - } + public override void AI() + { + projectile.SporeSacAI(); + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (projectile.owner == Main.myPlayer && projectile.ai[1] == 0f) - { - Vector2 value10 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - value10.Normalize(); - value10 *= 0.3f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value10.X, value10.Y, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 0f, 0f); - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (projectile.owner == Main.myPlayer && projectile.ai[1] == 0f) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 1f, 1f, 0.3f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 0f, 0f); + } + } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) - { - Rectangle frame = new Rectangle(0, 0, Main.projectileTexture[projectile.type].Width, Main.projectileTexture[projectile.type].Height); - spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Typeless/NebulaStarGlow"), projectile.Center - Main.screenPosition, frame, Color.White, projectile.rotation, projectile.Size / 2, 1f, SpriteEffects.None, 0f); - } - } + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Rectangle frame = new Rectangle(0, 0, Main.projectileTexture[projectile.type].Width, Main.projectileTexture[projectile.type].Height); + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Typeless/NebulaStarGlow"), projectile.Center - Main.screenPosition, frame, Color.White, projectile.rotation, projectile.Size / 2, 1f, SpriteEffects.None, 0f); + } + } } diff --git a/Projectiles/Typeless/OmegaBlueTentacle.cs b/Projectiles/Typeless/OmegaBlueTentacle.cs index c855387dae..24bdf104aa 100644 --- a/Projectiles/Typeless/OmegaBlueTentacle.cs +++ b/Projectiles/Typeless/OmegaBlueTentacle.cs @@ -232,8 +232,8 @@ namespace CalamityMod.Projectiles.Typeless public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp/*.PointWrap*/, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); GameShaders.Armor.ApplySecondary(Main.player[projectile.owner].cBody, Main.player[projectile.owner], new DrawData?()); projectile.rotation = (projectile.Center - segment[5]).ToRotation(); @@ -245,8 +245,8 @@ namespace CalamityMod.Projectiles.Typeless } Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), texture2D13.Bounds, projectile.GetAlpha(lightColor), projectile.rotation, texture2D13.Bounds.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix); + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); return false; } } diff --git a/Projectiles/Typeless/ReaverSpore.cs b/Projectiles/Typeless/ReaverSpore.cs new file mode 100644 index 0000000000..fb2d03a80c --- /dev/null +++ b/Projectiles/Typeless/ReaverSpore.cs @@ -0,0 +1,68 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class ReaverSpore : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Spore"); + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 16; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.alpha = 255; + projectile.timeLeft = 3600; + projectile.tileCollide = false; + projectile.ignoreWater = true; + } + + public override void AI() + { + projectile.SporeSacAI(); + } + + public override void Kill(int timeLeft) + { + if (projectile.owner == Main.myPlayer) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 1f, 1f, 0.3f); + int gas = Projectile.NewProjectile(projectile.Center, velocity, ProjectileID.SporeGas + Main.rand.Next(3), projectile.damage, 0f, projectile.owner); + Main.projectile[gas].usesLocalNPCImmunity = true; + Main.projectile[gas].localNPCHitCooldown = 30; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture; + switch (projectile.ai[0]) + { + case 1f: texture = ModContent.GetTexture("CalamityMod/Projectiles/Typeless/ReaverSpore2"); + break; + default: texture = Main.projectileTexture[projectile.type]; + break; + } + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, texture.Height / 2f), projectile.scale, SpriteEffects.None, 0f); + return false; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.Poisoned, 60 * Main.rand.Next(5, 11)); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.Poisoned, 60 * Main.rand.Next(5, 11)); + } + } +} diff --git a/Projectiles/Typeless/ReaverSpore.png b/Projectiles/Typeless/ReaverSpore.png new file mode 100644 index 0000000000..02c53c1a78 Binary files /dev/null and b/Projectiles/Typeless/ReaverSpore.png differ diff --git a/Projectiles/Typeless/ReaverSpore2.png b/Projectiles/Typeless/ReaverSpore2.png new file mode 100644 index 0000000000..235e4f51cc Binary files /dev/null and b/Projectiles/Typeless/ReaverSpore2.png differ diff --git a/Projectiles/Typeless/SkyFlareFriendly.cs b/Projectiles/Typeless/SkyFlareFriendly.cs index 818f5d7898..185f408433 100644 --- a/Projectiles/Typeless/SkyFlareFriendly.cs +++ b/Projectiles/Typeless/SkyFlareFriendly.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Typeless projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); for (int num621 = 0; num621 < 4; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -71,13 +71,13 @@ namespace CalamityMod.Projectiles.Typeless } for (int num623 = 0; num623 < 12; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - projectile.ExplosionGores(3); + CalamityUtils.ExplosionGores(projectile.Center, 3); } } } diff --git a/Projectiles/Typeless/TheDeadlyMicrobeProjectile.cs b/Projectiles/Typeless/TheDeadlyMicrobeProjectile.cs index 2882484679..f4815e83ce 100644 --- a/Projectiles/Typeless/TheDeadlyMicrobeProjectile.cs +++ b/Projectiles/Typeless/TheDeadlyMicrobeProjectile.cs @@ -6,201 +6,56 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { - public class TheDeadlyMicrobeProjectile : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Star"); - } - - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.friendly = true; - projectile.alpha = 255; - projectile.penetrate = 1; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.timeLeft = 3600; - } - - public override void AI() - { - float num944 = 1f - (float)projectile.alpha / 255f; - num944 *= projectile.scale; - Lighting.AddLight(projectile.Center, 0.25f * num944, 0.025f * num944, 0.275f * num944); - projectile.localAI[0] += 1f; - if (projectile.localAI[0] >= 90f) - { - projectile.localAI[0] *= -1f; - } - if (projectile.localAI[0] >= 0f) - { - projectile.scale += 0.003f; - } - else - { - projectile.scale -= 0.003f; - } - projectile.rotation += 0.0025f * projectile.scale; - float num945 = 1f; - float num946 = 1f; - if (projectile.identity % 6 == 0) - { - num946 *= -1f; - } - if (projectile.identity % 6 == 1) - { - num945 *= -1f; - } - if (projectile.identity % 6 == 2) - { - num946 *= -1f; - num945 *= -1f; - } - if (projectile.identity % 6 == 3) - { - num946 = 0f; - } - if (projectile.identity % 6 == 4) - { - num945 = 0f; - } - projectile.localAI[1] += 1f; - if (projectile.localAI[1] > 60f) - { - projectile.localAI[1] = -180f; - } - if (projectile.localAI[1] >= -60f) - { - projectile.velocity.X = projectile.velocity.X + 0.002f * num946; - projectile.velocity.Y = projectile.velocity.Y + 0.002f * num945; - } - else - { - projectile.velocity.X = projectile.velocity.X - 0.002f * num946; - projectile.velocity.Y = projectile.velocity.Y - 0.002f * num945; - } - projectile.ai[0] += 1f; - if (projectile.ai[0] > 5400f) - { - projectile.damage = 0; - projectile.ai[1] = 1f; - if (projectile.alpha < 255) - { - projectile.alpha += 5; - if (projectile.alpha > 255) - { - projectile.alpha = 255; - } - } - else if (projectile.owner == Main.myPlayer) - { - projectile.Kill(); - } - } - else - { - float num947 = (projectile.Center - Main.player[projectile.owner].Center).Length() / 100f; - if (num947 > 4f) - { - num947 *= 1.1f; - } - if (num947 > 5f) - { - num947 *= 1.2f; - } - if (num947 > 6f) - { - num947 *= 1.3f; - } - if (num947 > 7f) - { - num947 *= 1.4f; - } - if (num947 > 8f) - { - num947 *= 1.5f; - } - if (num947 > 9f) - { - num947 *= 1.6f; - } - if (num947 > 10f) - { - num947 *= 1.7f; - } - projectile.ai[0] += num947; - if (projectile.alpha > 50) - { - projectile.alpha -= 10; - if (projectile.alpha < 50) - { - projectile.alpha = 50; - } - } - } - bool flag49 = false; - Vector2 center12 = new Vector2(0f, 0f); - float num948 = 600f; - for (int num949 = 0; num949 < 200; num949++) - { - if (Main.npc[num949].CanBeChasedBy(projectile, false)) - { - float num950 = Main.npc[num949].position.X + (float)(Main.npc[num949].width / 2); - float num951 = Main.npc[num949].position.Y + (float)(Main.npc[num949].height / 2); - float num952 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num950) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num951); - if (num952 < num948) - { - num948 = num952; - center12 = Main.npc[num949].Center; - flag49 = true; - } - } - } - if (flag49) - { - Vector2 vector101 = center12 - projectile.Center; - vector101.Normalize(); - vector101 *= 0.75f; - projectile.velocity = (projectile.velocity * 10f + vector101) / 11f; - return; - } - if ((double)projectile.velocity.Length() > 0.2) - { - projectile.velocity *= 0.98f; - } - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.CursedInferno, 90); - } - - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.CursedInferno, 90); + public class TheDeadlyMicrobeProjectile : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Microbe"); } - public override void Kill(int timeLeft) - { - projectile.position = projectile.Center; - projectile.width = projectile.height = 56; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) - { - Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + projectile.Center; - Vector2 vector7 = vector6 - projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 44, vector7.X, vector7.Y, 100, default, 0.5f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; - } - projectile.Damage(); - } - } + public override void SetDefaults() + { + projectile.width = projectile.height = 14; + projectile.friendly = true; + projectile.alpha = 255; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 3600; + } + + public override void AI() + { + projectile.SporeSacAI(); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.CursedInferno, 90); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.CursedInferno, 90); + } + + public override void Kill(int timeLeft) + { + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 56); + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + int dustAmt = 36; + for (int d = 0; d < dustAmt; d++) + { + Vector2 source = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; + source = source.RotatedBy((double)((float)(d - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + projectile.Center; + Vector2 dustVel = source - projectile.Center; + int index = Dust.NewDust(source + dustVel, 0, 0, 44, dustVel.X, dustVel.Y, 100, default, 0.5f); + Main.dust[index].noGravity = true; + Main.dust[index].noLight = true; + Main.dust[index].velocity = dustVel; + } + projectile.Damage(); + } + } } diff --git a/Schematics/TilePlacementHelpers.cs b/Schematics/TilePlacementHelpers.cs index 4cdfc17fee..490eb7c518 100644 --- a/Schematics/TilePlacementHelpers.cs +++ b/Schematics/TilePlacementHelpers.cs @@ -49,6 +49,20 @@ namespace CalamityMod.Schematics yOffset += tiles.GetLength(1); break; } + ushort[,] oldWalls = new ushort[tiles.GetLength(0), tiles.GetLength(1)]; + for (int x = 0; x < tiles.GetLength(0); x++) + { + for (int y = 0; y < tiles.GetLength(1); y++) + { + Tile tile = Main.tile[x + xOffset, y + yOffset]; + oldWalls[x, y] = tile.wall; + + // Attempting to break chests causes the game to attempt to infinitely recurse in an attempt to break the tile, resulting in a stack overflow. + if (tile.type == TileID.Containers) + continue; + WorldGen.KillTile(x + xOffset, y + yOffset); + } + } for (int x = 0; x < tiles.GetLength(0); x++) { for (int y = 0; y < tiles.GetLength(1); y++) @@ -68,13 +82,12 @@ namespace CalamityMod.Schematics } } - ushort oldWall = Main.tile[x + xOffset, y + yOffset].wall; Main.tile[x + xOffset, y + yOffset] = (Tile)tiles[x, y].Clone(); // If specified, preserve walls if they're not not being overrided and there's no active tile in its place. - if (preserveWalls && Main.tile[x + xOffset, y + yOffset].wall == 0 && !Main.tile[x + xOffset, y + yOffset].active()) + if (preserveWalls && oldWalls[x, y] != 0) { - Main.tile[x + xOffset, y + yOffset].wall = oldWall; + Main.tile[x + xOffset, y + yOffset].wall = oldWalls[x, y]; } Rectangle placeInArea = new Rectangle(x, y, tiles.GetLength(0), tiles.GetLength(1)); diff --git a/Tiles/Astral/AstralBeacon.cs b/Tiles/Astral/AstralBeacon.cs index 34739c94f5..44369421e9 100644 --- a/Tiles/Astral/AstralBeacon.cs +++ b/Tiles/Astral/AstralBeacon.cs @@ -64,16 +64,6 @@ namespace CalamityMod.Tiles.Astral bool usingStarcore = Main.LocalPlayer.HasItem(ModContent.ItemType()); - if (!NPC.downedAncientCultist) - { - string localizationKey = "Mods.CalamityMod.DeusAltarRejectText"; - if (Main.netMode == NetmodeID.SinglePlayer) - Main.NewText(Language.GetTextValue(localizationKey), FailColor); - else if (Main.netMode == NetmodeID.Server) - NetMessage.BroadcastChatMessage(NetworkText.FromKey(localizationKey), FailColor); - return true; - } - if (Main.dayTime) { string localizationKey = "Mods.CalamityMod.DeusAltarRejectNightText"; diff --git a/Tiles/DraedonFactoryFieldGenerator.cs b/Tiles/DraedonFactoryFieldGenerator.cs index 7057fd8fb7..1ef04a2e0c 100644 --- a/Tiles/DraedonFactoryFieldGenerator.cs +++ b/Tiles/DraedonFactoryFieldGenerator.cs @@ -24,8 +24,9 @@ namespace CalamityMod.Tiles ModTranslation name = CreateMapEntryName(); name.SetDefault("Field Generator"); AddMapEntry(new Color(53, 49, 52), name); - minPick = 190; + minPick = 65; } + public TEDraedonFieldGenerator RetrieveTileEntity(int i, int j) { int determinedID = ModContent.GetInstance().Find(i, j); @@ -41,15 +42,20 @@ namespace CalamityMod.Tiles } return (TEDraedonFieldGenerator)TileEntity.ByID[determinedID]; } + + public override bool CanExplode(int i, int j) => false; + public override bool CreateDust(int i, int j, ref int type) { Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 226); return false; } + public override void NumDust(int i, int j, bool fail, ref int num) { num = fail ? 1 : 3; } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { TEDraedonFieldGenerator charger = RetrieveTileEntity(i, j); diff --git a/Tiles/DraedonTurretTile.cs b/Tiles/DraedonTurretTile.cs index 177098f5b7..f0e44dd1c4 100644 --- a/Tiles/DraedonTurretTile.cs +++ b/Tiles/DraedonTurretTile.cs @@ -29,9 +29,11 @@ namespace CalamityMod.Tiles AddMapEntry(new Color(67, 72, 81), name); soundType = SoundID.Item; soundStyle = 14; - minPick = 100; + minPick = 65; } + public override bool CanExplode(int i, int j) => false; + public TEDraedonTurret RetrieveTileEntity(int i, int j) { int left = i - Main.tile[i, j].frameX % (Width * 18) / 18; diff --git a/Tiles/MonsterBanner.cs b/Tiles/MonsterBanner.cs index badcf2fa13..b7b751bb1e 100644 --- a/Tiles/MonsterBanner.cs +++ b/Tiles/MonsterBanner.cs @@ -404,6 +404,18 @@ namespace CalamityMod.Tiles case 122: item = "GammaSlimeBanner"; break; + case 123: + item = "WulfrumGyratorBanner"; + break; + case 124: + item = "WulfrumHovercraftBanner"; + break; + case 125: + item = "WulfrumRoverBanner"; + break; + case 126: + item = "WulfrumPylonBanner"; + break; default: return; } @@ -791,6 +803,18 @@ namespace CalamityMod.Tiles case 122: type = "GammaSlime"; break; + case 123: + type = "WulfrumGyrator"; + break; + case 124: + type = "WulfrumHovercraft"; + break; + case 125: + type = "WulfrumRover"; + break; + case 126: + type = "WulfrumPylon"; + break; default: return; } diff --git a/Tiles/MonsterBanner.png b/Tiles/MonsterBanner.png index c5f9a41f24..c458c2b7fa 100644 Binary files a/Tiles/MonsterBanner.png and b/Tiles/MonsterBanner.png differ diff --git a/UI/DraedonsLogUI.cs b/UI/DraedonsLogUI.cs index d85bc3492a..effde96590 100644 --- a/UI/DraedonsLogUI.cs +++ b/UI/DraedonsLogUI.cs @@ -13,7 +13,7 @@ namespace CalamityMod.UI public int Page = 0; public int ArrowClickCooldown; public bool HoveringOverBook = false; - public const int TotalLinesPerPage = 16; + public int TotalLinesPerPage => (int)Math.Ceiling(16 * Main.screenHeight / 1440f - 1); public const int TextStartOffsetX = 40; public override void Update() { @@ -44,6 +44,8 @@ namespace CalamityMod.UI Vector2 scale = new Vector2(xScale, 1f) * new Vector2(Main.screenWidth, Main.screenHeight) / pageTexture.Size(); scale *= 0.5f; + float xResolutionScale = Main.screenWidth / 2560f; + float yResolutionScale = Main.screenHeight / 1440f; float bookScale = 0.75f; scale *= bookScale; @@ -69,24 +71,38 @@ namespace CalamityMod.UI } } - string placeholderText = "This is placeholder text. Yell at the lore writers to make something for this that pertains to Draedon and Co."; + string placeholderText = "A GOD DOES NOT FEAR DEATH "; + for (int i = 0; i < 7; i++) + { + placeholderText += placeholderText; + } // Create text and arrows. if (FadeTime >= FadeTimeMax - 4 && Active) { int textWidth = (int)(xScale * 2 * pageTexture.Width) - TextStartOffsetX; - textWidth = (int)(textWidth * Main.screenWidth / 2560f); + textWidth = (int)(textWidth * xResolutionScale); List dialogLines = Utils.WordwrapString(placeholderText, Main.fontMouseText, textWidth, 250, out _).ToList(); dialogLines.RemoveAll(text => string.IsNullOrEmpty(text)); int totalPages = dialogLines.Count / (TotalLinesPerPage * 2 + 2); + // Ensure the page number doesn't become nonsensical as a result of a resolution change (such as by resizing the game). + if (Page < 0) + Page = 0; + if (Page > totalPages) + Page = totalPages; + // Draw arrows. if (Page > 0) { Texture2D pageArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/DraedonsLogArrow"); - Vector2 bottomLeft = new Vector2(Main.screenWidth / 2 - pageTexture.Width * 2 - 36, yPageTop + pageTexture.Height + 32); + Vector2 offset = new Vector2(-(int)(pageTexture.Width * xResolutionScale) * 2 - (int)(36 * xResolutionScale), (int)(pageTexture.Height * yResolutionScale) + (int)(52 * yResolutionScale)); + Vector2 bottomLeft = new Vector2(Main.screenWidth / 2, yPageTop); + bottomLeft += offset; Rectangle arrowRectangle = new Rectangle((int)bottomLeft.X, (int)bottomLeft.Y, pageArrowTexture.Width, pageArrowTexture.Height); + arrowRectangle.Width = (int)(arrowRectangle.Width * xResolutionScale); + arrowRectangle.Height = (int)(arrowRectangle.Height * yResolutionScale); if (mouseRectangle.Intersects(arrowRectangle)) { pageArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/DraedonsLogArrowHover"); @@ -104,15 +120,19 @@ namespace CalamityMod.UI Color.White, 0f, Vector2.Zero, - 1f, + new Vector2(xResolutionScale, yResolutionScale), SpriteEffects.FlipHorizontally, 0f); } if (Page < totalPages) { Texture2D pageArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/DraedonsLogArrow"); - Vector2 bottomRight = new Vector2(Main.screenWidth / 2 + pageTexture.Width * 2 + 10, yPageTop + pageTexture.Height + 32); - Rectangle arrowRectangle = new Rectangle((int)bottomRight.X, (int)bottomRight.Y, pageArrowTexture.Width, pageArrowTexture.Height); + Vector2 offset = new Vector2((int)(pageTexture.Width * xResolutionScale) * 2 + (int)(10 * xResolutionScale), (int)(pageTexture.Height * yResolutionScale) + (int)(52 * yResolutionScale)); + Vector2 bottomRight = new Vector2(Main.screenWidth / 2, yPageTop); + bottomRight += offset; + Rectangle arrowRectangle = new Rectangle((int)bottomRight.X, (int)bottomRight.Y, pageArrowTexture.Width, pageArrowTexture.Height); ; + arrowRectangle.Width = (int)(arrowRectangle.Width * xResolutionScale); + arrowRectangle.Height = (int)(arrowRectangle.Height * yResolutionScale); if (mouseRectangle.Intersects(arrowRectangle)) { pageArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/DraedonsLogArrowHover"); @@ -130,7 +150,7 @@ namespace CalamityMod.UI Color.White, 0f, Vector2.Zero, - 1f, + new Vector2(xResolutionScale, yResolutionScale), SpriteEffects.None, 0f); } @@ -144,12 +164,12 @@ namespace CalamityMod.UI bool onNextPage = i - startingLine > TotalLinesPerPage; if (dialogLines[i] != null) { - int textDrawPositionX = Main.screenWidth / 2 - (int)((pageTexture.Width * 2) * Main.screenWidth / 2560f); - int textDrawPositionY = (int)(50 + (i - startingLine) * 24 * Main.screenHeight / 1440f) + (int)yPageTop; + int textDrawPositionX = (int)(Main.screenWidth / 2 - 50 * xResolutionScale) - (int)(pageTexture.Width * 2 * xResolutionScale); + int textDrawPositionY = (int)(50 * yResolutionScale) + (i - startingLine) * 24 + (int)yPageTop; if (onNextPage) { - textDrawPositionX = Main.screenWidth / 2 + (int)(TextStartOffsetX * 1.5 * Main.screenWidth / 2560f); - textDrawPositionY = (int)(50 + (i - startingLine - (TotalLinesPerPage + 1)) * 24 * Main.screenHeight / 1440f) + (int)yPageTop; + textDrawPositionX = (int)(Main.screenWidth / 2 + 16 * xResolutionScale) + (int)(TextStartOffsetX * 1.5 * xResolutionScale); + textDrawPositionY = (int)(50 * yResolutionScale) + (i - startingLine - (TotalLinesPerPage + 1)) * 24 + (int)yPageTop; } Color drawColor = Color.Lerp(Color.Cyan, Color.DarkCyan, (float)Math.Cos(i * 0.4) * 0.5f + 0.5f); diff --git a/UI/StealthUI.cs b/UI/StealthUI.cs index 84ae2c116c..9a54e251b1 100644 --- a/UI/StealthUI.cs +++ b/UI/StealthUI.cs @@ -20,7 +20,7 @@ namespace CalamityMod.UI DrawPosition.Y = Main.screenHeight / 2 + Main.LocalPlayer.height / 2f + 24f; } CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.stealthUIAlpha <= 0f || !CalamityConfig.Instance.StealthBar || modPlayer.rogueStealthMax <= 0) + if (modPlayer.stealthUIAlpha <= 0f || !CalamityConfig.Instance.StealthBar || modPlayer.rogueStealthMax <= 0f || !modPlayer.wearingRogueArmor) { if (CalamityConfig.Instance.StealthMeterPosX != DrawPosition.X) { diff --git a/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index 340248019a..f610e634f4 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -1,3 +1,5 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.Items; using CalamityMod.Items.Tools.ClimateChange; @@ -29,6 +31,7 @@ using CalamityMod.NPCs.StormWeaver; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.Yharon; using CalamityMod.Projectiles; +using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Summon; using CalamityMod.Tiles; using CalamityMod.Tiles.Abyss; @@ -94,6 +97,7 @@ namespace CalamityMod public static float AverageDamage(this Player player) => player.allDamage + (player.meleeDamage + player.rangedDamage + player.magicDamage + player.minionDamage + player.Calamity().throwingDamage - 5f) / 5f; public static bool IsUnderwater(this Player player) => Collision.DrownCollision(player.position, player.width, player.height, player.gravDir); + public static bool StandingStill(this Player player, float velocity = 0.05f) => player.velocity.Length() < velocity; public static bool InSpace(this Player player) { float x = Main.maxTilesX / 4200f; @@ -146,6 +150,25 @@ namespace CalamityMod { return player.inventory.Any(item => items.Contains(item.type)); } + + /// + /// Inflict typical exo weapon debuffs in pvp. + /// + /// The Player attacked. + /// Debuff time multiplier if needed. + /// Inflicts debuffs if the target isn't immune. + public static void ExoDebuffs(this Player target, float multiplier = 1f) + { + target.AddBuff(ModContent.BuffType(), (int)(30 * multiplier)); + target.AddBuff(ModContent.BuffType(), (int)(120 * multiplier)); + target.AddBuff(ModContent.BuffType(), (int)(120 * multiplier)); + target.AddBuff(ModContent.BuffType(), (int)(120 * multiplier)); + target.AddBuff(ModContent.BuffType(), (int)(120 * multiplier)); + target.AddBuff(BuffID.CursedInferno, (int)(120 * multiplier)); + target.AddBuff(BuffID.Frostburn, (int)(120 * multiplier)); + target.AddBuff(BuffID.OnFire, (int)(120 * multiplier)); + target.AddBuff(BuffID.Ichor, (int)(120 * multiplier)); + } #endregion #region NPC Utilities @@ -455,45 +478,6 @@ namespace CalamityMod return true; } - /// - /// Call this function in the Kill function of your npc to spawn cloud-like gores. - /// - /// The npc you're adding explosion clouds to - /// Number of times it loops to spawn gores - public static void ExplosionGores (this NPC npc, int goreAmt) - { - Vector2 goreVec = new Vector2(npc.position.X + (float)(npc.width / 2) - 24f, npc.position.Y + (float)(npc.height / 2) - 24f); - for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) - { - float velocityMult = 0.33f; - if (goreIndex < (int)(goreAmt/3)) - { - velocityMult = 0.66f; - } - if (goreIndex >= (int)((2*goreAmt)/3)) - { - velocityMult = 1f; - } - int smoke = Gore.NewGore(goreVec, default, Main.rand.Next(61, 64), 1f); - Gore gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - smoke = Gore.NewGore(goreVec, default, Main.rand.Next(61, 64), 1f); - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y += 1f; - smoke = Gore.NewGore(goreVec, default, Main.rand.Next(61, 64), 1f); - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y -= 1f; - smoke = Gore.NewGore(goreVec, default, Main.rand.Next(61, 64), 1f); - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y -= 1f; - } - } - /// /// Check if an NPC is organic /// @@ -539,6 +523,41 @@ namespace CalamityMod } return false; } + + /// + /// Shortcut for the generic boss summon message. + /// + /// The whoAmI index of the summoned npc. + public static void BossAwakenMessage(int npcIndex) + { + string typeName = Main.npc[npcIndex].TypeName; + if (Main.netMode == NetmodeID.SinglePlayer) + { + Main.NewText(Language.GetTextValue("Announcement.HasAwoken", typeName), new Color(175, 75, 255)); + } + else if (Main.netMode == NetmodeID.Server) + { + NetMessage.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", new object[]{Main.npc[npcIndex].GetTypeNetName()}), new Color(175, 75, 255)); + } + } + + /// Inflict typical exo weapon debuffs. Duration multiplier optional. + /// + /// The NPC attacked. + /// Debuff time multiplier if needed. + /// Inflicts debuffs if they can. + public static void ExoDebuffs(this NPC target, float multiplier = 1f) + { + target.AddBuff(BuffID.Ichor, (int)(120 * multiplier)); + target.AddBuff(BuffID.CursedInferno, (int)(120 * multiplier)); + target.AddBuff(ModContent.BuffType(), (int)(30 * multiplier)); + target.AddBuff(ModContent.BuffType(), (int)(120 * multiplier)); + target.AddBuff(ModContent.BuffType(), (int)(120 * multiplier)); + target.AddBuff(ModContent.BuffType(), (int)(120 * multiplier)); + target.AddBuff(ModContent.BuffType(), (int)(120 * multiplier)); + target.AddBuff(BuffID.Frostburn, (int)(120 * multiplier)); + target.AddBuff(BuffID.OnFire, (int)(120 * multiplier)); + } #endregion #region Item Utilities @@ -773,43 +792,19 @@ namespace CalamityMod } } - /// - /// Call this function in the Kill function of your projectile to spawn cloud-like gores. Used primarily for explosions - /// - /// The projectile you're adding explosion clouds to - /// Number of times it loops to spawn gores - public static void ExplosionGores (this Projectile projectile, int goreAmt) + public static int FindFirstProjectile(int Type) { - Vector2 goreVec = new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f); - for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) - { - float velocityMult = 0.33f; - if (goreIndex < (int)(goreAmt/3)) - { - velocityMult = 0.66f; - } - if (goreIndex >= (int)((2*goreAmt)/3)) - { - velocityMult = 1f; - } - int smoke = Gore.NewGore(goreVec, default, Main.rand.Next(61, 64), 1f); - Gore gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - smoke = Gore.NewGore(goreVec, default, Main.rand.Next(61, 64), 1f); - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y += 1f; - smoke = Gore.NewGore(goreVec, default, Main.rand.Next(61, 64), 1f); - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y -= 1f; - smoke = Gore.NewGore(goreVec, default, Main.rand.Next(61, 64), 1f); - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y -= 1f; - } + int index = -1; + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile proj = Main.projectile[x]; + if (proj.active && proj.type == Type) + { + index = x; + break; + } + } + return index; } /// @@ -969,6 +964,132 @@ namespace CalamityMod } } + public static void StickToTiles(this Projectile projectile) + { + try + { + int xLeft = (int)(projectile.position.X / 16f) - 1; + int xRight = (int)((projectile.position.X + (float)projectile.width) / 16f) + 2; + int yBottom = (int)(projectile.position.Y / 16f) - 1; + int yTop = (int)((projectile.position.Y + (float)projectile.height) / 16f) + 2; + if (xLeft < 0) + { + xLeft = 0; + } + if (xRight > Main.maxTilesX) + { + xRight = Main.maxTilesX; + } + if (yBottom < 0) + { + yBottom = 0; + } + if (yTop > Main.maxTilesY) + { + yTop = Main.maxTilesY; + } + for (int x = xLeft; x < xRight; x++) + { + for (int y = yBottom; y < yTop; y++) + { + Tile tile = Main.tile[x, y]; + if (tile != null && !TileID.Sets.Platforms[tile.type] && tile.type != TileID.PlanterBox && tile.nactive() && (Main.tileSolid[tile.type] || (Main.tileSolidTop[tile.type] && tile.frameY == 0))) + { + Vector2 tileSize; + tileSize.X = (float)(x * 16); + tileSize.Y = (float)(y * 16); + if (projectile.position.X + (float)projectile.width - 4f > tileSize.X && projectile.position.X + 4f < tileSize.X + 16f && projectile.position.Y + (float)projectile.height - 4f > tileSize.Y && projectile.position.Y + 4f < tileSize.Y + 16f) + { + projectile.velocity.X = 0f; + projectile.velocity.Y = -0.2f; + } + } + } + } + } catch + { + } + } + + public static Projectile ProjectileRain(Vector2 targetPos, float xLimit, float xVariance, float yLimitLower, float yLimitUpper, float projSpeed, int projType, int damage, float knockback, int owner, int forceType = 0, int immunitySetting = 0, int cooldown = 10) + { + float x = targetPos.X + Main.rand.NextFloat(-xLimit, xLimit); + if (projType == ModContent.ProjectileType()) + x = targetPos.X + xLimit; + float y = targetPos.Y - Main.rand.NextFloat(yLimitLower, yLimitUpper); + Vector2 source = new Vector2(x, y); + Vector2 velocity = targetPos - source; + velocity.X += Main.rand.NextFloat(-xVariance, xVariance); + float speed = projSpeed; + float targetDist = velocity.Length(); + targetDist = speed / targetDist; + velocity.X *= targetDist; + velocity.Y *= targetDist; + Projectile proj = Projectile.NewProjectileDirect(source, velocity, projType, damage, knockback, owner, 0f, 0f); + CalamityGlobalProjectile modProj = proj.Calamity(); + if (forceType > 0) + { + switch (forceType) + { + case 1: + modProj.forceMelee = true; + break; + case 2: + modProj.forceRanged = true; + break; + case 3: + modProj.forceMagic = true; + break; + case 4: + modProj.forceMinion = true; + break; + case 5: + modProj.forceRogue = true; + break; + case 6: + modProj.forceTypeless = true; + break; + } + } + if (immunitySetting > 0) + { + switch (forceType) + { + case 1: + proj.usesLocalNPCImmunity = true; + proj.localNPCHitCooldown = cooldown; + proj.usesIDStaticNPCImmunity = false; + break; + case 2: + proj.usesLocalNPCImmunity = false; + proj.idStaticNPCHitCooldown = cooldown; + proj.usesIDStaticNPCImmunity = true; + break; + } + } + return proj; + } + + public static Projectile ProjectileBarrage(Vector2 originVec, Vector2 targetPos, bool fromRight, float xOffsetMin, float xOffsetMax, float yOffsetMin, float yOffsetMax, float projSpeed, int projType, int damage, float knockback, int owner, bool clamped = false, float inaccuracyOffset = 5f) + { + float xPos = originVec.X + Main.rand.NextFloat(xOffsetMin, xOffsetMax) * fromRight.ToDirectionInt(); + float yPos = originVec.Y + Main.rand.NextFloat(yOffsetMin, yOffsetMax) * Main.rand.NextBool().ToDirectionInt(); + Vector2 spawnPosition = new Vector2(xPos, yPos); + Vector2 velocity = targetPos - spawnPosition; + velocity.X += Main.rand.NextFloat(-inaccuracyOffset, inaccuracyOffset); + velocity.Y += Main.rand.NextFloat(-inaccuracyOffset, inaccuracyOffset); + velocity.Normalize(); + velocity *= projSpeed * (clamped ? 150f : 1f); + //This clamp means the spawned projectiles only go at diagnals and are not accurate + if (clamped) + { + velocity.X = MathHelper.Clamp(velocity.X, -15f, 15f); + velocity.Y = MathHelper.Clamp(velocity.Y, -15f, 15f); + } + Projectile proj = Projectile.NewProjectileDirect(spawnPosition, velocity, projType, damage, knockback, owner); + return proj; + } + public static int DamageSoftCap(double dmgInput, int cap) { int newDamage = (int)(dmgInput); @@ -981,6 +1102,169 @@ namespace CalamityMod return newDamage; } + public static Vector2 RandomVelocity(float directionMult, float speedLowerLimit, float speedCap, float speedMult = 0.1f) + { + Vector2 velocity = new Vector2(Main.rand.NextFloat(-directionMult, directionMult), Main.rand.NextFloat(-directionMult, directionMult)); + //Rerolling to avoid dividing by zero + while (velocity.X == 0f && velocity.Y == 0f) + { + velocity = new Vector2(Main.rand.NextFloat(-directionMult, directionMult), Main.rand.NextFloat(-directionMult, directionMult)); + } + velocity.Normalize(); + velocity *= Main.rand.NextFloat(speedLowerLimit, speedCap) * speedMult; + return velocity; + } + + public static void SporeSacAI(this Projectile projectile) + { + Player player = Main.player[projectile.owner]; + + float scaleAmt = 1f - (float)projectile.alpha / 255f; + scaleAmt *= projectile.scale; + Lighting.AddLight(projectile.Center, 0.25f * scaleAmt, 0.025f * scaleAmt, 0.275f * scaleAmt); + + projectile.localAI[0] += 1f; + if (projectile.localAI[0] >= 90f) + { + projectile.localAI[0] *= -1f; + } + if (projectile.localAI[0] >= 0f) + { + projectile.scale += 0.003f; + } + else + { + projectile.scale -= 0.003f; + } + projectile.rotation += 0.0025f * projectile.scale; + float yVel = 1f; + float xVel = 1f; + if (projectile.identity % 6 == 0) + { + xVel *= -1f; + } + if (projectile.identity % 6 == 1) + { + yVel *= -1f; + } + if (projectile.identity % 6 == 2) + { + xVel *= -1f; + yVel *= -1f; + } + if (projectile.identity % 6 == 3) + { + xVel = 0f; + } + if (projectile.identity % 6 == 4) + { + yVel = 0f; + } + projectile.localAI[1] += 1f; + if (projectile.localAI[1] > 60f) + { + projectile.localAI[1] = -180f; + } + if (projectile.localAI[1] >= -60f) + { + projectile.velocity.X += 0.002f * xVel; + projectile.velocity.Y += 0.002f * yVel; + } + else + { + projectile.velocity.X -= 0.002f * xVel; + projectile.velocity.Y -= 0.002f * yVel; + } + projectile.ai[0] += 1f; + if (projectile.ai[0] > 5400f) + { + projectile.damage = 0; + projectile.ai[1] = 1f; + if (projectile.alpha < 255) + { + projectile.alpha += 5; + if (projectile.alpha > 255) + { + projectile.alpha = 255; + } + } + else if (projectile.owner == Main.myPlayer) + { + projectile.Kill(); + } + } + else + { + float playerDist = (projectile.Center - player.Center).Length() / 100f; + if (playerDist > 4f) + { + playerDist *= 1.1f; + } + if (playerDist > 5f) + { + playerDist *= 1.2f; + } + if (playerDist > 6f) + { + playerDist *= 1.3f; + } + if (playerDist > 7f) + { + playerDist *= 1.4f; + } + if (playerDist > 8f) + { + playerDist *= 1.5f; + } + if (playerDist > 9f) + { + playerDist *= 1.6f; + } + if (playerDist > 10f) + { + playerDist *= 1.7f; + } + projectile.ai[0] += playerDist; + if (projectile.alpha > 50) + { + projectile.alpha -= 10; + if (projectile.alpha < 50) + { + projectile.alpha = 50; + } + } + } + bool foundTarget = false; + Vector2 targetPos = new Vector2(0f, 0f); + float maxDist = 600f; + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) + { + float targetDist = Vector2.Distance(projectile.Center, npc.Center); + if (targetDist < maxDist) + { + targetPos = npc.Center; + foundTarget = true; + break; + } + } + } + if (foundTarget) + { + Vector2 targetVec = targetPos - projectile.Center; + targetVec.Normalize(); + targetVec *= 0.75f; + projectile.velocity = (projectile.velocity * 10f + targetVec) / 11f; + return; + } + if (projectile.velocity.Length() > 0.2f) + { + projectile.velocity *= 0.98f; + } + } + public static void MinionAntiClump(this Projectile projectile, float pushForce = 0.05f) { for (int k = 0; k < Main.maxProjectiles; k++) @@ -1008,7 +1292,7 @@ namespace CalamityMod } } - public static void ChargingMinionAI(this Projectile projectile, float range, float maxPlayerDist, float extraMaxPlayerDist, float safeDist, int initialUpdates, float chargeDelayTime, float goToSpeed, float goBackSpeed, float chargeCounterMax, float chargeSpeed, bool tileVision, bool ignoreTilesWhenCharging) + public static void ChargingMinionAI(this Projectile projectile, float range, float maxPlayerDist, float extraMaxPlayerDist, float safeDist, int initialUpdates, float chargeDelayTime, float goToSpeed, float goBackSpeed, float chargeCounterMax, float chargeSpeed, bool tileVision, bool ignoreTilesWhenCharging, int updateDifference = 1) { Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); @@ -1021,7 +1305,7 @@ namespace CalamityMod if (projectile.ai[0] == 2f) { projectile.ai[1] += 1f; - projectile.extraUpdates = initialUpdates + (projectile.type == ModContent.ProjectileType() ? 2 : 1); + projectile.extraUpdates = initialUpdates + updateDifference; if (projectile.ai[1] > chargeDelayTime) { projectile.ai[1] = 1f; @@ -1068,8 +1352,8 @@ namespace CalamityMod } } } - //If no npc is specifically targetted, check through the entire array - else + //If no npc is specifically targetted or the selected enemy can't be found, check through the entire array + if (!foundTarget) { for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) { @@ -3382,6 +3666,45 @@ namespace CalamityMod public static int SecondsToFrames(float seconds) => (int)(seconds * 60); + /// + /// Call this function to spawn explosion clouds at the specified location. Good for when NPCs or projectiles die and need to explode. + /// + /// The spot to spawn the explosion clouds + /// Number of times it loops to spawn gores + public static void ExplosionGores (Vector2 goreSource, int goreAmt) + { + Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); + for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) + { + float velocityMult = 0.33f; + if (goreIndex < (int)(goreAmt/3)) + { + velocityMult = 0.66f; + } + if (goreIndex >= (int)((2*goreAmt)/3)) + { + velocityMult = 1f; + } + int smoke = Gore.NewGore(source, default, Main.rand.Next(61, 64), 1f); + Gore gore = Main.gore[smoke]; + gore.velocity *= velocityMult; + gore.velocity.X += 1f; + gore.velocity.Y += 1f; + smoke = Gore.NewGore(source, default, Main.rand.Next(61, 64), 1f); + gore.velocity *= velocityMult; + gore.velocity.X -= 1f; + gore.velocity.Y += 1f; + smoke = Gore.NewGore(source, default, Main.rand.Next(61, 64), 1f); + gore.velocity *= velocityMult; + gore.velocity.X += 1f; + gore.velocity.Y -= 1f; + smoke = Gore.NewGore(source, default, Main.rand.Next(61, 64), 1f); + gore.velocity *= velocityMult; + gore.velocity.X -= 1f; + gore.velocity.Y -= 1f; + } + } + // REMOVE THIS IN CALAMITY 1.4, it's a 1.4 Main.cs function public static float GetLerpValue(float from, float to, float t, bool clamped = false) { diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index cf29374c75..dd496c5312 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -139,6 +139,7 @@ namespace CalamityMod.World //Spawned NPCs public static bool spawnedBandit = false; public static bool spawnedCirrus = false; + public static bool foundHomePermafrost = false; #region Downed Bools public static bool downedBossAny = false; //Any boss @@ -173,6 +174,7 @@ namespace CalamityMod.World public static bool downedSCal = false; public static bool downedGSS = false; public static bool downedCLAM = false; + public static bool downedCLAMHardMode = false; public static bool downedBetsy = false; //Betsy public static bool downedEoCAcidRain = false; @@ -219,6 +221,7 @@ namespace CalamityMod.World abyssSide = false; spawnedBandit = false; spawnedCirrus = false; + foundHomePermafrost = false; downedDesertScourge = false; downedAquaticScourge = false; downedHiveMind = false; @@ -240,6 +243,7 @@ namespace CalamityMod.World buffedEclipse = false; downedSCal = false; downedCLAM = false; + downedCLAMHardMode = false; downedBumble = false; downedCrabulon = false; downedBetsy = false; @@ -355,6 +359,8 @@ namespace CalamityMod.World downed.Add("bossRushActive"); if (downedCLAM) downed.Add("clam"); + if (downedCLAMHardMode) + downed.Add("clamHardmode"); if (dragonScalesBought) downed.Add("scales"); if (rainingAcid) @@ -363,6 +369,8 @@ namespace CalamityMod.World downed.Add("bandit"); if (spawnedCirrus) downed.Add("drunkPrincess"); + if (foundHomePermafrost) + downed.Add("archmageHome"); if (downedEoCAcidRain) downed.Add("eocRain"); if (downedAquaticScourgeAcidRain) @@ -443,10 +451,12 @@ namespace CalamityMod.World abyssSide = downed.Contains("abyssSide"); bossRushActive = downed.Contains("bossRushActive"); downedCLAM = downed.Contains("clam"); + downedCLAMHardMode = downed.Contains("clamHardmode"); dragonScalesBought = downed.Contains("scales"); rainingAcid = downed.Contains("acidRain"); spawnedBandit = downed.Contains("bandit"); spawnedCirrus = downed.Contains("drunkPrincess"); + foundHomePermafrost = downed.Contains("archmageHome"); downedEoCAcidRain = downed.Contains("eocRain"); downedAquaticScourgeAcidRain = downed.Contains("hmRain"); triedToSummonOldDuke = downed.Contains("spawnedBoomer"); @@ -547,8 +557,8 @@ namespace CalamityMod.World forcedRainAlready = flags8[0]; forcedDownpourWithTear = flags8[1]; downedSecondSentinels = flags8[2]; - _ = flags8[3]; - _ = flags8[4]; + foundHomePermafrost = flags8[3]; + downedCLAMHardMode = flags8[4]; _ = flags8[5]; _ = flags8[6]; _ = flags8[7]; @@ -638,8 +648,8 @@ namespace CalamityMod.World flags8[0] = forcedRainAlready; flags8[1] = forcedDownpourWithTear; flags8[2] = downedSecondSentinels; - flags8[3] = false; - flags8[4] = false; + flags8[3] = foundHomePermafrost; + flags8[4] = downedCLAMHardMode; flags8[5] = false; flags8[6] = false; flags8[7] = false; @@ -737,8 +747,8 @@ namespace CalamityMod.World forcedRainAlready = flags8[0]; forcedDownpourWithTear = flags8[1]; downedSecondSentinels = flags8[2]; - _ = flags8[3]; - _ = flags8[4]; + foundHomePermafrost = flags8[3]; + downedCLAMHardMode = flags8[4]; _ = flags8[5]; _ = flags8[6]; _ = flags8[7]; diff --git a/World/WorldGenerationMethods.cs b/World/WorldGenerationMethods.cs index b5bb64e742..1206237398 100644 --- a/World/WorldGenerationMethods.cs +++ b/World/WorldGenerationMethods.cs @@ -1606,18 +1606,29 @@ namespace CalamityMod.World if (CanAstralBiomeSpawn()) { DoAstralConversion(new Point(i, j)); - int checkWidth = 70; - float height = 9000; + int checkWidth = 180; + float averageHeight = 0f; + float lowestHeight = 0f; for (int x = i - checkWidth / 2; x < i + checkWidth / 2; x++) { - int y = j - 100; - while (!CalamityUtils.ParanoidTileRetrieval(x, y).active()) + int y = j - 200; + while (!CalamityUtils.ParanoidTileRetrieval(x, y).active() || CalamityUtils.ParanoidTileRetrieval(x, y).type == TileID.Trees) { y++; + if (y > j - 10) + break; } - height = (int)MathHelper.Min(height, y); + lowestHeight = (int)MathHelper.Max(lowestHeight, y); + averageHeight += y; } - SchematicPlacementHelpers.PlaceStructure("Astral Beacon", new Point(i, (int)height - 30), SchematicPlacementHelpers.PlacementAnchorType.Center); + lowestHeight -= 36f; + averageHeight /= checkWidth; + float height = lowestHeight; + + // If there's a sudden change between the average and lowest height (which is indicative of holes/chasms), go with the average. + if (Math.Abs(lowestHeight - averageHeight) > 50f) + height = averageHeight; + SchematicPlacementHelpers.PlaceStructure("Astral Beacon", new Point(i, (int)height - 20), SchematicPlacementHelpers.PlacementAnchorType.Center); } } return true;