From 42d66897c510d72123c556e43174b97fda62166e Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Mon, 30 Nov 2020 20:21:49 -0600 Subject: [PATCH 01/66] Artifical sulph seas require 300+ tiles --- CalPlayer/CalamityPlayer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 01f9fe0715..228d787b7b 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -2556,8 +2556,8 @@ namespace CalamityMod.CalPlayer ZoneAbyssLayer4 = ZoneAbyss && point.Y > (Main.rockLayer + y * 0.26); - - ZoneSulphur = (CalamityWorld.sulphurTiles > 30 || (player.ZoneOverworldHeight && sulphurPosX)) && !ZoneAbyss; + + ZoneSulphur = (CalamityWorld.sulphurTiles >= 300 || (player.ZoneOverworldHeight && sulphurPosX)) && !ZoneAbyss; //Overriding 1.4's ass req boosts if (Main.snowTiles > 300) From aa0fb42c2a2f46f0c2c124b48900e2891dbc6b1f Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Mon, 30 Nov 2020 20:37:19 -0600 Subject: [PATCH 02/66] Holograms don't talk over NPCs anymore --- UI/LabHologramProjectorUI.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/UI/LabHologramProjectorUI.cs b/UI/LabHologramProjectorUI.cs index 38ef84aeb4..94b275495c 100644 --- a/UI/LabHologramProjectorUI.cs +++ b/UI/LabHologramProjectorUI.cs @@ -48,6 +48,10 @@ namespace CalamityMod.UI if (projectorID == -1) return; + // The UI cannot draw if the player is already occupied with an NPC. + if (p.talkNPC > 0 || Main.npcShop > 0) + return; + // Check if this tile entity ID is actually a projector. If it's not, immediately destroy this UI. TELabHologramProjector projector; bool projectorIsValid = TileEntity.ByID.TryGetValue(projectorID, out TileEntity te); From ba40ad7269b627a03d33af3f7b63b52824030ac9 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sat, 5 Dec 2020 12:01:35 -0600 Subject: [PATCH 03/66] Draedon Labs no longer conflict with MoD labs --- World/DraedonStructures.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/World/DraedonStructures.cs b/World/DraedonStructures.cs index 9edc6a776e..2afdc92e5b 100644 --- a/World/DraedonStructures.cs +++ b/World/DraedonStructures.cs @@ -45,6 +45,20 @@ namespace CalamityMod.World { return true; } + // As well as MoD's special labs. + Mod modOfRedemption = ModLoader.GetMod("Redemption"); + if (modOfRedemption != null) + { + // Thanks to Hallam to providing these tile names. + string[] tilesToAvoid = new string[] + { + "LabTileUnsafe", + "OvergrownLabTile" + }; + + if (tilesToAvoid.Any(tileTypeName => tile.type == modOfRedemption.TileType(tileTypeName))) + return true; + } return false; } From 9ae1c620059756badac40debe55f83b802528e4f Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 5 Dec 2020 13:21:23 -0500 Subject: [PATCH 04/66] Cleaned up some code --- Items/Weapons/Ranged/OnyxChainBlaster.cs | 2 +- Items/Weapons/Ranged/Onyxia.cs | 8 ++-- Projectiles/CalamityGlobalProjectile.cs | 22 +++++------ Projectiles/Ranged/HyperiusSplit.cs | 1 + Projectiles/Ranged/HyperiusSplit.png | Bin 125 -> 0 bytes Projectiles/Summon/AstrageldonSummon.cs | 2 +- Projectiles/Summon/AstralProbeSummon.cs | 48 ++++------------------- Utilities/CalamityUtils.cs | 6 ++- 8 files changed, 28 insertions(+), 61 deletions(-) delete mode 100644 Projectiles/Ranged/HyperiusSplit.png diff --git a/Items/Weapons/Ranged/OnyxChainBlaster.cs b/Items/Weapons/Ranged/OnyxChainBlaster.cs index d73eab249d..159814daed 100644 --- a/Items/Weapons/Ranged/OnyxChainBlaster.cs +++ b/Items/Weapons/Ranged/OnyxChainBlaster.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.rare = 10; item.UseSound = SoundID.Item36; item.autoReuse = true; - item.shoot = ProjectileID.PurificationPowder; + item.shoot = ProjectileID.BlackBolt; item.shootSpeed = 24f; item.useAmmo = AmmoID.Bullet; item.Calamity().customRarity = CalamityRarity.Turquoise; diff --git a/Items/Weapons/Ranged/Onyxia.cs b/Items/Weapons/Ranged/Onyxia.cs index 90e3c091de..7372cbb520 100644 --- a/Items/Weapons/Ranged/Onyxia.cs +++ b/Items/Weapons/Ranged/Onyxia.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.rare = 10; item.UseSound = SoundID.Item36; item.autoReuse = true; - item.shoot = ProjectileID.PurificationPowder; // wait why + item.shoot = ProjectileID.BlackBolt; item.shootSpeed = 28f; item.useAmmo = AmmoID.Bullet; item.Calamity().customRarity = CalamityRarity.Violet; @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { // Fire the Onyx Shard that is characteristic of the Onyx Blaster - // The shard deals triple damage and double knockback + // The shard deals 2.5x damage and double knockback int shardDamage = (int)(2.5 * damage); float shardKB = 2f * knockBack; float shardVelocityX = (speedX + (float)Main.rand.Next(-25, 26) * 0.05f) * 0.9f; @@ -62,8 +62,8 @@ namespace CalamityMod.Items.Weapons.Ranged float randVelMultiplier = Main.rand.NextFloat(0.92f, 1.08f); Vector2 left = baseVelocity.RotatedBy(-randAngle) * randVelMultiplier; Vector2 right = baseVelocity.RotatedBy(randAngle) * randVelMultiplier; - Projectile.NewProjectile(position.X, position.Y, left.X, left.Y, type, damage, knockBack, player.whoAmI, 0f, 0f); - Projectile.NewProjectile(position.X, position.Y, right.X, right.Y, type, damage, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position, left, type, damage, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position, right, type, damage, knockBack, player.whoAmI, 0f, 0f); } return false; } diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index bf1f34427b..f14bd416e7 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -2321,6 +2321,9 @@ namespace CalamityMod.Projectiles public static void HomeInOnNPC(Projectile projectile, bool ignoreTiles, float distanceRequired, float homingVelocity, float N) { + if (!projectile.friendly) + return; + Vector2 center = projectile.Center; float maxDistance = distanceRequired; bool homeIn = false; @@ -2335,7 +2338,7 @@ namespace CalamityMod.Projectiles if (extraDistance < maxDistance && !ignoreTiles) canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1); - if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance) && canHit) + if (projectile.WithinRange(Main.npc[i].Center, maxDistance + extraDistance) && canHit) { center = Main.npc[i].Center; homeIn = true; @@ -2344,11 +2347,6 @@ namespace CalamityMod.Projectiles } } - if (!projectile.friendly) - { - homeIn = false; - } - if (homeIn) { Vector2 homeInVector = projectile.DirectionTo(center); @@ -2376,7 +2374,7 @@ namespace CalamityMod.Projectiles if (extraDistance < maxDistance) canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1); - if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance) && canHit) + if (projectile.WithinRange(Main.npc[i].Center, maxDistance + extraDistance) && canHit) { if (targetArrayIndex < maxTargets) { @@ -2399,18 +2397,18 @@ namespace CalamityMod.Projectiles if (projectile.localAI[0] > projectileTimer) { projectile.localAI[0] = 0f; - Vector2 value = projectile.Center + projectile.velocity * 4f; - Vector2 velocity = Vector2.Normalize(Main.npc[randomTarget].Center - value) * homingVelocity; + Vector2 spawnPos = projectile.Center + projectile.velocity * 4f; + Vector2 velocity = Vector2.Normalize(Main.npc[randomTarget].Center - spawnPos) * homingVelocity; if (attackMultiple) { for (int i = 0; i < targetArrayIndex; i++) { - velocity = Vector2.Normalize(Main.npc[targetArray[i]].Center - value) * homingVelocity; + velocity = Vector2.Normalize(Main.npc[targetArray[i]].Center - spawnPos) * homingVelocity; if (projectile.owner == Main.myPlayer) { - int projectile2 = Projectile.NewProjectile(value.X, value.Y, velocity.X, velocity.Y, spawnedProjectile, (int)(projectile.damage * damageMult), projectile.knockBack, projectile.owner, 0f, 0f); + int projectile2 = Projectile.NewProjectile(spawnPos, velocity, spawnedProjectile, (int)(projectile.damage * damageMult), projectile.knockBack, projectile.owner, 0f, 0f); if (projectile.type == ProjectileType()) Main.projectile[projectile2].Calamity().forceRogue = true; @@ -2428,7 +2426,7 @@ namespace CalamityMod.Projectiles if (projectile.owner == Main.myPlayer) { - int projectile2 = Projectile.NewProjectile(value.X, value.Y, velocity.X, velocity.Y, spawnedProjectile, (int)(projectile.damage * damageMult), projectile.knockBack, projectile.owner, 0f, 0f); + int projectile2 = Projectile.NewProjectile(spawnPos, velocity, spawnedProjectile, (int)(projectile.damage * damageMult), projectile.knockBack, projectile.owner, 0f, 0f); if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType()) diff --git a/Projectiles/Ranged/HyperiusSplit.cs b/Projectiles/Ranged/HyperiusSplit.cs index 60719f0a07..31670b1b7b 100644 --- a/Projectiles/Ranged/HyperiusSplit.cs +++ b/Projectiles/Ranged/HyperiusSplit.cs @@ -8,6 +8,7 @@ namespace CalamityMod.Projectiles.Ranged { public class HyperiusSplit : ModProjectile { + public override string Texture => "CalamityMod/Projectiles/Ranged/HyperiusBulletProj"; private Color currentColor = Color.Black; public override void SetStaticDefaults() diff --git a/Projectiles/Ranged/HyperiusSplit.png b/Projectiles/Ranged/HyperiusSplit.png deleted file mode 100644 index 796dc78281426fa5cb7c3aaa7fbeef5dbfb9328e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 125 zcmeAS@N?(olHy`uVBq!ia0vp^Oh7Ed!3HF~v+~XZDHl%{#}JO0$u%GTpRZ>F0yQ>` zgqho)$}@LyD7Q)Zuo>=>SZelhVdt8^39c7X?sM~HD3xEk>n6Ojjw^QhGRa*WZBh&d X#xhM_O9H0?&13L%^>bP0l+XkK{)Z)o diff --git a/Projectiles/Summon/AstrageldonSummon.cs b/Projectiles/Summon/AstrageldonSummon.cs index eeb30a3c4f..8d7139c9ab 100644 --- a/Projectiles/Summon/AstrageldonSummon.cs +++ b/Projectiles/Summon/AstrageldonSummon.cs @@ -212,7 +212,7 @@ namespace CalamityMod.Projectiles.Summon Vector2 laserVel = objectivepos - projectile.Center; laserVel.Normalize(); laserVel *= scaleFactor3; - int laser = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, laserVel.X, laserVel.Y, projType, projectile.damage, 0f, projectile.owner, 0f, 0f); + int laser = Projectile.NewProjectile(projectile.Center, laserVel, projType, projectile.damage, 0f, projectile.owner, 0f, 0f); projectile.netUpdate = true; } } diff --git a/Projectiles/Summon/AstralProbeSummon.cs b/Projectiles/Summon/AstralProbeSummon.cs index 1dc3e65293..82c54cf7f3 100644 --- a/Projectiles/Summon/AstralProbeSummon.cs +++ b/Projectiles/Summon/AstralProbeSummon.cs @@ -76,46 +76,12 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - float range = 1000f; - Vector2 targetVec = projectile.position; - bool foundTarget = false; - int targetIndex = -1; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { - float npcDist = Vector2.Distance(npc.Center, projectile.Center); - if (!foundTarget && npcDist < range) - { - targetVec = npc.Center; - foundTarget = true; - targetIndex = npc.whoAmI; - } - } - } - if (!foundTarget) - { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) - { - NPC npc = Main.npc[num645]; - if (npc.CanBeChasedBy(projectile, false)) - { - float npcDist = Vector2.Distance(npc.Center, projectile.Center); - if (!foundTarget && npcDist < range) - { - targetVec = npc.Center; - foundTarget = true; - targetIndex = num645; - } - } - } - } + NPC target = projectile.Center.MinionHoming(1000f, player, true, true); Vector2 vector = player.Center - projectile.Center; - if (foundTarget) + if (target != null) { - projectile.spriteDirection = projectile.direction = ((targetVec.X - projectile.Center.X) > 0).ToDirectionInt(); - projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi), 0.1f); + projectile.spriteDirection = projectile.direction = ((target.Center.X - projectile.Center.X) > 0).ToDirectionInt(); + projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(target.Center) + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi), 0.1f); } else { @@ -141,16 +107,16 @@ namespace CalamityMod.Projectiles.Summon } float speedMult = 6f; int projType = ModContent.ProjectileType(); - if (foundTarget && projectile.ai[1] == 0f && targetVec != projectile.position) + if (target != null && projectile.ai[1] == 0f) { Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 12, 0.5f, 0f); projectile.ai[1] += 1f; if (Main.myPlayer == projectile.owner) { - Vector2 velocity = targetVec - projectile.Center; + Vector2 velocity = target.Center - projectile.Center; velocity.Normalize(); velocity *= speedMult; - Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, 0f, projectile.owner, targetIndex, 0f); + Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, 0f, projectile.owner, target.whoAmI, 0f); projectile.netUpdate = true; } } diff --git a/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index 37b097c3a9..de8fd7ddf2 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -416,7 +416,7 @@ namespace CalamityMod /// Maximum amount of pixels to check around the origin /// Owner of the minion /// Whether to ignore tiles when finding a target or not - public static NPC MinionHoming(this Vector2 origin, float maxDistanceToCheck, Player owner, bool ignoreTiles = true) + public static NPC MinionHoming(this Vector2 origin, float maxDistanceToCheck, Player owner, bool ignoreTiles = true, bool checksRange = false) { if (owner is null || owner.whoAmI < 0 || owner.whoAmI > Main.maxPlayers || owner.MinionAttackTargetNPC < 0 || owner.MinionAttackTargetNPC > Main.maxNPCs) return ClosestNPCAt(origin, maxDistanceToCheck, ignoreTiles); @@ -424,7 +424,9 @@ namespace CalamityMod bool canHit = true; if (!ignoreTiles) canHit = Collision.CanHit(origin, 1, 1, npc.Center, 1, 1); - if (owner.HasMinionAttackTargetNPC && canHit) + float extraDistance = (npc.width / 2) + (npc.height / 2); + bool distCheck = Vector2.Distance(origin, npc.Center) < (maxDistanceToCheck + extraDistance) || !checksRange; + if (owner.HasMinionAttackTargetNPC && canHit && distCheck) { return npc; } From 0911551b38c2da4336602e5506b7bfcc7f6a0870 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 5 Dec 2020 13:21:41 -0500 Subject: [PATCH 05/66] made photo, crumbling, and soaring pots hm only (instead of phm by blood orbs) --- Items/Potions/CrumblingPotion.cs | 1 + Items/Potions/PhotosynthesisPotion.cs | 1 + Items/Potions/SoaringPotion.cs | 1 + 3 files changed, 3 insertions(+) diff --git a/Items/Potions/CrumblingPotion.cs b/Items/Potions/CrumblingPotion.cs index e441f2f980..3db18b670a 100644 --- a/Items/Potions/CrumblingPotion.cs +++ b/Items/Potions/CrumblingPotion.cs @@ -45,6 +45,7 @@ namespace CalamityMod.Items.Potions recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater); recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddTile(TileID.AlchemyTable); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Potions/PhotosynthesisPotion.cs b/Items/Potions/PhotosynthesisPotion.cs index 0f4f9ec321..d2000b6afd 100644 --- a/Items/Potions/PhotosynthesisPotion.cs +++ b/Items/Potions/PhotosynthesisPotion.cs @@ -46,6 +46,7 @@ namespace CalamityMod.Items.Potions recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater); recipe.AddIngredient(ModContent.ItemType(), 40); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddTile(TileID.AlchemyTable); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Potions/SoaringPotion.cs b/Items/Potions/SoaringPotion.cs index 4b31352d44..f280fd0c88 100644 --- a/Items/Potions/SoaringPotion.cs +++ b/Items/Potions/SoaringPotion.cs @@ -47,6 +47,7 @@ namespace CalamityMod.Items.Potions recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.BottledWater); recipe.AddIngredient(ModContent.ItemType(), 30); + recipe.AddIngredient(ItemID.SoulofFlight); recipe.AddTile(TileID.AlchemyTable); recipe.SetResult(this); recipe.AddRecipe(); From 925932ddd42965604abf627768480c3c66dae1c2 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 5 Dec 2020 13:22:48 -0500 Subject: [PATCH 06/66] Adjusted Fab's Vodka blood orb recipe as well --- Items/Potions/Alcohol/FabsolsVodka.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Items/Potions/Alcohol/FabsolsVodka.cs b/Items/Potions/Alcohol/FabsolsVodka.cs index 20dc403e40..10cf8707eb 100644 --- a/Items/Potions/Alcohol/FabsolsVodka.cs +++ b/Items/Potions/Alcohol/FabsolsVodka.cs @@ -43,8 +43,9 @@ namespace CalamityMod.Items.Potions.Alcohol recipe.SetResult(this); recipe.AddRecipe(); recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.CrystalShard); recipe.AddIngredient(ModContent.ItemType(), 40); - recipe.AddIngredient(ItemID.BottledWater); + recipe.AddIngredient(ItemID.Ale); recipe.AddTile(TileID.AlchemyTable); recipe.SetResult(this); recipe.AddRecipe(); From 8ce60b5ccf2f32a5b44e6d470ccac78b69cf77e2 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 5 Dec 2020 14:00:21 -0500 Subject: [PATCH 07/66] moved darksun eclipse loot to the EventLoot section --- NPCs/CalamityGlobalNPCLoot.cs | 50 ++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 78ed19ac71..f84969b7fd 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -1428,23 +1428,6 @@ namespace CalamityMod.NPCs case NPCID.Reaper: case NPCID.Psycho: DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas || NPC.downedPlantBoss, Main.expertMode ? 0.75f : 0.5f, 1, 4); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.buffedEclipse, Main.expertMode ? 0.06f : 0.04f, 1, 1); - break; - - //other solar eclipse creatures - case NPCID.Eyezor: - case NPCID.Frankenstein: - case NPCID.SwampThing: - case NPCID.Vampire: - case NPCID.VampireBat: - case NPCID.CreatureFromTheDeep: - case NPCID.Fritz: - case NPCID.ThePossessed: - case NPCID.Butcher: - case NPCID.DeadlySphere: - case NPCID.DrManFly: - case NPCID.Nailhead: - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.buffedEclipse, Main.expertMode ? 0.06f : 0.04f, 1, 1); break; case NPCID.MartianOfficer: @@ -1579,13 +1562,36 @@ namespace CalamityMod.NPCs return; } - if (npc.type == NPCID.Mothron) + if (eclipse) { - DropHelper.DropItem(npc, ModContent.ItemType(), 10, 20); + switch (npc.type) + { + case NPCID.Reaper: + case NPCID.Psycho: + case NPCID.Eyezor: + case NPCID.Frankenstein: + case NPCID.SwampThing: + case NPCID.Vampire: + case NPCID.VampireBat: + case NPCID.CreatureFromTheDeep: + case NPCID.Fritz: + case NPCID.ThePossessed: + case NPCID.Butcher: + case NPCID.DeadlySphere: + case NPCID.DrManFly: + DropHelper.DropItemChance(npc, ModContent.ItemType(), Main.expertMode ? 0.06f : 0.04f); + break; + case NPCID.Nailhead: + DropHelper.DropItem(npc, ModContent.ItemType(), 3, 5); + break; + case NPCID.Mothron: + DropHelper.DropItem(npc, ModContent.ItemType(), 10, 20); - // Mark a buffed Mothron as killed (allowing access to Yharon P2) - CalamityWorld.downedBuffedMothron = true; - CalamityNetcode.SyncWorld(); + // Mark a buffed Mothron as killed + CalamityWorld.downedBuffedMothron = true; + CalamityNetcode.SyncWorld(); + break; + } } } #endregion From e6ca4c5df639d56a46f0f698d1e635ed4912a463 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 5 Dec 2020 14:46:40 -0500 Subject: [PATCH 08/66] Lava proofed the post-ML furniture sets Fixed Profaned Piano not counting as a table and Botanic Planter, Effulgent Manipulator, and Profaned Crucible not counting as light sources for housing. --- Tiles/Furniture/CraftingStations/BotanicPlanter.cs | 5 +++-- Tiles/Furniture/CraftingStations/DraedonsForge.cs | 2 ++ Tiles/Furniture/CraftingStations/ProfanedBasin.cs | 4 +++- Tiles/Furniture/CraftingStations/SilvaBasin.cs | 5 +++-- Tiles/FurnitureBotanic/BotanicBathtub.cs | 2 +- Tiles/FurnitureBotanic/BotanicBed.cs | 2 +- Tiles/FurnitureBotanic/BotanicBench.cs | 2 +- Tiles/FurnitureBotanic/BotanicBookcase.cs | 2 +- Tiles/FurnitureBotanic/BotanicCandelabra.cs | 2 +- Tiles/FurnitureBotanic/BotanicCandle.cs | 2 +- Tiles/FurnitureBotanic/BotanicChair.cs | 2 +- Tiles/FurnitureBotanic/BotanicChandelier.cs | 2 +- Tiles/FurnitureBotanic/BotanicClock.cs | 2 +- Tiles/FurnitureBotanic/BotanicDoorClosed.cs | 2 +- Tiles/FurnitureBotanic/BotanicDoorOpen.cs | 2 +- Tiles/FurnitureBotanic/BotanicLamp.cs | 2 +- Tiles/FurnitureBotanic/BotanicLantern.cs | 2 +- Tiles/FurnitureBotanic/BotanicPiano.cs | 2 +- Tiles/FurnitureBotanic/BotanicPlatform.cs | 2 +- Tiles/FurnitureBotanic/BotanicSink.cs | 2 +- Tiles/FurnitureBotanic/BotanicTable.cs | 2 +- Tiles/FurnitureBotanic/BotanicWorkBench.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs | 3 ++- Tiles/FurnitureCosmilite/CosmiliteBath.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteBed.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteBookcase.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteCandelabra.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteCandle.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteChair.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteChandelier.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteClock.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteDoorClosed.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteDoorOpen.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteLamp.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteLantern.cs | 2 +- Tiles/FurnitureCosmilite/CosmilitePiano.cs | 2 +- Tiles/FurnitureCosmilite/CosmilitePlatform.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteSconce.cs | 4 +++- Tiles/FurnitureCosmilite/CosmiliteSink.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteSofa.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteTable.cs | 2 +- Tiles/FurnitureCosmilite/CosmiliteWorkbench.cs | 2 +- Tiles/FurnitureOccult/OccultBathtub.cs | 2 +- Tiles/FurnitureOccult/OccultBed.cs | 2 +- Tiles/FurnitureOccult/OccultBookcase.cs | 2 +- Tiles/FurnitureOccult/OccultCandelabra.cs | 2 +- Tiles/FurnitureOccult/OccultCandle.cs | 2 +- Tiles/FurnitureOccult/OccultChair.cs | 2 +- Tiles/FurnitureOccult/OccultChandelier.cs | 2 +- Tiles/FurnitureOccult/OccultClock.cs | 2 +- Tiles/FurnitureOccult/OccultDoorClosed.cs | 2 +- Tiles/FurnitureOccult/OccultDoorOpen.cs | 2 +- Tiles/FurnitureOccult/OccultLamp.cs | 2 +- Tiles/FurnitureOccult/OccultLantern.cs | 2 +- Tiles/FurnitureOccult/OccultPiano.cs | 2 +- Tiles/FurnitureOccult/OccultPlatform.cs | 2 +- Tiles/FurnitureOccult/OccultSink.cs | 2 +- Tiles/FurnitureOccult/OccultSofa.cs | 2 +- Tiles/FurnitureOccult/OccultTable.cs | 2 +- Tiles/FurnitureOccult/OccultWorkbench.cs | 2 +- Tiles/FurnitureProfaned/ProfanedBath.cs | 2 +- Tiles/FurnitureProfaned/ProfanedBed.cs | 2 +- Tiles/FurnitureProfaned/ProfanedBench.cs | 2 +- Tiles/FurnitureProfaned/ProfanedBookcase.cs | 2 +- Tiles/FurnitureProfaned/ProfanedCandelabra.cs | 2 +- Tiles/FurnitureProfaned/ProfanedCandle.cs | 2 +- Tiles/FurnitureProfaned/ProfanedChair.cs | 2 +- Tiles/FurnitureProfaned/ProfanedChandelier.cs | 2 +- Tiles/FurnitureProfaned/ProfanedClock.cs | 2 +- Tiles/FurnitureProfaned/ProfanedDoorClosed.cs | 2 +- Tiles/FurnitureProfaned/ProfanedDoorOpen.cs | 2 +- Tiles/FurnitureProfaned/ProfanedLamp.cs | 2 +- Tiles/FurnitureProfaned/ProfanedLantern.cs | 2 +- Tiles/FurnitureProfaned/ProfanedPiano.cs | 4 +++- Tiles/FurnitureProfaned/ProfanedPlatform.cs | 2 +- Tiles/FurnitureProfaned/ProfanedSink.cs | 2 +- Tiles/FurnitureProfaned/ProfanedTable.cs | 2 +- Tiles/FurnitureProfaned/ProfanedWorkbench.cs | 2 +- Tiles/FurnitureSilva/SilvaBathtub.cs | 2 +- Tiles/FurnitureSilva/SilvaBed.cs | 2 +- Tiles/FurnitureSilva/SilvaBench.cs | 2 +- Tiles/FurnitureSilva/SilvaBookcase.cs | 2 +- Tiles/FurnitureSilva/SilvaCandelabra.cs | 2 +- Tiles/FurnitureSilva/SilvaCandle.cs | 2 +- Tiles/FurnitureSilva/SilvaChair.cs | 2 +- Tiles/FurnitureSilva/SilvaChandelier.cs | 2 +- Tiles/FurnitureSilva/SilvaClock.cs | 2 +- Tiles/FurnitureSilva/SilvaDoorClosed.cs | 2 +- Tiles/FurnitureSilva/SilvaDoorOpen.cs | 2 +- Tiles/FurnitureSilva/SilvaLamp.cs | 2 +- Tiles/FurnitureSilva/SilvaLantern.cs | 2 +- Tiles/FurnitureSilva/SilvaPiano.cs | 2 +- Tiles/FurnitureSilva/SilvaPlatform.cs | 2 +- Tiles/FurnitureSilva/SilvaSink.cs | 2 +- Tiles/FurnitureSilva/SilvaTable.cs | 2 +- Tiles/FurnitureSilva/SilvaWorkBench.cs | 2 +- Tiles/FurnitureStratus/StratusBathtub.cs | 2 +- Tiles/FurnitureStratus/StratusBed.cs | 2 +- Tiles/FurnitureStratus/StratusBookcase.cs | 2 +- Tiles/FurnitureStratus/StratusCandelabra.cs | 2 +- Tiles/FurnitureStratus/StratusCandle.cs | 2 +- Tiles/FurnitureStratus/StratusChair.cs | 2 +- Tiles/FurnitureStratus/StratusChandelier.cs | 2 +- Tiles/FurnitureStratus/StratusClock.cs | 2 +- Tiles/FurnitureStratus/StratusDoorClosed.cs | 2 +- Tiles/FurnitureStratus/StratusDoorOpen.cs | 2 +- Tiles/FurnitureStratus/StratusLamp.cs | 2 +- Tiles/FurnitureStratus/StratusLantern.cs | 2 +- Tiles/FurnitureStratus/StratusPiano.cs | 2 +- Tiles/FurnitureStratus/StratusPlatform.cs | 2 +- Tiles/FurnitureStratus/StratusSink.cs | 2 +- Tiles/FurnitureStratus/StratusSofa.cs | 2 +- Tiles/FurnitureStratus/StratusTable.cs | 2 +- Tiles/FurnitureStratus/StratusWorkbench.cs | 2 +- Utilities/CalamityUtils.cs | 2 -- 115 files changed, 126 insertions(+), 117 deletions(-) diff --git a/Tiles/Furniture/CraftingStations/BotanicPlanter.cs b/Tiles/Furniture/CraftingStations/BotanicPlanter.cs index 559fee4265..3339045f1f 100644 --- a/Tiles/Furniture/CraftingStations/BotanicPlanter.cs +++ b/Tiles/Furniture/CraftingStations/BotanicPlanter.cs @@ -13,15 +13,16 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations { Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; + Main.tileLavaDeath[Type] = false; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); - TileObjectData.newTile.LavaDeath = true; + TileObjectData.newTile.LavaDeath = false; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Planter"); AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; adjTiles = new int[] { TileID.Torches }; + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/Furniture/CraftingStations/DraedonsForge.cs b/Tiles/Furniture/CraftingStations/DraedonsForge.cs index 43b65c7039..b80d345cb9 100644 --- a/Tiles/Furniture/CraftingStations/DraedonsForge.cs +++ b/Tiles/Furniture/CraftingStations/DraedonsForge.cs @@ -14,7 +14,9 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileNoAttach[Type] = true; + Main.tileLavaDeath[Type] = false; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.LavaDeath = false; TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); diff --git a/Tiles/Furniture/CraftingStations/ProfanedBasin.cs b/Tiles/Furniture/CraftingStations/ProfanedBasin.cs index 2fe608cb69..e9d7fb7926 100644 --- a/Tiles/Furniture/CraftingStations/ProfanedBasin.cs +++ b/Tiles/Furniture/CraftingStations/ProfanedBasin.cs @@ -13,14 +13,16 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations { Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; + Main.tileLavaDeath[Type] = false; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.LavaDeath = false; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Crucible"); AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; adjTiles = new int[] { TileID.Torches }; + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/Furniture/CraftingStations/SilvaBasin.cs b/Tiles/Furniture/CraftingStations/SilvaBasin.cs index 890557fb4a..154232df3b 100644 --- a/Tiles/Furniture/CraftingStations/SilvaBasin.cs +++ b/Tiles/Furniture/CraftingStations/SilvaBasin.cs @@ -13,15 +13,16 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations { Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; + Main.tileLavaDeath[Type] = false; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); - TileObjectData.newTile.LavaDeath = true; + TileObjectData.newTile.LavaDeath = false; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); name.SetDefault("Effulgent Manipulator"); AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; adjTiles = new int[] { TileID.Torches }; + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/FurnitureBotanic/BotanicBathtub.cs b/Tiles/FurnitureBotanic/BotanicBathtub.cs index 00cbff52fc..f2954b1e2b 100644 --- a/Tiles/FurnitureBotanic/BotanicBathtub.cs +++ b/Tiles/FurnitureBotanic/BotanicBathtub.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpBathtub(); + this.SetUpBathtub(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Bathtub"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicBed.cs b/Tiles/FurnitureBotanic/BotanicBed.cs index e38443be80..d06213a403 100644 --- a/Tiles/FurnitureBotanic/BotanicBed.cs +++ b/Tiles/FurnitureBotanic/BotanicBed.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpBed(); + this.SetUpBed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Bed"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicBench.cs b/Tiles/FurnitureBotanic/BotanicBench.cs index 5d9c44a0a2..f144ec35b3 100644 --- a/Tiles/FurnitureBotanic/BotanicBench.cs +++ b/Tiles/FurnitureBotanic/BotanicBench.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpSofa(); + this.SetUpSofa(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Bench"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicBookcase.cs b/Tiles/FurnitureBotanic/BotanicBookcase.cs index 7a72486aea..8ea38dcfce 100644 --- a/Tiles/FurnitureBotanic/BotanicBookcase.cs +++ b/Tiles/FurnitureBotanic/BotanicBookcase.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpBookcase(); + this.SetUpBookcase(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Bookcase"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicCandelabra.cs b/Tiles/FurnitureBotanic/BotanicCandelabra.cs index f403e08ece..5db67b3b16 100644 --- a/Tiles/FurnitureBotanic/BotanicCandelabra.cs +++ b/Tiles/FurnitureBotanic/BotanicCandelabra.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpCandelabra(); + this.SetUpCandelabra(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Candelabra"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicCandle.cs b/Tiles/FurnitureBotanic/BotanicCandle.cs index 4d95bdc1c1..da7d461831 100644 --- a/Tiles/FurnitureBotanic/BotanicCandle.cs +++ b/Tiles/FurnitureBotanic/BotanicCandle.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpCandle(); + this.SetUpCandle(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Candle"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicChair.cs b/Tiles/FurnitureBotanic/BotanicChair.cs index 94472a0b41..db958da5a3 100644 --- a/Tiles/FurnitureBotanic/BotanicChair.cs +++ b/Tiles/FurnitureBotanic/BotanicChair.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpChair(); + this.SetUpChair(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Chair"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicChandelier.cs b/Tiles/FurnitureBotanic/BotanicChandelier.cs index 9abd6913f6..29f176037e 100644 --- a/Tiles/FurnitureBotanic/BotanicChandelier.cs +++ b/Tiles/FurnitureBotanic/BotanicChandelier.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpChandelier(); + this.SetUpChandelier(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Chandelier"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicClock.cs b/Tiles/FurnitureBotanic/BotanicClock.cs index 58c0d26079..878d3e54c3 100644 --- a/Tiles/FurnitureBotanic/BotanicClock.cs +++ b/Tiles/FurnitureBotanic/BotanicClock.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpClock(); + this.SetUpClock(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Clock"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicDoorClosed.cs b/Tiles/FurnitureBotanic/BotanicDoorClosed.cs index 518ffc9949..2d235959de 100644 --- a/Tiles/FurnitureBotanic/BotanicDoorClosed.cs +++ b/Tiles/FurnitureBotanic/BotanicDoorClosed.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpDoorClosed(); + this.SetUpDoorClosed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicDoorOpen.cs b/Tiles/FurnitureBotanic/BotanicDoorOpen.cs index c7c7dc2b07..b7b9f267f9 100644 --- a/Tiles/FurnitureBotanic/BotanicDoorOpen.cs +++ b/Tiles/FurnitureBotanic/BotanicDoorOpen.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpDoorOpen(); + this.SetUpDoorOpen(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicLamp.cs b/Tiles/FurnitureBotanic/BotanicLamp.cs index a814793861..2586fa1969 100644 --- a/Tiles/FurnitureBotanic/BotanicLamp.cs +++ b/Tiles/FurnitureBotanic/BotanicLamp.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpLamp(); + this.SetUpLamp(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Lamp"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicLantern.cs b/Tiles/FurnitureBotanic/BotanicLantern.cs index 27021b037e..819aadba16 100644 --- a/Tiles/FurnitureBotanic/BotanicLantern.cs +++ b/Tiles/FurnitureBotanic/BotanicLantern.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpLantern(); + this.SetUpLantern(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Lantern"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicPiano.cs b/Tiles/FurnitureBotanic/BotanicPiano.cs index dc7a4376c7..bcd61cd7a9 100644 --- a/Tiles/FurnitureBotanic/BotanicPiano.cs +++ b/Tiles/FurnitureBotanic/BotanicPiano.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpPiano(); + this.SetUpPiano(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Piano"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicPlatform.cs b/Tiles/FurnitureBotanic/BotanicPlatform.cs index 47718f5454..41c4512bbe 100644 --- a/Tiles/FurnitureBotanic/BotanicPlatform.cs +++ b/Tiles/FurnitureBotanic/BotanicPlatform.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpPlatform(); + this.SetUpPlatform(true); AddMapEntry(new Color(191, 142, 111)); drop = ModContent.ItemType(); disableSmartCursor = true; diff --git a/Tiles/FurnitureBotanic/BotanicSink.cs b/Tiles/FurnitureBotanic/BotanicSink.cs index 149e861c74..262aa5a7dd 100644 --- a/Tiles/FurnitureBotanic/BotanicSink.cs +++ b/Tiles/FurnitureBotanic/BotanicSink.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpSink(); + this.SetUpSink(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Sink"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicTable.cs b/Tiles/FurnitureBotanic/BotanicTable.cs index 6295a2c4c3..9d4887c97a 100644 --- a/Tiles/FurnitureBotanic/BotanicTable.cs +++ b/Tiles/FurnitureBotanic/BotanicTable.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpTable(); + this.SetUpTable(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Table"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureBotanic/BotanicWorkBench.cs b/Tiles/FurnitureBotanic/BotanicWorkBench.cs index 3ede514034..2c96eb1a89 100644 --- a/Tiles/FurnitureBotanic/BotanicWorkBench.cs +++ b/Tiles/FurnitureBotanic/BotanicWorkBench.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic { public override void SetDefaults() { - this.SetUpWorkBench(); + this.SetUpWorkBench(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Botanic Work Bench"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs b/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs index 78d10a7148..bd65fb42d7 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs @@ -17,9 +17,10 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; + Main.tileLavaDeath[Type] = false; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.LavaDeath = false; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Basin"); diff --git a/Tiles/FurnitureCosmilite/CosmiliteBath.cs b/Tiles/FurnitureCosmilite/CosmiliteBath.cs index ef6791ed6d..8b2c9d242f 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteBath.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteBath.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpBathtub(); + this.SetUpBathtub(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Bathtub"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmiliteBed.cs b/Tiles/FurnitureCosmilite/CosmiliteBed.cs index baefb13234..86ebcb1cb2 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteBed.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteBed.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpBed(); + this.SetUpBed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Bed"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmiliteBookcase.cs b/Tiles/FurnitureCosmilite/CosmiliteBookcase.cs index 4f96bd3e70..6257f55336 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteBookcase.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteBookcase.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpBookcase(); + this.SetUpBookcase(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Bookcase"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmiliteCandelabra.cs b/Tiles/FurnitureCosmilite/CosmiliteCandelabra.cs index 88d09d8bf7..d286ddbf1c 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteCandelabra.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteCandelabra.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpCandelabra(); + this.SetUpCandelabra(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Candelabra"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmiliteCandle.cs b/Tiles/FurnitureCosmilite/CosmiliteCandle.cs index 8d648492ae..64f40910ea 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteCandle.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteCandle.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpCandle(); + this.SetUpCandle(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Candle"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmiliteChair.cs b/Tiles/FurnitureCosmilite/CosmiliteChair.cs index 612ccc596f..d728829c70 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteChair.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteChair.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpChair(); + this.SetUpChair(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Chair"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmiliteChandelier.cs b/Tiles/FurnitureCosmilite/CosmiliteChandelier.cs index 65bd59f6a6..9804f2fca9 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteChandelier.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteChandelier.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpChandelier(); + this.SetUpChandelier(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Chandelier"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmiliteClock.cs b/Tiles/FurnitureCosmilite/CosmiliteClock.cs index 7f60027a3a..2b6a0c3fa8 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteClock.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteClock.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpClock(); + this.SetUpClock(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Clock"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmiliteDoorClosed.cs b/Tiles/FurnitureCosmilite/CosmiliteDoorClosed.cs index aed053387d..7279f215af 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteDoorClosed.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteDoorClosed.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpDoorClosed(); + this.SetUpDoorClosed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmiliteDoorOpen.cs b/Tiles/FurnitureCosmilite/CosmiliteDoorOpen.cs index b54e6169db..9fc3a2d8b9 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteDoorOpen.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteDoorOpen.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpDoorOpen(); + this.SetUpDoorOpen(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmiliteLamp.cs b/Tiles/FurnitureCosmilite/CosmiliteLamp.cs index 944235d1e5..f33a0b939f 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteLamp.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteLamp.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpLamp(); + this.SetUpLamp(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Lamp"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmiliteLantern.cs b/Tiles/FurnitureCosmilite/CosmiliteLantern.cs index 96562421a1..dfefc8657f 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteLantern.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteLantern.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpLantern(); + this.SetUpLantern(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Lantern"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmilitePiano.cs b/Tiles/FurnitureCosmilite/CosmilitePiano.cs index f62d474430..5bd4a722d1 100644 --- a/Tiles/FurnitureCosmilite/CosmilitePiano.cs +++ b/Tiles/FurnitureCosmilite/CosmilitePiano.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpPiano(); + this.SetUpPiano(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Piano"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmilitePlatform.cs b/Tiles/FurnitureCosmilite/CosmilitePlatform.cs index aab34d9eae..fbd647b24f 100644 --- a/Tiles/FurnitureCosmilite/CosmilitePlatform.cs +++ b/Tiles/FurnitureCosmilite/CosmilitePlatform.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpPlatform(); + this.SetUpPlatform(true); AddMapEntry(new Color(191, 142, 111)); drop = ModContent.ItemType(); disableSmartCursor = true; diff --git a/Tiles/FurnitureCosmilite/CosmiliteSconce.cs b/Tiles/FurnitureCosmilite/CosmiliteSconce.cs index 49b66ae4e0..f645d78171 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteSconce.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteSconce.cs @@ -13,8 +13,9 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; + Main.tileLavaDeath[Type] = false; + TileObjectData.newTile.LavaDeath = false; TileObjectData.newTile.Height = 3; TileObjectData.newTile.Width = 1; TileObjectData.newTile.CoordinateWidth = 16; @@ -32,6 +33,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite disableSmartCursor = true; adjTiles = new int[] { TileID.Torches }; TileID.Sets.FramesOnKillWall[Type] = true; + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/FurnitureCosmilite/CosmiliteSink.cs b/Tiles/FurnitureCosmilite/CosmiliteSink.cs index ccaf72f707..aeb9e53e6b 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteSink.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteSink.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpSink(); + this.SetUpSink(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Sink"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmiliteSofa.cs b/Tiles/FurnitureCosmilite/CosmiliteSofa.cs index 9978817732..5a29d61de4 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteSofa.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteSofa.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpSofa(); + this.SetUpSofa(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Sofa"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmiliteTable.cs b/Tiles/FurnitureCosmilite/CosmiliteTable.cs index 9c34e8122c..17689182a1 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteTable.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteTable.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpTable(); + this.SetUpTable(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Table"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureCosmilite/CosmiliteWorkbench.cs b/Tiles/FurnitureCosmilite/CosmiliteWorkbench.cs index ef6f95077a..c5a67b1f35 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteWorkbench.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteWorkbench.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public override void SetDefaults() { - this.SetUpWorkBench(); + this.SetUpWorkBench(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Cosmilite Work Bench"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultBathtub.cs b/Tiles/FurnitureOccult/OccultBathtub.cs index f0fa5ecbd1..0a8f1c48c2 100644 --- a/Tiles/FurnitureOccult/OccultBathtub.cs +++ b/Tiles/FurnitureOccult/OccultBathtub.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpBathtub(); + this.SetUpBathtub(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Bathtub"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultBed.cs b/Tiles/FurnitureOccult/OccultBed.cs index af6fbd8359..4c89fc7e25 100644 --- a/Tiles/FurnitureOccult/OccultBed.cs +++ b/Tiles/FurnitureOccult/OccultBed.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpBed(); + this.SetUpBed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Bed"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultBookcase.cs b/Tiles/FurnitureOccult/OccultBookcase.cs index 936028afc2..92b58a6a45 100644 --- a/Tiles/FurnitureOccult/OccultBookcase.cs +++ b/Tiles/FurnitureOccult/OccultBookcase.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpBookcase(); + this.SetUpBookcase(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Bookcase"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultCandelabra.cs b/Tiles/FurnitureOccult/OccultCandelabra.cs index 75ee87c5b0..18a4f79913 100644 --- a/Tiles/FurnitureOccult/OccultCandelabra.cs +++ b/Tiles/FurnitureOccult/OccultCandelabra.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpCandelabra(); + this.SetUpCandelabra(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Candelabra"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultCandle.cs b/Tiles/FurnitureOccult/OccultCandle.cs index 41ee78a185..a2683130fd 100644 --- a/Tiles/FurnitureOccult/OccultCandle.cs +++ b/Tiles/FurnitureOccult/OccultCandle.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpCandle(); + this.SetUpCandle(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Candle"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultChair.cs b/Tiles/FurnitureOccult/OccultChair.cs index ac96949e67..cc10f96c57 100644 --- a/Tiles/FurnitureOccult/OccultChair.cs +++ b/Tiles/FurnitureOccult/OccultChair.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpChair(); + this.SetUpChair(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Chair"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultChandelier.cs b/Tiles/FurnitureOccult/OccultChandelier.cs index 0dc8072b9c..40bcede389 100644 --- a/Tiles/FurnitureOccult/OccultChandelier.cs +++ b/Tiles/FurnitureOccult/OccultChandelier.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpChandelier(); + this.SetUpChandelier(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Chandelier"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultClock.cs b/Tiles/FurnitureOccult/OccultClock.cs index a56246afa8..7e9cd7fd61 100644 --- a/Tiles/FurnitureOccult/OccultClock.cs +++ b/Tiles/FurnitureOccult/OccultClock.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpClock(); + this.SetUpClock(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Clock"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultDoorClosed.cs b/Tiles/FurnitureOccult/OccultDoorClosed.cs index a9cbec9694..700c57c38f 100644 --- a/Tiles/FurnitureOccult/OccultDoorClosed.cs +++ b/Tiles/FurnitureOccult/OccultDoorClosed.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpDoorClosed(); + this.SetUpDoorClosed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultDoorOpen.cs b/Tiles/FurnitureOccult/OccultDoorOpen.cs index 1f0c91cbd3..4414796543 100644 --- a/Tiles/FurnitureOccult/OccultDoorOpen.cs +++ b/Tiles/FurnitureOccult/OccultDoorOpen.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpDoorOpen(); + this.SetUpDoorOpen(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultLamp.cs b/Tiles/FurnitureOccult/OccultLamp.cs index 0564f733e9..ed8cd5fa3b 100644 --- a/Tiles/FurnitureOccult/OccultLamp.cs +++ b/Tiles/FurnitureOccult/OccultLamp.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpLamp(); + this.SetUpLamp(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Lamp"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultLantern.cs b/Tiles/FurnitureOccult/OccultLantern.cs index c54d00e75e..bd3a7e4c80 100644 --- a/Tiles/FurnitureOccult/OccultLantern.cs +++ b/Tiles/FurnitureOccult/OccultLantern.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpLantern(); + this.SetUpLantern(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Lantern"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultPiano.cs b/Tiles/FurnitureOccult/OccultPiano.cs index e1c2094e23..0949690a85 100644 --- a/Tiles/FurnitureOccult/OccultPiano.cs +++ b/Tiles/FurnitureOccult/OccultPiano.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpPiano(); + this.SetUpPiano(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Piano"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultPlatform.cs b/Tiles/FurnitureOccult/OccultPlatform.cs index f765779440..3653c2c741 100644 --- a/Tiles/FurnitureOccult/OccultPlatform.cs +++ b/Tiles/FurnitureOccult/OccultPlatform.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpPlatform(); + this.SetUpPlatform(true); AddMapEntry(new Color(191, 142, 111)); drop = ModContent.ItemType(); disableSmartCursor = true; diff --git a/Tiles/FurnitureOccult/OccultSink.cs b/Tiles/FurnitureOccult/OccultSink.cs index 9a3382449d..5704660360 100644 --- a/Tiles/FurnitureOccult/OccultSink.cs +++ b/Tiles/FurnitureOccult/OccultSink.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpSink(); + this.SetUpSink(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Sink"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultSofa.cs b/Tiles/FurnitureOccult/OccultSofa.cs index 2744ce6138..f3e84bdd70 100644 --- a/Tiles/FurnitureOccult/OccultSofa.cs +++ b/Tiles/FurnitureOccult/OccultSofa.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpSofa(); + this.SetUpSofa(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Sofa"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultTable.cs b/Tiles/FurnitureOccult/OccultTable.cs index 8277b56014..d93a3acd7f 100644 --- a/Tiles/FurnitureOccult/OccultTable.cs +++ b/Tiles/FurnitureOccult/OccultTable.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpTable(); + this.SetUpTable(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Table"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureOccult/OccultWorkbench.cs b/Tiles/FurnitureOccult/OccultWorkbench.cs index bbe6141914..826e151d3d 100644 --- a/Tiles/FurnitureOccult/OccultWorkbench.cs +++ b/Tiles/FurnitureOccult/OccultWorkbench.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureOccult { public override void SetDefaults() { - this.SetUpWorkBench(); + this.SetUpWorkBench(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Otherworldly Work Bench"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedBath.cs b/Tiles/FurnitureProfaned/ProfanedBath.cs index e1e508d534..2753dabe74 100644 --- a/Tiles/FurnitureProfaned/ProfanedBath.cs +++ b/Tiles/FurnitureProfaned/ProfanedBath.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpBathtub(); + this.SetUpBathtub(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Bathtub"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedBed.cs b/Tiles/FurnitureProfaned/ProfanedBed.cs index 921ba7fa2c..df70a152f8 100644 --- a/Tiles/FurnitureProfaned/ProfanedBed.cs +++ b/Tiles/FurnitureProfaned/ProfanedBed.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpBed(); + this.SetUpBed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Bed"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedBench.cs b/Tiles/FurnitureProfaned/ProfanedBench.cs index 69b64a12bc..9a6e63ca75 100644 --- a/Tiles/FurnitureProfaned/ProfanedBench.cs +++ b/Tiles/FurnitureProfaned/ProfanedBench.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpSofa(); + this.SetUpSofa(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Bench"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedBookcase.cs b/Tiles/FurnitureProfaned/ProfanedBookcase.cs index 2172bb0099..09d17ee7d5 100644 --- a/Tiles/FurnitureProfaned/ProfanedBookcase.cs +++ b/Tiles/FurnitureProfaned/ProfanedBookcase.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpBookcase(); + this.SetUpBookcase(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Bookcase"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedCandelabra.cs b/Tiles/FurnitureProfaned/ProfanedCandelabra.cs index f809a9a0c4..00de7fe7b3 100644 --- a/Tiles/FurnitureProfaned/ProfanedCandelabra.cs +++ b/Tiles/FurnitureProfaned/ProfanedCandelabra.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpCandelabra(); + this.SetUpCandelabra(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Candelabra"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedCandle.cs b/Tiles/FurnitureProfaned/ProfanedCandle.cs index b183e2fc8c..4946095dbd 100644 --- a/Tiles/FurnitureProfaned/ProfanedCandle.cs +++ b/Tiles/FurnitureProfaned/ProfanedCandle.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpCandle(); + this.SetUpCandle(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Candle"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedChair.cs b/Tiles/FurnitureProfaned/ProfanedChair.cs index 8aefc380f3..35f51165df 100644 --- a/Tiles/FurnitureProfaned/ProfanedChair.cs +++ b/Tiles/FurnitureProfaned/ProfanedChair.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpChair(); + this.SetUpChair(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Chair"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedChandelier.cs b/Tiles/FurnitureProfaned/ProfanedChandelier.cs index 4af1e58b3c..f983f413a0 100644 --- a/Tiles/FurnitureProfaned/ProfanedChandelier.cs +++ b/Tiles/FurnitureProfaned/ProfanedChandelier.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpChandelier(); + this.SetUpChandelier(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Chandelier"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedClock.cs b/Tiles/FurnitureProfaned/ProfanedClock.cs index 26e2ab6612..b3467a977d 100644 --- a/Tiles/FurnitureProfaned/ProfanedClock.cs +++ b/Tiles/FurnitureProfaned/ProfanedClock.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpClock(); + this.SetUpClock(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Clock"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedDoorClosed.cs b/Tiles/FurnitureProfaned/ProfanedDoorClosed.cs index be0956c8e6..d558f89bdd 100644 --- a/Tiles/FurnitureProfaned/ProfanedDoorClosed.cs +++ b/Tiles/FurnitureProfaned/ProfanedDoorClosed.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpDoorClosed(); + this.SetUpDoorClosed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedDoorOpen.cs b/Tiles/FurnitureProfaned/ProfanedDoorOpen.cs index 377154f463..c4c37c6282 100644 --- a/Tiles/FurnitureProfaned/ProfanedDoorOpen.cs +++ b/Tiles/FurnitureProfaned/ProfanedDoorOpen.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpDoorOpen(); + this.SetUpDoorOpen(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedLamp.cs b/Tiles/FurnitureProfaned/ProfanedLamp.cs index bf5c0e956a..bce7c22619 100644 --- a/Tiles/FurnitureProfaned/ProfanedLamp.cs +++ b/Tiles/FurnitureProfaned/ProfanedLamp.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpLamp(); + this.SetUpLamp(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Lamp"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedLantern.cs b/Tiles/FurnitureProfaned/ProfanedLantern.cs index 3b6ebc8ad3..a4f836b7cf 100644 --- a/Tiles/FurnitureProfaned/ProfanedLantern.cs +++ b/Tiles/FurnitureProfaned/ProfanedLantern.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpLantern(); + this.SetUpLantern(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Lantern"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedPiano.cs b/Tiles/FurnitureProfaned/ProfanedPiano.cs index 032dcb77e6..e940c9a2d9 100644 --- a/Tiles/FurnitureProfaned/ProfanedPiano.cs +++ b/Tiles/FurnitureProfaned/ProfanedPiano.cs @@ -12,13 +12,15 @@ namespace CalamityMod.Tiles.FurnitureProfaned { Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; + Main.tileLavaDeath[Type] = false; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.LavaDeath = false; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Piano"); AddMapEntry(new Color(191, 142, 111), name); + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/FurnitureProfaned/ProfanedPlatform.cs b/Tiles/FurnitureProfaned/ProfanedPlatform.cs index 28765ecb82..f1913ea446 100644 --- a/Tiles/FurnitureProfaned/ProfanedPlatform.cs +++ b/Tiles/FurnitureProfaned/ProfanedPlatform.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpPlatform(); + this.SetUpPlatform(true); AddMapEntry(new Color(191, 142, 111)); drop = ModContent.ItemType(); disableSmartCursor = true; diff --git a/Tiles/FurnitureProfaned/ProfanedSink.cs b/Tiles/FurnitureProfaned/ProfanedSink.cs index 67b47521e9..b0ede6764c 100644 --- a/Tiles/FurnitureProfaned/ProfanedSink.cs +++ b/Tiles/FurnitureProfaned/ProfanedSink.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpSink(); + this.SetUpSink(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Sink"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedTable.cs b/Tiles/FurnitureProfaned/ProfanedTable.cs index d82d55e5ff..dc9d7a4b39 100644 --- a/Tiles/FurnitureProfaned/ProfanedTable.cs +++ b/Tiles/FurnitureProfaned/ProfanedTable.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpTable(); + this.SetUpTable(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Table"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureProfaned/ProfanedWorkbench.cs b/Tiles/FurnitureProfaned/ProfanedWorkbench.cs index 9036aa2f7a..d4ab248f64 100644 --- a/Tiles/FurnitureProfaned/ProfanedWorkbench.cs +++ b/Tiles/FurnitureProfaned/ProfanedWorkbench.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public override void SetDefaults() { - this.SetUpWorkBench(); + this.SetUpWorkBench(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Profaned Work Bench"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaBathtub.cs b/Tiles/FurnitureSilva/SilvaBathtub.cs index 2944f9a710..7fa48ba2f0 100644 --- a/Tiles/FurnitureSilva/SilvaBathtub.cs +++ b/Tiles/FurnitureSilva/SilvaBathtub.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpBathtub(); + this.SetUpBathtub(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Bathtub"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaBed.cs b/Tiles/FurnitureSilva/SilvaBed.cs index 06edbda356..7fda4981bc 100644 --- a/Tiles/FurnitureSilva/SilvaBed.cs +++ b/Tiles/FurnitureSilva/SilvaBed.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpBed(); + this.SetUpBed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Bed"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaBench.cs b/Tiles/FurnitureSilva/SilvaBench.cs index 1fa9d7de34..e383b751b7 100644 --- a/Tiles/FurnitureSilva/SilvaBench.cs +++ b/Tiles/FurnitureSilva/SilvaBench.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpSofa(); + this.SetUpSofa(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Bench"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaBookcase.cs b/Tiles/FurnitureSilva/SilvaBookcase.cs index 90df04b038..e3126b7f00 100644 --- a/Tiles/FurnitureSilva/SilvaBookcase.cs +++ b/Tiles/FurnitureSilva/SilvaBookcase.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpBookcase(); + this.SetUpBookcase(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Bookcase"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaCandelabra.cs b/Tiles/FurnitureSilva/SilvaCandelabra.cs index e0b15ebada..e8875670c6 100644 --- a/Tiles/FurnitureSilva/SilvaCandelabra.cs +++ b/Tiles/FurnitureSilva/SilvaCandelabra.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpCandelabra(); + this.SetUpCandelabra(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Candelabra"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaCandle.cs b/Tiles/FurnitureSilva/SilvaCandle.cs index ece2028d95..4c0979016a 100644 --- a/Tiles/FurnitureSilva/SilvaCandle.cs +++ b/Tiles/FurnitureSilva/SilvaCandle.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpCandle(); + this.SetUpCandle(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Candle"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaChair.cs b/Tiles/FurnitureSilva/SilvaChair.cs index 079844f226..7b51507d20 100644 --- a/Tiles/FurnitureSilva/SilvaChair.cs +++ b/Tiles/FurnitureSilva/SilvaChair.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpChair(); + this.SetUpChair(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Chair"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaChandelier.cs b/Tiles/FurnitureSilva/SilvaChandelier.cs index b1cff31a2a..72206d4998 100644 --- a/Tiles/FurnitureSilva/SilvaChandelier.cs +++ b/Tiles/FurnitureSilva/SilvaChandelier.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpChandelier(); + this.SetUpChandelier(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Chandelier"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaClock.cs b/Tiles/FurnitureSilva/SilvaClock.cs index aebfb1db2b..9877c27032 100644 --- a/Tiles/FurnitureSilva/SilvaClock.cs +++ b/Tiles/FurnitureSilva/SilvaClock.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpClock(); + this.SetUpClock(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Clock"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaDoorClosed.cs b/Tiles/FurnitureSilva/SilvaDoorClosed.cs index 8ef1bcc480..7626a98526 100644 --- a/Tiles/FurnitureSilva/SilvaDoorClosed.cs +++ b/Tiles/FurnitureSilva/SilvaDoorClosed.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpDoorClosed(); + this.SetUpDoorClosed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaDoorOpen.cs b/Tiles/FurnitureSilva/SilvaDoorOpen.cs index 12ac6f22a3..9123dbf51f 100644 --- a/Tiles/FurnitureSilva/SilvaDoorOpen.cs +++ b/Tiles/FurnitureSilva/SilvaDoorOpen.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpDoorOpen(); + this.SetUpDoorOpen(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaLamp.cs b/Tiles/FurnitureSilva/SilvaLamp.cs index f923d990a3..5cf79c5eda 100644 --- a/Tiles/FurnitureSilva/SilvaLamp.cs +++ b/Tiles/FurnitureSilva/SilvaLamp.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpLamp(); + this.SetUpLamp(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Lamp"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaLantern.cs b/Tiles/FurnitureSilva/SilvaLantern.cs index eed93c6b63..5ab306771a 100644 --- a/Tiles/FurnitureSilva/SilvaLantern.cs +++ b/Tiles/FurnitureSilva/SilvaLantern.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpLantern(); + this.SetUpLantern(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Lantern"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaPiano.cs b/Tiles/FurnitureSilva/SilvaPiano.cs index 5e99787618..ac990dcc74 100644 --- a/Tiles/FurnitureSilva/SilvaPiano.cs +++ b/Tiles/FurnitureSilva/SilvaPiano.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpPiano(); + this.SetUpPiano(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Piano"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaPlatform.cs b/Tiles/FurnitureSilva/SilvaPlatform.cs index a77404b170..570a00395c 100644 --- a/Tiles/FurnitureSilva/SilvaPlatform.cs +++ b/Tiles/FurnitureSilva/SilvaPlatform.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpPlatform(); + this.SetUpPlatform(true); AddMapEntry(new Color(191, 142, 111)); drop = ModContent.ItemType(); disableSmartCursor = true; diff --git a/Tiles/FurnitureSilva/SilvaSink.cs b/Tiles/FurnitureSilva/SilvaSink.cs index a4a8a3b74e..994187363c 100644 --- a/Tiles/FurnitureSilva/SilvaSink.cs +++ b/Tiles/FurnitureSilva/SilvaSink.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpSink(); + this.SetUpSink(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Sink"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaTable.cs b/Tiles/FurnitureSilva/SilvaTable.cs index 9391c27cf6..e11812dd68 100644 --- a/Tiles/FurnitureSilva/SilvaTable.cs +++ b/Tiles/FurnitureSilva/SilvaTable.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpTable(); + this.SetUpTable(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Table"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureSilva/SilvaWorkBench.cs b/Tiles/FurnitureSilva/SilvaWorkBench.cs index ef8cf6f926..75f562b4ed 100644 --- a/Tiles/FurnitureSilva/SilvaWorkBench.cs +++ b/Tiles/FurnitureSilva/SilvaWorkBench.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureSilva { public override void SetDefaults() { - this.SetUpWorkBench(); + this.SetUpWorkBench(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Silva Work Bench"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusBathtub.cs b/Tiles/FurnitureStratus/StratusBathtub.cs index 8947ee23f8..75ead49829 100644 --- a/Tiles/FurnitureStratus/StratusBathtub.cs +++ b/Tiles/FurnitureStratus/StratusBathtub.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpBathtub(); + this.SetUpBathtub(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Bathtub"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusBed.cs b/Tiles/FurnitureStratus/StratusBed.cs index b347463b93..7226e77df3 100644 --- a/Tiles/FurnitureStratus/StratusBed.cs +++ b/Tiles/FurnitureStratus/StratusBed.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpBed(); + this.SetUpBed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Bed"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusBookcase.cs b/Tiles/FurnitureStratus/StratusBookcase.cs index 025c7b4ecd..60729ec3e7 100644 --- a/Tiles/FurnitureStratus/StratusBookcase.cs +++ b/Tiles/FurnitureStratus/StratusBookcase.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpBookcase(); + this.SetUpBookcase(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Bookcase"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusCandelabra.cs b/Tiles/FurnitureStratus/StratusCandelabra.cs index bc1be94278..e4eedbe0e8 100644 --- a/Tiles/FurnitureStratus/StratusCandelabra.cs +++ b/Tiles/FurnitureStratus/StratusCandelabra.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpCandelabra(); + this.SetUpCandelabra(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Candelabra"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusCandle.cs b/Tiles/FurnitureStratus/StratusCandle.cs index e990975b06..198416465c 100644 --- a/Tiles/FurnitureStratus/StratusCandle.cs +++ b/Tiles/FurnitureStratus/StratusCandle.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpCandle(); + this.SetUpCandle(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Candle"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusChair.cs b/Tiles/FurnitureStratus/StratusChair.cs index 9f48a73dd4..3e842fbc24 100644 --- a/Tiles/FurnitureStratus/StratusChair.cs +++ b/Tiles/FurnitureStratus/StratusChair.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpChair(); + this.SetUpChair(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Chair"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusChandelier.cs b/Tiles/FurnitureStratus/StratusChandelier.cs index af549c2547..2038f36c3c 100644 --- a/Tiles/FurnitureStratus/StratusChandelier.cs +++ b/Tiles/FurnitureStratus/StratusChandelier.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpChandelier(); + this.SetUpChandelier(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Chandelier"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusClock.cs b/Tiles/FurnitureStratus/StratusClock.cs index 689558c938..dd6fe9a800 100644 --- a/Tiles/FurnitureStratus/StratusClock.cs +++ b/Tiles/FurnitureStratus/StratusClock.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpClock(); + this.SetUpClock(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Clock"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusDoorClosed.cs b/Tiles/FurnitureStratus/StratusDoorClosed.cs index c5e0b4cafa..050e9f25f5 100644 --- a/Tiles/FurnitureStratus/StratusDoorClosed.cs +++ b/Tiles/FurnitureStratus/StratusDoorClosed.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpDoorClosed(); + this.SetUpDoorClosed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusDoorOpen.cs b/Tiles/FurnitureStratus/StratusDoorOpen.cs index 294d81ec5f..e5eb6e9c49 100644 --- a/Tiles/FurnitureStratus/StratusDoorOpen.cs +++ b/Tiles/FurnitureStratus/StratusDoorOpen.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpDoorOpen(); + this.SetUpDoorOpen(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusLamp.cs b/Tiles/FurnitureStratus/StratusLamp.cs index 33e87e40ad..6a9cbdf28e 100644 --- a/Tiles/FurnitureStratus/StratusLamp.cs +++ b/Tiles/FurnitureStratus/StratusLamp.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpLamp(); + this.SetUpLamp(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Lamp"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusLantern.cs b/Tiles/FurnitureStratus/StratusLantern.cs index 70208aa655..e0bc5cb5ab 100644 --- a/Tiles/FurnitureStratus/StratusLantern.cs +++ b/Tiles/FurnitureStratus/StratusLantern.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpLantern(); + this.SetUpLantern(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Lantern"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusPiano.cs b/Tiles/FurnitureStratus/StratusPiano.cs index b00db1fe51..4593aa58ea 100644 --- a/Tiles/FurnitureStratus/StratusPiano.cs +++ b/Tiles/FurnitureStratus/StratusPiano.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpPiano(); + this.SetUpPiano(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Piano"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusPlatform.cs b/Tiles/FurnitureStratus/StratusPlatform.cs index cb879e2dd3..93b630321d 100644 --- a/Tiles/FurnitureStratus/StratusPlatform.cs +++ b/Tiles/FurnitureStratus/StratusPlatform.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpPlatform(); + this.SetUpPlatform(true); AddMapEntry(new Color(191, 142, 111)); drop = ModContent.ItemType(); disableSmartCursor = true; diff --git a/Tiles/FurnitureStratus/StratusSink.cs b/Tiles/FurnitureStratus/StratusSink.cs index 43daf0fd97..c5490be0c3 100644 --- a/Tiles/FurnitureStratus/StratusSink.cs +++ b/Tiles/FurnitureStratus/StratusSink.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpSink(); + this.SetUpSink(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Sink"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusSofa.cs b/Tiles/FurnitureStratus/StratusSofa.cs index 31234a38ff..3f8e2e5479 100644 --- a/Tiles/FurnitureStratus/StratusSofa.cs +++ b/Tiles/FurnitureStratus/StratusSofa.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpSofa(); + this.SetUpSofa(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Sofa"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusTable.cs b/Tiles/FurnitureStratus/StratusTable.cs index ef4313f3d0..13c93b6582 100644 --- a/Tiles/FurnitureStratus/StratusTable.cs +++ b/Tiles/FurnitureStratus/StratusTable.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpTable(); + this.SetUpTable(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Table"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureStratus/StratusWorkbench.cs b/Tiles/FurnitureStratus/StratusWorkbench.cs index 5d02910fd9..a371b40dd9 100644 --- a/Tiles/FurnitureStratus/StratusWorkbench.cs +++ b/Tiles/FurnitureStratus/StratusWorkbench.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureStratus { public override void SetDefaults() { - this.SetUpWorkBench(); + this.SetUpWorkBench(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Stratus Work Bench"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index de8fd7ddf2..9d72595493 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -3494,8 +3494,6 @@ namespace CalamityMod Main.tileFrameImportant[mt.Type] = true; Main.tileLavaDeath[mt.Type] = false; Main.tileWaterDeath[mt.Type] = false; - //TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); - //TileObjectData.newTile.Width = 2; TileObjectData.newTile.LavaDeath = false; TileObjectData.addTile(mt.Type); TileID.Sets.HasOutlines[mt.Type] = true; From 99361dce4f983e748d49af0f81baf0400b1d1c09 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 5 Dec 2020 14:57:22 -0500 Subject: [PATCH 09/66] lavaproofed the hardmode sets too --- Tiles/FurnitureAbyss/AbyssBath.cs | 2 +- Tiles/FurnitureAbyss/AbyssBed.cs | 2 +- Tiles/FurnitureAbyss/AbyssBookcase.cs | 2 +- Tiles/FurnitureAbyss/AbyssCandelabra.cs | 2 +- Tiles/FurnitureAbyss/AbyssCandle.cs | 9 ++------- Tiles/FurnitureAbyss/AbyssChair.cs | 2 +- Tiles/FurnitureAbyss/AbyssChandelier.cs | 2 +- Tiles/FurnitureAbyss/AbyssClock.cs | 2 +- Tiles/FurnitureAbyss/AbyssDoorClosed.cs | 2 +- Tiles/FurnitureAbyss/AbyssDoorOpen.cs | 2 +- Tiles/FurnitureAbyss/AbyssLamp.cs | 2 +- Tiles/FurnitureAbyss/AbyssLantern.cs | 2 +- Tiles/FurnitureAbyss/AbyssPiano.cs | 2 +- Tiles/FurnitureAbyss/AbyssSink.cs | 2 +- Tiles/FurnitureAbyss/AbyssSofa.cs | 2 +- Tiles/FurnitureAbyss/AbyssTable.cs | 2 +- Tiles/FurnitureAbyss/AbyssTorch.cs | 2 +- Tiles/FurnitureAbyss/AbyssWorkbench.cs | 2 +- Tiles/FurnitureAbyss/SmoothAbyssGravelPlatform.cs | 2 +- Tiles/FurnitureAstral/MonolithBathtub.cs | 2 +- Tiles/FurnitureAstral/MonolithBed.cs | 2 +- Tiles/FurnitureAstral/MonolithBench.cs | 2 +- Tiles/FurnitureAstral/MonolithBookcase.cs | 2 +- Tiles/FurnitureAstral/MonolithCandelabra.cs | 2 +- Tiles/FurnitureAstral/MonolithCandle.cs | 2 +- Tiles/FurnitureAstral/MonolithChair.cs | 2 +- Tiles/FurnitureAstral/MonolithChandelier.cs | 2 +- Tiles/FurnitureAstral/MonolithClock.cs | 2 +- Tiles/FurnitureAstral/MonolithDoorClosed.cs | 2 +- Tiles/FurnitureAstral/MonolithDoorOpen.cs | 2 +- Tiles/FurnitureAstral/MonolithLamp.cs | 2 +- Tiles/FurnitureAstral/MonolithLantern.cs | 2 +- Tiles/FurnitureAstral/MonolithPiano.cs | 2 +- Tiles/FurnitureAstral/MonolithPlatform.cs | 2 +- Tiles/FurnitureAstral/MonolithSink.cs | 2 +- Tiles/FurnitureAstral/MonolithTable.cs | 2 +- Tiles/FurnitureAstral/MonolithWorkbench.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs | 3 ++- Tiles/FurniturePlaguedPlate/PlaguedPlateBathtub.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlateBed.cs | 3 ++- Tiles/FurniturePlaguedPlate/PlaguedPlateBookcase.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlateCandelabra.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlateCandle.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlateChair.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlateChandelier.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlateClock.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlateDoorClosed.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlateDoorOpen.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlateLamp.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlateLantern.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlatePiano.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlatePlatform.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlateSink.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlateSofa.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlateTable.cs | 2 +- Tiles/FurniturePlaguedPlate/PlaguedPlateWorkbench.cs | 2 +- Tiles/FurnitureVoid/SmoothVoidstonePlatform.cs | 2 +- Tiles/FurnitureVoid/VoidBath.cs | 2 +- Tiles/FurnitureVoid/VoidBed.cs | 2 +- Tiles/FurnitureVoid/VoidBookcase.cs | 2 +- Tiles/FurnitureVoid/VoidCandelabra.cs | 2 +- Tiles/FurnitureVoid/VoidCandle.cs | 2 +- Tiles/FurnitureVoid/VoidChair.cs | 2 +- Tiles/FurnitureVoid/VoidChandelier.cs | 2 +- Tiles/FurnitureVoid/VoidClock.cs | 2 +- Tiles/FurnitureVoid/VoidDoorClosed.cs | 2 +- Tiles/FurnitureVoid/VoidDoorOpen.cs | 2 +- Tiles/FurnitureVoid/VoidLamp.cs | 2 +- Tiles/FurnitureVoid/VoidLantern.cs | 2 +- Tiles/FurnitureVoid/VoidPiano.cs | 2 +- Tiles/FurnitureVoid/VoidSink.cs | 2 +- Tiles/FurnitureVoid/VoidSofa.cs | 2 +- Tiles/FurnitureVoid/VoidTable.cs | 2 +- Tiles/FurnitureVoid/VoidWorkbench.cs | 2 +- Utilities/CalamityUtils.cs | 4 ++-- 75 files changed, 79 insertions(+), 82 deletions(-) diff --git a/Tiles/FurnitureAbyss/AbyssBath.cs b/Tiles/FurnitureAbyss/AbyssBath.cs index be56829128..1efcd46aa3 100644 --- a/Tiles/FurnitureAbyss/AbyssBath.cs +++ b/Tiles/FurnitureAbyss/AbyssBath.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpBathtub(); + this.SetUpBathtub(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Bathtub"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssBed.cs b/Tiles/FurnitureAbyss/AbyssBed.cs index f280441e35..2e8c6f1776 100644 --- a/Tiles/FurnitureAbyss/AbyssBed.cs +++ b/Tiles/FurnitureAbyss/AbyssBed.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpBed(); + this.SetUpBed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Bed"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssBookcase.cs b/Tiles/FurnitureAbyss/AbyssBookcase.cs index 36b5317fc1..b6d3e27dfa 100644 --- a/Tiles/FurnitureAbyss/AbyssBookcase.cs +++ b/Tiles/FurnitureAbyss/AbyssBookcase.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpBookcase(); + this.SetUpBookcase(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Bookcase"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssCandelabra.cs b/Tiles/FurnitureAbyss/AbyssCandelabra.cs index 675df6d43b..5197dfa3ad 100644 --- a/Tiles/FurnitureAbyss/AbyssCandelabra.cs +++ b/Tiles/FurnitureAbyss/AbyssCandelabra.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpCandelabra(); + this.SetUpCandelabra(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Candelabra"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssCandle.cs b/Tiles/FurnitureAbyss/AbyssCandle.cs index 11d9a3c077..4cc49e7818 100644 --- a/Tiles/FurnitureAbyss/AbyssCandle.cs +++ b/Tiles/FurnitureAbyss/AbyssCandle.cs @@ -10,13 +10,8 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - Main.tileLighted[Type] = true; - Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; - Main.tileWaterDeath[Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.StyleOnTable1x1); - TileObjectData.newTile.CoordinateHeights = new int[] { 20 }; - TileObjectData.addTile(Type); + this.SetUpCandle(true, 0); + ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Candle"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssChair.cs b/Tiles/FurnitureAbyss/AbyssChair.cs index 8218df02d2..6ef9a4bbe6 100644 --- a/Tiles/FurnitureAbyss/AbyssChair.cs +++ b/Tiles/FurnitureAbyss/AbyssChair.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpChair(); + this.SetUpChair(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Chair"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssChandelier.cs b/Tiles/FurnitureAbyss/AbyssChandelier.cs index 61003db166..dcdb3d7e43 100644 --- a/Tiles/FurnitureAbyss/AbyssChandelier.cs +++ b/Tiles/FurnitureAbyss/AbyssChandelier.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpChandelier(); + this.SetUpChandelier(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Chandelier"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssClock.cs b/Tiles/FurnitureAbyss/AbyssClock.cs index b2a76142a0..5e8bb6ac62 100644 --- a/Tiles/FurnitureAbyss/AbyssClock.cs +++ b/Tiles/FurnitureAbyss/AbyssClock.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpClock(); + this.SetUpClock(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Clock"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssDoorClosed.cs b/Tiles/FurnitureAbyss/AbyssDoorClosed.cs index f2db6f1480..b72d2521f9 100644 --- a/Tiles/FurnitureAbyss/AbyssDoorClosed.cs +++ b/Tiles/FurnitureAbyss/AbyssDoorClosed.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpDoorClosed(); + this.SetUpDoorClosed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssDoorOpen.cs b/Tiles/FurnitureAbyss/AbyssDoorOpen.cs index 01a156250e..d8228ff59a 100644 --- a/Tiles/FurnitureAbyss/AbyssDoorOpen.cs +++ b/Tiles/FurnitureAbyss/AbyssDoorOpen.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpDoorOpen(); + this.SetUpDoorOpen(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssLamp.cs b/Tiles/FurnitureAbyss/AbyssLamp.cs index 9703458159..3317d61aff 100644 --- a/Tiles/FurnitureAbyss/AbyssLamp.cs +++ b/Tiles/FurnitureAbyss/AbyssLamp.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpLamp(); + this.SetUpLamp(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Lamp"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssLantern.cs b/Tiles/FurnitureAbyss/AbyssLantern.cs index 5301f21226..a5fcc4799e 100644 --- a/Tiles/FurnitureAbyss/AbyssLantern.cs +++ b/Tiles/FurnitureAbyss/AbyssLantern.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpLantern(); + this.SetUpLantern(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Lantern"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssPiano.cs b/Tiles/FurnitureAbyss/AbyssPiano.cs index c99b695592..1efde13613 100644 --- a/Tiles/FurnitureAbyss/AbyssPiano.cs +++ b/Tiles/FurnitureAbyss/AbyssPiano.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpPiano(); + this.SetUpPiano(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Synth"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssSink.cs b/Tiles/FurnitureAbyss/AbyssSink.cs index f2efacc8e7..8c5f590063 100644 --- a/Tiles/FurnitureAbyss/AbyssSink.cs +++ b/Tiles/FurnitureAbyss/AbyssSink.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpSink(); + this.SetUpSink(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Sink"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssSofa.cs b/Tiles/FurnitureAbyss/AbyssSofa.cs index 399f0ea036..130194317a 100644 --- a/Tiles/FurnitureAbyss/AbyssSofa.cs +++ b/Tiles/FurnitureAbyss/AbyssSofa.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpSofa(); + this.SetUpSofa(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Sofa"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssTable.cs b/Tiles/FurnitureAbyss/AbyssTable.cs index b7ab01d4b7..3e7ddfc279 100644 --- a/Tiles/FurnitureAbyss/AbyssTable.cs +++ b/Tiles/FurnitureAbyss/AbyssTable.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpTable(); + this.SetUpTable(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Table"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/AbyssTorch.cs b/Tiles/FurnitureAbyss/AbyssTorch.cs index d7224cb0aa..ec76fb1868 100644 --- a/Tiles/FurnitureAbyss/AbyssTorch.cs +++ b/Tiles/FurnitureAbyss/AbyssTorch.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpTorch(waterImmune: true); + this.SetUpTorch(true, true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Torch"); AddMapEntry(new Color(253, 221, 3), name); diff --git a/Tiles/FurnitureAbyss/AbyssWorkbench.cs b/Tiles/FurnitureAbyss/AbyssWorkbench.cs index 177c3822b3..4914e79012 100644 --- a/Tiles/FurnitureAbyss/AbyssWorkbench.cs +++ b/Tiles/FurnitureAbyss/AbyssWorkbench.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpWorkBench(); + this.SetUpWorkBench(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Abyss Work Bench"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAbyss/SmoothAbyssGravelPlatform.cs b/Tiles/FurnitureAbyss/SmoothAbyssGravelPlatform.cs index 63af8d5bc3..77363a8ff6 100644 --- a/Tiles/FurnitureAbyss/SmoothAbyssGravelPlatform.cs +++ b/Tiles/FurnitureAbyss/SmoothAbyssGravelPlatform.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss { public override void SetDefaults() { - this.SetUpPlatform(); + this.SetUpPlatform(true); soundType = SoundID.Tink; AddMapEntry(new Color(191, 142, 111)); drop = ModContent.ItemType(); diff --git a/Tiles/FurnitureAstral/MonolithBathtub.cs b/Tiles/FurnitureAstral/MonolithBathtub.cs index 4de7c09bec..a849f12d96 100644 --- a/Tiles/FurnitureAstral/MonolithBathtub.cs +++ b/Tiles/FurnitureAstral/MonolithBathtub.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpBathtub(); + this.SetUpBathtub(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Bathtub"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithBed.cs b/Tiles/FurnitureAstral/MonolithBed.cs index be49ef4965..97556cbcbd 100644 --- a/Tiles/FurnitureAstral/MonolithBed.cs +++ b/Tiles/FurnitureAstral/MonolithBed.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpBed(); + this.SetUpBed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Bed"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithBench.cs b/Tiles/FurnitureAstral/MonolithBench.cs index 133afad2bd..d824e72a6a 100644 --- a/Tiles/FurnitureAstral/MonolithBench.cs +++ b/Tiles/FurnitureAstral/MonolithBench.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpSofa(); + this.SetUpSofa(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Bench"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithBookcase.cs b/Tiles/FurnitureAstral/MonolithBookcase.cs index e85c077c04..b110f3ba99 100644 --- a/Tiles/FurnitureAstral/MonolithBookcase.cs +++ b/Tiles/FurnitureAstral/MonolithBookcase.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpBookcase(solidTop: false); + this.SetUpBookcase(true, false); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Bookcase"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithCandelabra.cs b/Tiles/FurnitureAstral/MonolithCandelabra.cs index d1b340ea27..da4b73c3de 100644 --- a/Tiles/FurnitureAstral/MonolithCandelabra.cs +++ b/Tiles/FurnitureAstral/MonolithCandelabra.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpCandelabra(); + this.SetUpCandelabra(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Candelabra"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithCandle.cs b/Tiles/FurnitureAstral/MonolithCandle.cs index b80d86845a..62586d63d6 100644 --- a/Tiles/FurnitureAstral/MonolithCandle.cs +++ b/Tiles/FurnitureAstral/MonolithCandle.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpCandle(); + this.SetUpCandle(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Candle"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithChair.cs b/Tiles/FurnitureAstral/MonolithChair.cs index cb6efe832e..096c532ddb 100644 --- a/Tiles/FurnitureAstral/MonolithChair.cs +++ b/Tiles/FurnitureAstral/MonolithChair.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpChair(); + this.SetUpChair(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Chair"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithChandelier.cs b/Tiles/FurnitureAstral/MonolithChandelier.cs index 8c6b2832f1..97e808e688 100644 --- a/Tiles/FurnitureAstral/MonolithChandelier.cs +++ b/Tiles/FurnitureAstral/MonolithChandelier.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpChandelier(); + this.SetUpChandelier(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Chandelier"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithClock.cs b/Tiles/FurnitureAstral/MonolithClock.cs index 101bffb878..9d62a4d6f1 100644 --- a/Tiles/FurnitureAstral/MonolithClock.cs +++ b/Tiles/FurnitureAstral/MonolithClock.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpClock(); + this.SetUpClock(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Clock"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithDoorClosed.cs b/Tiles/FurnitureAstral/MonolithDoorClosed.cs index d4578c36dc..f8d6d5f8a9 100644 --- a/Tiles/FurnitureAstral/MonolithDoorClosed.cs +++ b/Tiles/FurnitureAstral/MonolithDoorClosed.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpDoorClosed(); + this.SetUpDoorClosed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithDoorOpen.cs b/Tiles/FurnitureAstral/MonolithDoorOpen.cs index 3eca8a2faa..dd927426a7 100644 --- a/Tiles/FurnitureAstral/MonolithDoorOpen.cs +++ b/Tiles/FurnitureAstral/MonolithDoorOpen.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpDoorOpen(); + this.SetUpDoorOpen(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithLamp.cs b/Tiles/FurnitureAstral/MonolithLamp.cs index 50f6539b19..9596f2c9b4 100644 --- a/Tiles/FurnitureAstral/MonolithLamp.cs +++ b/Tiles/FurnitureAstral/MonolithLamp.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpLamp(); + this.SetUpLamp(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Lamp"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithLantern.cs b/Tiles/FurnitureAstral/MonolithLantern.cs index f70c1451ee..4fd2b665a5 100644 --- a/Tiles/FurnitureAstral/MonolithLantern.cs +++ b/Tiles/FurnitureAstral/MonolithLantern.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpLantern(); + this.SetUpLantern(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Lantern"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithPiano.cs b/Tiles/FurnitureAstral/MonolithPiano.cs index 2b89b33ed7..bd125930eb 100644 --- a/Tiles/FurnitureAstral/MonolithPiano.cs +++ b/Tiles/FurnitureAstral/MonolithPiano.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpPiano(); + this.SetUpPiano(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Piano"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithPlatform.cs b/Tiles/FurnitureAstral/MonolithPlatform.cs index a4e1588348..643765a99e 100644 --- a/Tiles/FurnitureAstral/MonolithPlatform.cs +++ b/Tiles/FurnitureAstral/MonolithPlatform.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpPlatform(); + this.SetUpPlatform(true); AddMapEntry(new Color(191, 142, 111)); drop = ModContent.ItemType(); disableSmartCursor = true; diff --git a/Tiles/FurnitureAstral/MonolithSink.cs b/Tiles/FurnitureAstral/MonolithSink.cs index ab38780a1f..0e6af2a72a 100644 --- a/Tiles/FurnitureAstral/MonolithSink.cs +++ b/Tiles/FurnitureAstral/MonolithSink.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpSink(); + this.SetUpSink(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Sink"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithTable.cs b/Tiles/FurnitureAstral/MonolithTable.cs index a0e1a5ec28..344678aa06 100644 --- a/Tiles/FurnitureAstral/MonolithTable.cs +++ b/Tiles/FurnitureAstral/MonolithTable.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpTable(); + this.SetUpTable(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Table"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureAstral/MonolithWorkbench.cs b/Tiles/FurnitureAstral/MonolithWorkbench.cs index 10957c40de..57329eed22 100644 --- a/Tiles/FurnitureAstral/MonolithWorkbench.cs +++ b/Tiles/FurnitureAstral/MonolithWorkbench.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.FurnitureAstral { public override void SetDefaults() { - this.SetUpWorkBench(); + this.SetUpWorkBench(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Work Bench"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs index b347cb7106..e7a55e3638 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs @@ -12,8 +12,9 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; + Main.tileLavaDeath[Type] = false; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.LavaDeath = false; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); name.SetDefault("Broken Plagued 'Bed'"); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateBathtub.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateBathtub.cs index 19408b8b9e..35d0f23c78 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateBathtub.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateBathtub.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpBathtub(); + this.SetUpBathtub(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Bathtub"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateBed.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateBed.cs index 49617315ee..20000e2ffa 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateBed.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateBed.cs @@ -11,9 +11,10 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate public override void SetDefaults() { Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; + Main.tileLavaDeath[Type] = false; TileID.Sets.HasOutlines[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); //This bed has different dimensions to conventional beds, using bookcase dimentions instead + TileObjectData.newTile.LavaDeath = false; TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateBookcase.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateBookcase.cs index d9e45274b3..0315ee1c7c 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateBookcase.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateBookcase.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpBookcase(); + this.SetUpBookcase(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Bookcase"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateCandelabra.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateCandelabra.cs index 03b0b1822f..04acb629ea 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateCandelabra.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateCandelabra.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpCandelabra(); + this.SetUpCandelabra(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Candelabra"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateCandle.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateCandle.cs index 6984047344..b455643293 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateCandle.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateCandle.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpCandle(); + this.SetUpCandle(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Candle"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateChair.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateChair.cs index fb5a52cb4b..38491e9e6f 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateChair.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateChair.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpChair(); + this.SetUpChair(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Chair"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateChandelier.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateChandelier.cs index 3b4e6e4908..f44b587b5f 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateChandelier.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateChandelier.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpChandelier(); + this.SetUpChandelier(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Chandelier"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateClock.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateClock.cs index 2c7cb5285d..6b067a5ed0 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateClock.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateClock.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpClock(); + this.SetUpClock(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Clock"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateDoorClosed.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateDoorClosed.cs index 597eb93cea..a5c6d298fd 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateDoorClosed.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateDoorClosed.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpDoorClosed(); + this.SetUpDoorClosed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateDoorOpen.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateDoorOpen.cs index 8c758742c8..d97b3ef758 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateDoorOpen.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateDoorOpen.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpDoorOpen(); + this.SetUpDoorOpen(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateLamp.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateLamp.cs index 719a4f314b..2c09810fb0 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateLamp.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateLamp.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpLamp(); + this.SetUpLamp(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Lamp"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateLantern.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateLantern.cs index 8c1e9f1121..472d4315d0 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateLantern.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateLantern.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpLantern(); + this.SetUpLantern(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Lantern"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlatePiano.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlatePiano.cs index 441a7c2b65..6a9cd8c20a 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlatePiano.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlatePiano.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpPiano(); + this.SetUpPiano(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Piano"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlatePlatform.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlatePlatform.cs index d0382cc708..a8d08d849a 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlatePlatform.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlatePlatform.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpPlatform(); + this.SetUpPlatform(true); AddMapEntry(new Color(191, 142, 111)); drop = ModContent.ItemType(); disableSmartCursor = true; diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateSink.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateSink.cs index 2e4f15ec01..78901f9560 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateSink.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateSink.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpSink(); + this.SetUpSink(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Sink"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateSofa.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateSofa.cs index 475c8e8907..2caf6af872 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateSofa.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateSofa.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpSofa(); + this.SetUpSofa(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Sofa"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateTable.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateTable.cs index f04d26e2f9..bc3185c123 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateTable.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateTable.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpTable(); + this.SetUpTable(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Table"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateWorkbench.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateWorkbench.cs index 6a824f0ec5..f3e497f9bf 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateWorkbench.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateWorkbench.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate { public override void SetDefaults() { - this.SetUpWorkBench(); + this.SetUpWorkBench(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Plagued Work Bench"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/SmoothVoidstonePlatform.cs b/Tiles/FurnitureVoid/SmoothVoidstonePlatform.cs index efafa9544f..987ebfca08 100644 --- a/Tiles/FurnitureVoid/SmoothVoidstonePlatform.cs +++ b/Tiles/FurnitureVoid/SmoothVoidstonePlatform.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpPlatform(); + this.SetUpPlatform(true); AddMapEntry(new Color(191, 142, 111)); drop = ModContent.ItemType(); disableSmartCursor = true; diff --git a/Tiles/FurnitureVoid/VoidBath.cs b/Tiles/FurnitureVoid/VoidBath.cs index b2a86409dd..6725fa6364 100644 --- a/Tiles/FurnitureVoid/VoidBath.cs +++ b/Tiles/FurnitureVoid/VoidBath.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpBathtub(); + this.SetUpBathtub(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Bathtub"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/VoidBed.cs b/Tiles/FurnitureVoid/VoidBed.cs index 3797a72a4c..f33f99cdce 100644 --- a/Tiles/FurnitureVoid/VoidBed.cs +++ b/Tiles/FurnitureVoid/VoidBed.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpBed(); + this.SetUpBed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Bed"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/VoidBookcase.cs b/Tiles/FurnitureVoid/VoidBookcase.cs index 6fdb9eb040..78835c1522 100644 --- a/Tiles/FurnitureVoid/VoidBookcase.cs +++ b/Tiles/FurnitureVoid/VoidBookcase.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpBookcase(); + this.SetUpBookcase(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Bookcase"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/VoidCandelabra.cs b/Tiles/FurnitureVoid/VoidCandelabra.cs index 23afc38c57..075c9572d9 100644 --- a/Tiles/FurnitureVoid/VoidCandelabra.cs +++ b/Tiles/FurnitureVoid/VoidCandelabra.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpCandelabra(); + this.SetUpCandelabra(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Candelabra"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/VoidCandle.cs b/Tiles/FurnitureVoid/VoidCandle.cs index bc9e402040..522ada233e 100644 --- a/Tiles/FurnitureVoid/VoidCandle.cs +++ b/Tiles/FurnitureVoid/VoidCandle.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpCandle(); + this.SetUpCandle(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Candle"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/VoidChair.cs b/Tiles/FurnitureVoid/VoidChair.cs index d7870d874e..d060c0da73 100644 --- a/Tiles/FurnitureVoid/VoidChair.cs +++ b/Tiles/FurnitureVoid/VoidChair.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpChair(); + this.SetUpChair(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Chair"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/VoidChandelier.cs b/Tiles/FurnitureVoid/VoidChandelier.cs index 1f15ef52db..e41a7a0f1e 100644 --- a/Tiles/FurnitureVoid/VoidChandelier.cs +++ b/Tiles/FurnitureVoid/VoidChandelier.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpChandelier(); + this.SetUpChandelier(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Chandelier"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/VoidClock.cs b/Tiles/FurnitureVoid/VoidClock.cs index 506003f84a..f8991975ed 100644 --- a/Tiles/FurnitureVoid/VoidClock.cs +++ b/Tiles/FurnitureVoid/VoidClock.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpClock(); + this.SetUpClock(true); animationFrameHeight = 90; ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Obelisk"); diff --git a/Tiles/FurnitureVoid/VoidDoorClosed.cs b/Tiles/FurnitureVoid/VoidDoorClosed.cs index ecf7ac19ff..b6bced9a35 100644 --- a/Tiles/FurnitureVoid/VoidDoorClosed.cs +++ b/Tiles/FurnitureVoid/VoidDoorClosed.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpDoorClosed(); + this.SetUpDoorClosed(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/VoidDoorOpen.cs b/Tiles/FurnitureVoid/VoidDoorOpen.cs index 6e2be97437..1744fde6f7 100644 --- a/Tiles/FurnitureVoid/VoidDoorOpen.cs +++ b/Tiles/FurnitureVoid/VoidDoorOpen.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpDoorOpen(); + this.SetUpDoorOpen(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Door"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/VoidLamp.cs b/Tiles/FurnitureVoid/VoidLamp.cs index d6ded956e8..10c6a12a0b 100644 --- a/Tiles/FurnitureVoid/VoidLamp.cs +++ b/Tiles/FurnitureVoid/VoidLamp.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpLamp(); + this.SetUpLamp(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Lamp"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/VoidLantern.cs b/Tiles/FurnitureVoid/VoidLantern.cs index 88273c9e3e..7610071d71 100644 --- a/Tiles/FurnitureVoid/VoidLantern.cs +++ b/Tiles/FurnitureVoid/VoidLantern.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpLantern(); + this.SetUpLantern(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Lantern"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/VoidPiano.cs b/Tiles/FurnitureVoid/VoidPiano.cs index eaa3d72a7d..5910622376 100644 --- a/Tiles/FurnitureVoid/VoidPiano.cs +++ b/Tiles/FurnitureVoid/VoidPiano.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpPiano(); + this.SetUpPiano(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Piano"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/VoidSink.cs b/Tiles/FurnitureVoid/VoidSink.cs index fd38170649..83208f8cd8 100644 --- a/Tiles/FurnitureVoid/VoidSink.cs +++ b/Tiles/FurnitureVoid/VoidSink.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpSink(); + this.SetUpSink(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Sink"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/VoidSofa.cs b/Tiles/FurnitureVoid/VoidSofa.cs index af37badf8d..36dcc16caf 100644 --- a/Tiles/FurnitureVoid/VoidSofa.cs +++ b/Tiles/FurnitureVoid/VoidSofa.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpSofa(); + this.SetUpSofa(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Sofa"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/VoidTable.cs b/Tiles/FurnitureVoid/VoidTable.cs index a0789a4658..212d408c1d 100644 --- a/Tiles/FurnitureVoid/VoidTable.cs +++ b/Tiles/FurnitureVoid/VoidTable.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpTable(); + this.SetUpTable(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Table"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Tiles/FurnitureVoid/VoidWorkbench.cs b/Tiles/FurnitureVoid/VoidWorkbench.cs index 348ca1c050..5ba9e26185 100644 --- a/Tiles/FurnitureVoid/VoidWorkbench.cs +++ b/Tiles/FurnitureVoid/VoidWorkbench.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.FurnitureVoid { public override void SetDefaults() { - this.SetUpWorkBench(); + this.SetUpWorkBench(true); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Work Bench"); AddMapEntry(new Color(191, 142, 111), name); diff --git a/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index 9d72595493..4c889f62c5 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -3027,7 +3027,7 @@ namespace CalamityMod /// /// The ModTile which is being initialized. /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpCandle(this ModTile mt, bool lavaImmune = false) + internal static void SetUpCandle(this ModTile mt, bool lavaImmune = false, int offset = -4) { Main.tileLighted[mt.Type] = true; Main.tileFrameImportant[mt.Type] = true; @@ -3036,7 +3036,7 @@ namespace CalamityMod TileObjectData.newTile.CopyFrom(TileObjectData.StyleOnTable1x1); TileObjectData.newTile.CoordinateHeights = new int[] { 20 }; TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.DrawYOffset = -4; + TileObjectData.newTile.DrawYOffset = offset; TileObjectData.addTile(mt.Type); // All candles count as light sources. From 3a01c269bc69480ae7bb95c7632d252fc4f96ed6 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 5 Dec 2020 15:00:50 -0500 Subject: [PATCH 10/66] lavaproofed the hardmode crafting stations Fixed monolith amalgam counting as a bookcase --- Tiles/Furniture/CraftingStations/MonolithCrafting.cs | 3 +-- Tiles/Furniture/CraftingStations/PlagueInfuser.cs | 3 ++- Tiles/Furniture/CraftingStations/VoidCondenser.cs | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Tiles/Furniture/CraftingStations/MonolithCrafting.cs b/Tiles/Furniture/CraftingStations/MonolithCrafting.cs index 705a4d1503..681bbc9ac1 100644 --- a/Tiles/Furniture/CraftingStations/MonolithCrafting.cs +++ b/Tiles/Furniture/CraftingStations/MonolithCrafting.cs @@ -11,12 +11,11 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations { public override void SetDefaults() { - this.SetUpBookcase(solidTop: false); + this.SetUpBookcase(true, false); ModTranslation name = CreateMapEntryName(); name.SetDefault("Monolith Amalgam"); AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; - adjTiles = new int[] { TileID.Bookcases }; } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/Furniture/CraftingStations/PlagueInfuser.cs b/Tiles/Furniture/CraftingStations/PlagueInfuser.cs index 26b9986987..69a5ca684d 100644 --- a/Tiles/Furniture/CraftingStations/PlagueInfuser.cs +++ b/Tiles/Furniture/CraftingStations/PlagueInfuser.cs @@ -13,8 +13,9 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations { Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; + Main.tileLavaDeath[Type] = false; + TileObjectData.newTile.LavaDeath = false; TileObjectData.newTile.Width = 2; TileObjectData.newTile.Height = 4; TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; diff --git a/Tiles/Furniture/CraftingStations/VoidCondenser.cs b/Tiles/Furniture/CraftingStations/VoidCondenser.cs index b32a0abd58..eb66374f5f 100644 --- a/Tiles/Furniture/CraftingStations/VoidCondenser.cs +++ b/Tiles/Furniture/CraftingStations/VoidCondenser.cs @@ -11,10 +11,11 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations { Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; + Main.tileLavaDeath[Type] = false; Main.tileWaterDeath[Type] = false; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.LavaDeath = false; TileObjectData.addTile(Type); ModTranslation name = CreateMapEntryName(); name.SetDefault("Void Condenser"); From f227e7ef89c881defcde839566f1fdb8b181cbd9 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 5 Dec 2020 15:09:43 -0500 Subject: [PATCH 11/66] True Night's Edge now inflicts CI to mimic True Bloody Edge --- CalPlayer/CalamityPlayer.cs | 8 ++++++++ Items/Weapons/Melee/TrueBloodyEdge.cs | 17 ++++++++--------- Projectiles/Melee/BloodyBlade.cs | 5 +++++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 24d1992a64..f239e728a9 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -4915,6 +4915,10 @@ namespace CalamityMod.CalPlayer else if (Main.rand.NextBool(3)) target.AddBuff(BuffID.Frostburn, 120); break; + + case ProjectileID.NightBeam: + target.AddBuff(BuffID.CursedInferno, 60); + break; } if (!proj.npcProj && !proj.trap) @@ -5258,6 +5262,10 @@ namespace CalamityMod.CalPlayer else if (Main.rand.NextBool(3)) target.AddBuff(BuffID.Frostburn, 120); break; + + case ProjectileID.NightBeam: + target.AddBuff(BuffID.CursedInferno, 60); + break; } if (!proj.npcProj && !proj.trap) diff --git a/Items/Weapons/Melee/TrueBloodyEdge.cs b/Items/Weapons/Melee/TrueBloodyEdge.cs index 477a61ae48..fb10960a80 100644 --- a/Items/Weapons/Melee/TrueBloodyEdge.cs +++ b/Items/Weapons/Melee/TrueBloodyEdge.cs @@ -53,20 +53,19 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - if (target.type == NPCID.TargetDummy || player.moonLeech) + if (target.type != NPCID.TargetDummy) { - return; - } - int healAmount = Main.rand.Next(6) + 1; - if (Main.rand.NextBool(2)) - { - player.statLife += healAmount; - player.HealEffect(healAmount); + OnHitEffects(player); } } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { + OnHitEffects(player); + } + + private void OnHitEffects(Player player) + { if (player.moonLeech) return; int healAmount = Main.rand.Next(6) + 1; @@ -75,6 +74,6 @@ namespace CalamityMod.Items.Weapons.Melee player.statLife += healAmount; player.HealEffect(healAmount); } - } + } } } diff --git a/Projectiles/Melee/BloodyBlade.cs b/Projectiles/Melee/BloodyBlade.cs index b32f471883..d3014e0bc2 100644 --- a/Projectiles/Melee/BloodyBlade.cs +++ b/Projectiles/Melee/BloodyBlade.cs @@ -54,5 +54,10 @@ namespace CalamityMod.Projectiles.Melee target.immune[projectile.owner] = 9; target.AddBuff(BuffID.Ichor, 60); } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.Ichor, 60); + } } } From e46ccc679e16e05ad5b65a2a0d695702dfc6234a Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 5 Dec 2020 15:15:13 -0500 Subject: [PATCH 12/66] compile error? what compile error? --- Tiles/FurnitureProfaned/ProfanedPiano.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Tiles/FurnitureProfaned/ProfanedPiano.cs b/Tiles/FurnitureProfaned/ProfanedPiano.cs index e940c9a2d9..b502bcf053 100644 --- a/Tiles/FurnitureProfaned/ProfanedPiano.cs +++ b/Tiles/FurnitureProfaned/ProfanedPiano.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts.Furniture; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; From 6664f7bda6e55a429c3672f4e875b54ea1b39109 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 5 Dec 2020 16:51:28 -0500 Subject: [PATCH 13/66] Hive/Perf Cysts can now spawn on Hardened Crim/Ebonsand and Crim/Ebonsandstone --- CalPlayer/CalamityPlayerFishing.cs | 62 +++++++++++++++--------------- Items/Weapons/Ranged/Onyxia.cs | 6 +-- NPCs/HiveMind/HiveCyst.cs | 11 ++++-- NPCs/Perforator/PerforatorCyst.cs | 10 +++-- 4 files changed, 47 insertions(+), 42 deletions(-) diff --git a/CalPlayer/CalamityPlayerFishing.cs b/CalPlayer/CalamityPlayerFishing.cs index 71acd2b6af..55e684613a 100644 --- a/CalPlayer/CalamityPlayerFishing.cs +++ b/CalPlayer/CalamityPlayerFishing.cs @@ -94,11 +94,11 @@ namespace CalamityMod.CalPlayer if (lava) { - CalamityUtils.AddWithCondition(fishList, ItemID.FlarefinKoi, !modPlayer.ZoneCalamity); - CalamityUtils.AddWithCondition(fishList, ItemID.Obsidifish, !modPlayer.ZoneCalamity); - CalamityUtils.AddWithCondition(fishList, ModContent.ItemType(), modPlayer.ZoneCalamity); - CalamityUtils.AddWithCondition(fishList, ModContent.ItemType(), modPlayer.ZoneCalamity); - CalamityUtils.AddWithCondition(fishList, ModContent.ItemType(), modPlayer.ZoneCalamity); + fishList.AddWithCondition(ItemID.FlarefinKoi, !modPlayer.ZoneCalamity); + fishList.AddWithCondition(ItemID.Obsidifish, !modPlayer.ZoneCalamity); + fishList.AddWithCondition(ModContent.ItemType(), modPlayer.ZoneCalamity); + fishList.AddWithCondition(ModContent.ItemType(), modPlayer.ZoneCalamity); + fishList.AddWithCondition(ModContent.ItemType(), modPlayer.ZoneCalamity); } else if (water) { @@ -107,24 +107,24 @@ namespace CalamityMod.CalPlayer fishList.Add(ItemID.ArmoredCavefish); fishList.Add(ItemID.Stinkfish); fishList.Add(ItemID.SpecularFish); - CalamityUtils.AddWithCondition(fishList, ItemID.ChaosFish, player.ZoneHoly); - CalamityUtils.AddWithCondition(fishList, ItemID.VariegatedLardfish, player.ZoneJungle); + fishList.AddWithCondition(ItemID.ChaosFish, player.ZoneHoly); + fishList.AddWithCondition(ItemID.VariegatedLardfish, player.ZoneJungle); } if (player.ZoneOverworldHeight || player.ZoneSkyHeight) { - CalamityUtils.AddWithCondition(fishList, ItemID.DoubleCod, player.ZoneJungle); + fishList.AddWithCondition(ItemID.DoubleCod, player.ZoneJungle); } - CalamityUtils.AddWithCondition(fishList, ItemID.FrostMinnow, player.ZoneSnow); - CalamityUtils.AddWithCondition(fishList, ItemID.Ebonkoi, player.ZoneCorrupt); - CalamityUtils.AddWithCondition(fishList, ItemID.CrimsonTigerfish, player.ZoneCrimson); - CalamityUtils.AddWithCondition(fishList, ItemID.Hemopiranha, player.ZoneCrimson); - CalamityUtils.AddWithCondition(fishList, ItemID.PrincessFish, player.ZoneHoly); - CalamityUtils.AddWithCondition(fishList, ItemID.Prismite, player.ZoneHoly); - CalamityUtils.AddWithCondition(fishList, ItemID.Damselfish, player.ZoneSkyHeight); - CalamityUtils.AddWithCondition(fishList, ModContent.ItemType(), modPlayer.ZoneAstral); - CalamityUtils.AddWithCondition(fishList, ModContent.ItemType(), modPlayer.ZoneSunkenSea); - CalamityUtils.AddWithCondition(fishList, ModContent.ItemType(), modPlayer.ZoneSunkenSea); - CalamityUtils.AddWithCondition(fishList, ModContent.ItemType(), modPlayer.ZoneSunkenSea); + fishList.AddWithCondition(ItemID.FrostMinnow, player.ZoneSnow); + fishList.AddWithCondition(ItemID.Ebonkoi, player.ZoneCorrupt); + fishList.AddWithCondition(ItemID.CrimsonTigerfish, player.ZoneCrimson); + fishList.AddWithCondition(ItemID.Hemopiranha, player.ZoneCrimson); + fishList.AddWithCondition(ItemID.PrincessFish, player.ZoneHoly); + fishList.AddWithCondition(ItemID.Prismite, player.ZoneHoly); + fishList.AddWithCondition(ItemID.Damselfish, player.ZoneSkyHeight); + fishList.AddWithCondition(ModContent.ItemType(), modPlayer.ZoneAstral); + fishList.AddWithCondition(ModContent.ItemType(), modPlayer.ZoneSunkenSea); + fishList.AddWithCondition(ModContent.ItemType(), modPlayer.ZoneSunkenSea); + fishList.AddWithCondition(ModContent.ItemType(), modPlayer.ZoneSunkenSea); } if (fishList.Any()) @@ -228,9 +228,9 @@ namespace CalamityMod.CalPlayer { rareItemList.Add(ItemID.ScalyTruffle); } - CalamityUtils.AddWithCondition(rareItemList, ItemID.Toxikarp, player.ZoneCorrupt); - CalamityUtils.AddWithCondition(rareItemList, ItemID.Bladetongue, player.ZoneCrimson); - CalamityUtils.AddWithCondition(rareItemList, ItemID.CrystalSerpent, player.ZoneHoly); + rareItemList.AddWithCondition(ItemID.Toxikarp, player.ZoneCorrupt); + rareItemList.AddWithCondition(ItemID.Bladetongue, player.ZoneCrimson); + rareItemList.AddWithCondition(ItemID.CrystalSerpent, player.ZoneHoly); if (rareItemList.Any()) { @@ -247,15 +247,15 @@ namespace CalamityMod.CalPlayer { List biomeCrateList = new List(); - CalamityUtils.AddWithCondition(biomeCrateList, ModContent.ItemType(), modPlayer.ZoneAstral); - CalamityUtils.AddWithCondition(biomeCrateList, ModContent.ItemType(), modPlayer.ZoneSunkenSea); - CalamityUtils.AddWithCondition(biomeCrateList, ModContent.ItemType(), canSulphurFish); - CalamityUtils.AddWithCondition(biomeCrateList, ItemID.CorruptFishingCrate, player.ZoneCorrupt); - CalamityUtils.AddWithCondition(biomeCrateList, ItemID.CrimsonFishingCrate, player.ZoneCrimson); - CalamityUtils.AddWithCondition(biomeCrateList, ItemID.HallowedFishingCrate, player.ZoneHoly); - CalamityUtils.AddWithCondition(biomeCrateList, ItemID.DungeonFishingCrate, player.ZoneDungeon); - CalamityUtils.AddWithCondition(biomeCrateList, ItemID.JungleFishingCrate, player.ZoneJungle); - CalamityUtils.AddWithCondition(biomeCrateList, ItemID.FloatingIslandFishingCrate, player.ZoneSkyHeight); + biomeCrateList.AddWithCondition(ModContent.ItemType(), modPlayer.ZoneAstral); + biomeCrateList.AddWithCondition(ModContent.ItemType(), modPlayer.ZoneSunkenSea); + biomeCrateList.AddWithCondition(ModContent.ItemType(), canSulphurFish); + biomeCrateList.AddWithCondition(ItemID.CorruptFishingCrate, player.ZoneCorrupt); + biomeCrateList.AddWithCondition(ItemID.CrimsonFishingCrate, player.ZoneCrimson); + biomeCrateList.AddWithCondition(ItemID.HallowedFishingCrate, player.ZoneHoly); + biomeCrateList.AddWithCondition(ItemID.DungeonFishingCrate, player.ZoneDungeon); + biomeCrateList.AddWithCondition(ItemID.JungleFishingCrate, player.ZoneJungle); + biomeCrateList.AddWithCondition(ItemID.FloatingIslandFishingCrate, player.ZoneSkyHeight); if (biomeCrateList.Any()) { diff --git a/Items/Weapons/Ranged/Onyxia.cs b/Items/Weapons/Ranged/Onyxia.cs index 7372cbb520..f9e22dc197 100644 --- a/Items/Weapons/Ranged/Onyxia.cs +++ b/Items/Weapons/Ranged/Onyxia.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { // Fire the Onyx Shard that is characteristic of the Onyx Blaster - // The shard deals 2.5x damage and double knockback + // The shard deals triple damage and double knockback int shardDamage = (int)(2.5 * damage); float shardKB = 2f * knockBack; float shardVelocityX = (speedX + (float)Main.rand.Next(-25, 26) * 0.05f) * 0.9f; @@ -62,8 +62,8 @@ namespace CalamityMod.Items.Weapons.Ranged float randVelMultiplier = Main.rand.NextFloat(0.92f, 1.08f); Vector2 left = baseVelocity.RotatedBy(-randAngle) * randVelMultiplier; Vector2 right = baseVelocity.RotatedBy(randAngle) * randVelMultiplier; - Projectile.NewProjectile(position, left, type, damage, knockBack, player.whoAmI, 0f, 0f); - Projectile.NewProjectile(position, right, type, damage, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position.X, position.Y, left.X, left.Y, type, damage, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position.X, position.Y, right.X, right.Y, type, damage, knockBack, player.whoAmI, 0f, 0f); } return false; } diff --git a/NPCs/HiveMind/HiveCyst.cs b/NPCs/HiveMind/HiveCyst.cs index 254ba0bc61..6f80d765ea 100644 --- a/NPCs/HiveMind/HiveCyst.cs +++ b/NPCs/HiveMind/HiveCyst.cs @@ -40,15 +40,18 @@ namespace CalamityMod.NPCs.HiveMind public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.playerSafe || NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || spawnInfo.player.Calamity().corruptionLore) + bool corrupt = TileID.Sets.Corrupt[spawnInfo.spawnTileType] || spawnInfo.spawnTileType == TileID.Demonite && spawnInfo.player.ZoneCorrupt; + if (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || + spawnInfo.playerSafe || spawnInfo.player.Calamity().corruptionLore || !corrupt) { return 0f; } - else if (NPC.downedBoss2 && !CalamityWorld.downedHiveMind) + + if (NPC.downedBoss2 && !CalamityWorld.downedHiveMind) { - return SpawnCondition.Corruption.Chance * 1.5f; + return 1.5f; } - return SpawnCondition.Corruption.Chance * (Main.hardMode ? 0.05f : 0.5f); + return Main.hardMode ? 0.05f : 0.5f; } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) diff --git a/NPCs/Perforator/PerforatorCyst.cs b/NPCs/Perforator/PerforatorCyst.cs index 1858f46dfe..6f1966993b 100644 --- a/NPCs/Perforator/PerforatorCyst.cs +++ b/NPCs/Perforator/PerforatorCyst.cs @@ -63,15 +63,17 @@ namespace CalamityMod.NPCs.Perforator public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.playerSafe || NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || spawnInfo.player.Calamity().crimsonLore) + bool crimson = TileID.Sets.Crimson[spawnInfo.spawnTileType] || spawnInfo.spawnTileType == TileID.Crimtane && spawnInfo.player.ZoneCrimson; + if (spawnInfo.playerSafe || NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || spawnInfo.player.Calamity().crimsonLore || !crimson) { return 0f; } - else if (NPC.downedBoss2 && !CalamityWorld.downedPerforator) + + if (NPC.downedBoss2 && !CalamityWorld.downedPerforator) { - return SpawnCondition.Crimson.Chance * 1.5f; + return 1.5f; } - return SpawnCondition.Crimson.Chance * (Main.hardMode ? 0.05f : 0.5f); + return Main.hardMode ? 0.05f : 0.5f; } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) From ac075ff99c403743764b7605191fcbed8cad8c2e Mon Sep 17 00:00:00 2001 From: Dominic Date: Sat, 5 Dec 2020 17:40:46 -0600 Subject: [PATCH 14/66] Fixed antibutcher tampering in CalamityGlobalNPC --- NPCs/CalamityGlobalNPC.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 3ec4cf0ddf..b5e04a6be1 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1394,6 +1394,11 @@ namespace CalamityMod.NPCs #region Strike NPC public override bool StrikeNPC(NPC npc, ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { + // Don't bother tampering with the damage is it is already zero. + // Zero damage does not happen in the base game and is always indicative of antibutcher in Calamity. + if (damage == 0D) + return false; + // Damage reduction on spawn bool destroyerResist = DestroyerIDs.Contains(npc.type) && (CalamityWorld.revenge || BossRushEvent.BossRushActive); bool eaterofWorldsResist = EaterofWorldsIDs.Contains(npc.type) && BossRushEvent.BossRushActive; From 29ad117422a327328e6b996b4eea4a2f3ad5af15 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 5 Dec 2020 21:38:24 -0500 Subject: [PATCH 15/66] Fixed a bug with corrosive spine --- Items/Accessories/CorrosiveSpine.cs | 32 ++++++++++------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/Items/Accessories/CorrosiveSpine.cs b/Items/Accessories/CorrosiveSpine.cs index 42159dadd8..06ca65e4bf 100644 --- a/Items/Accessories/CorrosiveSpine.cs +++ b/Items/Accessories/CorrosiveSpine.cs @@ -33,28 +33,18 @@ namespace CalamityMod.Items.Accessories { if (Main.rand.NextBool(15)) { - for (int i = 0; i < Main.rand.Next(3,7); i++) + int cloudCount = Main.rand.Next(3,7); + for (int i = 0; i < cloudCount; i++) { - int type = -1; - switch (Main.rand.Next(3)) - { - case 0: - type = ModContent.ProjectileType(); - break; - case 1: - type = ModContent.ProjectileType(); - break; - case 2: - type = ModContent.ProjectileType(); - break; - } - // Should never happen, but just in case- - if (type != -1) - { - float speed = Main.rand.NextFloat(3f, 11f); - Projectile.NewProjectile(player.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * speed, - type, (int)(100 * player.RogueDamage()), 0f, player.whoAmI); - } + int type = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType() + }); + float speed = Main.rand.NextFloat(3f, 11f); + Projectile.NewProjectile(player.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * speed, + type, (int)(100 * player.RogueDamage()), 0f, player.whoAmI); } } } From 0986b966a5fc4d2d42401d654c420662239d800b Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 5 Dec 2020 21:39:26 -0500 Subject: [PATCH 16/66] reduced the amt of clouds when you get hit to compensate --- Items/Accessories/CorrosiveSpine.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Accessories/CorrosiveSpine.cs b/Items/Accessories/CorrosiveSpine.cs index 06ca65e4bf..6a194e07f2 100644 --- a/Items/Accessories/CorrosiveSpine.cs +++ b/Items/Accessories/CorrosiveSpine.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Accessories { if (Main.rand.NextBool(15)) { - int cloudCount = Main.rand.Next(3,7); + int cloudCount = Main.rand.Next(2,5); for (int i = 0; i < cloudCount; i++) { int type = Utils.SelectRandom(Main.rand, new int[] From b4f593e27e928ccd69c8899f7f8b039df0eb5306 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 5 Dec 2020 21:40:48 -0500 Subject: [PATCH 17/66] corrosive spine is no longer rev exclusive --- Items/TreasureBags/AquaticScourgeBag.cs | 2 +- NPCs/AquaticScourge/AquaticScourgeHead.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Items/TreasureBags/AquaticScourgeBag.cs b/Items/TreasureBags/AquaticScourgeBag.cs index 3370c3eefb..1923e32c3a 100644 --- a/Items/TreasureBags/AquaticScourgeBag.cs +++ b/Items/TreasureBags/AquaticScourgeBag.cs @@ -69,7 +69,7 @@ namespace CalamityMod.Items.TreasureBags // Equipment DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItemChance(player, ModContent.ItemType(), 8); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.revenge, 0.25f); + DropHelper.DropItemChance(player, ModContent.ItemType(), 8); // Vanity DropHelper.DropItemChance(player, ModContent.ItemType(), 7); diff --git a/NPCs/AquaticScourge/AquaticScourgeHead.cs b/NPCs/AquaticScourge/AquaticScourgeHead.cs index c516b68d25..d93a686047 100644 --- a/NPCs/AquaticScourge/AquaticScourgeHead.cs +++ b/NPCs/AquaticScourge/AquaticScourgeHead.cs @@ -191,6 +191,7 @@ namespace CalamityMod.NPCs.AquaticScourge // Equipment DropHelper.DropItemChance(npc, ModContent.ItemType(), 9); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 9); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); From 64cbc9a649198c7ce6fbeec1d37622c6fc09d2b7 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 5 Dec 2020 22:04:29 -0500 Subject: [PATCH 18/66] bordernados should make a more symmetrical arena now --- NPCs/Yharon/Yharon.cs | 4 ++-- Projectiles/Boss/InfernadoRevenge.cs | 6 ++++-- Projectiles/Boss/SkyFlareRevenge.cs | 25 +++++++++++++------------ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index c4d32785a1..0b5700b2b8 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -402,8 +402,8 @@ namespace CalamityMod.NPCs.Yharon safeBox.Y = (int)(player.Center.Y - (revenge ? 9000f : 10500f)); safeBox.Width = revenge ? 6000 : 7000; safeBox.Height = revenge ? 18000 : 21000; - Projectile.NewProjectile(player.Center.X + (revenge ? 3000f : 3500f), player.Center.Y + 100f, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); - Projectile.NewProjectile(player.Center.X - (revenge ? 3000f : 3500f), player.Center.Y + 100f, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center.X + (revenge ? 3000f : 3500f), player.Center.Y + 100f, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, 0f); + Projectile.NewProjectile(player.Center.X - (revenge ? 3000f : 3500f), player.Center.Y + 100f, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, -1f, 0f); } // Force Yharon to send a sync packet so that the arena gets sent immediately diff --git a/Projectiles/Boss/InfernadoRevenge.cs b/Projectiles/Boss/InfernadoRevenge.cs index 6394f8ab28..83c00de8e7 100644 --- a/Projectiles/Boss/InfernadoRevenge.cs +++ b/Projectiles/Boss/InfernadoRevenge.cs @@ -35,11 +35,13 @@ namespace CalamityMod.Projectiles.Boss public override void SendExtraAI(BinaryWriter writer) { writer.Write(projectile.localAI[0]); + writer.Write(projectile.Calamity().lineColor); } public override void ReceiveExtraAI(BinaryReader reader) { projectile.localAI[0] = reader.ReadSingle(); + projectile.Calamity().lineColor = reader.ReadInt32(); } public override void AI() @@ -120,10 +122,10 @@ namespace CalamityMod.Projectiles.Boss float num623 = (float)projectile.width / 5f; num623 *= 2f; float num624 = (float)(Math.Cos((double)(num622 * -(double)projectile.ai[0])) - 0.5) * num623; - projectile.position.X -= num624 * -projectile.direction; + projectile.position.X -= num624 * -projectile.direction * (float)projectile.Calamity().lineColor; projectile.ai[0] -= 1f; num624 = (float)(Math.Cos((double)(num622 * -(double)projectile.ai[0])) - 0.5) * num623; - projectile.position.X += num624 * -projectile.direction; + projectile.position.X += num624 * -projectile.direction * (float)projectile.Calamity().lineColor; } } diff --git a/Projectiles/Boss/SkyFlareRevenge.cs b/Projectiles/Boss/SkyFlareRevenge.cs index ea94b94a4e..355bbce68a 100644 --- a/Projectiles/Boss/SkyFlareRevenge.cs +++ b/Projectiles/Boss/SkyFlareRevenge.cs @@ -56,22 +56,23 @@ namespace CalamityMod.Projectiles.Boss public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item20, projectile.position); - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int d = 0; d < dustAmt; d++) { - 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, 244, vector7.X * 2f, vector7.Y * 2f, 100, default, 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 dustSource = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; + dustSource = dustSource.RotatedBy((double)((float)(d - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + projectile.Center; + Vector2 dustVel = dustSource - projectile.Center; + int idx = Dust.NewDust(dustSource + dustVel, 0, 0, 244, dustVel.X * 2f, dustVel.Y * 2f, 100, default, 1.4f); + Main.dust[idx].noGravity = true; + Main.dust[idx].noLight = true; + Main.dust[idx].velocity = dustVel; } if (projectile.owner == Main.myPlayer) { - int num235 = 100; - int num236 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), num235, 4f, Main.myPlayer, 16f, 50f); - Main.projectile[num236].netUpdate = true; + int dmg = 100; //damage is irrelevant since the player is instantly killed + int nado = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), dmg, 4f, Main.myPlayer, 16f, 50f); + Main.projectile[nado].Calamity().lineColor = (int)projectile.ai[0]; + Main.projectile[nado].netUpdate = true; } } From 6feb1231599897e7abd46d6c2c2357684cffbefd Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 6 Dec 2020 00:05:47 -0500 Subject: [PATCH 19/66] nerfed chaotic puffer dmg but it now spawns in layers 2 and 3 --- NPCs/Abyss/ChaoticPuffer.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/NPCs/Abyss/ChaoticPuffer.cs b/NPCs/Abyss/ChaoticPuffer.cs index 545eca6de1..6123f05f2b 100644 --- a/NPCs/Abyss/ChaoticPuffer.cs +++ b/NPCs/Abyss/ChaoticPuffer.cs @@ -51,7 +51,7 @@ namespace CalamityMod.NPCs.Abyss npc.velocity.X = npc.velocity.X + (float)npc.direction * 0.03f; npc.velocity.Y = npc.velocity.Y + (float)npc.directionY * 0.03f; - npc.damage = puffedUp ? (Main.expertMode ? 230 : 115) : 0; + npc.damage = puffedUp ? (Main.expertMode ? 175 : 100) : 0; if (!puffing || !unpuffing) @@ -121,7 +121,7 @@ namespace CalamityMod.NPCs.Abyss Main.PlaySound(SoundID.NPCDeath14, (int)npc.position.X, (int)npc.position.Y); if (Main.netMode != NetmodeID.MultiplayerClient && puffedUp) { - int damageBoom = 100; + int damageBoom = 45; int projectileType = ModContent.ProjectileType(); int boom = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, 0, projectileType, damageBoom, 0f, Main.myPlayer, 0f, 0f); } @@ -206,7 +206,11 @@ namespace CalamityMod.NPCs.Abyss public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.player.Calamity().ZoneAbyssLayer4 && spawnInfo.water) + if (spawnInfo.player.Calamity().ZoneAbyssLayer2 && spawnInfo.water) + { + return SpawnCondition.CaveJellyfish.Chance * 0.4f; + } + if (spawnInfo.player.Calamity().ZoneAbyssLayer3 && spawnInfo.water) { return SpawnCondition.CaveJellyfish.Chance * 0.6f; } From ff2bb4b773385645d4adcf4b7ee5261d5603466f Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 6 Dec 2020 02:12:41 -0600 Subject: [PATCH 20/66] Fixed Dungeon Abyss collision issues --- ILEditing/ILChanges.cs | 43 +++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/ILEditing/ILChanges.cs b/ILEditing/ILChanges.cs index c4b45d9222..1f45e81914 100644 --- a/ILEditing/ILChanges.cs +++ b/ILEditing/ILChanges.cs @@ -1,4 +1,6 @@ using CalamityMod.Tiles.DraedonStructures; +using CalamityMod.World; +using Microsoft.Xna.Framework; using Mono.Cecil.Cil; using MonoMod.Cil; using System; @@ -7,6 +9,7 @@ using System.Reflection; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Terraria.World.Generation; namespace CalamityMod.ILEditing { @@ -48,7 +51,7 @@ namespace CalamityMod.ILEditing ApplyLifeBytesChanges(); ApplyBossZenDuringSlimeRain(); - SlideDungeonOver(); + PreventDungeonAbyssInteraction(); BlockLivingTreesNearOcean(); LabDoorFixes(); AlterTownNPCSpawnRate(); @@ -68,23 +71,41 @@ namespace CalamityMod.ILEditing private static void ApplyBossZenDuringSlimeRain() => On.Terraria.NPC.SlimeRainSpawns += PreventBossSlimeRainSpawns; - private static void SlideDungeonOver() + private static void PreventDungeonAbyssInteraction() { - IL.Terraria.WorldGen.MakeDungeon += (il) => + // Prevent the Dungeon from appearing near the Sulph sea. + IL.Terraria.WorldGen.MakeDungeon += il => { var cursor = new ILCursor(il); - if (!cursor.TryGotoNext(i => i.MatchStsfld("Terraria.WorldGen", "dMaxY"))) - { - CalamityMod.Instance.Logger.Warn("Dungeon movement editing code failed."); - return; - } - cursor.Index++; + cursor.GotoNext(MoveType.After, i => i.MatchStsfld("dungeonY")); + cursor.EmitDelegate(() => { - WorldGen.dungeonX += (WorldGen.dungeonX < Main.maxTilesX / 2).ToDirectionInt() * 450; - WorldGen.dungeonX = Utils.Clamp(WorldGen.dungeonX, 200, Main.maxTilesX - 200); + WorldGen.dungeonX = Utils.Clamp(WorldGen.dungeonX, SulphurousSea.BiomeWidth + 100, Main.maxTilesX - SulphurousSea.BiomeWidth - 100); + + // Adjust the Y position of the dungeon to accomodate for the X shift. + WorldUtils.Find(new Point(WorldGen.dungeonX, WorldGen.dungeonY), Searches.Chain(new Searches.Down(9001), new Conditions.IsSolid()), out Point result); + WorldGen.dungeonY = result.Y - 10; }); }; + + // And prevent its halls from getting anywhere near the Abyss. + IL.Terraria.WorldGen.DungeonHalls += il => + { + var cursor = new ILCursor(il); + + // Forcefully clamp the X position of the new hall end. + // This prevents a hall, and as a result, the dungeon, from ever impeding on the Abyss/Sulph Sea. + cursor.GotoNext(MoveType.After, i => i.MatchStloc(6)); + + cursor.Emit(OpCodes.Ldloc, 6); + cursor.EmitDelegate>(unclampedValue => + { + unclampedValue.X = MathHelper.Clamp(unclampedValue.X, SulphurousSea.BiomeWidth + 25, Main.maxTilesX - SulphurousSea.BiomeWidth); + return unclampedValue; + }); + cursor.Emit(OpCodes.Stloc, 6); + }; } private static void BlockLivingTreesNearOcean() From 0f77aaf312f6e00bbe33c2b1a8d0345043ba8c35 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 6 Dec 2020 17:54:42 -0500 Subject: [PATCH 21/66] dragon scales no longer has purchase restrictions --- CalPlayer/CalamityPlayer.cs | 4 ++-- NPCs/TownNPCs/THIEF.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index f239e728a9..36a5e4da8e 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -3807,13 +3807,13 @@ namespace CalamityMod.CalPlayer } #region Dragon Scale Logic - public override void PostBuyItem(NPC vendor, Item[] shopInventory, Item item) + /*public override void PostBuyItem(NPC vendor, Item[] shopInventory, Item item) { if (item.type == ModContent.ItemType() && !CalamityWorld.dragonScalesBought) { CalamityWorld.dragonScalesBought = true; } - } + }*/ #endregion #region Shop Restrictions diff --git a/NPCs/TownNPCs/THIEF.cs b/NPCs/TownNPCs/THIEF.cs index 1ebd69f7de..1ab955fd03 100644 --- a/NPCs/TownNPCs/THIEF.cs +++ b/NPCs/TownNPCs/THIEF.cs @@ -327,7 +327,7 @@ namespace CalamityMod.NPCs.TownNPCs shop.item[nextSlot].shopCustomPrice = Item.buyPrice(25, 0, 0, 0); nextSlot++; } - if (CalamityWorld.buffedEclipse && !CalamityWorld.dragonScalesBought) + if (CalamityWorld.buffedEclipse) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(40, 0, 0, 0); From 9aa5d6840746d7facd077f90933f00e2d8ce080c Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Mon, 7 Dec 2020 15:00:15 -0500 Subject: [PATCH 22/66] made microwave beeping less spammable --- CalPlayer/CalamityPlayer.cs | 186 ++++++++++++----------- Projectiles/Melee/MicrowaveAura.cs | 51 ++++--- Projectiles/Melee/Yoyos/MicrowaveYoyo.cs | 37 ++++- 3 files changed, 160 insertions(+), 114 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 36a5e4da8e..32285056dd 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -4282,98 +4282,100 @@ namespace CalamityMod.CalPlayer //Custom Death Messages - if (alcoholPoisoning && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - if (Main.rand.Next(2) == 0) - damageSource = PlayerDeathReason.ByCustomReason(player.name + " downed too many shots."); - else - damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s liver failed."); - } - if (vHex && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - damageSource = PlayerDeathReason.ByCustomReason(player.name + " was charred by the brimstone inferno."); - } - if ((ZoneCalamity && player.lavaWet) && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s soul was released by the lava."); - } - if (gsInferno && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s soul was extinguished."); - } - if (sulphurPoison && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - if (Main.rand.NextBool(2)) - damageSource = PlayerDeathReason.ByCustomReason(player.name + " was melted by the toxic waste."); - else - damageSource = PlayerDeathReason.ByOther(9); - } - if (lethalLavaBurn && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - damageSource = PlayerDeathReason.ByCustomReason(player.name + " disintegrated into ashes."); - } - if (hInferno && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - damageSource = PlayerDeathReason.ByCustomReason(player.name + " was turned to ashes by the Profaned Goddess."); - } - if (hFlames && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - damageSource = PlayerDeathReason.ByCustomReason(player.name + " fell prey to their sins."); - } - if (waterLeechBleeding && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - damageSource = PlayerDeathReason.ByCustomReason(player.name + " lost too much blood."); - } - if (shadowflame && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s spirit was turned to ash."); - } - if (bBlood && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - damageSource = PlayerDeathReason.ByCustomReason(player.name + " became a blood geyser."); - } - if (cDepth && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - if (Main.rand.NextBool(2)) - damageSource = PlayerDeathReason.ByCustomReason(player.name + " was crushed by the pressure."); - else - damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s lungs collapsed."); - } - if ((bFlames || aFlames) && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - damageSource = PlayerDeathReason.ByCustomReason(player.name + " was consumed by the black flames."); - } - if (pFlames && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - if (Main.rand.NextBool(2)) - damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s flesh was melted by the plague."); - else - damageSource = PlayerDeathReason.ByCustomReason(player.name + " didn't vaccinate."); - } - if (astralInfection && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - if (Main.rand.NextBool(2)) - damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s infection spread too far."); - else - damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s skin was replaced by the astral virus."); - } - if (nightwither && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - damageSource = PlayerDeathReason.ByCustomReason(player.name + " was incinerated by lunar rays."); - } - if (vaporfied && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - damageSource = PlayerDeathReason.ByCustomReason(player.name + " vaporized into thin air."); - } - if (manaOverloader && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s life was completely converted into mana."); - } - if ((bloodyMary || everclear || evergreenGin || fireball || margarita || moonshine || moscowMule || redWine || screwdriver || starBeamRye || tequila || tequilaSunrise || vodka || whiteWine) - && damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) - { - damageSource = PlayerDeathReason.ByCustomReason(player.name + " succumbed to alcohol sickness."); - } + if (damage == 10.0 && hitDirection == 0 && damageSource.SourceOtherIndex == 8) + { + if (alcoholPoisoning) + { + if (Main.rand.NextBool()) + damageSource = PlayerDeathReason.ByCustomReason(player.name + " downed too many shots."); + else + damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s liver failed."); + } + if (vHex) + { + damageSource = PlayerDeathReason.ByCustomReason(player.name + " was charred by the brimstone inferno."); + } + if (ZoneCalamity && player.lavaWet) + { + damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s soul was released by the lava."); + } + if (gsInferno) + { + damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s soul was extinguished."); + } + if (sulphurPoison) + { + if (Main.rand.NextBool(2)) + damageSource = PlayerDeathReason.ByCustomReason(player.name + " was melted by the toxic waste."); + else + damageSource = PlayerDeathReason.ByOther(9); + } + if (lethalLavaBurn) + { + damageSource = PlayerDeathReason.ByCustomReason(player.name + " disintegrated into ashes."); + } + if (hInferno) + { + damageSource = PlayerDeathReason.ByCustomReason(player.name + " was turned to ashes by the Profaned Goddess."); + } + if (hFlames) + { + damageSource = PlayerDeathReason.ByCustomReason(player.name + " fell prey to their sins."); + } + if (waterLeechBleeding) + { + damageSource = PlayerDeathReason.ByCustomReason(player.name + " lost too much blood."); + } + if (shadowflame) + { + damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s spirit was turned to ash."); + } + if (bBlood) + { + damageSource = PlayerDeathReason.ByCustomReason(player.name + " became a blood geyser."); + } + if (cDepth) + { + if (Main.rand.NextBool()) + damageSource = PlayerDeathReason.ByCustomReason(player.name + " was crushed by the pressure."); + else + damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s lungs collapsed."); + } + if (bFlames || aFlames) + { + damageSource = PlayerDeathReason.ByCustomReason(player.name + " was consumed by the black flames."); + } + if (pFlames) + { + if (Main.rand.NextBool()) + damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s flesh was melted by the plague."); + else + damageSource = PlayerDeathReason.ByCustomReason(player.name + " didn't vaccinate."); + } + if (astralInfection) + { + if (Main.rand.NextBool()) + damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s infection spread too far."); + else + damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s skin was replaced by the astral virus."); + } + if (nightwither) + { + damageSource = PlayerDeathReason.ByCustomReason(player.name + " was incinerated by lunar rays."); + } + if (vaporfied) + { + damageSource = PlayerDeathReason.ByCustomReason(player.name + " vaporized into thin air."); + } + if (manaOverloader) + { + damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s life was completely converted into mana."); + } + if (bloodyMary || everclear || evergreenGin || fireball || margarita || moonshine || moscowMule || redWine || screwdriver || starBeamRye || tequila || tequilaSunrise || vodka || whiteWine) + { + damageSource = PlayerDeathReason.ByCustomReason(player.name + " succumbed to alcohol sickness."); + } + } if (profanedCrystalBuffs && !profanedCrystalHide) { damageSource = PlayerDeathReason.ByCustomReason(player.name + " was summoned too soon."); diff --git a/Projectiles/Melee/MicrowaveAura.cs b/Projectiles/Melee/MicrowaveAura.cs index df6062a62a..52402d19b8 100644 --- a/Projectiles/Melee/MicrowaveAura.cs +++ b/Projectiles/Melee/MicrowaveAura.cs @@ -34,20 +34,8 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - Projectile parent = Main.projectile[0]; - bool active = false; - for (int i = 0; i < Main.projectile.Length; i++) - { - Projectile p = Main.projectile[i]; - if (p.identity == projectile.ai[0] && p.active && p.type == ModContent.ProjectileType()) - { - parent = p; - active = true; - break; - } - } - - if (active) + Projectile parent = FindParent(); + if (parent != null && parent.active) { projectile.Center = parent.Center; projectile.timeLeft = 2; @@ -56,18 +44,43 @@ namespace CalamityMod.Projectiles.Melee { projectile.Kill(); } - - if (!parent.active) - { - projectile.Kill(); - } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 180); + if (target.life <= 0 && (FindParent().modProjectile as MicrowaveYoyo).soundCooldown <= 0) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/MicrowaveBeep"), (int)projectile.Center.X, (int)projectile.Center.Y); + (FindParent().modProjectile as MicrowaveYoyo).soundCooldown = 60; + } } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + if (target.statLife <= 0 && (FindParent().modProjectile as MicrowaveYoyo).soundCooldown <= 0) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/MicrowaveBeep"), (int)projectile.Center.X, (int)projectile.Center.Y); + (FindParent().modProjectile as MicrowaveYoyo).soundCooldown = 60; + } + } + + private Projectile FindParent() + { + Projectile parent = null; + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile p = Main.projectile[i]; + if (p.identity == projectile.ai[0] && p.active && p.type == ModContent.ProjectileType() && p.owner == projectile.owner) + { + parent = p; + break; + } + } + return parent; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { float dist1 = Vector2.Distance(projectile.Center, targetHitbox.TopLeft()); diff --git a/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs b/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs index ada3206e56..655739a74a 100644 --- a/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs +++ b/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -14,6 +15,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos private const float Radius = 100f; private SoundEffectInstance mmmmmm = null; private bool spawnedAura = false; + public int soundCooldown = 0; public override void SetStaticDefaults() { @@ -41,6 +43,16 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.localNPCHitCooldown = 10; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(soundCooldown); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + soundCooldown = reader.ReadInt32(); + } + public override void AI() { // Sound is done manually, so that it can loop correctly. @@ -51,7 +63,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos CalamityUtils.ApplySoundStats(ref mmmmmm, projectile.Center); Main.PlaySoundInstance(mmmmmm); } - else if(!mmmmmm.IsDisposed) + else if (!mmmmmm.IsDisposed) CalamityUtils.ApplySoundStats(ref mmmmmm, projectile.Center); // Spawn invisible but damaging aura projectile @@ -61,6 +73,10 @@ namespace CalamityMod.Projectiles.Melee.Yoyos spawnedAura = true; } + // Decrement sound cooldown + if (soundCooldown > 0) + soundCooldown--; + // Dust circle appears for all players, even though the aura projectile is only spawned by the owner int numDust = (int)(0.2f * MathHelper.TwoPi * Radius); float angleIncrement = MathHelper.TwoPi / (float)numDust; @@ -81,13 +97,13 @@ namespace CalamityMod.Projectiles.Melee.Yoyos Main.dust[dust].scale = 0.1599999999f; } - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + // Delete the projectile if it is farther than 200 blocks away from the player + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) projectile.Kill(); } public override void Kill(int timeLeft) { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/MicrowaveBeep"), (int)projectile.Center.X, (int)projectile.Center.Y); mmmmmm?.Stop(); mmmmmm?.Dispose(); } @@ -107,6 +123,21 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 300); + if (target.life <= 0 && soundCooldown <= 0) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/MicrowaveBeep"), (int)projectile.Center.X, (int)projectile.Center.Y); + soundCooldown = 60; + } + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + if (target.statLife <= 0 && soundCooldown <= 0) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/MicrowaveBeep"), (int)projectile.Center.X, (int)projectile.Center.Y); + soundCooldown = 60; + } } } } From fdc375393d1d9076c4078c5fe78ca4a9f1d3101b Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Mon, 7 Dec 2020 15:05:10 -0500 Subject: [PATCH 23/66] changed microwave cooldown from 0.5 to 0.75 seconds --- Projectiles/Melee/Yoyos/MicrowaveYoyo.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs b/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs index 655739a74a..3eef5ddb9c 100644 --- a/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs +++ b/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs @@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos } // Decrement sound cooldown - if (soundCooldown > 0) + if (soundCooldown > 0 && projectile.FinalExtraUpdate()) soundCooldown--; // Dust circle appears for all players, even though the aura projectile is only spawned by the owner @@ -126,7 +126,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (target.life <= 0 && soundCooldown <= 0) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/MicrowaveBeep"), (int)projectile.Center.X, (int)projectile.Center.Y); - soundCooldown = 60; + soundCooldown = 45; } } @@ -136,7 +136,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (target.statLife <= 0 && soundCooldown <= 0) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/MicrowaveBeep"), (int)projectile.Center.X, (int)projectile.Center.Y); - soundCooldown = 60; + soundCooldown = 45; } } } From ac6aebc3dbdf3352029fa50f9d59a3e56f037350 Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Mon, 7 Dec 2020 19:39:12 -0600 Subject: [PATCH 24/66] Cleaned out Darksun Mothron AI and fixed desync problems --- NPCs/CalamityGlobalAI.cs | 1041 +------------------------- NPCs/CalamityVanillaMinibossesAI.cs | 1044 +++++++++++++++++++++++++++ 2 files changed, 1045 insertions(+), 1040 deletions(-) create mode 100644 NPCs/CalamityVanillaMinibossesAI.cs diff --git a/NPCs/CalamityGlobalAI.cs b/NPCs/CalamityGlobalAI.cs index 2f1e5bbe42..c6b1dd2d29 100644 --- a/NPCs/CalamityGlobalAI.cs +++ b/NPCs/CalamityGlobalAI.cs @@ -18,7 +18,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs { - public class CalamityGlobalAI + public partial class CalamityGlobalAI { #region Queen Bee Lore AI Changes public static void QueenBeeLoreEffect(NPC npc) @@ -14859,1045 +14859,6 @@ namespace CalamityMod.NPCs } #endregion - #region Buffed Mothron AI - public static bool BuffedMothronAI(NPC npc) - { - npc.noTileCollide = false; - npc.noGravity = true; - npc.knockBackResist = 0f; - npc.damage = npc.defDamage; - - // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; - - // Phases - bool phase2 = lifeRatio < 0.4f; - bool phase3 = lifeRatio < 0.1f; - - if (!Main.eclipse) - npc.ai[0] = -1f; - else if (npc.target < 0 || Main.player[npc.target].dead || !Main.player[npc.target].active) - { - npc.TargetClosest(true); - if (Main.player[npc.target].dead) - npc.ai[0] = -1f; - } - - if (npc.ai[0] == -1f) - { - Vector2 value37 = new Vector2(0f, -8f); - npc.velocity = (npc.velocity * 22f + value37) / 10f; - npc.noTileCollide = true; - npc.dontTakeDamage = true; - return false; - } - - if (npc.ai[0] == 0f) - { - npc.TargetClosest(true); - - if (npc.Center.X < Main.player[npc.target].Center.X - 2f) - npc.direction = 1; - if (npc.Center.X > Main.player[npc.target].Center.X + 2f) - npc.direction = -1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * 9f + npc.velocity.X * 0.025f) / 10f; - - if (npc.collideX) - { - npc.velocity.X *= -npc.oldVelocity.X * 0.5f; - - if (npc.velocity.X > 4f) - npc.velocity.X = 4f; - if (npc.velocity.X < -4f) - npc.velocity.X = -4f; - } - if (npc.collideY) - { - npc.velocity.Y *= -npc.oldVelocity.Y * 0.5f; - - if (npc.velocity.Y > 4f) - npc.velocity.Y = 4f; - if (npc.velocity.Y < -4f) - npc.velocity.Y = -4f; - } - - Vector2 value38 = Main.player[npc.target].Center - npc.Center; - value38.Y -= 200f; - if (value38.Length() > 3000f) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - else if (value38.Length() > 600f) - { - float scaleFactor15 = 15f; - float num1354 = 30f; - value38.Normalize(); - value38 *= scaleFactor15; - npc.velocity = (npc.velocity * (num1354 - 1f) + value38) / num1354; - } - else if (npc.velocity.Length() > 2f) - npc.velocity *= 0.95f; - else if (npc.velocity.Length() < 1f) - npc.velocity *= 1.05f; - - npc.ai[1] += 1f; - - if (npc.ai[1] >= 10f && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - - while (npc.ai[0] == 0f) - { - int num1355 = Main.rand.Next(3); - if (phase3) - num1355 = 1; - else if (phase2) - num1355 = Main.rand.Next(2); - - if (num1355 == 0 && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - npc.ai[0] = 2f; - else if (num1355 == 1) - npc.ai[0] = 3f; - else if (num1355 == 2 && NPC.CountNPCS(NPCID.MothronEgg) + NPC.CountNPCS(NPCID.MothronSpawn) < 2) - npc.ai[0] = 4f; - } - } - } - else - { - if (npc.ai[0] == 1f) - { - npc.collideX = false; - npc.collideY = false; - npc.noTileCollide = true; - - if (npc.target < 0 || !Main.player[npc.target].active || Main.player[npc.target].dead) - npc.TargetClosest(true); - - if (npc.velocity.X < 0f) - npc.direction = -1; - else if (npc.velocity.X > 0f) - npc.direction = 1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * 9f + npc.velocity.X * 0.02f) / 10f; - - Vector2 value39 = Main.player[npc.target].Center - npc.Center; - if (value39.Length() < 800f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - - float scaleFactor16 = 18f + value39.Length() / 100f; - float num1356 = 25f; - value39.Normalize(); - value39 *= scaleFactor16; - npc.velocity = (npc.velocity * (num1356 - 1f) + value39) / num1356; - return false; - } - - if (npc.ai[0] == 2f) - { - if (npc.target < 0 || !Main.player[npc.target].active || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - - if (Main.player[npc.target].Center.X - 10f < npc.Center.X) - npc.direction = -1; - else if (Main.player[npc.target].Center.X + 10f > npc.Center.X) - npc.direction = 1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * 4f + npc.velocity.X * 0.025f) / 5f; - - if (npc.collideX) - { - npc.velocity.X *= -npc.oldVelocity.X * 0.5f; - - if (npc.velocity.X > 4f) - npc.velocity.X = 4f; - if (npc.velocity.X < -4f) - npc.velocity.X = -4f; - } - if (npc.collideY) - { - npc.velocity.Y *= -npc.oldVelocity.Y * 0.5f; - - if (npc.velocity.Y > 4f) - npc.velocity.Y = 4f; - if (npc.velocity.Y < -4f) - npc.velocity.Y = -4f; - } - - Vector2 value40 = Main.player[npc.target].Center - npc.Center; - value40.Y -= 20f; - - npc.ai[2] += 0.0222222228f; - if (Main.expertMode) - npc.ai[2] += 0.0166666675f; - - float scaleFactor17 = 12f + npc.ai[2] + value40.Length() / 120f; - float num1357 = 20f; - value40.Normalize(); - value40 *= scaleFactor17; - npc.velocity = (npc.velocity * (num1357 - 1f) + value40) / num1357; - - npc.ai[1] += 1f; - if (npc.ai[1] >= 120f || !Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - } - else - { - if (npc.ai[0] == 3f) - { - npc.noTileCollide = true; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * 4f + npc.velocity.X * 0.0175f) / 5f; - - Vector2 value41 = Main.player[npc.target].Center - npc.Center; - value41.Y -= 12f; - if (npc.Center.X > Main.player[npc.target].Center.X) - value41.X += 600f; - else - value41.X -= 600f; - - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > 550f && Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) < 20f) - { - npc.ai[0] = 3.1f; - npc.ai[1] = 0f; - } - - npc.ai[1] += 0.0333333351f; - float scaleFactor18 = 24f + npc.ai[1]; - float num1358 = 4f; - value41.Normalize(); - value41 *= scaleFactor18; - npc.velocity = (npc.velocity * (num1358 - 1f) + value41) / num1358; - return false; - } - - if (npc.ai[0] == 3.1f) - { - npc.noTileCollide = true; - npc.rotation = (npc.rotation * 4f + npc.velocity.X * 0.0175f) / 5f; - - Vector2 vector237 = Main.player[npc.target].Center - npc.Center; - vector237.Y -= 12f; - float scaleFactor19 = 32f; - float num1359 = 8f; - vector237.Normalize(); - vector237 *= scaleFactor19; - npc.velocity = (npc.velocity * (num1359 - 1f) + vector237) / num1359; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.spriteDirection = npc.direction; - - npc.ai[1] += 1f; - if (npc.ai[1] > 10f) - { - npc.velocity = vector237; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.ai[0] = 3.2f; - npc.ai[1] = 0f; - npc.ai[1] = (float)npc.direction; - } - } - else - { - if (npc.ai[0] == 3.2f) - { - npc.damage = (int)((double)npc.defDamage * 1.2); - npc.collideX = false; - npc.collideY = false; - npc.noTileCollide = true; - npc.ai[2] += 0.0333333351f; - npc.velocity.X = (32f + npc.ai[2]) * npc.ai[1]; - - if ((npc.ai[1] > 0f && npc.Center.X > Main.player[npc.target].Center.X + 460f) || (npc.ai[1] < 0f && npc.Center.X < Main.player[npc.target].Center.X - 460f)) - { - if (!Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - else if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > 800f) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - } - npc.rotation = (npc.rotation * 4f + npc.velocity.X * 0.0175f) / 5f; - return false; - } - - if (npc.ai[0] == 4f) - { - npc.ai[0] = 0f; - npc.TargetClosest(true); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[1] = -1f; - npc.ai[2] = -1f; - - int num; - for (int num1360 = 0; num1360 < 1000; num1360 = num + 1) - { - int num1361 = (int)Main.player[npc.target].Center.X / 16; - int num1362 = (int)Main.player[npc.target].Center.Y / 16; - int num1363 = 30 + num1360 / 50; - int num1364 = 20 + num1360 / 75; - - num1361 += Main.rand.Next(-num1363, num1363 + 1); - num1362 += Main.rand.Next(-num1364, num1364 + 1); - - if (!WorldGen.SolidTile(num1361, num1362)) - { - while (!WorldGen.SolidTile(num1361, num1362) && (double)num1362 < Main.worldSurface) - num1362++; - - if ((new Vector2((float)(num1361 * 16 + 8), (float)(num1362 * 16 + 8)) - Main.player[npc.target].Center).Length() < 1600f) - { - npc.ai[0] = 4.1f; - npc.ai[1] = (float)num1361; - npc.ai[2] = (float)num1362; - break; - } - } - num = num1360; - } - } - npc.netUpdate = true; - return false; - } - - if (npc.ai[0] == 4.1f) - { - if (npc.velocity.X < -2f) - npc.direction = -1; - else if (npc.velocity.X > 2f) - npc.direction = 1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * 9f + npc.velocity.X * 0.025f) / 10f; - npc.noTileCollide = true; - - int num1365 = (int)npc.ai[1]; - int num1366 = (int)npc.ai[2]; - float x2 = (float)(num1365 * 16 + 8); - float y2 = (float)(num1366 * 16 - 20); - Vector2 vector238 = new Vector2(x2, y2); - vector238 -= npc.Center; - float num1367 = 12f + vector238.Length() / 150f; - - if (num1367 > 20f) - num1367 = 20f; - - if (vector238.Length() < 10f) - npc.ai[0] = 4.2f; - - vector238.Normalize(); - vector238 *= num1367; - float num1368 = 10f; - npc.velocity = (npc.velocity * (num1368 - 1f) + vector238) / num1368; - return false; - } - - if (npc.ai[0] == 4.2f) - { - npc.rotation = (npc.rotation * 9f + npc.velocity.X * 0.025f) / 10f; - npc.noTileCollide = true; - - int num1369 = (int)npc.ai[1]; - int num1370 = (int)npc.ai[2]; - float x3 = (float)(num1369 * 16 + 8); - float y3 = (float)(num1370 * 16 - 20); - Vector2 vector239 = new Vector2(x3, y3); - vector239 -= npc.Center; - float num1371 = 4f; - float num1372 = 2f; - - if (Main.netMode != NetmodeID.MultiplayerClient && vector239.Length() < 4f) - { - int num1373 = 20; - if (Main.expertMode) - num1373 = (int)((double)num1373 * 0.75); - - npc.ai[3] += 1f; - - if (npc.ai[3] == (float)num1373) - NPC.NewNPC(num1369 * 16 + 8, num1370 * 16, 478, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - else if (npc.ai[3] == (float)(num1373 * 2)) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - - if (NPC.CountNPCS(478) + NPC.CountNPCS(479) < 3 && Main.rand.Next(3) != 0) - npc.ai[0] = 4f; - else if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.ai[0] = 1f; - } - } - - if (vector239.Length() > num1371) - { - vector239.Normalize(); - vector239 *= num1371; - } - npc.velocity = (npc.velocity * (num1372 - 1f) + vector239) / num1372; - } - } - } - } - return false; - } - #endregion - - #region Buffed Pumpking and Pumpking Blade AI - public static bool BuffedPumpkingAI(NPC npc) - { - npc.localAI[0] += 1f; - if (npc.localAI[0] > 6f) - { - npc.localAI[0] = 0f; - npc.localAI[1] += 1f; - - if (npc.localAI[1] > 4f) - npc.localAI[1] = 0f; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[2] += 1f; - if (npc.localAI[2] > 300f) - { - npc.ai[3] = (float)Main.rand.Next(3); - npc.localAI[2] = 0f; - } - else if (npc.ai[3] == 0f && npc.localAI[2] % 30f == 0f && npc.localAI[2] > 30f) - { - float num856 = 10f; - Vector2 vector109 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f + 30f); - if (!WorldGen.SolidTile((int)vector109.X / 16, (int)vector109.Y / 16)) - { - float num857 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector109.X; - float num858 = Main.player[npc.target].position.Y - vector109.Y; - num857 += (float)Main.rand.Next(-50, 51); - num858 += (float)Main.rand.Next(50, 201); - num858 *= 0.2f; - float num859 = (float)Math.Sqrt((double)(num857 * num857 + num858 * num858)); - num859 = num856 / num859; - num857 *= num859; - num858 *= num859; - num857 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; - num858 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; - Projectile.NewProjectile(vector109.X, vector109.Y, num857, num858, ProjectileID.GreekFire1 + Main.rand.Next(3), 60, 0f, Main.myPlayer, 0f, 0f); - } - } - } - - if (npc.ai[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.TargetClosest(true); - npc.ai[0] = 1f; - - int num861 = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PumpkingBlade, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num861].ai[0] = -1f; - Main.npc[num861].ai[1] = (float)npc.whoAmI; - Main.npc[num861].target = npc.target; - Main.npc[num861].netUpdate = true; - - num861 = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PumpkingBlade, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num861].ai[0] = 1f; - Main.npc[num861].ai[1] = (float)npc.whoAmI; - Main.npc[num861].ai[3] = 150f; - Main.npc[num861].target = npc.target; - Main.npc[num861].netUpdate = true; - } - - if (Main.player[npc.target].dead || Math.Abs(npc.position.X - Main.player[npc.target].position.X) > 2000f || Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f) - { - npc.TargetClosest(true); - - if (Main.player[npc.target].dead || Math.Abs(npc.position.X - Main.player[npc.target].position.X) > 2000f || Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f) - npc.ai[1] = 2f; - } - - if (Main.dayTime) - { - npc.velocity.Y += 0.3f; - npc.velocity.X *= 0.9f; - } - else if (npc.ai[1] == 0f) - { - npc.ai[2] += 1f; - if (npc.ai[2] >= 300f) - { - if (npc.ai[3] != 1f) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - else - { - npc.ai[2] = 0f; - npc.ai[1] = 1f; - npc.TargetClosest(true); - npc.netUpdate = true; - } - } - - Vector2 vector110 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num862 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector110.X; - float num863 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 200f - vector110.Y; - float num864 = (float)Math.Sqrt((double)(num862 * num862 + num863 * num863)); - float num865 = 8f; - - if (npc.ai[3] == 1f) - { - if (num864 > 900f) - num865 = 14f; - else if (num864 > 600f) - num865 = 12f; - else if (num864 > 300f) - num865 = 10f; - } - - if (num864 > 50f) - { - num864 = num865 / num864; - npc.velocity.X = (npc.velocity.X * 14f + num862 * num864) / 15f; - npc.velocity.Y = (npc.velocity.Y * 14f + num863 * num864) / 15f; - } - } - else if (npc.ai[1] == 1f) - { - npc.ai[2] += 1f; - if (npc.ai[2] >= 600f || npc.ai[3] != 1f) - { - npc.ai[2] = 0f; - npc.ai[1] = 0f; - } - - Vector2 vector111 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num866 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector111.X; - float num867 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector111.Y; - float num868 = (float)Math.Sqrt((double)(num866 * num866 + num867 * num867)); - num868 = 20f / num868; - - npc.velocity.X = (npc.velocity.X * 49f + num866 * num868) / 50f; - npc.velocity.Y = (npc.velocity.Y * 49f + num867 * num868) / 50f; - } - else if (npc.ai[1] == 2f) - { - npc.ai[1] = 3f; - npc.velocity.Y += 0.1f; - - if (npc.velocity.Y < 0f) - npc.velocity.Y *= 0.95f; - - npc.velocity.X *= 0.95f; - - if (npc.timeLeft > 500) - npc.timeLeft = 500; - } - npc.rotation = npc.velocity.X * -0.02f; - - return false; - } - - public static bool BuffedPumpkingBladeAI(NPC npc) - { - npc.spriteDirection = -(int)npc.ai[0]; - - if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != 58) - { - npc.ai[2] += 10f; - if (npc.ai[2] > 50f || Main.netMode != NetmodeID.Server) - { - npc.life = -1; - npc.HitEffect(0, 10.0); - npc.active = false; - } - } - - if (Main.netMode != NetmodeID.MultiplayerClient && Main.npc[(int)npc.ai[1]].ai[3] == 2f) - { - npc.localAI[1] += 1f; - if (npc.localAI[1] > 30f) - { - npc.localAI[1] = 0f; - - float num869 = 0.01f; - Vector2 vector112 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f + 30f); - float num870 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector112.X; - float num871 = Main.player[npc.target].position.Y - vector112.Y; - float num872 = (float)Math.Sqrt((double)(num870 * num870 + num871 * num871)); - - num872 = num869 / num872; - num870 *= num872; - num871 *= num872; - - Projectile.NewProjectile(npc.Center.X, npc.Center.Y, num870, num871, ProjectileID.FlamingScythe, 70, 0f, Main.myPlayer, npc.rotation, (float)npc.spriteDirection); - } - } - - if (Main.dayTime) - { - npc.velocity.Y += 0.3f; - npc.velocity.X *= 0.9f; - return false; - } - - if (npc.ai[2] == 0f || npc.ai[2] == 3f) - { - if (Main.npc[(int)npc.ai[1]].ai[1] == 3f && npc.timeLeft > 10) - npc.timeLeft = 10; - - npc.ai[3] += 1f; - if (npc.ai[3] >= 180f) - { - npc.ai[2] += 1f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - Vector2 vector113 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num874 = (Main.player[npc.target].Center.X + Main.npc[(int)npc.ai[1]].Center.X) / 2f; - float num875 = (Main.player[npc.target].Center.Y + Main.npc[(int)npc.ai[1]].Center.Y) / 2f; - num874 += -170f * npc.ai[0] - vector113.X; - num875 += 90f - vector113.Y; - - float num876 = Math.Abs(Main.player[npc.target].Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(Main.player[npc.target].Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); - if (num876 > 700f) - { - num874 = Main.npc[(int)npc.ai[1]].Center.X - 170f * npc.ai[0] - vector113.X; - num875 = Main.npc[(int)npc.ai[1]].Center.Y + 90f - vector113.Y; - } - - float num877 = (float)Math.Sqrt((double)(num874 * num874 + num875 * num875)); - float num878 = 8f; - if (num877 > 1000f) - num878 = 23f; - else if (num877 > 800f) - num878 = 20f; - else if (num877 > 600f) - num878 = 17f; - else if (num877 > 400f) - num878 = 14f; - else if (num877 > 200f) - num878 = 11f; - - if (npc.ai[0] < 0f && npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X) - num874 -= 4f; - if (npc.ai[0] > 0f && npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X) - num874 += 4f; - - num877 = num878 / num877; - npc.velocity.X = (npc.velocity.X * 14f + num874 * num877) / 15f; - npc.velocity.Y = (npc.velocity.Y * 14f + num875 * num877) / 15f; - num877 = (float)Math.Sqrt((double)(num874 * num874 + num875 * num875)); - - if (num877 > 20f) - npc.rotation = (float)Math.Atan2((double)num875, (double)num874) + MathHelper.PiOver2; - } - else if (npc.ai[2] == 1f) - { - Vector2 vector114 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num879 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector114.X; - float num880 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector114.Y; - float num881 = (float)Math.Sqrt((double)(num879 * num879 + num880 * num880)); - - npc.rotation = (float)Math.Atan2((double)num880, (double)num879) + MathHelper.PiOver2; - npc.velocity.X *= 0.95f; - npc.velocity.Y -= 0.3f; - - if (npc.velocity.Y < -18f) - npc.velocity.Y = -18f; - - if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 200f) - { - npc.TargetClosest(true); - npc.ai[2] = 2f; - - vector114 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num879 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector114.X; - num880 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector114.Y; - num881 = (float)Math.Sqrt((double)(num879 * num879 + num880 * num880)); - num881 = 24f / num881; - - npc.velocity.X = num879 * num881; - npc.velocity.Y = num880 * num881; - npc.netUpdate = true; - } - } - else if (npc.ai[2] == 2f) - { - float num882 = Math.Abs(npc.Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(npc.Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); - - if (npc.position.Y > Main.player[npc.target].position.Y || npc.velocity.Y < 0f || num882 > 800f) - npc.ai[2] = 3f; - } - else if (npc.ai[2] == 4f) - { - Vector2 vector115 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num883 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector115.X; - float num884 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector115.Y; - float num885 = (float)Math.Sqrt((double)(num883 * num883 + num884 * num884)); - - npc.rotation = (float)Math.Atan2((double)num884, (double)num883) + MathHelper.PiOver2; - npc.velocity.Y *= 0.95f; - npc.velocity.X += 0.3f * -npc.ai[0]; - - if (npc.velocity.X < -18f) - npc.velocity.X = -18f; - if (npc.velocity.X > 18f) - npc.velocity.X = 18f; - - if (npc.position.X + (float)(npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 500f || npc.position.X + (float)(npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) + 500f) - { - npc.TargetClosest(true); - npc.ai[2] = 5f; - - vector115 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num883 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector115.X; - num884 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector115.Y; - num885 = (float)Math.Sqrt((double)(num883 * num883 + num884 * num884)); - num885 = 17f / num885; - - npc.velocity.X = num883 * num885; - npc.velocity.Y = num884 * num885; - npc.netUpdate = true; - } - } - else if (npc.ai[2] == 5f) - { - float num886 = Math.Abs(npc.Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(npc.Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); - - if ((npc.velocity.X > 0f && npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || (npc.velocity.X < 0f && npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || num886 > 800f) - npc.ai[2] = 0f; - } - - return false; - } - #endregion - - #region Buffed Ice Queen AI - public static bool BuffedIceQueenAI(NPC npc) - { - if (Main.dayTime) - { - if (npc.velocity.X > 0f) - npc.velocity.X += 0.25f; - else - npc.velocity.X -= 0.25f; - - npc.velocity.Y -= 0.1f; - npc.rotation = npc.velocity.X * 0.05f; - } - else if (npc.ai[0] == 0f) - { - if (npc.ai[2] == 0f) - { - npc.TargetClosest(true); - - if (npc.Center.X < Main.player[npc.target].Center.X) - npc.ai[2] = 1f; - else - npc.ai[2] = -1f; - } - - npc.TargetClosest(true); - int num887 = 800; - float num888 = Math.Abs(npc.Center.X - Main.player[npc.target].Center.X); - - if (npc.Center.X < Main.player[npc.target].Center.X && npc.ai[2] < 0f && num888 > (float)num887) - npc.ai[2] = 0f; - if (npc.Center.X > Main.player[npc.target].Center.X && npc.ai[2] > 0f && num888 > (float)num887) - npc.ai[2] = 0f; - - float num889 = 0.6f; - float num890 = 10f; - if ((double)npc.life < (double)npc.lifeMax * 0.75) - { - num889 = 0.7f; - num890 = 12f; - } - if ((double)npc.life < (double)npc.lifeMax * 0.5) - { - num889 = 0.8f; - num890 = 14f; - } - if ((double)npc.life < (double)npc.lifeMax * 0.25) - { - num889 = 0.95f; - num890 = 16f; - } - - npc.velocity.X += npc.ai[2] * num889; - if (npc.velocity.X > num890) - npc.velocity.X = num890; - if (npc.velocity.X < -num890) - npc.velocity.X = -num890; - - float num891 = Main.player[npc.target].position.Y - (npc.position.Y + (float)npc.height); - if (num891 < 150f) - npc.velocity.Y -= 0.2f; - if (num891 > 200f) - npc.velocity.Y += 0.2f; - if (npc.velocity.Y > 9f) - npc.velocity.Y = 9f; - if (npc.velocity.Y < -9f) - npc.velocity.Y = -9f; - - npc.rotation = npc.velocity.X * 0.05f; - - if ((num888 < 500f || npc.ai[3] < 0f) && npc.position.Y < Main.player[npc.target].position.Y) - { - npc.ai[3] += 1f; - int num892 = 8; - if ((double)npc.life < (double)npc.lifeMax * 0.75) - num892 = 7; - if ((double)npc.life < (double)npc.lifeMax * 0.5) - num892 = 6; - if ((double)npc.life < (double)npc.lifeMax * 0.25) - num892 = 5; - - num892++; - if (npc.ai[3] > (float)num892) - npc.ai[3] = (float)-(float)num892; - - if (npc.ai[3] == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 vector116 = new Vector2(npc.Center.X, npc.Center.Y); - vector116.X += npc.velocity.X * 7f; - float num893 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector116.X; - float num894 = Main.player[npc.target].Center.Y - vector116.Y; - float num895 = (float)Math.Sqrt((double)(num893 * num893 + num894 * num894)); - - float num896 = 8f; - if ((double)npc.life < (double)npc.lifeMax * 0.75) - num896 = 9f; - if ((double)npc.life < (double)npc.lifeMax * 0.5) - num896 = 10f; - if ((double)npc.life < (double)npc.lifeMax * 0.25) - num896 = 11f; - - num895 = num896 / num895; - num893 *= num895; - num894 *= num895; - - Projectile.NewProjectile(vector116.X, vector116.Y, num893, num894, ProjectileID.FrostWave, 50, 0f, Main.myPlayer, 0f, 0f); - } - } - else if (npc.ai[3] < 0f) - npc.ai[3] += 1f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[1] += (float)Main.rand.Next(1, 4); - - if (npc.ai[1] > 600f && num888 < 600f) - npc.ai[0] = -1f; - } - } - else if (npc.ai[0] == 1f) - { - npc.TargetClosest(true); - - float num898 = 0.2f; - float num899 = 10f; - if ((double)npc.life < (double)npc.lifeMax * 0.75) - { - num898 = 0.24f; - num899 = 12f; - } - if ((double)npc.life < (double)npc.lifeMax * 0.5) - { - num898 = 0.28f; - num899 = 14f; - } - if ((double)npc.life < (double)npc.lifeMax * 0.25) - { - num898 = 0.32f; - num899 = 16f; - } - num898 -= 0.05f; - num899 -= 1f; - - if (npc.Center.X < Main.player[npc.target].Center.X) - { - npc.velocity.X += num898; - if (npc.velocity.X < 0f) - npc.velocity.X *= 0.98f; - } - if (npc.Center.X > Main.player[npc.target].Center.X) - { - npc.velocity.X -= num898; - if (npc.velocity.X > 0f) - npc.velocity.X *= 0.98f; - } - if (npc.velocity.X > num899 || npc.velocity.X < -num899) - npc.velocity.X *= 0.95f; - - float num900 = Main.player[npc.target].position.Y - (npc.position.Y + (float)npc.height); - if (num900 < 180f) - npc.velocity.Y -= 0.1f; - if (num900 > 200f) - npc.velocity.Y += 0.1f; - - if (npc.velocity.Y > 7f) - npc.velocity.Y = 7f; - if (npc.velocity.Y < -7f) - npc.velocity.Y = -7f; - - npc.rotation = npc.velocity.X * 0.01f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[3] += 1f; - int num901 = 10; - if ((double)npc.life < (double)npc.lifeMax * 0.75) - num901 = 8; - if ((double)npc.life < (double)npc.lifeMax * 0.5) - num901 = 6; - if ((double)npc.life < (double)npc.lifeMax * 0.25) - num901 = 4; - if ((double)npc.life < (double)npc.lifeMax * 0.1) - num901 = 2; - - num901 += 3; - if (npc.ai[3] >= (float)num901) - { - npc.ai[3] = 0f; - Vector2 vector117 = new Vector2(npc.Center.X, npc.position.Y + (float)npc.height - 14f); - int i2 = (int)(vector117.X / 16f); - int j2 = (int)(vector117.Y / 16f); - if (!WorldGen.SolidTile(i2, j2)) - { - float num902 = npc.velocity.Y; - - if (num902 < 0f) - num902 = 0f; - - num902 += 3f; - float speedX2 = npc.velocity.X * 0.25f; - Projectile.NewProjectile(vector117.X, vector117.Y, speedX2, num902, ProjectileID.FrostShard, 44, 0f, Main.myPlayer, (float)Main.rand.Next(5), 0f); - } - } - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[1] += (float)Main.rand.Next(1, 4); - - if (npc.ai[1] > 450f) - npc.ai[0] = -1f; - } - } - else if (npc.ai[0] == 2f) - { - npc.TargetClosest(true); - - Vector2 vector118 = new Vector2(npc.Center.X, npc.Center.Y - 20f); - float num904 = (float)Main.rand.Next(-1000, 1001); - float num905 = (float)Main.rand.Next(-1000, 1001); - float num906 = (float)Math.Sqrt((double)(num904 * num904 + num905 * num905)); - float num907 = 20f; - - npc.velocity *= 0.95f; - num906 = num907 / num906; - num904 *= num906; - num905 *= num906; - npc.rotation += 0.2f; - vector118.X += num904 * 4f; - vector118.Y += num905 * 4f; - - npc.ai[3] += 1f; - int num908 = 7; - if ((double)npc.life < (double)npc.lifeMax * 0.75) - num908--; - if ((double)npc.life < (double)npc.lifeMax * 0.5) - num908 -= 2; - if ((double)npc.life < (double)npc.lifeMax * 0.25) - num908 -= 3; - if ((double)npc.life < (double)npc.lifeMax * 0.1) - num908 -= 4; - - if (npc.ai[3] > (float)num908) - { - npc.ai[3] = 0f; - int num909 = Projectile.NewProjectile(vector118.X, vector118.Y, num904, num905, ProjectileID.FrostShard, 40, 0f, Main.myPlayer, 0f, 0f); - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[1] += (float)Main.rand.Next(1, 4); - - if (npc.ai[1] > 300f) - npc.ai[0] = -1f; - } - } - if (npc.ai[0] == -1f) - { - int num910 = Main.rand.Next(3); - npc.TargetClosest(true); - - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > 1000f) - num910 = 0; - - npc.ai[0] = (float)num910; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - - return false; - } - #endregion - #region Revengeance Dungeon Guardian AI public static void RevengeanceDungeonGuardianAI(NPC npc, bool configBossRushBoost, bool enraged) { diff --git a/NPCs/CalamityVanillaMinibossesAI.cs b/NPCs/CalamityVanillaMinibossesAI.cs new file mode 100644 index 0000000000..d029e197ce --- /dev/null +++ b/NPCs/CalamityVanillaMinibossesAI.cs @@ -0,0 +1,1044 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.NPCs +{ + public partial class CalamityGlobalAI + { + internal enum MothronAIState + { + DespawnYeet = -1, + NewAISelection = 0, + FlyTowardsPlayer = 1, + AccelerateTowardsPlayer = 2, + ChargeRedirect = 3, + ChargePreparation = 4, + DoTheFuckingCharge = 5, + PickSpotToLayEgg = 6, + FlyToEggSpot = 7, + LayEgg = 8 + } + + #region Buffed Mothron AI + public static bool BuffedMothronAI(NPC npc) + { + npc.noTileCollide = false; + npc.noGravity = true; + npc.knockBackResist = 0f; + npc.damage = npc.defDamage; + + ref float aiState = ref npc.ai[0]; + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Phases + bool phase2 = lifeRatio < 0.4f; + bool phase3 = lifeRatio < 0.1f; + + Player target = Main.player[npc.target]; + + // Despawn if no valid target exists or there's no ongoing eclipse. + if (!Main.eclipse) + aiState = (int)MothronAIState.DespawnYeet; + else if (npc.target < 0 || target.dead || !target.active) + { + npc.TargetClosest(true); + if (target.dead) + { + aiState = (int)MothronAIState.DespawnYeet; + if (Main.netMode != NetmodeID.MultiplayerClient) + npc.netUpdate = true; + } + } + + float flyInertia; + float chargeSpeed = 32f; + Vector2 idealFlyVelocity; + switch ((MothronAIState)(int)aiState) + { + case MothronAIState.DespawnYeet: + Vector2 idealVelocity = Vector2.UnitY * -34f; + npc.velocity = (npc.velocity * 4f + idealVelocity) / 5f; + npc.noTileCollide = true; + npc.dontTakeDamage = true; + return false; + + case MothronAIState.NewAISelection: + ref float aiTimer = ref npc.ai[1]; + + npc.TargetClosest(true); + + if (npc.Center.X < target.Center.X - 2f) + npc.direction = 1; + if (npc.Center.X > target.Center.X + 2f) + npc.direction = -1; + + npc.spriteDirection = npc.direction; + npc.rotation = (npc.rotation * 9f + npc.velocity.X * 0.025f) / 10f; + + // Rebounding on tile collision. + if (npc.collideX) + { + npc.velocity.X *= -npc.oldVelocity.X * 0.5f; + npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -4f, 4f); + } + if (npc.collideY) + { + npc.velocity.Y *= -npc.oldVelocity.Y * 0.5f; + npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y, -4f, 4f); + } + + Vector2 destinationAboveTarget = target.Center - Vector2.UnitY * 200f; + float distanceFromAboveTarget = npc.Distance(destinationAboveTarget); + if (distanceFromAboveTarget > 3000f) + { + aiState = (int)MothronAIState.FlyTowardsPlayer; + aiTimer = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.netUpdate = true; + } + + // Otherwise fly towards the destination if relatively far from it. + else if (distanceFromAboveTarget > 600f) + { + flyInertia = 30f; + idealFlyVelocity = npc.DirectionTo(destinationAboveTarget) * 15f; + npc.velocity = (npc.velocity * (flyInertia - 1f) + idealFlyVelocity) / flyInertia; + } + + // And otherwise, if near the destination, slow down a bit. + else if (npc.velocity.Length() > 2f) + npc.velocity *= 0.95f; + else if (npc.velocity.Length() < 1f) + npc.velocity *= 1.05f; + + aiTimer++; + + // Select a new AI state after 10 frames. + if (aiTimer >= 10f && Main.netMode != NetmodeID.MultiplayerClient) + { + aiTimer = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + + while ((MothronAIState)(int)aiState == MothronAIState.NewAISelection) + { + int selection = Main.rand.Next(3); + if (phase3) + selection = 1; + else if (phase2) + selection = Main.rand.Next(2); + + if (selection == 0 && Collision.CanHit(npc.Center, 1, 1, target.Center, 1, 1)) + aiState = (int)MothronAIState.AccelerateTowardsPlayer; + else if (selection == 1) + aiState = (int)MothronAIState.ChargePreparation; + else if (selection == 2 && NPC.CountNPCS(NPCID.MothronEgg) + NPC.CountNPCS(NPCID.MothronSpawn) < 2) + aiState = (int)MothronAIState.PickSpotToLayEgg; + } + npc.netUpdate = true; + } + break; + + case MothronAIState.FlyTowardsPlayer: + npc.collideX = false; + npc.collideY = false; + npc.noTileCollide = true; + + if (npc.target < 0 || !target.active || target.dead) + npc.TargetClosest(true); + + npc.spriteDirection = npc.direction = (npc.velocity.X > 0).ToDirectionInt(); + npc.rotation = (npc.rotation * 9f + npc.velocity.X * 0.02f) / 10f; + + // Don't bother flying anymore if we're stuck and the target is somewhat close. + if (npc.WithinRange(target.Center, 500f) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + { + aiState = (int)MothronAIState.NewAISelection; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.netUpdate = true; + } + + float flySpeed = 18f + npc.Distance(target.Center) / 100f; + flyInertia = 25f; + idealFlyVelocity = npc.DirectionTo(target.Center) * flySpeed; + npc.velocity = (npc.velocity * (flyInertia - 1f) + idealFlyVelocity) / flyInertia; + break; + + case MothronAIState.AccelerateTowardsPlayer: + aiTimer = ref npc.ai[1]; + ref float flySpeedAdditive = ref npc.ai[2]; + + // If no valid target exists, try to find a new one and select a new attack. + if (npc.target < 0 || !target.active || target.dead) + { + npc.TargetClosest(true); + aiState = (int)MothronAIState.NewAISelection; + aiTimer = 0f; + flySpeedAdditive = 0f; + npc.ai[3] = 0f; + npc.netUpdate = true; + } + + npc.spriteDirection = npc.direction = (npc.velocity.X > 0).ToDirectionInt(); + npc.rotation = (npc.rotation * 4f + npc.velocity.X * 0.025f) / 5f; + + // Rebounding on tile collision. + if (npc.collideX) + { + npc.velocity.X *= -npc.oldVelocity.X * 0.5f; + npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -4f, 4f); + } + if (npc.collideY) + { + npc.velocity.Y *= -npc.oldVelocity.Y * 0.5f; + npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y, -4f, 4f); + } + + Vector2 destination = target.Center - Vector2.UnitY * 20f; + + flySpeedAdditive += 0.0222222228f; + if (Main.expertMode) + flySpeedAdditive += 0.0166666675f; + + flySpeed = 12f + flySpeedAdditive + npc.Distance(destination) / 120f; + flyInertia = 20f; + idealFlyVelocity = npc.DirectionTo(destination) * flySpeed; + npc.velocity = (npc.velocity * (flyInertia - 1f) + idealFlyVelocity) / flyInertia; + + aiTimer++; + // Stop flying if there's an obstacle between the npc and target. + if (aiTimer >= 120f || !Collision.CanHit(npc.Center, 1, 1, target.Center, 1, 1)) + { + aiState = (int)MothronAIState.NewAISelection; + aiTimer = 0f; + flySpeedAdditive = 0f; + npc.ai[3] = 0f; + npc.netUpdate = true; + } + break; + + case MothronAIState.ChargeRedirect: + flySpeedAdditive = ref npc.ai[2]; + npc.noTileCollide = true; + + npc.spriteDirection = npc.direction = (npc.velocity.X > 0).ToDirectionInt(); + npc.rotation = (npc.rotation * 4f + npc.velocity.X * 0.0175f) / 5f; + + destination = target.Center - npc.Center; + destination -= Vector2.UnitY * 12f; + + float xOffset = 600f; + if (npc.Center.X > target.Center.X) + destination.X += xOffset; + else + destination.X -= xOffset; + + // If close to the destination beside the player, enter the charge phase. + if (Main.netMode != NetmodeID.MultiplayerClient && + Math.Abs(npc.Center.X - target.Center.X) > xOffset - 50f && Math.Abs(npc.Center.Y - target.Center.Y) < 20f) + { + aiState = (int)MothronAIState.ChargePreparation; + flySpeedAdditive = 0f; + npc.netUpdate = true; + } + + flySpeedAdditive += 0.0333333351f; + flySpeed = 24f + flySpeedAdditive; + flyInertia = 4f; + idealVelocity = npc.DirectionTo(destination); + npc.velocity = (npc.velocity * (flyInertia - 1f) + idealVelocity) / flyInertia; + break; + case MothronAIState.ChargePreparation: + aiTimer = ref npc.ai[1]; + ref float chargeDirection = ref npc.ai[2]; + + npc.noTileCollide = true; + npc.rotation = (npc.rotation * 4f + npc.velocity.X * 0.0175f) / 5f; + + destination = target.Center - Vector2.UnitY * 12f; + + float chargePreperationInertia = 8f; + Vector2 chargeVelocity = npc.DirectionTo(destination) * chargeSpeed; + npc.velocity = (npc.velocity * (chargePreperationInertia - 1f) + chargeVelocity) / chargePreperationInertia; + npc.spriteDirection = npc.direction = (npc.velocity.X > 0).ToDirectionInt(); + + aiTimer++; + // Redirect for 10 frames. After that time has been spent, immediately charge as usual. + if (Main.netMode != NetmodeID.MultiplayerClient && + aiTimer > 10f) + { + npc.velocity = chargeVelocity; + + if (npc.velocity.X < 0f) + npc.direction = -1; + else + npc.direction = 1; + + aiState = (int)MothronAIState.DoTheFuckingCharge; + chargeDirection = npc.direction; + npc.netUpdate = true; + } + break; + + case MothronAIState.DoTheFuckingCharge: + chargeDirection = ref npc.ai[2]; + flySpeedAdditive = ref npc.ai[3]; + + npc.damage = (int)(npc.defDamage * 1.2); + npc.collideX = false; + npc.collideY = false; + npc.noTileCollide = true; + flySpeedAdditive += 0.0333333351f; + npc.velocity.X = (chargeSpeed + flySpeedAdditive) * chargeDirection; + + float chargeDistance = 460f; + if (Main.netMode != NetmodeID.MultiplayerClient && + (chargeDirection > 0f && npc.Center.X > target.Center.X + chargeDistance) || + (chargeDirection < 0f && npc.Center.X < target.Center.X - chargeDistance)) + { + // If not stuck, pick a new attack. + if (!Collision.SolidCollision(npc.position, npc.width, npc.height)) + { + aiState = (int)MothronAIState.NewAISelection; + chargeDirection = 0f; + flySpeedAdditive = 0f; + npc.netUpdate = true; + } + + // Otherwise, if somewhat horizontally far from the target, go to typical flying by default. + else if (Math.Abs(npc.Center.X - target.Center.X) > chargeDistance * 2f - 120f) + { + aiState = (int)MothronAIState.FlyTowardsPlayer; + chargeDirection = 0f; + flySpeedAdditive = 0f; + npc.netUpdate = true; + } + } + npc.rotation = (npc.rotation * 4f + npc.velocity.X * 0.0175f) / 5f; + break; + + case MothronAIState.PickSpotToLayEgg: + ref float laySpotPositionX = ref npc.ai[2]; + ref float laySpotPositionY = ref npc.ai[3]; + // Fallback if the spot selection fails. + npc.TargetClosest(true); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + aiState = (int)MothronAIState.NewAISelection; + laySpotPositionX = laySpotPositionY = -1f; + + for (int i = 0; i < 1000; i++) + { + int potentialSpotX = (int)target.Center.X / 16; + int potentialSpotY = (int)target.Center.Y / 16; + + // Become more open to positions to search the more failed tries that have been accumulated. + int checkAreaX = 30 + i / 50; + int checkAreaY = 20 + i / 75; + + potentialSpotX += Main.rand.Next(-checkAreaX, checkAreaX + 1); + potentialSpotY += Main.rand.Next(-checkAreaY, checkAreaY + 1); + + if (!WorldGen.SolidTile(potentialSpotX, potentialSpotY)) + { + // Search downward until a solid tile is reached. + // Stop checking if the spot is below the world surface, to prevent potential infinite loops. + while (!WorldGen.SolidTile(potentialSpotX, potentialSpotY) && potentialSpotY < Main.worldSurface) + potentialSpotY++; + + // And ensure that the spot isn't too far away. + if (npc.WithinRange(new Vector2(potentialSpotX, potentialSpotY).ToWorldCoordinates(), 1600f)) + { + aiState = (int)MothronAIState.FlyToEggSpot; + laySpotPositionX = potentialSpotX; + laySpotPositionY = potentialSpotY; + break; + } + } + } + npc.netUpdate = true; + } + break; + + case MothronAIState.FlyToEggSpot: + npc.spriteDirection = npc.direction = (npc.velocity.X > 0).ToDirectionInt(); + npc.rotation = (npc.rotation * 9f + npc.velocity.X * 0.025f) / 10f; + npc.noTileCollide = true; + + Vector2 spotToLayEgg = new Vector2(npc.ai[2], npc.ai[3]).ToWorldCoordinates(8f, -20f); + float distanceFromSpot = npc.Distance(spotToLayEgg); + flySpeed = 12f + distanceFromSpot / 150f; + + if (flySpeed > 20f) + flySpeed = 20f; + + if (Main.netMode != NetmodeID.MultiplayerClient && distanceFromSpot < 10f) + { + aiState = (int)MothronAIState.LayEgg; + npc.netUpdate = true; + } + + flyInertia = 10f; + npc.velocity = (npc.velocity * (flyInertia - 1f) + npc.DirectionTo(spotToLayEgg) * flySpeed) / flyInertia; + break; + + case MothronAIState.LayEgg: + npc.rotation = (npc.rotation * 9f + npc.velocity.X * 0.025f) / 10f; + npc.noTileCollide = false; + + spotToLayEgg = new Vector2(npc.ai[2], npc.ai[3]).ToWorldCoordinates(8f, -28f); + distanceFromSpot = npc.Distance(spotToLayEgg); + float hoverSpeed = 4f; + float hoverInertia = 2f; + + if (Main.netMode != NetmodeID.MultiplayerClient && distanceFromSpot < 36f) + { + ref float attackTimer = ref npc.ai[1]; + int eggLayTime = 20; + if (Main.expertMode) + eggLayTime = (int)(eggLayTime * 0.75); + int waitTime = eggLayTime; + + attackTimer++; + if (attackTimer == eggLayTime) + NPC.NewNPC((int)spotToLayEgg.X, (int)spotToLayEgg.Y + 20, 478, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + else if (attackTimer == eggLayTime + waitTime) + { + aiState = (int)MothronAIState.NewAISelection; + attackTimer = 0f; + npc.ai[2] = npc.ai[3] = 0f; + + // Try to lay another egg at a 66% chance if the amount of eggs + spawns is not at the limit. + if (NPC.CountNPCS(NPCID.MothronEgg) + NPC.CountNPCS(NPCID.MothronSpawn) < 3 && Main.rand.Next(3) != 0) + aiState = (int)MothronAIState.PickSpotToLayEgg; + else if (Collision.SolidCollision(npc.position, npc.width, npc.height)) + aiState = (int)MothronAIState.FlyTowardsPlayer; + npc.netUpdate = true; + } + } + + if (distanceFromSpot < hoverSpeed) + hoverSpeed = distanceFromSpot; + + Vector2 hoverVelocity = npc.DirectionTo(spotToLayEgg).SafeNormalize(Vector2.Zero) * hoverSpeed; + npc.velocity = (npc.velocity * (hoverInertia - 1f) + hoverVelocity) / hoverInertia; + if (npc.velocity.HasNaNs()) + npc.velocity = Vector2.Zero; + break; + } + return false; + } + #endregion + + #region Buffed Pumpking and Pumpking Blade AI + public static bool BuffedPumpkingAI(NPC npc) + { + npc.localAI[0] += 1f; + if (npc.localAI[0] > 6f) + { + npc.localAI[0] = 0f; + npc.localAI[1] += 1f; + + if (npc.localAI[1] > 4f) + npc.localAI[1] = 0f; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.localAI[2] += 1f; + if (npc.localAI[2] > 300f) + { + npc.ai[3] = (float)Main.rand.Next(3); + npc.localAI[2] = 0f; + } + else if (npc.ai[3] == 0f && npc.localAI[2] % 30f == 0f && npc.localAI[2] > 30f) + { + float num856 = 10f; + Vector2 vector109 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f + 30f); + if (!WorldGen.SolidTile((int)vector109.X / 16, (int)vector109.Y / 16)) + { + float num857 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector109.X; + float num858 = Main.player[npc.target].position.Y - vector109.Y; + num857 += (float)Main.rand.Next(-50, 51); + num858 += (float)Main.rand.Next(50, 201); + num858 *= 0.2f; + float num859 = (float)Math.Sqrt((double)(num857 * num857 + num858 * num858)); + num859 = num856 / num859; + num857 *= num859; + num858 *= num859; + num857 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; + num858 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; + Projectile.NewProjectile(vector109.X, vector109.Y, num857, num858, ProjectileID.GreekFire1 + Main.rand.Next(3), 60, 0f, Main.myPlayer, 0f, 0f); + } + } + } + + if (npc.ai[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + npc.TargetClosest(true); + npc.ai[0] = 1f; + + int num861 = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PumpkingBlade, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[num861].ai[0] = -1f; + Main.npc[num861].ai[1] = (float)npc.whoAmI; + Main.npc[num861].target = npc.target; + Main.npc[num861].netUpdate = true; + + num861 = NPC.NewNPC((int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PumpkingBlade, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[num861].ai[0] = 1f; + Main.npc[num861].ai[1] = (float)npc.whoAmI; + Main.npc[num861].ai[3] = 150f; + Main.npc[num861].target = npc.target; + Main.npc[num861].netUpdate = true; + } + + if (Main.player[npc.target].dead || Math.Abs(npc.position.X - Main.player[npc.target].position.X) > 2000f || Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f) + { + npc.TargetClosest(true); + + if (Main.player[npc.target].dead || Math.Abs(npc.position.X - Main.player[npc.target].position.X) > 2000f || Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f) + npc.ai[1] = 2f; + } + + if (Main.dayTime) + { + npc.velocity.Y += 0.3f; + npc.velocity.X *= 0.9f; + } + else if (npc.ai[1] == 0f) + { + npc.ai[2] += 1f; + if (npc.ai[2] >= 300f) + { + if (npc.ai[3] != 1f) + { + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + else + { + npc.ai[2] = 0f; + npc.ai[1] = 1f; + npc.TargetClosest(true); + npc.netUpdate = true; + } + } + + Vector2 vector110 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num862 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector110.X; + float num863 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 200f - vector110.Y; + float num864 = (float)Math.Sqrt((double)(num862 * num862 + num863 * num863)); + float num865 = 8f; + + if (npc.ai[3] == 1f) + { + if (num864 > 900f) + num865 = 14f; + else if (num864 > 600f) + num865 = 12f; + else if (num864 > 300f) + num865 = 10f; + } + + if (num864 > 50f) + { + num864 = num865 / num864; + npc.velocity.X = (npc.velocity.X * 14f + num862 * num864) / 15f; + npc.velocity.Y = (npc.velocity.Y * 14f + num863 * num864) / 15f; + } + } + else if (npc.ai[1] == 1f) + { + npc.ai[2] += 1f; + if (npc.ai[2] >= 600f || npc.ai[3] != 1f) + { + npc.ai[2] = 0f; + npc.ai[1] = 0f; + } + + Vector2 vector111 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num866 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector111.X; + float num867 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector111.Y; + float num868 = (float)Math.Sqrt((double)(num866 * num866 + num867 * num867)); + num868 = 20f / num868; + + npc.velocity.X = (npc.velocity.X * 49f + num866 * num868) / 50f; + npc.velocity.Y = (npc.velocity.Y * 49f + num867 * num868) / 50f; + } + else if (npc.ai[1] == 2f) + { + npc.ai[1] = 3f; + npc.velocity.Y += 0.1f; + + if (npc.velocity.Y < 0f) + npc.velocity.Y *= 0.95f; + + npc.velocity.X *= 0.95f; + + if (npc.timeLeft > 500) + npc.timeLeft = 500; + } + npc.rotation = npc.velocity.X * -0.02f; + + return false; + } + + public static bool BuffedPumpkingBladeAI(NPC npc) + { + npc.spriteDirection = -(int)npc.ai[0]; + + if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != 58) + { + npc.ai[2] += 10f; + if (npc.ai[2] > 50f || Main.netMode != NetmodeID.Server) + { + npc.life = -1; + npc.HitEffect(0, 10.0); + npc.active = false; + } + } + + if (Main.netMode != NetmodeID.MultiplayerClient && Main.npc[(int)npc.ai[1]].ai[3] == 2f) + { + npc.localAI[1] += 1f; + if (npc.localAI[1] > 30f) + { + npc.localAI[1] = 0f; + + float num869 = 0.01f; + Vector2 vector112 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f + 30f); + float num870 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector112.X; + float num871 = Main.player[npc.target].position.Y - vector112.Y; + float num872 = (float)Math.Sqrt((double)(num870 * num870 + num871 * num871)); + + num872 = num869 / num872; + num870 *= num872; + num871 *= num872; + + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, num870, num871, ProjectileID.FlamingScythe, 70, 0f, Main.myPlayer, npc.rotation, (float)npc.spriteDirection); + } + } + + if (Main.dayTime) + { + npc.velocity.Y += 0.3f; + npc.velocity.X *= 0.9f; + return false; + } + + if (npc.ai[2] == 0f || npc.ai[2] == 3f) + { + if (Main.npc[(int)npc.ai[1]].ai[1] == 3f && npc.timeLeft > 10) + npc.timeLeft = 10; + + npc.ai[3] += 1f; + if (npc.ai[3] >= 180f) + { + npc.ai[2] += 1f; + npc.ai[3] = 0f; + npc.netUpdate = true; + } + + Vector2 vector113 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num874 = (Main.player[npc.target].Center.X + Main.npc[(int)npc.ai[1]].Center.X) / 2f; + float num875 = (Main.player[npc.target].Center.Y + Main.npc[(int)npc.ai[1]].Center.Y) / 2f; + num874 += -170f * npc.ai[0] - vector113.X; + num875 += 90f - vector113.Y; + + float num876 = Math.Abs(Main.player[npc.target].Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(Main.player[npc.target].Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); + if (num876 > 700f) + { + num874 = Main.npc[(int)npc.ai[1]].Center.X - 170f * npc.ai[0] - vector113.X; + num875 = Main.npc[(int)npc.ai[1]].Center.Y + 90f - vector113.Y; + } + + float num877 = (float)Math.Sqrt((double)(num874 * num874 + num875 * num875)); + float num878 = 8f; + if (num877 > 1000f) + num878 = 23f; + else if (num877 > 800f) + num878 = 20f; + else if (num877 > 600f) + num878 = 17f; + else if (num877 > 400f) + num878 = 14f; + else if (num877 > 200f) + num878 = 11f; + + if (npc.ai[0] < 0f && npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X) + num874 -= 4f; + if (npc.ai[0] > 0f && npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X) + num874 += 4f; + + num877 = num878 / num877; + npc.velocity.X = (npc.velocity.X * 14f + num874 * num877) / 15f; + npc.velocity.Y = (npc.velocity.Y * 14f + num875 * num877) / 15f; + num877 = (float)Math.Sqrt((double)(num874 * num874 + num875 * num875)); + + if (num877 > 20f) + npc.rotation = (float)Math.Atan2((double)num875, (double)num874) + MathHelper.PiOver2; + } + else if (npc.ai[2] == 1f) + { + Vector2 vector114 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num879 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector114.X; + float num880 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector114.Y; + float num881 = (float)Math.Sqrt((double)(num879 * num879 + num880 * num880)); + + npc.rotation = (float)Math.Atan2((double)num880, (double)num879) + MathHelper.PiOver2; + npc.velocity.X *= 0.95f; + npc.velocity.Y -= 0.3f; + + if (npc.velocity.Y < -18f) + npc.velocity.Y = -18f; + + if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 200f) + { + npc.TargetClosest(true); + npc.ai[2] = 2f; + + vector114 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + num879 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector114.X; + num880 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector114.Y; + num881 = (float)Math.Sqrt((double)(num879 * num879 + num880 * num880)); + num881 = 24f / num881; + + npc.velocity.X = num879 * num881; + npc.velocity.Y = num880 * num881; + npc.netUpdate = true; + } + } + else if (npc.ai[2] == 2f) + { + float num882 = Math.Abs(npc.Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(npc.Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); + + if (npc.position.Y > Main.player[npc.target].position.Y || npc.velocity.Y < 0f || num882 > 800f) + npc.ai[2] = 3f; + } + else if (npc.ai[2] == 4f) + { + Vector2 vector115 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num883 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector115.X; + float num884 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector115.Y; + float num885 = (float)Math.Sqrt((double)(num883 * num883 + num884 * num884)); + + npc.rotation = (float)Math.Atan2((double)num884, (double)num883) + MathHelper.PiOver2; + npc.velocity.Y *= 0.95f; + npc.velocity.X += 0.3f * -npc.ai[0]; + + if (npc.velocity.X < -18f) + npc.velocity.X = -18f; + if (npc.velocity.X > 18f) + npc.velocity.X = 18f; + + if (npc.position.X + (float)(npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 500f || npc.position.X + (float)(npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) + 500f) + { + npc.TargetClosest(true); + npc.ai[2] = 5f; + + vector115 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + num883 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector115.X; + num884 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector115.Y; + num885 = (float)Math.Sqrt((double)(num883 * num883 + num884 * num884)); + num885 = 17f / num885; + + npc.velocity.X = num883 * num885; + npc.velocity.Y = num884 * num885; + npc.netUpdate = true; + } + } + else if (npc.ai[2] == 5f) + { + float num886 = Math.Abs(npc.Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(npc.Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); + + if ((npc.velocity.X > 0f && npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || (npc.velocity.X < 0f && npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || num886 > 800f) + npc.ai[2] = 0f; + } + + return false; + } + #endregion + + #region Buffed Ice Queen AI + public static bool BuffedIceQueenAI(NPC npc) + { + if (Main.dayTime) + { + if (npc.velocity.X > 0f) + npc.velocity.X += 0.25f; + else + npc.velocity.X -= 0.25f; + + npc.velocity.Y -= 0.1f; + npc.rotation = npc.velocity.X * 0.05f; + } + else if (npc.ai[0] == 0f) + { + if (npc.ai[2] == 0f) + { + npc.TargetClosest(true); + + if (npc.Center.X < Main.player[npc.target].Center.X) + npc.ai[2] = 1f; + else + npc.ai[2] = -1f; + } + + npc.TargetClosest(true); + int num887 = 800; + float num888 = Math.Abs(npc.Center.X - Main.player[npc.target].Center.X); + + if (npc.Center.X < Main.player[npc.target].Center.X && npc.ai[2] < 0f && num888 > (float)num887) + npc.ai[2] = 0f; + if (npc.Center.X > Main.player[npc.target].Center.X && npc.ai[2] > 0f && num888 > (float)num887) + npc.ai[2] = 0f; + + float num889 = 0.6f; + float num890 = 10f; + if ((double)npc.life < (double)npc.lifeMax * 0.75) + { + num889 = 0.7f; + num890 = 12f; + } + if ((double)npc.life < (double)npc.lifeMax * 0.5) + { + num889 = 0.8f; + num890 = 14f; + } + if ((double)npc.life < (double)npc.lifeMax * 0.25) + { + num889 = 0.95f; + num890 = 16f; + } + + npc.velocity.X += npc.ai[2] * num889; + if (npc.velocity.X > num890) + npc.velocity.X = num890; + if (npc.velocity.X < -num890) + npc.velocity.X = -num890; + + float num891 = Main.player[npc.target].position.Y - (npc.position.Y + (float)npc.height); + if (num891 < 150f) + npc.velocity.Y -= 0.2f; + if (num891 > 200f) + npc.velocity.Y += 0.2f; + if (npc.velocity.Y > 9f) + npc.velocity.Y = 9f; + if (npc.velocity.Y < -9f) + npc.velocity.Y = -9f; + + npc.rotation = npc.velocity.X * 0.05f; + + if ((num888 < 500f || npc.ai[3] < 0f) && npc.position.Y < Main.player[npc.target].position.Y) + { + npc.ai[3] += 1f; + int num892 = 8; + if ((double)npc.life < (double)npc.lifeMax * 0.75) + num892 = 7; + if ((double)npc.life < (double)npc.lifeMax * 0.5) + num892 = 6; + if ((double)npc.life < (double)npc.lifeMax * 0.25) + num892 = 5; + + num892++; + if (npc.ai[3] > (float)num892) + npc.ai[3] = (float)-(float)num892; + + if (npc.ai[3] == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 vector116 = new Vector2(npc.Center.X, npc.Center.Y); + vector116.X += npc.velocity.X * 7f; + float num893 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector116.X; + float num894 = Main.player[npc.target].Center.Y - vector116.Y; + float num895 = (float)Math.Sqrt((double)(num893 * num893 + num894 * num894)); + + float num896 = 8f; + if ((double)npc.life < (double)npc.lifeMax * 0.75) + num896 = 9f; + if ((double)npc.life < (double)npc.lifeMax * 0.5) + num896 = 10f; + if ((double)npc.life < (double)npc.lifeMax * 0.25) + num896 = 11f; + + num895 = num896 / num895; + num893 *= num895; + num894 *= num895; + + Projectile.NewProjectile(vector116.X, vector116.Y, num893, num894, ProjectileID.FrostWave, 50, 0f, Main.myPlayer, 0f, 0f); + } + } + else if (npc.ai[3] < 0f) + npc.ai[3] += 1f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.ai[1] += (float)Main.rand.Next(1, 4); + + if (npc.ai[1] > 600f && num888 < 600f) + npc.ai[0] = -1f; + } + } + else if (npc.ai[0] == 1f) + { + npc.TargetClosest(true); + + float num898 = 0.2f; + float num899 = 10f; + if ((double)npc.life < (double)npc.lifeMax * 0.75) + { + num898 = 0.24f; + num899 = 12f; + } + if ((double)npc.life < (double)npc.lifeMax * 0.5) + { + num898 = 0.28f; + num899 = 14f; + } + if ((double)npc.life < (double)npc.lifeMax * 0.25) + { + num898 = 0.32f; + num899 = 16f; + } + num898 -= 0.05f; + num899 -= 1f; + + if (npc.Center.X < Main.player[npc.target].Center.X) + { + npc.velocity.X += num898; + if (npc.velocity.X < 0f) + npc.velocity.X *= 0.98f; + } + if (npc.Center.X > Main.player[npc.target].Center.X) + { + npc.velocity.X -= num898; + if (npc.velocity.X > 0f) + npc.velocity.X *= 0.98f; + } + if (npc.velocity.X > num899 || npc.velocity.X < -num899) + npc.velocity.X *= 0.95f; + + float num900 = Main.player[npc.target].position.Y - (npc.position.Y + (float)npc.height); + if (num900 < 180f) + npc.velocity.Y -= 0.1f; + if (num900 > 200f) + npc.velocity.Y += 0.1f; + + if (npc.velocity.Y > 7f) + npc.velocity.Y = 7f; + if (npc.velocity.Y < -7f) + npc.velocity.Y = -7f; + + npc.rotation = npc.velocity.X * 0.01f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.ai[3] += 1f; + int num901 = 10; + if ((double)npc.life < (double)npc.lifeMax * 0.75) + num901 = 8; + if ((double)npc.life < (double)npc.lifeMax * 0.5) + num901 = 6; + if ((double)npc.life < (double)npc.lifeMax * 0.25) + num901 = 4; + if ((double)npc.life < (double)npc.lifeMax * 0.1) + num901 = 2; + + num901 += 3; + if (npc.ai[3] >= (float)num901) + { + npc.ai[3] = 0f; + Vector2 vector117 = new Vector2(npc.Center.X, npc.position.Y + (float)npc.height - 14f); + int i2 = (int)(vector117.X / 16f); + int j2 = (int)(vector117.Y / 16f); + if (!WorldGen.SolidTile(i2, j2)) + { + float num902 = npc.velocity.Y; + + if (num902 < 0f) + num902 = 0f; + + num902 += 3f; + float speedX2 = npc.velocity.X * 0.25f; + Projectile.NewProjectile(vector117.X, vector117.Y, speedX2, num902, ProjectileID.FrostShard, 44, 0f, Main.myPlayer, (float)Main.rand.Next(5), 0f); + } + } + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.ai[1] += (float)Main.rand.Next(1, 4); + + if (npc.ai[1] > 450f) + npc.ai[0] = -1f; + } + } + else if (npc.ai[0] == 2f) + { + npc.TargetClosest(true); + + Vector2 vector118 = new Vector2(npc.Center.X, npc.Center.Y - 20f); + float num904 = (float)Main.rand.Next(-1000, 1001); + float num905 = (float)Main.rand.Next(-1000, 1001); + float num906 = (float)Math.Sqrt((double)(num904 * num904 + num905 * num905)); + float num907 = 20f; + + npc.velocity *= 0.95f; + num906 = num907 / num906; + num904 *= num906; + num905 *= num906; + npc.rotation += 0.2f; + vector118.X += num904 * 4f; + vector118.Y += num905 * 4f; + + npc.ai[3] += 1f; + int num908 = 7; + if ((double)npc.life < (double)npc.lifeMax * 0.75) + num908--; + if ((double)npc.life < (double)npc.lifeMax * 0.5) + num908 -= 2; + if ((double)npc.life < (double)npc.lifeMax * 0.25) + num908 -= 3; + if ((double)npc.life < (double)npc.lifeMax * 0.1) + num908 -= 4; + + if (npc.ai[3] > (float)num908) + { + npc.ai[3] = 0f; + int num909 = Projectile.NewProjectile(vector118.X, vector118.Y, num904, num905, ProjectileID.FrostShard, 40, 0f, Main.myPlayer, 0f, 0f); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.ai[1] += (float)Main.rand.Next(1, 4); + + if (npc.ai[1] > 300f) + npc.ai[0] = -1f; + } + } + if (npc.ai[0] == -1f) + { + int num910 = Main.rand.Next(3); + npc.TargetClosest(true); + + if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > 1000f) + num910 = 0; + + npc.ai[0] = (float)num910; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + } + + return false; + } + #endregion + } +} From 4ca9b0ed3326ff88dacdbd1f5ebae8fd29c0424e Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Mon, 7 Dec 2020 23:46:04 -0500 Subject: [PATCH 25/66] Afflicted no longer displays how much time is left --- Buffs/StatBuffs/Afflicted.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Buffs/StatBuffs/Afflicted.cs b/Buffs/StatBuffs/Afflicted.cs index 368e6a2f37..a3e69763b7 100644 --- a/Buffs/StatBuffs/Afflicted.cs +++ b/Buffs/StatBuffs/Afflicted.cs @@ -9,6 +9,7 @@ namespace CalamityMod.Buffs.StatBuffs { DisplayName.SetDefault("Afflicted"); Description.SetDefault("Empowered by otherworldly spirits"); + Main.buffNoTimeDisplay[Type] = true; Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; From 07865c5fce13e0c1049562d5ba432844d5b42533 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Tue, 8 Dec 2020 12:04:48 -0500 Subject: [PATCH 26/66] reworked dragon rage --- CalamityLists.cs | 3 +- Items/Weapons/Melee/DragonRage.cs | 46 ++--- Projectiles/Melee/DragonRageProj.cs | 63 +++--- Projectiles/Melee/DragonRageStaff.cs | 264 ++++++++++++++++++++++++++ Projectiles/Melee/DragonRageStaff.png | Bin 0 -> 1360 bytes Projectiles/Typeless/FuckYou.cs | 10 +- Utilities/CalamityUtils.cs | 6 +- 7 files changed, 309 insertions(+), 83 deletions(-) create mode 100644 Projectiles/Melee/DragonRageStaff.cs create mode 100644 Projectiles/Melee/DragonRageStaff.png diff --git a/CalamityLists.cs b/CalamityLists.cs index 460d419830..0059b2fda1 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -357,7 +357,8 @@ namespace CalamityMod ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), - ModContent.ProjectileType() + ModContent.ProjectileType(), + ModContent.ProjectileType() }; rangedProjectileExceptionList = new List() diff --git a/Items/Weapons/Melee/DragonRage.cs b/Items/Weapons/Melee/DragonRage.cs index f0c4867db7..705a2a3890 100644 --- a/Items/Weapons/Melee/DragonRage.cs +++ b/Items/Weapons/Melee/DragonRage.cs @@ -11,51 +11,29 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Dragon Rage"); - Tooltip.SetDefault("Fires a spread of five fire waves"); + Tooltip.SetDefault("Swings a large baton that summons fire waves and explosions on enemy hits"); } public override void SetDefaults() { - item.width = 68; item.damage = 800; - item.melee = true; - item.useAnimation = 25; - item.useTime = 25; - item.useTurn = true; - item.useStyle = ItemUseStyleID.SwingThrow; item.knockBack = 7.5f; - item.UseSound = SoundID.Item1; + item.useAnimation = item.useTime = 25; + item.melee = true; + item.noMelee = true; + item.channel = true; item.autoReuse = true; + item.shootSpeed = 14f; + item.shoot = ModContent.ProjectileType(); + + item.width = 68; item.height = 82; + item.noUseGraphic = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.UseSound = SoundID.DD2_SkyDragonsFurySwing; item.value = Item.buyPrice(1, 80, 0, 0); item.rare = 10; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 14f; item.Calamity().customRarity = CalamityRarity.DarkBlue; } - - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - for (int index = 0; index < 5; ++index) - { - float SpeedX = speedX + (float)Main.rand.Next(-25, 26) * 0.05f; - float SpeedY = speedY + (float)Main.rand.Next(-25, 26) * 0.05f; - Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)((double)damage * 0.75), knockBack, player.whoAmI, 0.0f, 0.0f); - } - return false; - } - - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.NextBool(3)) - { - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 244); - } - } - - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.Daybreak, 360); - } } } diff --git a/Projectiles/Melee/DragonRageProj.cs b/Projectiles/Melee/DragonRageProj.cs index b38af4fda1..965b404135 100644 --- a/Projectiles/Melee/DragonRageProj.cs +++ b/Projectiles/Melee/DragonRageProj.cs @@ -23,37 +23,21 @@ namespace CalamityMod.Projectiles.Melee projectile.height = 70; projectile.friendly = true; projectile.ignoreWater = true; + projectile.tileCollide = false; projectile.melee = true; - projectile.penetrate = 1; + projectile.penetrate = -1; projectile.extraUpdates = 3; - projectile.timeLeft = 120; + projectile.timeLeft = 60; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -1; } public override void AI() { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; - if (projectile.localAI[0] == 0f) - { - Main.PlaySound(SoundID.Item20, (int)projectile.position.X, (int)projectile.position.Y); - projectile.localAI[0] += 1f; - } - if (projectile.localAI[1] <= 60f) - { - projectile.localAI[1] += 1f; - projectile.tileCollide = false; - } + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; Lighting.AddLight(projectile.Center, 0.5f, 0.25f, 0f); } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - if (projectile.owner == Main.myPlayer) - { - Projectile explosion = Projectile.NewProjectileDirect(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - explosion.Calamity().forceMelee = true; - } - } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { if (projectile.timeLeft > 115) @@ -63,32 +47,31 @@ namespace CalamityMod.Projectiles.Melee return false; } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.Daybreak, 120); + } + public override void Kill(int timeLeft) { - Main.PlaySound(SoundID.Item14, (int)projectile.position.X, (int)projectile.position.Y); - 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 < 6; num621++) + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 100); + for (int d = 0; d < 6; d++) { - int num622 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[idx].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[idx].scale = 0.5f; + Main.dust[idx].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(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(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity *= 5f; + idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[idx].velocity *= 2f; } CalamityUtils.ExplosionGores(projectile.Center, 3); } diff --git a/Projectiles/Melee/DragonRageStaff.cs b/Projectiles/Melee/DragonRageStaff.cs new file mode 100644 index 0000000000..a1afc7f4c4 --- /dev/null +++ b/Projectiles/Melee/DragonRageStaff.cs @@ -0,0 +1,264 @@ +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class DragonRageStaff : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Dragon Rage"); + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 158; + projectile.scale = 2.2f; + projectile.melee = true; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft = 300; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.alpha = 255; + projectile.hide = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 5; + } + + public override void AI() + { + Player player = Main.player[projectile.owner]; + float lifeSpan = 50f; + + // If the player is dead, destroy the projectile + if (player.dead) + { + projectile.Kill(); + return; + } + + int direction = Math.Sign(projectile.velocity.X); + projectile.velocity = new Vector2(direction, 0f); + + // Initial Rotation + if (projectile.ai[0] == 0f) + { + projectile.rotation = new Vector2(direction, -player.gravDir).ToRotation() + MathHelper.ToRadians(135f); + if (projectile.velocity.X < 0f) + { + projectile.rotation -= MathHelper.PiOver2; + } + } + + projectile.ai[0] += 1f; + projectile.rotation += MathHelper.TwoPi * 2f / lifeSpan * (float)direction; + bool halfWay = projectile.ai[0] == lifeSpan / 2f; + if (projectile.ai[0] >= lifeSpan || (halfWay && !player.controlUseItem)) + { + projectile.Kill(); + player.reuseDelay = 2; + } + else if (halfWay) + { + int direction2 = (player.DirectionTo(Main.MouseWorld).X > 0f) ? 1 : -1; + if ((float)direction2 != projectile.velocity.X) + { + player.ChangeDir(direction2); + projectile.velocity = new Vector2(direction2, 0f); + projectile.netUpdate = true; + projectile.rotation -= MathHelper.Pi; + } + } + if ((projectile.ai[0] == 1f || (halfWay && projectile.active)) && projectile.owner == Main.myPlayer) + { + Vector2 mouse = player.DirectionTo(Main.MouseWorld) * 0f; + player.DirectionTo(mouse); + } + + SpawnDust(player, direction); + PositionAndRotation(player); + VisibilityAndLight(); + } + + private void SpawnDust(Player player, int direction) + { + float num12 = projectile.rotation - MathHelper.PiOver4 * (float)direction; + Vector2 value3 = projectile.Center + (num12 + ((direction == -1) ? MathHelper.Pi : 0f)).ToRotationVector2() * 30f; + Vector2 vector2 = num12.ToRotationVector2(); + Vector2 value4 = vector2.RotatedBy((double)(MathHelper.PiOver2 * projectile.spriteDirection), default); + if (Main.rand.NextBool(2)) + { + Dust dust = Dust.NewDustDirect(value3 - new Vector2(5f), 10, 10, 244, player.velocity.X, player.velocity.Y, 150, default, 1f); + dust.velocity = projectile.DirectionTo(dust.position) * 0.1f + dust.velocity * 0.1f; + } + for (int j = 0; j < 4; j++) + { + float dustVelMult = 1f; + float dustVelMult2 = 1f; + switch (j) + { + case 1: + dustVelMult2 = -1f; + break; + case 2: + dustVelMult2 = 1.25f; + dustVelMult = 0.5f; + break; + case 3: + dustVelMult2 = -1.25f; + dustVelMult = 0.5f; + break; + } + if (Main.rand.Next(6) != 0) + { + Dust dust = Dust.NewDustDirect(projectile.position, 0, 0, 244, 0f, 0f, 100, default, 1f); + dust.position = projectile.Center + vector2 * (60f + Main.rand.NextFloat() * 20f) * dustVelMult2; + dust.velocity = value4 * (4f + 4f * Main.rand.NextFloat()) * dustVelMult2 * dustVelMult; + dust.noGravity = true; + dust.noLight = true; + dust.scale = 0.5f; + if (Main.rand.NextBool(4)) + { + dust.noGravity = false; + } + } + } + } + + private void PositionAndRotation(Player player) + { + Vector2 plrCtr = player.RotatedRelativePoint(player.MountedCenter, true); + Vector2 offset = Vector2.Zero; + projectile.Center = plrCtr + offset; + projectile.spriteDirection = projectile.direction; + projectile.timeLeft = 2; + player.ChangeDir(projectile.direction); + player.heldProj = projectile.whoAmI; + player.itemTime = player.itemAnimation = 2; + player.itemRotation = MathHelper.WrapAngle(projectile.rotation); + } + + private void VisibilityAndLight() + { + Lighting.AddLight(projectile.Center, 1.45f, 1.22f, 0.58f); + projectile.alpha -= 128; + if (projectile.alpha < 0) + { + projectile.alpha = 0; + } + } + + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + Player player = Main.player[projectile.owner]; + Rectangle myRect = projectile.Hitbox; + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + bool voodooDolls = projectile.owner < Main.maxPlayers && (npc.type == NPCID.Guide && player.killGuide || npc.type == NPCID.Clothier && player.killClothier); + bool friendlyProjs = projectile.friendly && (!npc.friendly || voodooDolls); + bool hostileProjs = projectile.hostile && npc.friendly && !npc.dontTakeDamageFromHostiles; + if (npc.active && !npc.dontTakeDamage && (friendlyProjs || hostileProjs) && (projectile.owner < 0 || npc.immune[projectile.owner] == 0 || projectile.maxPenetrate == 1)) + { + if (npc.noTileCollide || !projectile.ownerHitCheck || projectile.CanHit(npc)) + { + bool canHit; + Rectangle rect = npc.Hitbox; + if (npc.type == NPCID.SolarCrawltipedeTail) + { + int offset = 8; + rect.X -= offset; + rect.Y -= offset; + rect.Width += offset * 2; + rect.Height += offset * 2; + canHit = projectile.Colliding(myRect, rect); + } + else + { + canHit = projectile.Colliding(myRect, rect); + } + if (canHit) + { + hitDirection = (player.Center.X < npc.Center.X) ? 1 : -1; + } + } + } + } + } + } + + public override void CutTiles() + { + float num5 = 60f; + float f = projectile.rotation - MathHelper.PiOver4 * (float)Math.Sign(projectile.velocity.X); + DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; + Utils.PlotTileLine(projectile.Center + f.ToRotationVector2() * -num5, projectile.Center + f.ToRotationVector2() * num5, (float)projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (projHitbox.Intersects(targetHitbox)) + { + return true; + } + float f = projectile.rotation - MathHelper.PiOver4 * (float)Math.Sign(projectile.velocity.X); + float num2 = 0f; + float num3 = 110f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center + f.ToRotationVector2() * -num3, projectile.Center + f.ToRotationVector2() * num3, 23f * projectile.scale, ref num2)) + { + return true; + } + return false; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D tex = Main.projectileTexture[projectile.type]; + Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Rectangle rectangle = new Rectangle(0, 0, tex.Width, tex.Height); + Vector2 origin = tex.Size() / 2f; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + spriteBatch.Draw(tex, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), lightColor, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + return false; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.Daybreak, 360); + OnHitEffects(target.Center); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(target.Center); + } + + private void OnHitEffects(Vector2 position) + { + if (projectile.owner == Main.myPlayer) + { + int proj = Projectile.NewProjectile(position, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + Main.projectile[proj].Calamity().forceMelee = true; + + Vector2 velocity = position - projectile.Center; + velocity.Normalize(); + velocity *= 6f; + velocity.X += Main.rand.NextFloat(-1.75f, 1.75f); + velocity.Y += Main.rand.NextFloat(-1.75f, 1.75f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner); + } + } + } +} diff --git a/Projectiles/Melee/DragonRageStaff.png b/Projectiles/Melee/DragonRageStaff.png new file mode 100644 index 0000000000000000000000000000000000000000..4d3ee425bb2d390480a3ea1eb1573bc24936e761 GIT binary patch literal 1360 zcmV-W1+V&vP)Px#1ZP1_K>z@;j|==^1poj5KTu3mMF0Q*I|d;Ce<#>RM*r1ItS?OW|D!_+DR(DJ z|ItEEA~`1(H&}jWqOMjxQ))3WRKA^6ka~JsJz;rRbpQYWQxCrJ0000LbW%=J|NsC0 z|NsC0|NsC0|NsC0|NsC004v#j>Hq)$32;bRa{vGi!vFvd!vV){sAK>D1bInBK~#8N z?VRCqsz?wrh`$X^7g3t^fLNu*!b<&^CE2*FnXH6cvX-$^2H z@-svPVHg(wF^5XkgfLBSNyno}NC=Pvl0hf}FnqrpHme>46bZ?Rj)CYFb3f-)&8i6j z027j_hzS`(5CA}Y^D9722r(!Rhe${#sF6|2jL-RA^tXdEh zM&o!sgK)XLzcUPDaQ+UXCWOAfT>9P+Ad8e`*|hw;JlBVSH4qde25DgACiXLkIuNkn z74u7y02C__M435eEeBnx76h7h00;p|+4mYBj}~rGrfE6gKdJ`-dqcoG5Ci~WnhZzn z2yGhx1c8(bTaCHc`wE~A1edkEV97(yi(IB~KYa~Q55h1o5jiFMEvCP-z1H_fur0yf zM9iW1|N7nt7%~BK`v1f_^gR(UM4Wz_(_8G(_d&QGWSoBNX-T>5;kSRTvJt|Rt>t$9 zI?0Q7Z*bL(5EHESv><#k5dpYd&gV4%N=DEa+gQAz1+hsDfb*HQbvfV$m5rb+2=R^} z(4b*YlUg$ZMoMD=XvYnKLBO1SmV<6ksR&HKT#nBi2}BeCFy|7U%eH0rn^h))5VoYi z1P0bFVYsNX?0mCIMKIA^taI6}?>YG{=y}<;?6`u;ML=TMq>rN^IGx6kf_*qJh3Dz} z7L|yAahzrs>qtuwSmI~df(3sDDH!f|o61DMQV0+zNO6;g!ATGVs2M>BFHmgJxV7Qn z1dSr~_Qoy2bpXmmU?`H5Y%NeC(4rWMZ6I9V@)v<0#u*BS0e3r6E|Fu}9v{0wGUYv9NQuLHTq99~)Tw=aQ^!<=w|H zt(}nNAbbWu5C{!_5yDXQ{d%d0Npyk5@^>l=fkADD8dtGqs Sn+~A>0000 Date: Tue, 8 Dec 2020 12:07:12 -0500 Subject: [PATCH 27/66] adjusted tooltip --- Items/Weapons/Melee/DragonRage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Melee/DragonRage.cs b/Items/Weapons/Melee/DragonRage.cs index 705a2a3890..fd72be0a91 100644 --- a/Items/Weapons/Melee/DragonRage.cs +++ b/Items/Weapons/Melee/DragonRage.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Dragon Rage"); - Tooltip.SetDefault("Swings a large baton that summons fire waves and explosions on enemy hits"); + Tooltip.SetDefault("Twirls a dual-bladed baton that summons fire waves and explosions on enemy hits"); } public override void SetDefaults() From 0cdc046ad34715950f1603922c10205fde415a76 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Tue, 8 Dec 2020 14:51:31 -0500 Subject: [PATCH 28/66] you now summon a ring of fireballs every 10 hits instead of fire waves also removed some coloring on some yhar projs --- CalPlayer/CalamityPlayer.cs | 2 + Items/Weapons/Melee/DragonRage.cs | 3 +- Projectiles/Boss/YharonFireball.cs | 5 +- Projectiles/Boss/YharonFireball2.cs | 5 +- Projectiles/Melee/DragonRageFireball.cs | 111 ++++++++++++++++++ Projectiles/Melee/DragonRageProj.cs | 79 ------------- Projectiles/Melee/DragonRageProj.png | Bin 670 -> 0 bytes Projectiles/Melee/DragonRageStaff.cs | 71 ++++++----- Projectiles/Rogue/InfernalFireball.cs | 5 +- Projectiles/Rogue/InfernalFireballEruption.cs | 5 +- 10 files changed, 163 insertions(+), 123 deletions(-) create mode 100644 Projectiles/Melee/DragonRageFireball.cs delete mode 100644 Projectiles/Melee/DragonRageProj.cs delete mode 100644 Projectiles/Melee/DragonRageProj.png diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 24d1992a64..9e61776b65 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -227,6 +227,7 @@ namespace CalamityMod.CalPlayer public int bloodflareHeartTimer = 180; public int bloodflareManaTimer = 180; public int polarisBoostCounter = 0; + public int dragonRageHits = 0; public int gaelSwipes = 0; public float modStealth = 1f; public float aquaticBoost = 1f; @@ -2082,6 +2083,7 @@ namespace CalamityMod.CalPlayer externalAbyssLight = 0; externalColdImmunity = externalHeatImmunity = false; polarisBoostCounter = 0; + dragonRageHits = 0; spectralVeilImmunity = 0; jetPackCooldown = 0; jetPackDash = 0; diff --git a/Items/Weapons/Melee/DragonRage.cs b/Items/Weapons/Melee/DragonRage.cs index fd72be0a91..b6e1a1973b 100644 --- a/Items/Weapons/Melee/DragonRage.cs +++ b/Items/Weapons/Melee/DragonRage.cs @@ -11,7 +11,8 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Dragon Rage"); - Tooltip.SetDefault("Twirls a dual-bladed baton that summons fire waves and explosions on enemy hits"); + Tooltip.SetDefault("Twirls a dual-bladed baton that causes explosions on enemy hits\n" + + "Every ten hits will summon a ring of fireballs"); } public override void SetDefaults() diff --git a/Projectiles/Boss/YharonFireball.cs b/Projectiles/Boss/YharonFireball.cs index 3bc785d903..5f8f230470 100644 --- a/Projectiles/Boss/YharonFireball.cs +++ b/Projectiles/Boss/YharonFireball.cs @@ -63,10 +63,7 @@ namespace CalamityMod.Projectiles.Boss speedX2 = reader.ReadSingle(); } - public override Color? GetAlpha(Color lightColor) - { - return new Color(255, Main.DiscoG, 53, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, projectile.alpha); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Boss/YharonFireball2.cs b/Projectiles/Boss/YharonFireball2.cs index 92658f4e77..a3bfb2a610 100644 --- a/Projectiles/Boss/YharonFireball2.cs +++ b/Projectiles/Boss/YharonFireball2.cs @@ -104,10 +104,7 @@ namespace CalamityMod.Projectiles.Boss return true; } - public override Color? GetAlpha(Color lightColor) - { - return new Color(255, Main.DiscoG, 53, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, projectile.alpha); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Melee/DragonRageFireball.cs b/Projectiles/Melee/DragonRageFireball.cs new file mode 100644 index 0000000000..8338673f60 --- /dev/null +++ b/Projectiles/Melee/DragonRageFireball.cs @@ -0,0 +1,111 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class DragonRageFireball : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/Rogue/DragonShit"; + public NPC target; + private int lifeTime = 420; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Fire"); + Main.projFrames[projectile.type] = 5; + } + + public override void SetDefaults() + { + projectile.width = 64; + projectile.height = 66; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = 1; + projectile.timeLeft = lifeTime; + projectile.melee = true; + } + + public override void AI() + { + if (projectile.ai[0] == 0f) + { + projectile.ai[0] = Main.rand.NextFloat(40f, 70f); + projectile.ai[1] = Main.rand.NextFloat(35f, 55f); + } + target = projectile.Center.ClosestNPCAt(1200f); + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } + + projectile.velocity *= 1.01f; + + if (target != null && projectile.timeLeft < lifeTime - 10) + { + float inertia = projectile.ai[0]; + float speed = projectile.ai[1]; + Vector2 targetPos = projectile.DirectionTo(target.Center); + if (targetPos.HasNaNs()) + { + targetPos = Vector2.UnitY; + } + projectile.velocity = (projectile.velocity * (inertia - 1f) + targetPos * speed) / inertia; + } + } + + public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, projectile.alpha); + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D projectileTexture = Main.projectileTexture[projectile.type]; + int frameHeight = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int frameY = frameHeight * projectile.frame; + Main.spriteBatch.Draw(projectileTexture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameY, projectileTexture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)projectileTexture.Width / 2f, (float)frameHeight / 2f), projectile.scale, SpriteEffects.None, 0f); + return false; + } + + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item14, projectile.Center); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 80); + for (int d = 0; d < 5; d++) + { + int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); + Main.dust[idx].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[idx].scale = 0.5f; + Main.dust[idx].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int d = 0; d < 8; d++) + { + int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity *= 5f; + idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); + Main.dust[idx].velocity *= 2f; + } + CalamityUtils.ExplosionGores(projectile.Center, 3); + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.Daybreak, 120); + } + } +} diff --git a/Projectiles/Melee/DragonRageProj.cs b/Projectiles/Melee/DragonRageProj.cs deleted file mode 100644 index 965b404135..0000000000 --- a/Projectiles/Melee/DragonRageProj.cs +++ /dev/null @@ -1,79 +0,0 @@ -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee -{ - public class DragonRageProj : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Rage"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 15; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } - - public override void SetDefaults() - { - projectile.width = 70; - projectile.height = 70; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.melee = true; - projectile.penetrate = -1; - projectile.extraUpdates = 3; - projectile.timeLeft = 60; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = -1; - } - - public override void AI() - { - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - Lighting.AddLight(projectile.Center, 0.5f, 0.25f, 0f); - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.timeLeft > 115) - return false; - - 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(BuffID.Daybreak, 120); - } - - public override void Kill(int timeLeft) - { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 100); - for (int d = 0; d < 6; d++) - { - int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[idx].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[idx].scale = 0.5f; - Main.dust[idx].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int d = 0; d < 9; d++) - { - int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 5f; - idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[idx].velocity *= 2f; - } - CalamityUtils.ExplosionGores(projectile.Center, 3); - } - } -} diff --git a/Projectiles/Melee/DragonRageProj.png b/Projectiles/Melee/DragonRageProj.png deleted file mode 100644 index 3961db41dfc63c071309063dabf33a7af6e2e238..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 670 zcmV;P0%84$P)mV85zoCvww-CuC&e`q^fmQ-z?#unO)Z$vq1>?01MRJM!eS$!%I#4U`Y+55oYdNJ!brC$I z35({N2Z2^OFk4>CbxLtfrZKcV=!mu3QKYbIhkJ>+u_Px#V68y43^ph1DK6Pfq(oNK zsF=oB?ZUac4zH<7f64cn%H&)>RlAn#$`EMX3rn&4csR**qv??qUB-EiTvngchCuHe zC`nS+jjc{`DbBWN?+F5X3e-xKe%)&p6+0^gUZX&%SC&r6dxx|RYl#rpst(Mq7g=xI z>!gB3jR%3(m;-BSDi?{)>w>_s<-oC>&f*hf;M1&07*qoM6N<$ Eg0P+>W&i*H diff --git a/Projectiles/Melee/DragonRageStaff.cs b/Projectiles/Melee/DragonRageStaff.cs index a1afc7f4c4..5a252533b9 100644 --- a/Projectiles/Melee/DragonRageStaff.cs +++ b/Projectiles/Melee/DragonRageStaff.cs @@ -1,3 +1,4 @@ +using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -155,6 +156,49 @@ namespace CalamityMod.Projectiles.Melee } } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.Daybreak, 360); + OnHitEffects(target.Center); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + OnHitEffects(target.Center); + } + + private void OnHitEffects(Vector2 position) + { + if (projectile.owner == Main.myPlayer) + { + CalamityPlayer modPlayer = Main.player[projectile.owner].Calamity(); + modPlayer.dragonRageHits++; + if (modPlayer.dragonRageHits > 10) + { + SpawnFireballs(); + modPlayer.dragonRageHits = 0; + } + + int proj = Projectile.NewProjectile(position, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + Main.projectile[proj].Calamity().forceMelee = true; + } + } + + private void SpawnFireballs() + { + // 10 to 15 fireballs + int fireballAmt = Main.rand.Next(10, 16); + for (int i = 0; i < fireballAmt; i++) + { + float angleStep = MathHelper.TwoPi / fireballAmt; + float speed = 20f; + Vector2 velocity = new Vector2(0f, speed); + velocity = velocity.RotatedBy(angleStep * i * Main.rand.NextFloat(0.9f, 1.1f)); + + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 3, projectile.knockBack / 3f, projectile.owner); + } + } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { Player player = Main.player[projectile.owner]; @@ -233,32 +277,5 @@ namespace CalamityMod.Projectiles.Melee spriteBatch.Draw(tex, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), lightColor, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); return false; } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.Daybreak, 360); - OnHitEffects(target.Center); - } - - public override void OnHitPvp(Player target, int damage, bool crit) - { - OnHitEffects(target.Center); - } - - private void OnHitEffects(Vector2 position) - { - if (projectile.owner == Main.myPlayer) - { - int proj = Projectile.NewProjectile(position, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - Main.projectile[proj].Calamity().forceMelee = true; - - Vector2 velocity = position - projectile.Center; - velocity.Normalize(); - velocity *= 6f; - velocity.X += Main.rand.NextFloat(-1.75f, 1.75f); - velocity.Y += Main.rand.NextFloat(-1.75f, 1.75f); - Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner); - } - } } } diff --git a/Projectiles/Rogue/InfernalFireball.cs b/Projectiles/Rogue/InfernalFireball.cs index fc6aa00ad1..2ba3020708 100644 --- a/Projectiles/Rogue/InfernalFireball.cs +++ b/Projectiles/Rogue/InfernalFireball.cs @@ -44,10 +44,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.rotation += MathHelper.Pi; } - public override Color? GetAlpha(Color lightColor) - { - return new Color(255, Main.DiscoG, 53, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, projectile.alpha); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Rogue/InfernalFireballEruption.cs b/Projectiles/Rogue/InfernalFireballEruption.cs index 07d39c93ba..d35f8eff92 100644 --- a/Projectiles/Rogue/InfernalFireballEruption.cs +++ b/Projectiles/Rogue/InfernalFireballEruption.cs @@ -105,10 +105,7 @@ namespace CalamityMod.Projectiles.Rogue return true; } - public override Color? GetAlpha(Color lightColor) - { - return new Color(255, Main.DiscoG, 53, projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, projectile.alpha); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { From b5f0e25f426c980c30b14cf0cd15f9208089012b Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Tue, 8 Dec 2020 14:16:38 -0600 Subject: [PATCH 29/66] Oops lol Fixed a distance vector from being the destination when the math was altered to not require it in that context. --- NPCs/CalamityVanillaMinibossesAI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NPCs/CalamityVanillaMinibossesAI.cs b/NPCs/CalamityVanillaMinibossesAI.cs index d029e197ce..6667a0fa90 100644 --- a/NPCs/CalamityVanillaMinibossesAI.cs +++ b/NPCs/CalamityVanillaMinibossesAI.cs @@ -231,7 +231,7 @@ namespace CalamityMod.NPCs npc.spriteDirection = npc.direction = (npc.velocity.X > 0).ToDirectionInt(); npc.rotation = (npc.rotation * 4f + npc.velocity.X * 0.0175f) / 5f; - destination = target.Center - npc.Center; + destination = target.Center; destination -= Vector2.UnitY * 12f; float xOffset = 600f; From c43bc9a6bea18f0535dbc4d4e18c099777c2fa3b Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Tue, 8 Dec 2020 14:43:59 -0600 Subject: [PATCH 30/66] Fixed Draedon Panels not sticking to walls --- Tiles/DraedonStructures/AgedLaboratoryElectricPanel.cs | 1 + Tiles/DraedonStructures/LaboratoryElectricPanel.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/Tiles/DraedonStructures/AgedLaboratoryElectricPanel.cs b/Tiles/DraedonStructures/AgedLaboratoryElectricPanel.cs index 9ea513cbed..e7ce79cb0d 100644 --- a/Tiles/DraedonStructures/AgedLaboratoryElectricPanel.cs +++ b/Tiles/DraedonStructures/AgedLaboratoryElectricPanel.cs @@ -21,6 +21,7 @@ namespace CalamityMod.Tiles.DraedonStructures TileObjectData.newTile.StyleMultiplier = 2; TileObjectData.newTile.StyleHorizontal = true; TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.AnchorWall = true; TileObjectData.newTile.Direction = TileObjectDirection.PlaceRight; diff --git a/Tiles/DraedonStructures/LaboratoryElectricPanel.cs b/Tiles/DraedonStructures/LaboratoryElectricPanel.cs index d740674727..71ef4babdd 100644 --- a/Tiles/DraedonStructures/LaboratoryElectricPanel.cs +++ b/Tiles/DraedonStructures/LaboratoryElectricPanel.cs @@ -21,6 +21,7 @@ namespace CalamityMod.Tiles.DraedonStructures TileObjectData.newTile.StyleMultiplier = 2; TileObjectData.newTile.StyleHorizontal = true; TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.AnchorWall = true; TileObjectData.newTile.Direction = TileObjectDirection.PlaceRight; From a80a6ac208da5b0afd73bb0974da18e2e9f2ea6a Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Tue, 8 Dec 2020 14:46:03 -0600 Subject: [PATCH 31/66] Fixed a small mothron egg laying bug --- NPCs/CalamityVanillaMinibossesAI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NPCs/CalamityVanillaMinibossesAI.cs b/NPCs/CalamityVanillaMinibossesAI.cs index 6667a0fa90..e17056354e 100644 --- a/NPCs/CalamityVanillaMinibossesAI.cs +++ b/NPCs/CalamityVanillaMinibossesAI.cs @@ -399,7 +399,7 @@ namespace CalamityMod.NPCs float hoverSpeed = 4f; float hoverInertia = 2f; - if (Main.netMode != NetmodeID.MultiplayerClient && distanceFromSpot < 36f) + if (Main.netMode != NetmodeID.MultiplayerClient && distanceFromSpot < 44f) { ref float attackTimer = ref npc.ai[1]; int eggLayTime = 20; From 56f6815f0890b4e3e2d0ad0bb65879f6c3514961 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Tue, 8 Dec 2020 19:55:51 -0500 Subject: [PATCH 32/66] Changed the stealth damage boost formula --- CalPlayer/CalamityPlayer.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 24d1992a64..dfed3ac44c 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -9823,11 +9823,14 @@ namespace CalamityMod.CalPlayer private void ProvideStealthStatBonuses() { - // At full stealth, you get a higher damage bonus than at any partial level of stealth. - if (rogueStealth >= rogueStealthMax) - throwingDamage += rogueStealth * 0.6666666f; - else - throwingDamage += rogueStealth * 0.5f; + if (!wearingRogueArmor || rogueStealthMax <= 0) + return; + + // Stealth provides a damage bonus based on the item's damage and use time as well as the player's moving life regen + Item it = player.ActiveItem(); + float stealthRegenTime = 11.1111111f * stealthGenMoving * stealthAcceleration; + float stealthBonus = rogueStealth * 0.1f * it.damage * ((float)Math.Log(it.useTime + 2, 4) / it.useTime) * (float)Math.Log((double)stealthRegenTime, 2.5); + throwingDamage += stealthBonus; // Crit increases based on your stealth value. With certain gear, it's locked at 100% for stealth strikes. if (stealthStrikeAlwaysCrits && StealthStrikeAvailable()) @@ -9836,11 +9839,8 @@ namespace CalamityMod.CalPlayer throwingCrit += (int)(rogueStealth * 20f); // Stealth slightly increases movement speed and decreases aggro. - if (wearingRogueArmor && rogueStealthMax > 0) - { - player.moveSpeed += rogueStealth * 0.05f; - player.aggro -= (int)(rogueStealth * 400f); - } + player.moveSpeed += rogueStealth * 0.05f; + player.aggro -= (int)(rogueStealth * 400f); } private float UpdateStealthGenStats() From 633a7bee1e40133bb9175ee595357274547aac2a Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Tue, 8 Dec 2020 23:29:11 -0500 Subject: [PATCH 33/66] Fixed some math --- CalPlayer/CalamityPlayer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index dfed3ac44c..20d3748d29 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -9828,7 +9828,8 @@ namespace CalamityMod.CalPlayer // Stealth provides a damage bonus based on the item's damage and use time as well as the player's moving life regen Item it = player.ActiveItem(); - float stealthRegenTime = 11.1111111f * stealthGenMoving * stealthAcceleration; + // This variable is the amount of time it takes for the player to regenerate to full stealth from 0 while moving. It takes 9 seconds without any boosts. + float stealthRegenTime = 9f / (stealthGenMoving * stealthAcceleration); float stealthBonus = rogueStealth * 0.1f * it.damage * ((float)Math.Log(it.useTime + 2, 4) / it.useTime) * (float)Math.Log((double)stealthRegenTime, 2.5); throwingDamage += stealthBonus; From f89a0eeea68133705089a3dcecf98a95e74babd9 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Tue, 8 Dec 2020 23:32:39 -0500 Subject: [PATCH 34/66] added a comment --- CalPlayer/CalamityPlayer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 20d3748d29..a45f0a7b5b 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -9826,8 +9826,9 @@ namespace CalamityMod.CalPlayer if (!wearingRogueArmor || rogueStealthMax <= 0) return; - // Stealth provides a damage bonus based on the item's damage and use time as well as the player's moving life regen Item it = player.ActiveItem(); + // Stealth provides a damage bonus based on the item's damage and use time as well as the player's moving life regen + // Lower stealth regen will increase the stealth damage bonus to allow for more freedom in rogue builds while still giving stealth value (e.g. Menacing vs Silent) // This variable is the amount of time it takes for the player to regenerate to full stealth from 0 while moving. It takes 9 seconds without any boosts. float stealthRegenTime = 9f / (stealthGenMoving * stealthAcceleration); float stealthBonus = rogueStealth * 0.1f * it.damage * ((float)Math.Log(it.useTime + 2, 4) / it.useTime) * (float)Math.Log((double)stealthRegenTime, 2.5); From 1a0a83b8ca1d5f0ffc883bc39a7acf7f84f06c45 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Tue, 8 Dec 2020 23:38:16 -0500 Subject: [PATCH 35/66] now checks for hover item --- CalPlayer/CalamityPlayer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index a45f0a7b5b..e3773350b2 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -9826,7 +9826,9 @@ namespace CalamityMod.CalPlayer if (!wearingRogueArmor || rogueStealthMax <= 0) return; - Item it = player.ActiveItem(); + // Checking the item you hover over should allow for more accurate readings. + // While this is potentially abusable with accessories that work off of rogue boosts like Ink Bomb line, shouldn't you be using a weapon instead? + Item it = !Main.HoverItem.IsAir ? Main.HoverItem : player.ActiveItem(); // Stealth provides a damage bonus based on the item's damage and use time as well as the player's moving life regen // Lower stealth regen will increase the stealth damage bonus to allow for more freedom in rogue builds while still giving stealth value (e.g. Menacing vs Silent) // This variable is the amount of time it takes for the player to regenerate to full stealth from 0 while moving. It takes 9 seconds without any boosts. From e5711eec60a124e0deda475a8cf8c8f79fc0e97c Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Wed, 9 Dec 2020 07:20:15 -0500 Subject: [PATCH 36/66] fixed typo --- CalPlayer/CalamityPlayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index e3773350b2..669f039f8c 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -9829,7 +9829,7 @@ namespace CalamityMod.CalPlayer // Checking the item you hover over should allow for more accurate readings. // While this is potentially abusable with accessories that work off of rogue boosts like Ink Bomb line, shouldn't you be using a weapon instead? Item it = !Main.HoverItem.IsAir ? Main.HoverItem : player.ActiveItem(); - // Stealth provides a damage bonus based on the item's damage and use time as well as the player's moving life regen + // Stealth provides a damage bonus based on the item's damage and use time as well as the player's moving stealth regen // Lower stealth regen will increase the stealth damage bonus to allow for more freedom in rogue builds while still giving stealth value (e.g. Menacing vs Silent) // This variable is the amount of time it takes for the player to regenerate to full stealth from 0 while moving. It takes 9 seconds without any boosts. float stealthRegenTime = 9f / (stealthGenMoving * stealthAcceleration); From 32e24869f4e11fbbb15ae1d6285b619de3f6979a Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Wed, 9 Dec 2020 12:46:40 -0500 Subject: [PATCH 37/66] fixed hydrothermic mask issues --- Items/Armor/AtaxiaMask.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Items/Armor/AtaxiaMask.cs b/Items/Armor/AtaxiaMask.cs index 339ae4ff52..0b4182b4f8 100644 --- a/Items/Armor/AtaxiaMask.cs +++ b/Items/Armor/AtaxiaMask.cs @@ -14,8 +14,8 @@ namespace CalamityMod.Items.Armor public override void SetStaticDefaults() { 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"); + Tooltip.SetDefault("12% increased magic damage, +100 max mana, and 10% increased magic critical strike chance\n" + + "Temporary immunity to lava, and immunity to fire damage"); } public override void SetDefaults() @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { - player.setBonus = "5% increased magic damage\n" + + player.setBonus = "5% increased magic damage and 15% reduced mana usage\n" + "Inferno effect when below 50% life\n" + "Magic attacks summon damaging and healing flare orbs on hit\n" + "You have a 20% chance to emit a blazing explosion when you are hit"; @@ -63,11 +63,11 @@ namespace CalamityMod.Items.Armor modPlayer.ataxiaBlaze = true; modPlayer.ataxiaMage = true; player.magicDamage += 0.05f; + player.manaCost *= 0.85f; } public override void UpdateEquip(Player player) { - player.manaCost *= 0.85f; player.statManaMax2 += 100; player.magicDamage += 0.12f; player.magicCrit += 10; From 4f4445bd2b9c97e876590564ea808fdde575c56c Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Wed, 9 Dec 2020 19:00:28 -0500 Subject: [PATCH 38/66] fixed some basins not counting as a light source --- Tiles/FurnitureAncient/AncientBasin.cs | 1 + Tiles/FurnitureAshen/AshenBasin.cs | 1 + Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs | 1 + 3 files changed, 3 insertions(+) diff --git a/Tiles/FurnitureAncient/AncientBasin.cs b/Tiles/FurnitureAncient/AncientBasin.cs index 5c59623ee5..748c8c4a80 100644 --- a/Tiles/FurnitureAncient/AncientBasin.cs +++ b/Tiles/FurnitureAncient/AncientBasin.cs @@ -24,6 +24,7 @@ namespace CalamityMod.Tiles.FurnitureAncient AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; adjTiles = new int[] { TileID.Torches }; + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/FurnitureAshen/AshenBasin.cs b/Tiles/FurnitureAshen/AshenBasin.cs index 24f777d1e1..54b0988925 100644 --- a/Tiles/FurnitureAshen/AshenBasin.cs +++ b/Tiles/FurnitureAshen/AshenBasin.cs @@ -24,6 +24,7 @@ namespace CalamityMod.Tiles.FurnitureAshen AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; adjTiles = new int[] { TileID.Torches }; + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs b/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs index bd65fb42d7..bae7dca78c 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs @@ -27,6 +27,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite AddMapEntry(new Color(238, 145, 105), name); animationFrameHeight = 54; adjTiles = new int[] { TileID.Torches }; + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) From 9fd58cf9ed997e4b0cd6b0fca5f5faf3f9212e9e Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Wed, 9 Dec 2020 19:01:35 -0500 Subject: [PATCH 39/66] plagued plate basin is now a light source --- Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs index e7a55e3638..efdc89ac9c 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs @@ -21,6 +21,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate AddMapEntry(new Color(191, 142, 111), name); animationFrameHeight = 54; adjTiles = new int[] { TileID.Torches }; + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); } public override bool CreateDust(int i, int j, ref int type) From 335709e80ad702620121c1c0cb9ac1d05ef39a67 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Wed, 9 Dec 2020 23:37:35 -0500 Subject: [PATCH 40/66] moved most OnHit effects to a new file (why were they split up in 3 files) --- CalPlayer/CalamityPlayer.cs | 1069 ++----------- CalPlayer/CalamityPlayerOnHit.cs | 1441 ++++++++++++++++++ Items/CalamityGlobalItem.cs | 34 - Items/Weapons/Melee/BalefulHarvester.cs | 5 +- Items/Weapons/Melee/TheLastMourning.cs | 71 +- NPCs/CalamityGlobalNPC.cs | 75 - Projectiles/CalamityGlobalProjectile.cs | 657 -------- Projectiles/Rogue/BlastBarrelProjectile.cs | 33 +- Projectiles/Rogue/BouncingBettyProjectile.cs | 41 +- 9 files changed, 1631 insertions(+), 1795 deletions(-) create mode 100644 CalPlayer/CalamityPlayerOnHit.cs diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 24d1992a64..fc7f7c1e31 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -4699,26 +4699,9 @@ namespace CalamityMod.CalPlayer #region On Hit NPC public override void OnHitNPC(Item item, NPC target, int damage, float knockback, bool crit) { - if (desertProwler && item.ranged && crit) //for obscure stuff like marnite bayonet - { - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1 && player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - if (Main.rand.NextBool(15)) - { - if (player.whoAmI == Main.myPlayer) - { - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(item.damage * player.RangedDamage(), 50), knockback, player.whoAmI, 0f, 0f); - } - } - } - } - if (!item.melee && player.meleeEnchant == 7) - Projectile.NewProjectile(target.Center, target.velocity, ProjectileID.ConfettiMelee, 0, 0f, player.whoAmI, 0f, 0f); + if (player.whoAmI != Main.myPlayer) + return; - if (omegaBlueChestplate) - target.AddBuff(ModContent.BuffType(), 240); - if (sulfurSet) - target.AddBuff(BuffID.Poisoned, 120); switch (item.type) { case ItemID.IceSickle: @@ -4734,148 +4717,18 @@ namespace CalamityMod.CalPlayer break; } - if (item.melee) //prevents Deep Sea Dumbell from snagging true melee debuff memes - { - titanBoost = 600; - if (eGauntlet) - { - int duration = 90; - target.AddBuff(BuffID.CursedInferno, duration / 2, false); - target.AddBuff(BuffID.Frostburn, duration, false); - target.AddBuff(BuffID.Ichor, duration, false); - target.AddBuff(BuffID.Venom, duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - if (Main.rand.NextBool(5)) - { - target.AddBuff(ModContent.BuffType(), duration, false); - } - } - if (cryogenSoul || frostFlare) - { - CalamityUtils.Inflict246DebuffsNPC(target, BuffID.Frostburn); - } - if (yInsignia) - { - CalamityUtils.Inflict246DebuffsNPC(target, ModContent.BuffType()); - } - if (ataxiaFire) - { - CalamityUtils.Inflict246DebuffsNPC(target, BuffID.OnFire, 4f); - } - if (aWeapon) - { - CalamityUtils.Inflict246DebuffsNPC(target, ModContent.BuffType()); - } - } - if (abyssalAmulet) - { - CalamityUtils.Inflict246DebuffsNPC(target, ModContent.BuffType()); - } - if (dsSetBonus) - { - CalamityUtils.Inflict246DebuffsNPC(target, ModContent.BuffType()); - } - if (alchFlask) - { - CalamityUtils.Inflict246DebuffsNPC(target, ModContent.BuffType()); - } - if (armorCrumbling || armorShattering) - { - if (item.melee || item.Calamity().rogue) - { - CalamityUtils.Inflict246DebuffsNPC(target, ModContent.BuffType()); - } - } - if (item.Calamity().rogue) - { - switch (player.meleeEnchant) - { - case 1: - target.AddBuff(BuffID.Venom, 60 * Main.rand.Next(5, 10), false); - break; - case 2: - target.AddBuff(BuffID.CursedInferno, 60 * Main.rand.Next(3, 7), false); - break; - case 3: - target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(3, 7), false); - break; - case 5: - target.AddBuff(BuffID.Ichor, 60 * Main.rand.Next(10, 20), false); - break; - case 6: - target.AddBuff(BuffID.Confused, 60 * Main.rand.Next(1, 4), false); - break; - case 8: - target.AddBuff(BuffID.Poisoned, 60 * Main.rand.Next(5, 10), false); - break; - case 4: - 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) - { - target.AddBuff(ModContent.BuffType(), 600, false); - } - if (vexation) - { - if ((player.armor[0].type == ModContent.ItemType() || player.armor[0].type == ModContent.ItemType() || - player.armor[0].type == ModContent.ItemType()) && player.armor[1].type == ModContent.ItemType() && - player.armor[2].type == ModContent.ItemType()) - { - target.AddBuff(BuffID.CursedInferno, 90, false); - target.AddBuff(BuffID.Venom, 120, false); - } - } - if (reaverDefense) - { - player.lifeRegenTime += 1; - if (Main.player[Main.myPlayer].lifeSteal > 0f && target.canGhostHeal && target.type != NPCID.TargetDummy && target.type != ModContent.NPCType() && !player.moonLeech) - { - float healMult = 0.2f; - float heal = damage * healMult; - - if (heal > 50) - heal = 50; - if (Main.rand.Next(10) > 0) - heal = 0; - - if ((int)heal > 0 && !Main.player[Main.myPlayer].moonLeech) - { - Main.player[Main.myPlayer].lifeSteal -= heal * 2f; - float lowestHealthCheck = 0f; - int healTarget = player.whoAmI; - for (int i = 0; i < Main.maxPlayers; i++) - { - Player otherPlayer = Main.player[i]; - if (otherPlayer.active && !otherPlayer.dead && ((!player.hostile && !otherPlayer.hostile) || player.team == otherPlayer.team)) - { - float playerDist = Vector2.Distance(target.Center, otherPlayer.Center); - if (playerDist < 1200f && (otherPlayer.statLifeMax2 - otherPlayer.statLife) > lowestHealthCheck) - { - lowestHealthCheck = otherPlayer.statLifeMax2 - otherPlayer.statLife; - healTarget = i; - } - } - } - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI, healTarget, heal); - } - } - } + CalamityPlayerOnHit.ItemLifesteal(player, mod, target, item, damage); + CalamityPlayerOnHit.ItemOnHit(player, mod, item, damage, target.Center, crit, (target.damage > 5 || target.boss) && !target.SpawnedFromStatue); + CalamityPlayerOnHit.NPCDebuffs(player, mod, target, item.melee, item.ranged, item.magic, item.summon, item.Calamity().rogue, false); } #endregion #region On Hit NPC With Proj public override void OnHitNPCWithProj(Projectile proj, NPC target, int damage, float knockback, bool crit) { + if (player.whoAmI != Main.myPlayer) + return; + switch (proj.type) { case ProjectileID.BoneArrow: @@ -4917,199 +4770,35 @@ namespace CalamityMod.CalPlayer break; } - if (!proj.npcProj && !proj.trap) + if (ProjectileID.Sets.StardustDragon[proj.type]) + { + target.immune[proj.owner] = 10; + } + + if (!proj.npcProj && !proj.trap && proj.friendly) { - if (desertProwler && proj.ranged && crit) - { - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1 && player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - if (Main.rand.NextBool(15)) - { - if (player.whoAmI == Main.myPlayer) - { - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage, 50), proj.knockBack, player.whoAmI, 0f, 0f); - } - } - } - } - - if (proj.Calamity().trueMelee) - titanBoost = 600; - - if (sulfurSet && proj.friendly && !target.friendly) - target.AddBuff(BuffID.Poisoned, 120); - - if (omegaBlueChestplate && proj.friendly && !target.friendly) - target.AddBuff(ModContent.BuffType(), 240); - - if (proj.melee && silvaMelee && Main.rand.NextBool(4)) - target.AddBuff(ModContent.BuffType(), 20); - - if (abyssalAmulet) - { - CalamityUtils.Inflict246DebuffsNPC(target, ModContent.BuffType()); - } - if (dsSetBonus) - { - CalamityUtils.Inflict246DebuffsNPC(target, ModContent.BuffType()); - } if ((plaguebringerCarapace || uberBees) && CalamityLists.friendlyBeeList.Contains(proj.type)) { target.AddBuff(ModContent.BuffType(), 360); } - else if (alchFlask) - { - CalamityUtils.Inflict246DebuffsNPC(target, ModContent.BuffType()); - } - if (proj.melee) - { - if (eGauntlet) - { - int duration = 90; - target.AddBuff(BuffID.CursedInferno, duration / 2, false); - target.AddBuff(BuffID.Frostburn, duration, false); - target.AddBuff(BuffID.Ichor, duration, false); - target.AddBuff(BuffID.Venom, duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - if (Main.rand.NextBool(5)) - { - target.AddBuff(ModContent.BuffType(), duration, false); - } - } - if (aWeapon) - { - CalamityUtils.Inflict246DebuffsNPC(target, ModContent.BuffType()); - } - if (cryogenSoul || frostFlare) - { - CalamityUtils.Inflict246DebuffsNPC(target, BuffID.Frostburn); - } - if (yInsignia) - { - CalamityUtils.Inflict246DebuffsNPC(target, ModContent.BuffType()); - } - if (ataxiaFire) - { - CalamityUtils.Inflict246DebuffsNPC(target, BuffID.OnFire, 4f); - } - } - if (armorCrumbling || armorShattering) - { - if (proj.melee || proj.Calamity().rogue) - { - CalamityUtils.Inflict246DebuffsNPC(target, ModContent.BuffType()); - } - } - if (perforatorLore) - { - target.AddBuff(BuffID.Ichor, 90); - } - if (hiveMindLore) - { - target.AddBuff(BuffID.CursedInferno, 90); - } - if (holyWrath) - { - target.AddBuff(ModContent.BuffType(), 600, false); - } - else if (providenceLore) - { - target.AddBuff(ModContent.BuffType(), 420, false); - } - if (proj.Calamity().rogue) - { - switch (player.meleeEnchant) - { - case 1: - target.AddBuff(BuffID.Venom, 60 * Main.rand.Next(5, 10), false); - break; - case 2: - target.AddBuff(BuffID.CursedInferno, 60 * Main.rand.Next(3, 7), false); - break; - case 3: - target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(3, 7), false); - break; - case 5: - target.AddBuff(BuffID.Ichor, 60 * Main.rand.Next(10, 20), false); - break; - case 6: - target.AddBuff(BuffID.Confused, 60 * Main.rand.Next(1, 4), false); - break; - case 8: - target.AddBuff(BuffID.Poisoned, 60 * Main.rand.Next(5, 10), false); - break; - case 4: - target.AddBuff(BuffID.Midas, 120, false); - break; - } - if (etherealExtorter) - { - if (ZoneSunkenSea) - { - target.AddBuff(ModContent.BuffType(), 60, false); - } - if (ZoneSulphur) - { - target.AddBuff(ModContent.BuffType(), 120, false); - target.AddBuff(ModContent.BuffType(), 300, false); - } - if (Main.moonPhase == 6) //first quarter - { - target.AddBuff(BuffID.Midas, 120, false); - } - if (ZoneCalamity && CalamityLists.fireWeaponList.Contains(player.ActiveItem().type)) - { - 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) - { - if ((player.armor[0].type == ModContent.ItemType() || player.armor[0].type == ModContent.ItemType() || - player.armor[0].type == ModContent.ItemType()) && player.armor[1].type == ModContent.ItemType() && - player.armor[2].type == ModContent.ItemType()) - { - target.AddBuff(BuffID.CursedInferno, 90, false); - target.AddBuff(BuffID.Venom, 120, false); - } - } + if (proj.type == ProjectileID.IchorArrow && player.ActiveItem().type == ModContent.ItemType()) + { + target.AddBuff(BuffID.Midas, 300, false); + } + + CalamityPlayerOnHit.ProjLifesteal(player, mod, target, proj, damage, crit); + CalamityPlayerOnHit.ProjOnHit(player, mod, proj, target.Center, crit, (target.damage > 5 || target.boss) && !target.SpawnedFromStatue); + CalamityPlayerOnHit.NPCDebuffs(player, mod, target, proj.melee, proj.ranged, proj.magic, proj.IsSummon(), proj.Calamity().rogue, true); } - proj.Calamity().stealthStrikeHitCount++; } #endregion #region PvP public override void OnHitPvp(Item item, Player target, int damage, bool crit) { - if (desertProwler && item.ranged && crit) //for obscure stuff like Marnite Bayonet - { - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1 && player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - if (Main.rand.NextBool(15)) - { - if (player.whoAmI == Main.myPlayer) - { - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(item.damage * player.RangedDamage(), 50), item.knockBack, player.whoAmI, 0f, 0f); - } - } - } - } + if (player.whoAmI != Main.myPlayer) + return; - 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); - if (sulfurSet) - target.AddBuff(BuffID.Poisoned, 120); switch (item.type) { case ItemID.IceSickle: @@ -5124,101 +4813,15 @@ namespace CalamityMod.CalPlayer target.AddBuff(BuffID.Frostburn, 120); break; } - - if (item.melee) - { - titanBoost = 600; - if (eGauntlet) - { - int duration = 90; - target.AddBuff(BuffID.CursedInferno, duration / 2, false); - target.AddBuff(BuffID.Frostburn, duration, false); - target.AddBuff(BuffID.Ichor, duration, false); - target.AddBuff(BuffID.Venom, duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - if (Main.rand.NextBool(5)) - { - target.AddBuff(ModContent.BuffType(), duration, false); - } - } - if (aWeapon) - { - CalamityUtils.Inflict246DebuffsPvp(target, ModContent.BuffType()); - } - if (cryogenSoul || frostFlare) - { - CalamityUtils.Inflict246DebuffsPvp(target, BuffID.Frostburn); - } - if (yInsignia) - { - CalamityUtils.Inflict246DebuffsPvp(target, ModContent.BuffType()); - } - if (ataxiaFire) - { - CalamityUtils.Inflict246DebuffsPvp(target, BuffID.OnFire, 4f); - } - } - if (alchFlask) - { - CalamityUtils.Inflict246DebuffsPvp(target, ModContent.BuffType()); - } - if (abyssalAmulet) - { - CalamityUtils.Inflict246DebuffsPvp(target, ModContent.BuffType()); - } - if (item.Calamity().rogue) - { - switch (player.meleeEnchant) - { - case 1: - target.AddBuff(BuffID.Venom, 60 * Main.rand.Next(5, 10), false); - break; - case 2: - target.AddBuff(BuffID.CursedInferno, 60 * Main.rand.Next(3, 7), false); - break; - case 3: - target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(3, 7), false); - break; - case 5: - target.AddBuff(BuffID.Ichor, 60 * Main.rand.Next(10, 20), false); - break; - case 6: - target.AddBuff(BuffID.Confused, 60 * Main.rand.Next(1, 4), false); - break; - case 8: - target.AddBuff(BuffID.Poisoned, 60 * Main.rand.Next(5, 10), false); - break; - /*case 4: - 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) - { - target.AddBuff(ModContent.BuffType(), 600, false); - } - if (vexation) - { - if ((player.armor[0].type == ModContent.ItemType() || player.armor[0].type == ModContent.ItemType() || - player.armor[0].type == ModContent.ItemType()) && player.armor[1].type == ModContent.ItemType() && - player.armor[2].type == ModContent.ItemType()) - { - target.AddBuff(BuffID.CursedInferno, 90, false); - target.AddBuff(BuffID.Venom, 120, false); - } - } + CalamityPlayerOnHit.ItemOnHit(player, mod, item, damage, target.Center, crit, true); + CalamityPlayerOnHit.PvpDebuffs(player, mod, target, item.melee, item.ranged, item.magic, item.summon, item.Calamity().rogue, false); } public override void OnHitPvpWithProj(Projectile proj, Player target, int damage, bool crit) { + if (player.whoAmI != Main.myPlayer) + return; + switch (proj.type) { case ProjectileID.BoneArrow: @@ -5260,171 +4863,14 @@ namespace CalamityMod.CalPlayer break; } - if (!proj.npcProj && !proj.trap) + if (!proj.npcProj && !proj.trap && proj.friendly) { - if (desertProwler && proj.ranged && crit) - { - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1 && player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - if (Main.rand.NextBool(15)) - { - if (player.whoAmI == Main.myPlayer) - { - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage, 50), proj.knockBack, player.whoAmI, 0f, 0f); - } - } - } - } - - if (proj.Calamity().trueMelee) - titanBoost = 600; - - if (sulfurSet && proj.friendly) - target.AddBuff(BuffID.Poisoned, 120); - - if (omegaBlueChestplate && proj.friendly) - target.AddBuff(ModContent.BuffType(), 240); - - if (proj.melee && silvaMelee && Main.rand.NextBool(4)) - target.AddBuff(ModContent.BuffType(), 20); - - - if (abyssalAmulet) - { - CalamityUtils.Inflict246DebuffsPvp(target, ModContent.BuffType()); - } if ((plaguebringerCarapace || uberBees) && CalamityLists.friendlyBeeList.Contains(proj.type)) { target.AddBuff(ModContent.BuffType(), 360); } - else if (alchFlask) - { - CalamityUtils.Inflict246DebuffsPvp(target, ModContent.BuffType()); - } - if (proj.melee) - { - if (eGauntlet) - { - int duration = 90; - target.AddBuff(BuffID.CursedInferno, duration / 2, false); - target.AddBuff(BuffID.Frostburn, duration, false); - target.AddBuff(BuffID.Ichor, duration, false); - target.AddBuff(BuffID.Venom, duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - target.AddBuff(ModContent.BuffType(), duration, false); - if (Main.rand.NextBool(5)) - { - target.AddBuff(ModContent.BuffType(), duration, false); - } - } - if (aWeapon) - { - CalamityUtils.Inflict246DebuffsPvp(target, ModContent.BuffType()); - } - if (cryogenSoul || frostFlare) - { - CalamityUtils.Inflict246DebuffsPvp(target, BuffID.Frostburn); - } - if (yInsignia) - { - CalamityUtils.Inflict246DebuffsPvp(target, ModContent.BuffType()); - } - if (ataxiaFire) - { - CalamityUtils.Inflict246DebuffsPvp(target, BuffID.OnFire, 4f); - } - } - if (armorCrumbling || armorShattering) - { - if (proj.melee || proj.Calamity().rogue) - { - CalamityUtils.Inflict246DebuffsPvp(target, ModContent.BuffType()); - } - } - if (perforatorLore) - { - target.AddBuff(BuffID.Ichor, 90); - } - if (hiveMindLore) - { - target.AddBuff(BuffID.CursedInferno, 90); - } - if (holyWrath) - { - target.AddBuff(ModContent.BuffType(), 600, false); - } - else if (providenceLore) - { - target.AddBuff(ModContent.BuffType(), 420, false); - } - if (proj.Calamity().rogue) - { - switch (player.meleeEnchant) - { - case 1: - target.AddBuff(BuffID.Venom, 60 * Main.rand.Next(5, 10), false); - break; - case 2: - target.AddBuff(BuffID.CursedInferno, 60 * Main.rand.Next(3, 7), false); - break; - case 3: - target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(3, 7), false); - break; - case 5: - target.AddBuff(BuffID.Ichor, 60 * Main.rand.Next(10, 20), false); - break; - case 6: - target.AddBuff(BuffID.Confused, 60 * Main.rand.Next(1, 4), false); - break; - case 8: - target.AddBuff(BuffID.Poisoned, 60 * Main.rand.Next(5, 10), false); - break; - /*case 4: - target.AddBuff(BuffID.Midas, 120, false); - break;*/ - } - if (etherealExtorter) - { - if (ZoneSunkenSea) - { - target.AddBuff(ModContent.BuffType(), 60, false); - } - if (ZoneSulphur) - { - target.AddBuff(ModContent.BuffType(), 120, false); - target.AddBuff(ModContent.BuffType(), 300, false); - } - /*if (Main.moonPhase == 6) //first quarter - { - target.AddBuff(BuffID.Midas, 120, false); - }*/ - if (ZoneCalamity && CalamityLists.fireWeaponList.Contains(player.ActiveItem().type)) - { - 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) - { - if ((player.armor[0].type == ModContent.ItemType() || player.armor[0].type == ModContent.ItemType() || - player.armor[0].type == ModContent.ItemType()) && player.armor[1].type == ModContent.ItemType() && - player.armor[2].type == ModContent.ItemType()) - { - target.AddBuff(BuffID.CursedInferno, 90, false); - target.AddBuff(BuffID.Venom, 120, false); - } - } - if (proj.type == ProjectileID.IchorArrow && player.ActiveItem().type == ModContent.ItemType()) - { - target.AddBuff(BuffID.Midas, 300, false); - } + CalamityPlayerOnHit.ProjOnHit(player, mod, proj, target.Center, crit, true); + CalamityPlayerOnHit.PvpDebuffs(player, mod, target, proj.melee, proj.ranged, proj.magic, proj.IsSummon(), proj.Calamity().rogue, true); } } #endregion @@ -5512,72 +4958,15 @@ namespace CalamityMod.CalPlayer if (yharonLore) damage = (int)(damage * 0.75); - if ((target.damage > 5 || target.boss) && player.whoAmI == Main.myPlayer && !target.SpawnedFromStatue) - { - if (item.melee && soaring) - { - double useTimeMultiplier = 0.85 + (item.useTime * item.useAnimation / 3600D); //28 * 28 = 784 is average so that equals 784 / 3600 = 0.217777 + 1 = 21.7% boost - double wingTimeFraction = player.wingTimeMax / 20D; - double meleeStatMultiplier = (double)(player.meleeDamage * (float)(player.meleeCrit / 10D)); - - if (player.wingTime < player.wingTimeMax) - player.wingTime += (int)(useTimeMultiplier * (wingTimeFraction + meleeStatMultiplier)); - - if (player.wingTime > player.wingTimeMax) - player.wingTime = player.wingTimeMax; - } - if (item.melee && !item.noMelee && !item.noUseGraphic) - { - if (ataxiaGeyser) - { - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 3) - { - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(damage * 0.15, 45), 2f, player.whoAmI, 0f, 0f); - } - } - } - if (unstablePrism && crit) + if ((target.damage > 0 || target.boss) && !target.SpawnedFromStatue) + { + if (CalamityConfig.Instance.Proficiency) { - for (int s = 0; s < 3; s++) + if (gainLevelCooldown <= 0) { - Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); - Projectile.NewProjectile(target.Center, velocity, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(damage * 0.15, 30), 0f, player.whoAmI); - } - } - if (astralStarRain && crit && astralStarRainCooldown <= 0) - { - astralStarRainCooldown = 60; - for (int n = 0; n < 3; n++) - { - int projectileType = Utils.SelectRandom(Main.rand, new int[] + gainLevelCooldown = 120; + if (meleeLevel <= 12500) { - ModContent.ProjectileType(), - ProjectileID.HallowStar, - ModContent.ProjectileType() - }); - CalamityUtils.ProjectileRain(target.Center, 400f, 100f, 500f, 800f, 12f, projectileType, (int)(120 * player.AverageDamage()), 5f, player.whoAmI, 6, 0, 10, 2); - } - } - if (bloodflareMelee && item.melee) - { - if (bloodflareMeleeHits < 15 && !bloodflareFrenzy && !bloodFrenzyCooldown) - { - bloodflareMeleeHits++; - } - if (player.whoAmI == Main.myPlayer && target.canGhostHeal) - { - int healAmount = Main.rand.Next(3) + 1; - player.statLife += healAmount; - player.HealEffect(healAmount); - } - } - if (CalamityConfig.Instance.Proficiency) - { - if (gainLevelCooldown <= 0) - { - gainLevelCooldown = 120; - if (item.melee && meleeLevel <= 12500) - { if (!ReduceCooldown((int)ClassType.Melee)) { if (!Main.hardMode && meleeLevel >= 1500) @@ -5591,36 +4980,15 @@ namespace CalamityMod.CalPlayer if (fasterMeleeLevel) gainLevelCooldown /= 2; - meleeLevel++; - shootFireworksLevelUpMelee = true; + meleeLevel++; + shootFireworksLevelUpMelee = true; - if (Main.netMode == NetmodeID.MultiplayerClient) - LevelPacket(false, (int)ClassType.Melee); - } - } - } - if (CalamityWorld.revenge && CalamityConfig.Instance.Rippers) - { - if (item.melee) - { - int stressGain = (int)(damage * 0.1); - int stressMaxGain = 10; - if (stressGain < 1) - { - stressGain = 1; - } - if (stressGain > stressMaxGain) - { - stressGain = stressMaxGain; - } - rage += stressGain; - if (rage >= rageMax) - { - rage = rageMax; - } - } - } - } + if (Main.netMode == NetmodeID.MultiplayerClient) + LevelPacket(false, (int)ClassType.Melee); + } + } + } + } } public override void ModifyHitNPCWithProj(Projectile proj, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) @@ -5634,19 +5002,6 @@ namespace CalamityMod.CalPlayer Item heldItem = player.ActiveItem(); - if (isTrueMelee && soaring) - { - double useTimeMultiplier = 0.85 + (heldItem.useTime * heldItem.useAnimation / 3600D); //28 * 28 = 784 is average so that equals 784 / 3600 = 0.217777 + 1 = 21.7% boost - double wingTimeFraction = player.wingTimeMax / 20D; - double meleeStatMultiplier = player.meleeDamage * (float)(player.meleeCrit / 10D); - - if (player.wingTime < player.wingTimeMax) - player.wingTime += (int)(useTimeMultiplier * (wingTimeFraction + meleeStatMultiplier)); - - if (player.wingTime > player.wingTimeMax) - player.wingTime = player.wingTimeMax; - } - #region MultiplierBoosts double damageMult = 1.0; if (isSummon) @@ -5945,258 +5300,118 @@ namespace CalamityMod.CalPlayer #endregion - if (tarraMage && crit && proj.magic) - { - tarraCrits++; - } - if (tarraThrowing && !tarragonImmunity && !tarragonImmunityCooldown && tarraThrowingCrits < 25 && crit && proj.Calamity().rogue) - { - tarraThrowingCrits++; - } - - if ((target.damage > 5 || target.boss) && player.whoAmI == Main.myPlayer && !target.SpawnedFromStatue) - { - if (theBee && player.statLife >= player.statLifeMax2) - { - Main.PlaySound(SoundID.Item110, proj.Center); - } - if (unstablePrism && crit) - { - for (int s = 0; s < 3; s++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); - Projectile.NewProjectile(target.Center, velocity, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(damage * 0.15, 30), 0f, player.whoAmI); - } - } - if (electricianGlove && proj.Calamity().stealthStrike && proj.Calamity().rogue && proj.Calamity().stealthStrikeHitCount < 5) - { - for (int s = 0; s < 3; s++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); - int spark = Projectile.NewProjectile(target.Center, velocity, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(damage * 0.1, 30), 0f, player.whoAmI); - Main.projectile[spark].Calamity().forceRogue = true; - Main.projectile[spark].localNPCHitCooldown = -1; - } - } - if (astralStarRain && crit && astralStarRainCooldown <= 0) - { - astralStarRainCooldown = 60; - for (int n = 0; n < 3; n++) - { - int projectileType = Utils.SelectRandom(Main.rand, new int[] + if ((target.damage > 0 || target.boss) && !target.SpawnedFromStatue && CalamityConfig.Instance.Proficiency) + { + if (gainLevelCooldown <= 0) //max is 12501 to avoid setting off fireworks forever + { + gainLevelCooldown = 120; //2 seconds + if (proj.melee && meleeLevel <= 12500) + { + if (!ReduceCooldown((int)ClassType.Melee)) { - ModContent.ProjectileType(), - ProjectileID.HallowStar, - ModContent.ProjectileType() - }); - CalamityUtils.ProjectileRain(target.Center, 400f, 100f, 500f, 800f, 25f, projectileType, (int)(120 * player.AverageDamage()), 5f, player.whoAmI, 6); - } - } - if (tarraRanged && crit && proj.ranged) - { - int leafAmt = Main.rand.Next(2, 4); - for (int l = 0; l < leafAmt; l++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int FUCKYOU = Projectile.NewProjectile(target.Center, velocity, ProjectileID.Leaf, CalamityUtils.DamageSoftCap(damage * 0.25, 60), 0f, player.whoAmI); - Main.projectile[FUCKYOU].Calamity().forceTypeless = true; - Main.projectile[FUCKYOU].netUpdate = true; - } - } - if (bloodflareThrowing && proj.Calamity().rogue && crit && Main.rand.NextBool(2)) - { - if (target.canGhostHeal) - { - float projHitMult = 0.03f; - projHitMult -= (float)proj.numHits * 0.015f; - if (projHitMult < 0f) - { - projHitMult = 0f; - } - float cooldownMult = proj.damage * projHitMult; - if (cooldownMult < 0f) - { - cooldownMult = 0f; - } - if (player.lifeSteal > 0f) - { - player.statLife += 1; - player.HealEffect(1); - player.lifeSteal -= cooldownMult * 2f; - } - } - } - if (bloodflareMage && bloodflareMageCooldown <= 0 && crit && proj.magic) - { - bloodflareMageCooldown = 120; - for (int i = 0; i < 3; i++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int fire = Projectile.NewProjectile(target.Center, velocity, ProjectileID.BallofFire, CalamityUtils.DamageSoftCap(damage * 0.5, 120), 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.Calamity().stealthStrikeHitCount < 5)) && proj.type != ModContent.ProjectileType()) - { - Projectile.NewProjectile(proj.Center, Vector2.Zero, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.25, 50), 0f, player.whoAmI); - } - if (bloodflareMelee && isTrueMelee) - { - if (bloodflareMeleeHits < 15 && !bloodflareFrenzy && !bloodFrenzyCooldown) - { - bloodflareMeleeHits++; - } - if (player.whoAmI == Main.myPlayer && target.canGhostHeal) - { - int healAmount = Main.rand.Next(3) + 1; - player.statLife += healAmount; - player.HealEffect(healAmount); - } - } - if (proj.type == ModContent.ProjectileType()) - { - polarisBoostCounter += 1; - } - if (CalamityConfig.Instance.Proficiency) - { - if (gainLevelCooldown <= 0) //max is 12501 to avoid setting off fireworks forever - { - gainLevelCooldown = 120; //2 seconds - if (proj.melee && meleeLevel <= 12500) - { - if (!ReduceCooldown((int)ClassType.Melee)) - { - if (!Main.hardMode && meleeLevel >= 1500) - gainLevelCooldown = 1200; //20 seconds - if (!NPC.downedMoonlord && meleeLevel >= 5500) - gainLevelCooldown = 2400; //40 seconds - } - else - gainLevelCooldown /= 2; + if (!Main.hardMode && meleeLevel >= 1500) + gainLevelCooldown = 1200; //20 seconds + if (!NPC.downedMoonlord && meleeLevel >= 5500) + gainLevelCooldown = 2400; //40 seconds + } + else + gainLevelCooldown /= 2; - if (fasterMeleeLevel) - gainLevelCooldown /= 2; + if (fasterMeleeLevel) + gainLevelCooldown /= 2; - meleeLevel++; - shootFireworksLevelUpMelee = true; + meleeLevel++; + shootFireworksLevelUpMelee = true; - if (Main.netMode == NetmodeID.MultiplayerClient) - LevelPacket(false, (int)ClassType.Melee); - } - else if (proj.ranged && rangedLevel <= 12500) - { - if (!ReduceCooldown((int)ClassType.Ranged)) - { - if (!Main.hardMode && rangedLevel >= 1500) - gainLevelCooldown = 1200; //20 seconds - if (!NPC.downedMoonlord && rangedLevel >= 5500) - gainLevelCooldown = 2400; //40 seconds - } - else - gainLevelCooldown /= 2; + if (Main.netMode == NetmodeID.MultiplayerClient) + LevelPacket(false, (int)ClassType.Melee); + } + else if (proj.ranged && rangedLevel <= 12500) + { + if (!ReduceCooldown((int)ClassType.Ranged)) + { + if (!Main.hardMode && rangedLevel >= 1500) + gainLevelCooldown = 1200; //20 seconds + if (!NPC.downedMoonlord && rangedLevel >= 5500) + gainLevelCooldown = 2400; //40 seconds + } + else + gainLevelCooldown /= 2; - if (fasterRangedLevel) - gainLevelCooldown /= 2; + if (fasterRangedLevel) + gainLevelCooldown /= 2; - rangedLevel++; - shootFireworksLevelUpRanged = true; + rangedLevel++; + shootFireworksLevelUpRanged = true; - if (Main.netMode == NetmodeID.MultiplayerClient) - LevelPacket(false, (int)ClassType.Ranged); - } - else if (proj.magic && magicLevel <= 12500) - { - if (!ReduceCooldown((int)ClassType.Magic)) - { - if (!Main.hardMode && magicLevel >= 1500) - gainLevelCooldown = 1200; //20 seconds - if (!NPC.downedMoonlord && magicLevel >= 5500) - gainLevelCooldown = 2400; //40 seconds - } - else - gainLevelCooldown /= 2; + if (Main.netMode == NetmodeID.MultiplayerClient) + LevelPacket(false, (int)ClassType.Ranged); + } + else if (proj.magic && magicLevel <= 12500) + { + if (!ReduceCooldown((int)ClassType.Magic)) + { + if (!Main.hardMode && magicLevel >= 1500) + gainLevelCooldown = 1200; //20 seconds + if (!NPC.downedMoonlord && magicLevel >= 5500) + gainLevelCooldown = 2400; //40 seconds + } + else + gainLevelCooldown /= 2; - if (fasterMagicLevel) - gainLevelCooldown /= 2; + if (fasterMagicLevel) + gainLevelCooldown /= 2; - magicLevel++; - shootFireworksLevelUpMagic = true; + magicLevel++; + shootFireworksLevelUpMagic = true; - if (Main.netMode == NetmodeID.MultiplayerClient) - LevelPacket(false, (int)ClassType.Magic); - } - else if (isSummon && summonLevel <= 12500) - { - if (!ReduceCooldown((int)ClassType.Summon)) - { - if (!Main.hardMode && summonLevel >= 1500) - gainLevelCooldown = 1200; //20 seconds - if (!NPC.downedMoonlord && summonLevel >= 5500) - gainLevelCooldown = 2400; //40 seconds - } - else - gainLevelCooldown /= 2; + if (Main.netMode == NetmodeID.MultiplayerClient) + LevelPacket(false, (int)ClassType.Magic); + } + else if (proj.IsSummon() && summonLevel <= 12500) + { + if (!ReduceCooldown((int)ClassType.Summon)) + { + if (!Main.hardMode && summonLevel >= 1500) + gainLevelCooldown = 1200; //20 seconds + if (!NPC.downedMoonlord && summonLevel >= 5500) + gainLevelCooldown = 2400; //40 seconds + } + else + gainLevelCooldown /= 2; - if (fasterSummonLevel) - gainLevelCooldown /= 2; + if (fasterSummonLevel) + gainLevelCooldown /= 2; - summonLevel++; - shootFireworksLevelUpSummon = true; + summonLevel++; + shootFireworksLevelUpSummon = true; - if (Main.netMode == NetmodeID.MultiplayerClient) - LevelPacket(false, (int)ClassType.Summon); - } - else if (proj.Calamity().rogue && rogueLevel <= 12500) - { - if (!ReduceCooldown((int)ClassType.Rogue)) - { - if (!Main.hardMode && rogueLevel >= 1500) - gainLevelCooldown = 1200; //20 seconds - if (!NPC.downedMoonlord && rogueLevel >= 5500) - gainLevelCooldown = 2400; //40 seconds - } - else - gainLevelCooldown /= 2; + if (Main.netMode == NetmodeID.MultiplayerClient) + LevelPacket(false, (int)ClassType.Summon); + } + else if (proj.Calamity().rogue && rogueLevel <= 12500) + { + if (!ReduceCooldown((int)ClassType.Rogue)) + { + if (!Main.hardMode && rogueLevel >= 1500) + gainLevelCooldown = 1200; //20 seconds + if (!NPC.downedMoonlord && rogueLevel >= 5500) + gainLevelCooldown = 2400; //40 seconds + } + else + gainLevelCooldown /= 2; - if (fasterRogueLevel) - gainLevelCooldown /= 2; + if (fasterRogueLevel) + gainLevelCooldown /= 2; - rogueLevel++; - shootFireworksLevelUpRogue = true; + rogueLevel++; + shootFireworksLevelUpRogue = true; - if (Main.netMode == NetmodeID.MultiplayerClient) - LevelPacket(false, (int)ClassType.Rogue); - } - } - } - if (raiderTalisman && raiderStack < 150 && proj.Calamity().rogue && crit && raiderCooldown <= 0) - { - raiderStack++; - raiderCooldown = 30; - } - if (CalamityWorld.revenge && CalamityConfig.Instance.Rippers) - { - if (isTrueMelee) - { - int stressGain = (int)(damage * 0.1); - int stressMaxGain = 10; - if (stressGain < 1) - { - stressGain = 1; - } - if (stressGain > stressMaxGain) - { - stressGain = stressMaxGain; - } - rage += stressGain; - if (rage >= rageMax) - { - rage = rageMax; - } - } - } - } + if (Main.netMode == NetmodeID.MultiplayerClient) + LevelPacket(false, (int)ClassType.Rogue); + } + } + } } #endregion diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs new file mode 100644 index 0000000000..8217af6ceb --- /dev/null +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -0,0 +1,1441 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatBuffs; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Dusts; +using CalamityMod.Items.Armor; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Projectiles; +using CalamityMod.Projectiles.Healing; +using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Ranged; +using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Summon; +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; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.CalPlayer +{ + public class CalamityPlayerOnHit + { + #region Item + public static void ItemOnHit(Player player, Mod mod, Item item, int damage, Vector2 position, bool crit, bool npcCheck) + { + CalamityPlayer modPlayer = player.Calamity(); + + if (!item.melee && player.meleeEnchant == 7) + Projectile.NewProjectile(position, player.velocity, ProjectileID.ConfettiMelee, 0, 0f, player.whoAmI); + + if (modPlayer.reaverDefense) + player.lifeRegenTime += 1; + + if (modPlayer.desertProwler && crit && item.ranged) + { + if (player.ownedProjectileCounts[ProjectileType()] < 1 && player.ownedProjectileCounts[ProjectileType()] < 1) + { + if (Main.rand.NextBool(15)) + { + if (player.whoAmI == Main.myPlayer) + { + Projectile.NewProjectile(position, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(damage * player.RangedDamage(), 50), item.knockBack, player.whoAmI); + } + } + } + } + + if (npcCheck) + { + if (modPlayer.unstablePrism && crit) + { + for (int s = 0; s < 3; s++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); + Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(damage * 0.15, 30), 0f, player.whoAmI); + } + } + if (modPlayer.astralStarRain && crit && modPlayer.astralStarRainCooldown <= 0) + { + modPlayer.astralStarRainCooldown = 60; + for (int n = 0; n < 3; n++) + { + int projectileType = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.ProjectileType(), + ProjectileID.HallowStar, + ModContent.ProjectileType() + }); + CalamityUtils.ProjectileRain(position, 400f, 100f, 500f, 800f, 12f, projectileType, (int)(120 * player.AverageDamage()), 5f, player.whoAmI, 6, 0, 10, 2); + } + } + } + + if (item.melee) + { + modPlayer.titanBoost = 600; + if (npcCheck) + { + if (modPlayer.ataxiaGeyser && player.ownedProjectileCounts[ProjectileType()] < 3) + { + Projectile.NewProjectile(position, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(damage * 0.15, 45), 2f, player.whoAmI, 0f, 0f); + } + if (modPlayer.soaring) + { + double useTimeMultiplier = 0.85 + (item.useTime * item.useAnimation / 3600D); //28 * 28 = 784 is average so that equals 784 / 3600 = 0.217777 + 1 = 21.7% boost + double wingTimeFraction = player.wingTimeMax / 20D; + double meleeStatMultiplier = (double)(player.meleeDamage * (float)(player.meleeCrit / 10D)); + + if (player.wingTime < player.wingTimeMax) + player.wingTime += (int)(useTimeMultiplier * (wingTimeFraction + meleeStatMultiplier)); + + if (player.wingTime > player.wingTimeMax) + player.wingTime = player.wingTimeMax; + } + if (modPlayer.bloodflareMelee && item.melee) + { + if (modPlayer.bloodflareMeleeHits < 15 && !modPlayer.bloodflareFrenzy && !modPlayer.bloodFrenzyCooldown) + { + modPlayer.bloodflareMeleeHits++; + } + } + if (CalamityWorld.revenge && CalamityConfig.Instance.Rippers) + { + int stressGain = (int)(damage * 0.1); + int stressMaxGain = 10; + if (stressGain < 1) + { + stressGain = 1; + } + if (stressGain > stressMaxGain) + { + stressGain = stressMaxGain; + } + modPlayer.rage += stressGain; + if (modPlayer.rage >= modPlayer.rageMax) + { + modPlayer.rage = modPlayer.rageMax; + } + } + } + } + } + #endregion + + #region Proj On Hit + public static void ProjOnHit(Player player, Mod mod, Projectile proj, Vector2 position, bool crit, bool npcCheck) + { + CalamityPlayer modPlayer = player.Calamity(); + CalamityGlobalProjectile modProj = proj.Calamity(); + bool hasClass = proj.melee || proj.ranged || proj.magic || proj.IsSummon() || modProj.rogue; + + //flask of party affects all types of weapons, !proj.melee is to prevent double flask effects + if (!proj.melee && player.meleeEnchant == 7) + Projectile.NewProjectile(position, proj.velocity, ProjectileID.ConfettiMelee, 0, 0f, proj.owner, 0f, 0f); + + if (modPlayer.alchFlask && player.ownedProjectileCounts[ProjectileType()] < 6 && hasClass) + { + int plague = Projectile.NewProjectile(proj.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.25, 30), 0f, proj.owner); + Main.projectile[plague].Calamity().forceTypeless = true; + } + if (modPlayer.theBee && player.statLife >= player.statLifeMax2) + { + Main.PlaySound(SoundID.Item110, proj.Center); + } + if (modPlayer.reaverDefense) + player.lifeRegenTime += 1; + if (npcCheck) + { + if (modPlayer.unstablePrism && crit) + { + for (int s = 0; s < 3; s++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); + Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.15, 30), 0f, player.whoAmI); + } + } + if (modPlayer.astralStarRain && crit && modPlayer.astralStarRainCooldown <= 0) + { + modPlayer.astralStarRainCooldown = 60; + for (int n = 0; n < 3; n++) + { + int projectileType = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.ProjectileType(), + ProjectileID.HallowStar, + ModContent.ProjectileType() + }); + CalamityUtils.ProjectileRain(position, 400f, 100f, 500f, 800f, 25f, projectileType, (int)(120 * player.AverageDamage()), 5f, player.whoAmI, 6); + } + } + } + + if (proj.melee) + MeleeOnHit(player, modPlayer, mod, proj, modProj, position, crit, npcCheck); + if (proj.ranged) + RangedOnHit(player, modPlayer, mod, proj, modProj, position, crit, npcCheck); + if (proj.magic) + MagicOnHit(player, modPlayer, mod, proj, modProj, position, crit, npcCheck); + if (proj.IsSummon()) + SummonOnHit(player, modPlayer, mod, proj, modProj, position, crit, npcCheck); + if (modProj.rogue) + RogueOnHit(player, modPlayer, mod, proj, modProj, position, crit, npcCheck); + } + + #region Melee + private static void MeleeOnHit(Player player, CalamityPlayer modPlayer, Mod mod, Projectile proj, CalamityGlobalProjectile modProj, Vector2 position, bool crit, bool npcCheck) + { + Item heldItem = player.ActiveItem(); + + if (modProj.trueMelee) + { + modPlayer.titanBoost = 600; + if (modPlayer.soaring) + { + double useTimeMultiplier = 0.85 + (heldItem.useTime * heldItem.useAnimation / 3600D); //28 * 28 = 784 is average so that equals 784 / 3600 = 0.217777 + 1 = 21.7% boost + double wingTimeFraction = player.wingTimeMax / 20D; + double meleeStatMultiplier = player.meleeDamage * (float)(player.meleeCrit / 10D); + + if (player.wingTime < player.wingTimeMax) + player.wingTime += (int)(useTimeMultiplier * (wingTimeFraction + meleeStatMultiplier)); + + if (player.wingTime > player.wingTimeMax) + player.wingTime = player.wingTimeMax; + } + } + + if (npcCheck) + { + if (modPlayer.ataxiaGeyser && player.ownedProjectileCounts[ProjectileType()] < 3) + { + Projectile.NewProjectile(proj.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.15, 35), 0f, player.whoAmI, 0f, 0f); + } + if (modPlayer.bloodflareMelee && modProj.trueMelee) + { + if (modPlayer.bloodflareMeleeHits < 15 && !modPlayer.bloodflareFrenzy && !modPlayer.bloodFrenzyCooldown) + { + modPlayer.bloodflareMeleeHits++; + } + } + if (CalamityWorld.revenge && CalamityConfig.Instance.Rippers) + { + if (modProj.trueMelee) + { + int stressGain = (int)(proj.damage * 0.1); + int stressMaxGain = 10; + if (stressGain < 1) + { + stressGain = 1; + } + if (stressGain > stressMaxGain) + { + stressGain = stressMaxGain; + } + modPlayer.rage += stressGain; + if (modPlayer.rage >= modPlayer.rageMax) + { + modPlayer.rage = modPlayer.rageMax; + } + } + } + } + } + #endregion + + #region Ranged + private static void RangedOnHit(Player player, CalamityPlayer modPlayer, Mod mod, Projectile proj, CalamityGlobalProjectile modProj, Vector2 position, bool crit, bool npcCheck) + { + if (modPlayer.desertProwler && crit) + { + if (player.ownedProjectileCounts[ProjectileType()] < 1 && player.ownedProjectileCounts[ProjectileType()] < 1) + { + if (Main.rand.NextBool(15)) + { + if (player.whoAmI == Main.myPlayer) + { + Projectile.NewProjectile(position, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * player.RangedDamage(), 50), proj.knockBack, player.whoAmI); + } + } + } + } + if (modPlayer.tarraRanged && Main.rand.Next(0, 100) >= 88 && player.ownedProjectileCounts[ProjectileType()] <= 20 && (proj.timeLeft <= 2 || proj.penetrate <= 1)) + { + int projAmt = Main.rand.Next(2, 4); + for (int projCount = 0; projCount < projAmt; projCount++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(proj.Center, velocity, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.33, 65), 0f, proj.owner, 0f, 0f); + } + } + if (npcCheck) + { + if (modPlayer.tarraRanged && crit && proj.ranged) + { + int leafAmt = Main.rand.Next(2, 4); + for (int l = 0; l < leafAmt; l++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int FUCKYOU = Projectile.NewProjectile(position, velocity, ProjectileID.Leaf, CalamityUtils.DamageSoftCap(proj.damage * 0.25, 60), 0f, player.whoAmI); + Main.projectile[FUCKYOU].Calamity().forceTypeless = true; + Main.projectile[FUCKYOU].netUpdate = true; + } + } + if (proj.type == ModContent.ProjectileType()) + { + modPlayer.polarisBoostCounter += 1; + } + } + } + #endregion + + #region Magic + private static void MagicOnHit(Player player, CalamityPlayer modPlayer, Mod mod, Projectile proj, CalamityGlobalProjectile modProj, Vector2 position, bool crit, bool npcCheck) + { + if (modPlayer.ataxiaMage && modPlayer.ataxiaDmg <= 0) + { + int projDamage = CalamityUtils.DamageSoftCap(proj.damage * 0.625, 100); + CalamityGlobalProjectile.SpawnOrb(proj, projDamage, ProjectileType(), 800f, 20f); + int cooldown = (int)(projDamage * 0.5); + modPlayer.ataxiaDmg += cooldown; + } + else if (modPlayer.godSlayerMage && modPlayer.godSlayerDmg <= 0) + { + int projDamage = CalamityUtils.DamageSoftCap(proj.damage * 0.75, 225); + CalamityGlobalProjectile.SpawnOrb(proj, projDamage, ProjectileType(), 800f, 20f); + int cooldown = (int)(projDamage * 0.5); + modPlayer.godSlayerDmg += cooldown; + } + if (modPlayer.tarraMage && crit) + { + modPlayer.tarraCrits++; + } + if (npcCheck) + { + if (modPlayer.bloodflareMage && modPlayer.bloodflareMageCooldown <= 0 && crit) + { + modPlayer.bloodflareMageCooldown = 120; + for (int i = 0; i < 3; i++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int fire = Projectile.NewProjectile(position, velocity, ProjectileID.BallofFire, CalamityUtils.DamageSoftCap(proj.damage * 0.5, 120), 0f, player.whoAmI); + Main.projectile[fire].Calamity().forceTypeless = true; + Main.projectile[fire].netUpdate = true; + } + } + } + if (modPlayer.silvaMage && proj.penetrate == 1 && Main.rand.Next(0, 100) >= 97) + { + Main.PlaySound(SoundID.Zombie, (int)proj.position.X, (int)proj.position.Y, 103); + CalamityGlobalProjectile.ExpandHitboxBy(proj, 96); + for (int d = 0; d < 3; d++) + { + Dust.NewDust(proj.position, proj.width, proj.height, 157, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.5f); + } + for (int d = 0; d < 30; d++) + { + int explode = Dust.NewDust(proj.position, proj.width, proj.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(proj.position, proj.width, proj.height, 157, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.5f); + Main.dust[explode].velocity *= 2f; + Main.dust[explode].noGravity = true; + } + proj.damage *= 4; + proj.localNPCHitCooldown = 10; + proj.usesLocalNPCImmunity = true; + proj.Damage(); + } + } + #endregion + + #region Summon + private static void SummonOnHit(Player player, CalamityPlayer modPlayer, Mod mod, Projectile proj, CalamityGlobalProjectile modProj, Vector2 position, bool crit, bool npcCheck) + { + if (npcCheck) + { + if (modPlayer.sGenerator) + { + int buffType = Utils.SelectRandom(Main.rand, new int[] + { + BuffType(), + BuffType(), + BuffType() + }); + player.AddBuff(buffType, 120); + } + if (modPlayer.hallowedRune) + { + int buffType = Utils.SelectRandom(Main.rand, new int[] + { + BuffType(), + BuffType(), + BuffType() + }); + player.AddBuff(buffType, 120); + } + } + // Fearmonger set's colossal life regeneration + if(modPlayer.fearmongerSet) + { + modPlayer.fearmongerRegenFrames += 20; + if (modPlayer.fearmongerRegenFrames > 180) + modPlayer.fearmongerRegenFrames = 180; + } + + if (modPlayer.godSlayerSummon && modPlayer.godSlayerDmg <= 0) + { + int projDamage = CalamityUtils.DamageSoftCap(proj.damage, 300); + CalamityGlobalProjectile.SpawnOrb(proj, projDamage, ProjectileType(), 800f, 15f, true); + int cooldown = (int)(projDamage * 0.5f); + modPlayer.godSlayerDmg += cooldown; + } + + //Priorities: Nucleogenesis => Starbuster Core => Nuclear Rod => Jelly-Charged Battery + List summonExceptionList = new List() + { + ProjectileType(), + ProjectileType(), + ProjectileType(), + ProjectileType(), + ProjectileType() + }; + + if (summonExceptionList.TrueForAll(x => proj.type != x)) + { + if (modPlayer.jellyDmg <= 0) + { + if (modPlayer.nucleogenesis) + { + if (Main.rand.NextBool(4)) + { + Projectile.NewProjectile(proj.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.25, 90), proj.knockBack * 0.25f, proj.owner); + modPlayer.jellyDmg = 25f; + } + } + else if (modPlayer.starbusterCore) + { + if (Main.rand.NextBool(3)) + { + int cap = modPlayer.starTaintedGenerator ? 75 : 60; + Projectile.NewProjectile(proj.Center, Vector2.Zero, ProjectileType(), + CalamityUtils.DamageSoftCap(proj.damage * 0.5, cap), 3f, proj.owner); + modPlayer.jellyDmg = 20f; + } + } + else if (modPlayer.nuclearRod) + { + if (Main.rand.NextBool(3)) + { + Projectile.NewProjectile(proj.Center, Vector2.Zero, ProjectileType(), + CalamityUtils.DamageSoftCap(proj.damage * 0.25, 40), 0f, proj.owner); + modPlayer.jellyDmg = 20f; + } + } + else if (modPlayer.jellyChargedBattery) + { + int projDamage = CalamityUtils.DamageSoftCap(proj.damage * 0.525, 50); + CalamityGlobalProjectile.SpawnOrb(proj, projDamage, ProjectileType(), 800f, 15f); + int cooldown = (int)(projDamage * 0.5f); + modPlayer.jellyDmg += cooldown; + } + } + + if (modPlayer.hallowedPower) + { + if (Main.rand.NextBool(3) && modPlayer.hallowedRuneCooldown <= 0) + { + modPlayer.hallowedRuneCooldown = 60; + Vector2 spawnPosition = position - new Vector2(0f, 920f).RotatedByRandom(0.3f); + float speed = Main.rand.NextFloat(17f, 23f); + Projectile.NewProjectile(spawnPosition, Vector2.Normalize(position - spawnPosition) * speed, + ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage / 3, 50), 3f, proj.owner); + } + } + } + } + #endregion + + #region Rogue + private static void RogueOnHit(Player player, CalamityPlayer modPlayer, Mod mod, Projectile proj, CalamityGlobalProjectile modProj, Vector2 position, bool crit, bool npcCheck) + { + if (modProj.stealthStrike && modPlayer.dragonScales && CalamityUtils.CountProjectiles(ProjectileType()) < 2) + { + int projTileX = (int)(proj.Center.X / 16f); + int projTileY = (int)(proj.Center.Y / 16f); + int distance = 100; + if (projTileX < 10) + { + projTileX = 10; + } + if (projTileX > Main.maxTilesX - 10) + { + projTileX = Main.maxTilesX - 10; + } + if (projTileY < 10) + { + projTileY = 10; + } + if (projTileY > Main.maxTilesY - distance - 10) + { + projTileY = Main.maxTilesY - distance - 10; + } + for (int x = projTileX; x < projTileX + distance; x++) + { + Tile tile = Main.tile[projTileX, projTileY]; + if (tile.active() && (Main.tileSolid[tile.type] || tile.liquid != 0)) + { + projTileX = x; + break; + } + } + int projectileIndex = Projectile.NewProjectile(projTileX * 16 + 8, projTileY * 16 - 24, 0f, 0f, ProjectileType(), 420, 15f, Main.myPlayer, 16f, 16f); + Main.projectile[projectileIndex].Calamity().forceRogue = true; + Main.projectile[projectileIndex].netUpdate = true; + Main.projectile[projectileIndex].localNPCHitCooldown = 1; + } + if (modPlayer.tarraThrowing && !modPlayer.tarragonImmunity && !modPlayer.tarragonImmunityCooldown && modPlayer.tarraThrowingCrits < 25 && crit) + { + modPlayer.tarraThrowingCrits++; + } + if (modPlayer.electricianGlove && modProj.stealthStrike && modProj.stealthStrikeHitCount < 5) + { + for (int s = 0; s < 3; s++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); + int spark = Projectile.NewProjectile(position, velocity, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.1, 30), 0f, player.whoAmI); + Main.projectile[spark].Calamity().forceRogue = true; + Main.projectile[spark].localNPCHitCooldown = -1; + } + } + if (modPlayer.xerocSet && modPlayer.xerocDmg <= 0 && player.ownedProjectileCounts[ProjectileType()] < 3 && player.ownedProjectileCounts[ProjectileType()] < 3) + { + switch (Main.rand.Next(5)) + { + case 0: + int projDamage = CalamityUtils.DamageSoftCap(proj.damage * 0.8, 120); + CalamityGlobalProjectile.SpawnOrb(proj, projDamage, ProjectileType(), 800f, Main.rand.Next(15, 30)); + modPlayer.xerocDmg += (int)(projDamage * 0.5); + break; + + case 1: + int projDamage2 = CalamityUtils.DamageSoftCap(proj.damage * 0.625, 100); + CalamityGlobalProjectile.SpawnOrb(proj, projDamage2, ProjectileType(), 800f, 30f); + modPlayer.xerocDmg += (int)(projDamage2 * 0.5); + break; + + case 2: + Projectile.NewProjectile(proj.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.15, 30), 0f, proj.owner, 0f, 0f); + break; + + case 3: + Projectile.NewProjectile(proj.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.2, 40), 0f, proj.owner, 0f, 0f); + break; + + case 4: + int projDamage3 = CalamityUtils.DamageSoftCap(proj.damage * 0.6, 90); + CalamityGlobalProjectile.SpawnOrb(proj, projDamage3, ProjectileType(), 800f, 15f); + modPlayer.xerocDmg += (int)(projDamage3 * 0.5); + break; + + default: + break; + } + } + + if (modPlayer.featherCrown && modProj.stealthStrike && modPlayer.featherCrownCooldown <= 0 && modProj.stealthStrikeHitCount < 5) + { + for (int i = 0; i < 6; i++) + { + Vector2 source = new Vector2(position.X + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + float speedX = (position.X - source.X) / 30f; + float speedY = (position.Y - source.Y) * 8; + Vector2 velocity = new Vector2(speedX, speedY); + int dmg = (int)(15 + (proj.damage * 0.05f)); + int feather = Projectile.NewProjectile(source, velocity, ProjectileType(), dmg, 3f, proj.owner); + Main.projectile[feather].Calamity().forceRogue = true; + modPlayer.featherCrownCooldown = 15; + } + } + + if (modPlayer.moonCrown && modProj.stealthStrike && modPlayer.moonCrownCooldown <= 0 && modProj.stealthStrikeHitCount < 5) + { + for (int i = 0; i < 6; i++) + { + Vector2 source = new Vector2(position.X + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + Vector2 velocity = (position - source) / 10f; + int dmg = (int)(150 + (proj.damage * 0.05f)); + int flare = Projectile.NewProjectile(source, velocity, ProjectileID.LunarFlare, dmg, 3, proj.owner); + Main.projectile[flare].Calamity().forceRogue = true; + modPlayer.moonCrownCooldown = 15; + } + } + + if (modPlayer.nanotech && modProj.stealthStrike && modPlayer.nanoFlareCooldown <= 0 && modProj.stealthStrikeHitCount < 5) + { + for (int i = 0; i < 6; i++) + { + Vector2 source = new Vector2(position.X + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + Vector2 velocity = (position - source) / 40f; + int dmg = (int)(1000 + (proj.damage * 0.05f)); + int flare = Projectile.NewProjectile(source, velocity, ProjectileType(),dmg, 3f, proj.owner); + Main.projectile[flare].Calamity().rogue = true; + modPlayer.nanoFlareCooldown = 15; + } + } + + if (modPlayer.forbiddenCirclet && modProj.stealthStrike && modPlayer.forbiddenCooldown <= 0 && modProj.stealthStrikeHitCount < 5) + { + for (int index2 = 0; index2 < 6; index2++) + { + float xVector = Main.rand.Next(-35, 36) * 0.02f; + float yVector = Main.rand.Next(-35, 36) * 0.02f; + xVector *= 10f; + yVector *= 10f; + int dmg = (int)(75 + (proj.damage * 0.05f)); + Projectile.NewProjectile(proj.Center.X, proj.Center.Y, xVector, yVector, ProjectileType(), dmg, proj.knockBack, proj.owner, 0f, 0f); + modPlayer.forbiddenCooldown = 15; + } + } + + if (modPlayer.titanHeartSet && modProj.stealthStrike && modPlayer.titanCooldown <= 0 && modProj.stealthStrikeHitCount < 5) + { + int dmg = (int)(100 + (proj.damage * 0.01f)); + int boom = Projectile.NewProjectile(proj.Center, Vector2.Zero, ProjectileType(), dmg, proj.knockBack, proj.owner, 1f, 0f); + Main.projectile[boom].Calamity().forceRogue = true; + Main.PlaySound(SoundID.Item14, proj.Center); + for (int dustexplode = 0; dustexplode < 360; dustexplode++) + { + Vector2 dustd = new Vector2(17f, 17f).RotatedBy(MathHelper.ToRadians(dustexplode)); + int d = Dust.NewDust(proj.Center, proj.width, proj.height, Main.rand.NextBool(2) ? DustType() : DustType(), dustd.X, dustd.Y, 100, default, 1f); + Main.dust[d].noGravity = true; + Main.dust[d].position = proj.Center; + Main.dust[d].velocity *= 0.1f; + } + modPlayer.titanCooldown = 15; + } + + if (modPlayer.corrosiveSpine && proj.type != ProjectileType() && proj.type != ProjectileType() && proj.type != ProjectileType() && modProj.stealthStrikeHitCount < 5) + { + for (int i = 0; i < 3; i++) + { + if (Main.rand.NextBool(2)) + { + int type = -1; + switch (Main.rand.Next(15)) + { + case 0: + type = ProjectileType(); + break; + case 1: + type = ProjectileType(); + break; + case 2: + type = ProjectileType(); + break; + } + // Should never happen, but just in case- + if (type != -1) + { + float speed = Main.rand.NextFloat(5f, 11f); + Projectile.NewProjectile(position, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * speed, + type, CalamityUtils.DamageSoftCap(proj.damage * 0.6, 90), proj.knockBack, player.whoAmI); + } + } + } + } + + if (modPlayer.shadow && modPlayer.shadowPotCooldown <= 0 && modProj.stealthStrikeHitCount < 5) + { + if (CalamityLists.javelinProjList.Contains(proj.type)) + { + int randrot = Main.rand.Next(-30, 391); + Vector2 SoulSpeed = new Vector2(13f, 13f).RotatedBy(MathHelper.ToRadians(randrot)); + Projectile.NewProjectile(proj.Center, SoulSpeed, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.1, 60), 3f, proj.owner, 0f, 0f); + modPlayer.shadowPotCooldown = 30; + } + if (CalamityLists.spikyBallProjList.Contains(proj.type)) + { + int scythe = Projectile.NewProjectile(proj.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.05, 60), 3f, proj.owner, 1f, 0f); + Main.projectile[scythe].usesLocalNPCImmunity = true; + Main.projectile[scythe].localNPCHitCooldown = 10; + Main.projectile[scythe].penetrate = 2; + modPlayer.shadowPotCooldown = 30; + } + if (CalamityLists.daggerProjList.Contains(proj.type)) + { + Vector2 shardVelocity = new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f)); + shardVelocity.Normalize(); + shardVelocity *= 5f; + int shard = Projectile.NewProjectile(proj.Center, shardVelocity, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.15, 60), 0f, proj.owner); + Main.projectile[shard].timeLeft = 150; + modPlayer.shadowPotCooldown = 30; + } + if (CalamityLists.boomerangProjList.Contains(proj.type)) + { + int spiritDamage = CalamityUtils.DamageSoftCap(proj.damage * 0.2, 60); + Projectile ghost = CalamityGlobalProjectile.SpawnOrb(proj, spiritDamage, ProjectileID.SpectreWrath, 800f, 4f); + ghost.Calamity().forceRogue = true; + ghost.penetrate = 1; + modPlayer.shadowPotCooldown = 30; + } + if (CalamityLists.flaskBombProjList.Contains(proj.type)) + { + int blackhole = Projectile.NewProjectile(proj.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.05, 60), 3f, proj.owner, 0f, 0f); + Main.projectile[blackhole].Center = proj.Center; + modPlayer.shadowPotCooldown = 30; + } + } + if (npcCheck) + { + if (modPlayer.umbraphileSet && (Main.rand.NextBool(4) || (modProj.stealthStrike && modProj.stealthStrikeHitCount < 5)) && proj.type != ProjectileType()) + { + Projectile.NewProjectile(proj.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.25, 50), 0f, player.whoAmI); + } + if (modPlayer.raiderTalisman && modPlayer.raiderStack < 150 && crit && modPlayer.raiderCooldown <= 0) + { + modPlayer.raiderStack++; + modPlayer.raiderCooldown = 30; + } + } + modProj.stealthStrikeHitCount++; + } + #endregion + #endregion + + #region Debuffs + public static void NPCDebuffs(Player player, Mod mod, NPC target, bool melee, bool ranged, bool magic, bool summon, bool rogue, bool proj) + { + CalamityPlayer modPlayer = player.Calamity(); + if (melee) //prevents Deep Sea Dumbell from snagging true melee debuff memes + { + if (modPlayer.eGauntlet) + { + int duration = 90; + target.AddBuff(BuffID.CursedInferno, duration / 2, false); + target.AddBuff(BuffID.Frostburn, duration, false); + target.AddBuff(BuffID.Ichor, duration, false); + target.AddBuff(BuffID.Venom, duration, false); + target.AddBuff(BuffType(), duration, false); + target.AddBuff(BuffType(), duration, false); + target.AddBuff(BuffType(), duration, false); + target.AddBuff(BuffType(), duration, false); + target.AddBuff(BuffType(), duration, false); + if (Main.rand.NextBool(5)) + { + target.AddBuff(BuffType(), duration, false); + } + } + if (modPlayer.cryogenSoul || modPlayer.frostFlare) + { + CalamityUtils.Inflict246DebuffsNPC(target, BuffID.Frostburn); + } + if (modPlayer.yInsignia) + { + CalamityUtils.Inflict246DebuffsNPC(target, BuffType()); + } + if (modPlayer.ataxiaFire) + { + CalamityUtils.Inflict246DebuffsNPC(target, BuffID.OnFire, 4f); + } + if (modPlayer.aWeapon) + { + CalamityUtils.Inflict246DebuffsNPC(target, BuffType()); + } + + if (modPlayer.silvaMelee && Main.rand.NextBool(4) && proj) + target.AddBuff(BuffType(), 20); + } + if (modPlayer.armorCrumbling || modPlayer.armorShattering) + { + if (melee || rogue) + { + CalamityUtils.Inflict246DebuffsNPC(target, BuffType()); + } + } + if (rogue) + { + switch (player.meleeEnchant) + { + case 1: + target.AddBuff(BuffID.Venom, 60 * Main.rand.Next(5, 10), false); + break; + case 2: + target.AddBuff(BuffID.CursedInferno, 60 * Main.rand.Next(3, 7), false); + break; + case 3: + target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(3, 7), false); + break; + case 5: + target.AddBuff(BuffID.Ichor, 60 * Main.rand.Next(10, 20), false); + break; + case 6: + target.AddBuff(BuffID.Confused, 60 * Main.rand.Next(1, 4), false); + break; + case 8: + target.AddBuff(BuffID.Poisoned, 60 * Main.rand.Next(5, 10), false); + break; + case 4: + target.AddBuff(BuffID.Midas, 120, false); + break; + } + if (modPlayer.titanHeartMask) + { + target.AddBuff(BuffType(), 60 * Main.rand.Next(1,6), false); // 1 to 5 seconds + } + if (modPlayer.etherealExtorter) + { + if (modPlayer.ZoneSunkenSea) + { + target.AddBuff(BuffType(), 60, false); + } + if (modPlayer.ZoneSulphur) + { + target.AddBuff(BuffType(), 120, false); + target.AddBuff(BuffType(), 300, false); + } + if (Main.moonPhase == 6) //first quarter + { + target.AddBuff(BuffID.Midas, 120, false); + } + if (modPlayer.ZoneCalamity && CalamityLists.fireWeaponList.Contains(player.ActiveItem().type)) + { + target.AddBuff(BuffType(), 240, false); + } + } + if (modPlayer.corrosiveSpine) + { + target.AddBuff(BuffID.Venom, 240); + } + } + if (summon) + { + if (modPlayer.pArtifact && !modPlayer.profanedCrystal) + { + target.AddBuff(BuffType(), 300); + } + if (modPlayer.profanedCrystalBuffs) + { + target.AddBuff(Main.dayTime ? BuffType() : BuffType(), 600); + } + + if (modPlayer.tearMinions) + { + target.AddBuff(BuffType(), 60); + } + + if (modPlayer.shadowMinions) + { + target.AddBuff(BuffID.ShadowFlame, 300); + } + + if (modPlayer.voltaicJelly) + { + //100% chance for Star Tainted Generator or Nucleogenesis + //20% chance for Voltaic Jelly + if (Main.rand.NextBool(modPlayer.starTaintedGenerator ? 1 : 5)) + { + target.AddBuff(BuffID.Electrified, 60); + } + } + + if (modPlayer.starTaintedGenerator) + { + target.AddBuff(BuffType(), 180); + target.AddBuff(BuffType(), 180); + } + } + if (modPlayer.omegaBlueChestplate) + target.AddBuff(BuffType(), 240); + if (modPlayer.sulfurSet) + target.AddBuff(BuffID.Poisoned, 120); + if (modPlayer.abyssalAmulet) + { + CalamityUtils.Inflict246DebuffsNPC(target, BuffType()); + } + if (modPlayer.dsSetBonus) + { + CalamityUtils.Inflict246DebuffsNPC(target, BuffType()); + } + if (modPlayer.alchFlask) + { + CalamityUtils.Inflict246DebuffsNPC(target, BuffType()); + } + if (modPlayer.perforatorLore && proj) + { + target.AddBuff(BuffID.Ichor, 90); + } + if (modPlayer.hiveMindLore && proj) + { + target.AddBuff(BuffID.CursedInferno, 90); + } + if (modPlayer.holyWrath) + { + target.AddBuff(BuffType(), 600, false); + } + else if (modPlayer.providenceLore && proj) + { + target.AddBuff(BuffType(), 420, false); + } + if (modPlayer.vexation) + { + if ((player.armor[0].type == ItemType() || player.armor[0].type == ItemType() || + player.armor[0].type == ItemType()) && player.armor[1].type == ItemType() && + player.armor[2].type == ItemType()) + { + target.AddBuff(BuffID.CursedInferno, 90, false); + target.AddBuff(BuffID.Venom, 120, false); + } + } + } + + public static void PvpDebuffs(Player player, Mod mod, Player target, bool melee, bool ranged, bool magic, bool summon, bool rogue, bool proj) + { + CalamityPlayer modPlayer = player.Calamity(); + if (melee) + { + if (modPlayer.eGauntlet) + { + int duration = 90; + target.AddBuff(BuffID.CursedInferno, duration / 2, false); + target.AddBuff(BuffID.Frostburn, duration, false); + target.AddBuff(BuffID.Ichor, duration, false); + target.AddBuff(BuffID.Venom, duration, false); + target.AddBuff(BuffType(), duration, false); + target.AddBuff(BuffType(), duration, false); + target.AddBuff(BuffType(), duration, false); + target.AddBuff(BuffType(), duration, false); + target.AddBuff(BuffType(), duration, false); + if (Main.rand.NextBool(5)) + { + target.AddBuff(BuffType(), duration, false); + } + } + if (modPlayer.aWeapon) + { + CalamityUtils.Inflict246DebuffsPvp(target, BuffType()); + } + if (modPlayer.cryogenSoul || modPlayer.frostFlare) + { + CalamityUtils.Inflict246DebuffsPvp(target, BuffID.Frostburn); + } + if (modPlayer.yInsignia) + { + CalamityUtils.Inflict246DebuffsPvp(target, BuffType()); + } + if (modPlayer.ataxiaFire) + { + CalamityUtils.Inflict246DebuffsPvp(target, BuffID.OnFire, 4f); + } + if (modPlayer.silvaMelee && Main.rand.NextBool(4) && proj) + target.AddBuff(BuffType(), 20); + } + if (modPlayer.armorCrumbling || modPlayer.armorShattering) + { + if (melee || rogue) + { + CalamityUtils.Inflict246DebuffsPvp(target, BuffType()); + } + } + if (rogue) + { + switch (player.meleeEnchant) + { + case 1: + target.AddBuff(BuffID.Venom, 60 * Main.rand.Next(5, 10), false); + break; + case 2: + target.AddBuff(BuffID.CursedInferno, 60 * Main.rand.Next(3, 7), false); + break; + case 3: + target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(3, 7), false); + break; + case 5: + target.AddBuff(BuffID.Ichor, 60 * Main.rand.Next(10, 20), false); + break; + case 6: + target.AddBuff(BuffID.Confused, 60 * Main.rand.Next(1, 4), false); + break; + case 8: + target.AddBuff(BuffID.Poisoned, 60 * Main.rand.Next(5, 10), false); + break; + } + if (modPlayer.titanHeartMask) + { + target.AddBuff(BuffType(), 60 * Main.rand.Next(1,6), false); // 1 to 5 seconds + } + if (modPlayer.etherealExtorter) + { + if (modPlayer.ZoneSunkenSea) + { + target.AddBuff(BuffType(), 60, false); + } + if (modPlayer.ZoneSulphur) + { + target.AddBuff(BuffType(), 120, false); + target.AddBuff(BuffType(), 300, false); + } + if (modPlayer.ZoneCalamity && CalamityLists.fireWeaponList.Contains(player.ActiveItem().type)) + { + target.AddBuff(BuffType(), 240, false); + } + } + if (modPlayer.corrosiveSpine) + { + target.AddBuff(BuffID.Venom, 240); + } + } + if (summon) + { + if (modPlayer.pArtifact && !modPlayer.profanedCrystal) + { + target.AddBuff(BuffType(), 300); + } + if (modPlayer.profanedCrystalBuffs) + { + target.AddBuff(Main.dayTime ? BuffType() : BuffType(), 600); + } + + if (modPlayer.tearMinions) + { + target.AddBuff(BuffType(), 60); + } + + if (modPlayer.shadowMinions) + { + target.AddBuff(BuffID.ShadowFlame, 300); + } + + if (modPlayer.voltaicJelly) + { + //100% chance for Star Tainted Generator or Nucleogenesis + //20% chance for Voltaic Jelly + if (Main.rand.NextBool(modPlayer.starTaintedGenerator ? 1 : 5)) + { + target.AddBuff(BuffID.Electrified, 60); + } + } + + if (modPlayer.starTaintedGenerator) + { + target.AddBuff(BuffType(), 180); + target.AddBuff(BuffType(), 180); + } + } + if (modPlayer.omegaBlueChestplate) + target.AddBuff(BuffType(), 240); + if (modPlayer.sulfurSet) + target.AddBuff(BuffID.Poisoned, 120); + if (modPlayer.alchFlask) + { + CalamityUtils.Inflict246DebuffsPvp(target, BuffType()); + } + if (modPlayer.abyssalAmulet) + { + CalamityUtils.Inflict246DebuffsPvp(target, BuffType()); + } + if (modPlayer.perforatorLore && proj) + { + target.AddBuff(BuffID.Ichor, 90); + } + if (modPlayer.hiveMindLore && proj) + { + target.AddBuff(BuffID.CursedInferno, 90); + } + if (modPlayer.holyWrath) + { + target.AddBuff(BuffType(), 600, false); + } + else if (modPlayer.providenceLore && proj) + { + target.AddBuff(BuffType(), 420, false); + } + if (modPlayer.vexation) + { + if ((player.armor[0].type == ItemType() || player.armor[0].type == ItemType() || + player.armor[0].type == ItemType()) && player.armor[1].type == ItemType() && + player.armor[2].type == ItemType()) + { + target.AddBuff(BuffID.CursedInferno, 90, false); + target.AddBuff(BuffID.Venom, 120, false); + } + } + } + #endregion + + #region Lifesteal + public static void ProjLifesteal(Player player, Mod mod, NPC target, Projectile proj, int damage, bool crit) + { + CalamityPlayer modPlayer = player.Calamity(); + CalamityGlobalProjectile modProj = proj.Calamity(); + + // Spectre Damage set and Nebula set work on enemies which are "immune to lifesteal" + if (!target.canGhostHeal) + { + if (player.ghostHurt) + { + proj.ghostHurt(damage, target.Center); + } + + if (player.setNebula && player.nebulaCD == 0 && Main.rand.NextBool(3)) + { + player.nebulaCD = 30; + int boosterType = Utils.SelectRandom(Main.rand, new int[] + { + ItemID.NebulaPickup1, + ItemID.NebulaPickup2, + ItemID.NebulaPickup3 + }); + 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 * proj.direction; + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendData(MessageID.SyncItem, -1, -1, null, nebulaBooster, 0f, 0f, 0f, 0, 0, 0); + } + } + } + + if (modPlayer.bloodflareSet && !target.SpawnedFromStatue && (target.damage > 0 || target.boss) && !player.moonLeech) + { + if ((target.life < target.lifeMax * 0.5) && modPlayer.bloodflareHeartTimer <= 0) + { + modPlayer.bloodflareHeartTimer = 180; + DropHelper.DropItem(target, ItemID.Heart); + } + else if ((target.life > target.lifeMax * 0.5) && modPlayer.bloodflareManaTimer <= 0) + { + modPlayer.bloodflareManaTimer = 180; + DropHelper.DropItem(target, ItemID.Star); + } + } + + if (Main.player[Main.myPlayer].lifeSteal > 0f && target.canGhostHeal && target.type != NPCID.TargetDummy && target.type != NPCType() && !player.moonLeech) + { + // Increases the degree to which Spectre Healing set contributes to the lifesteal cap + if (player.ghostHeal) + { + float cooldownMult = 0.1f; + cooldownMult -= proj.numHits * 0.025f; + if (cooldownMult < 0f) + cooldownMult = 0f; + + float cooldown = damage * cooldownMult; + Main.player[Main.myPlayer].lifeSteal -= cooldown; + } + + // Increases the degree to which Vampire Knives contribute to the lifesteal cap + if (proj.type == ProjectileID.VampireKnife) + { + float cooldown = damage * 0.075f; + if (cooldown < 0f) + cooldown = 0f; + + Main.player[Main.myPlayer].lifeSteal -= cooldown; + } + + if (modPlayer.vampiricTalisman && modProj.rogue && crit) + { + float heal = MathHelper.Clamp(damage * 0.015f, 0f, 6f); + if ((int)heal > 0) + { + CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, player, heal, ProjectileID.VampireHeal, 1200f, 2f); + } + } + + if ((modPlayer.bloodyGlove || modPlayer.electricianGlove) && modProj.rogue && modProj.stealthStrike) + { + player.statLife += 1; + player.HealEffect(1); + } + + if ((target.damage > 5 || target.boss) && !target.SpawnedFromStatue) + { + if (modPlayer.bloodflareThrowing && modProj.rogue && crit && Main.rand.NextBool(2)) + { + float projHitMult = 0.03f; + projHitMult -= (float)proj.numHits * 0.015f; + if (projHitMult < 0f) + { + projHitMult = 0f; + } + float cooldownMult = damage * projHitMult; + if (cooldownMult < 0f) + { + cooldownMult = 0f; + } + if (player.lifeSteal > 0f) + { + player.statLife += 1; + player.HealEffect(1); + player.lifeSteal -= cooldownMult * 2f; + } + } + if (modPlayer.bloodflareMelee && modProj.trueMelee) + { + int healAmount = Main.rand.Next(3) + 1; + player.statLife += healAmount; + player.HealEffect(healAmount); + } + } + + bool otherHealTypes = modPlayer.auricSet || modPlayer.silvaSet || modPlayer.godSlayerMage || modPlayer.tarraMage || modPlayer.ataxiaMage; + + if (proj.magic && player.ActiveItem().magic) + { + if (modPlayer.manaOverloader && otherHealTypes) + { + if (Main.rand.NextBool(2)) + { + float healMult = 0.2f; + healMult -= proj.numHits * 0.05f; + float heal = damage * healMult * (player.statMana / (float)player.statManaMax2); + + if (heal > 50) + heal = 50; + + if (!CalamityGlobalProjectile.CanSpawnLifeStealProjectile(proj, healMult, heal)) + return; + + CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, player, heal, ProjectileType(), 1200f, 2f); + } + } + } + + if (modPlayer.auricSet) + { + float healMult = 0.05f; + healMult -= proj.numHits * 0.025f; + float heal = damage * healMult; + + if (heal > 50) + heal = 50; + + if (!CalamityGlobalProjectile.CanSpawnLifeStealProjectile(proj, healMult, heal)) + return; + + CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, player, heal, ProjectileType(), 1200f, 3f); + } + else if (modPlayer.silvaSet) + { + float healMult = 0.03f; + healMult -= proj.numHits * 0.015f; + float heal = damage * healMult; + + if (heal > 50) + heal = 50; + + if (!CalamityGlobalProjectile.CanSpawnLifeStealProjectile(proj, healMult, heal)) + return; + + CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, player, heal, ProjectileType(), 1200f, 3f); + } + else if (proj.magic && player.ActiveItem().magic) + { + if (modPlayer.manaOverloader) + { + float healMult = 0.2f; + healMult -= proj.numHits * 0.05f; + float heal = damage * healMult * (player.statMana / (float)player.statManaMax2); + + if (heal > 50) + heal = 50; + + if (!CalamityGlobalProjectile.CanSpawnLifeStealProjectile(proj, healMult, heal)) + return; + + CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, player, heal, ProjectileType(), 1200f, 2f); + } + if (modPlayer.godSlayerMage) + { + float healMult = 0.06f; + healMult -= proj.numHits * 0.015f; + float heal = damage * healMult; + + if (heal > 50) + heal = 50; + + if (!CalamityGlobalProjectile.CanSpawnLifeStealProjectile(proj, healMult, heal)) + return; + + CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, player, heal, ProjectileType(), 1200f, 2f); + } + else if (modPlayer.tarraMage) + { + if (modPlayer.tarraMageHealCooldown <= 0) + { + modPlayer.tarraMageHealCooldown = 90; + + float healMult = 0.1f; + healMult -= proj.numHits * 0.05f; + float heal = damage * healMult; + + if (heal > 50) + heal = 50; + + if (!CalamityGlobalProjectile.CanSpawnLifeStealProjectile(proj, healMult, heal)) + return; + + Main.player[Main.myPlayer].lifeSteal -= heal * 6f; + int healAmount = (int)heal; + player.statLife += healAmount; + player.HealEffect(healAmount); + + if (player.statLife > player.statLifeMax2) + player.statLife = player.statLifeMax2; + } + } + else if (modPlayer.ataxiaMage) + { + float healMult = 0.1f; + healMult -= proj.numHits * 0.05f; + float heal = damage * healMult; + + if (heal > 50) + heal = 50; + + if (!CalamityGlobalProjectile.CanSpawnLifeStealProjectile(proj, healMult, heal)) + return; + + CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, player, heal, ProjectileType(), 1200f, 2f); + } + } + if (modPlayer.reaverDefense) + { + float healMult = 0.2f; + healMult -= proj.numHits * 0.05f; + float heal = damage * healMult; + + if (heal > 50) + heal = 50; + if (Main.rand.Next(10) > 0) + heal = 0; + + if (!CalamityGlobalProjectile.CanSpawnLifeStealProjectile(proj, healMult, heal)) + return; + + CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, player, heal, ProjectileType(), 1200f, 2f); + } + if (modProj.rogue) + { + if (modPlayer.xerocSet && modPlayer.xerocDmg <= 0 && player.ownedProjectileCounts[ProjectileType()] < 3 && player.ownedProjectileCounts[ProjectileType()] < 3) + { + float healMult = 0.06f; + healMult -= proj.numHits * 0.015f; + float heal = damage * healMult; + + if (!CalamityGlobalProjectile.CanSpawnLifeStealProjectile(proj, healMult, heal)) + return; + + CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, player, heal, ProjectileType(), 1200f, 1.5f); + } + } + } + } + + public static void ItemLifesteal(Player player, Mod mod, NPC target, Item item, int damage) + { + CalamityPlayer modPlayer = player.Calamity(); + + if (modPlayer.bloodflareSet && !target.SpawnedFromStatue && (target.damage > 0 || target.boss)) + { + if ((target.life < target.lifeMax * 0.5) && modPlayer.bloodflareHeartTimer <= 0) + { + modPlayer.bloodflareHeartTimer = 180; + DropHelper.DropItem(target, ItemID.Heart); + } + else if ((target.life > target.lifeMax * 0.5) && modPlayer.bloodflareManaTimer <= 0) + { + modPlayer.bloodflareManaTimer = 180; + DropHelper.DropItem(target, ItemID.Star); + } + } + + if ((target.damage > 5 || target.boss) && !target.SpawnedFromStatue && target.canGhostHeal && !player.moonLeech) + { + if (modPlayer.bloodflareMelee && item.melee) + { + int healAmount = Main.rand.Next(3) + 1; + player.statLife += healAmount; + player.HealEffect(healAmount); + } + } + + if (modPlayer.reaverDefense) + { + if (Main.player[Main.myPlayer].lifeSteal > 0f && target.canGhostHeal && target.type != NPCID.TargetDummy && target.type != ModContent.NPCType() && !player.moonLeech) + { + float healMult = 0.2f; + float heal = damage * healMult; + + if (heal > 50) + heal = 50; + if (Main.rand.Next(10) > 0) + heal = 0; + + if ((int)heal > 0 && !Main.player[Main.myPlayer].moonLeech) + { + Main.player[Main.myPlayer].lifeSteal -= heal * 2f; + float lowestHealthCheck = 0f; + int healTarget = player.whoAmI; + for (int i = 0; i < Main.maxPlayers; i++) + { + Player otherPlayer = Main.player[i]; + if (otherPlayer.active && !otherPlayer.dead && ((!player.hostile && !otherPlayer.hostile) || player.team == otherPlayer.team)) + { + float playerDist = Vector2.Distance(target.Center, otherPlayer.Center); + if (playerDist < 1200f && (otherPlayer.statLifeMax2 - otherPlayer.statLife) > lowestHealthCheck) + { + lowestHealthCheck = otherPlayer.statLifeMax2 - otherPlayer.statLife; + healTarget = i; + } + } + } + Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI, healTarget, heal); + } + } + } + } + #endregion + + + #region The Horseman's Blade + public static void HorsemansBladeOnHit(Player player, int targetIdx, int damage, float knockback, int extraUpdateAmt = 0, int type = ProjectileID.FlamingJack) + { + int logicCheckScreenHeight = Main.LogicCheckScreenHeight; + int logicCheckScreenWidth = Main.LogicCheckScreenWidth; + int x = Main.rand.Next(100, 300); + int y = Main.rand.Next(100, 300); + switch (Main.rand.Next(4)) + { + case 0: + x -= logicCheckScreenWidth / 2 + x; + break; + case 1: + x += logicCheckScreenWidth / 2 - x; + break; + case 2: + y -= logicCheckScreenHeight / 2 + y; + break; + case 3: + y += logicCheckScreenHeight / 2 - y; + break; + default: + break; + } + x += (int)player.position.X; + y += (int)player.position.Y; + float speed = 8f; + Vector2 spawnPos = new Vector2((float)x, (float)y); + Vector2 velocity = Main.npc[targetIdx].DirectionFrom(spawnPos); + velocity *= speed; + int projectile = Projectile.NewProjectile(spawnPos, velocity, type, damage, knockback, player.whoAmI, targetIdx, 0f); + Main.projectile[projectile].extraUpdates += extraUpdateAmt; + } + #endregion + } +} \ No newline at end of file diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 1e756fd933..3f6c354dd7 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -3535,40 +3535,6 @@ Grants immunity to fire blocks, and temporary immunity to lava"; } #endregion - #region The Horseman's Blade - public static void HorsemansBladeOnHit(Player player, int targetIdx, int damage, float knockback, bool hasExtraUpdates) - { - int x = Main.rand.Next(100, 300); - int y = Main.rand.Next(100, 300); - - // Pick a random side: left or right - if (Main.rand.NextBool(2)) - x -= Main.LogicCheckScreenWidth / 2 + x; - else - x += Main.LogicCheckScreenWidth / 2 - x; - - // Pick a random side: top or bottom - if (Main.rand.NextBool(2)) - y -= Main.LogicCheckScreenHeight / 2 + y; - else - y += Main.LogicCheckScreenHeight / 2 - y; - - x += (int)player.position.X; - y += (int)player.position.Y; - float speed = 8f; - Vector2 vector = new Vector2((float)x, (float)y); - float dx = Main.npc[targetIdx].position.X - vector.X; - float dy = Main.npc[targetIdx].position.Y - vector.Y; - float dist = (float)Math.Sqrt(dx * dx + dy * dy); - dist = speed / dist; - dx *= dist; - dy *= dist; - int projectile = Projectile.NewProjectile(x, y, dx, dy, ProjectileID.FlamingJack, damage, knockback, player.whoAmI, targetIdx, 0f); - if (hasExtraUpdates) - Main.projectile[projectile].extraUpdates += 1; - } - #endregion - #region Ammo public override bool ConsumeAmmo(Item item, Player player) => Main.rand.NextFloat() <= player.Calamity().rangedAmmoCost; diff --git a/Items/Weapons/Melee/BalefulHarvester.cs b/Items/Weapons/Melee/BalefulHarvester.cs index 844d57d178..d093895d46 100644 --- a/Items/Weapons/Melee/BalefulHarvester.cs +++ b/Items/Weapons/Melee/BalefulHarvester.cs @@ -1,3 +1,4 @@ +using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Melee; using Terraria; using Terraria.ID; @@ -46,13 +47,13 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - CalamityGlobalItem.HorsemansBladeOnHit(player, target.whoAmI, (int)(item.damage * (player.allDamage + player.meleeDamage - 1f) * 1.5f), knockback, false); + CalamityPlayerOnHit.HorsemansBladeOnHit(player, target.whoAmI, (int)(item.damage * player.MeleeDamage() * 1.5f), knockback); target.AddBuff(BuffID.OnFire, 300); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - CalamityGlobalItem.HorsemansBladeOnHit(player, target.whoAmI, (int)(item.damage * (player.allDamage + player.meleeDamage - 1f) * 1.5f), item.knockBack, false); + CalamityPlayerOnHit.HorsemansBladeOnHit(player, -1, (int)(item.damage * player.MeleeDamage() * 1.5f), item.knockBack); target.AddBuff(BuffID.OnFire, 300); } } diff --git a/Items/Weapons/Melee/TheLastMourning.cs b/Items/Weapons/Melee/TheLastMourning.cs index 31495d54df..063ca1c2a4 100644 --- a/Items/Weapons/Melee/TheLastMourning.cs +++ b/Items/Weapons/Melee/TheLastMourning.cs @@ -1,3 +1,4 @@ +using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; @@ -41,76 +42,14 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - int logicCheckScreenHeight = Main.LogicCheckScreenHeight; - int logicCheckScreenWidth = Main.LogicCheckScreenWidth; - int num = Main.rand.Next(100, 300); - int num2 = Main.rand.Next(100, 300); - switch (Main.rand.Next(4)) - { - case 0: - num -= logicCheckScreenWidth / 2 + num; - break; - case 1: - num += logicCheckScreenWidth / 2 - num; - break; - case 2: - num2 -= logicCheckScreenHeight / 2 + num2; - break; - case 3: - num2 += logicCheckScreenHeight / 2 - num2; - break; - default: - break; - } - num += (int)player.position.X; - num2 += (int)player.position.Y; - float speed = 8f; - Vector2 vector = new Vector2((float)num, (float)num2); - float num3 = target.position.X - vector.X; - float num4 = target.position.Y - vector.Y; - float num5 = (float)Math.Sqrt((double)(num3 * num3 + num4 * num4)); - num5 = speed / num5; - num3 *= num5; - num4 *= num5; - Projectile.NewProjectile((float)num, (float)num2, num3, num4, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f) * 1.5f), knockback, player.whoAmI, (float)target.whoAmI, 0f); - CalamityGlobalItem.HorsemansBladeOnHit(player, target.whoAmI, (int)(item.damage * (player.allDamage + player.meleeDamage - 1f) * 1.5f), knockback, true); + CalamityPlayerOnHit.HorsemansBladeOnHit(player, target.whoAmI, (int)(item.damage * player.MeleeDamage() * 1.5f), knockback, 0, ModContent.ProjectileType()); + CalamityPlayerOnHit.HorsemansBladeOnHit(player, target.whoAmI, (int)(item.damage * player.MeleeDamage() * 1.5f), knockback, 1); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - int logicCheckScreenHeight = Main.LogicCheckScreenHeight; - int logicCheckScreenWidth = Main.LogicCheckScreenWidth; - int num = Main.rand.Next(100, 300); - int num2 = Main.rand.Next(100, 300); - switch (Main.rand.Next(4)) - { - case 0: - num -= logicCheckScreenWidth / 2 + num; - break; - case 1: - num += logicCheckScreenWidth / 2 - num; - break; - case 2: - num2 -= logicCheckScreenHeight / 2 + num2; - break; - case 3: - num2 += logicCheckScreenHeight / 2 - num2; - break; - default: - break; - } - num += (int)player.position.X; - num2 += (int)player.position.Y; - float speed = 8f; - Vector2 vector = new Vector2((float)num, (float)num2); - float num3 = target.position.X - vector.X; - float num4 = target.position.Y - vector.Y; - float num5 = (float)Math.Sqrt((double)(num3 * num3 + num4 * num4)); - num5 = speed / num5; - num3 *= num5; - num4 *= num5; - Projectile.NewProjectile((float)num, (float)num2, num3, num4, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f) * 1.5f), item.knockBack, player.whoAmI, (float)target.whoAmI, 0f); - CalamityGlobalItem.HorsemansBladeOnHit(player, target.whoAmI, (int)(item.damage * (player.allDamage + player.meleeDamage - 1f) * 1.5f), item.knockBack, true); + CalamityPlayerOnHit.HorsemansBladeOnHit(player, -1, (int)(item.damage * player.MeleeDamage() * 1.5f), item.knockBack, 0, ModContent.ProjectileType()); + CalamityPlayerOnHit.HorsemansBladeOnHit(player, -1, (int)(item.damage * player.MeleeDamage() * 1.5f), item.knockBack, 1); } public override void MeleeEffects(Player player, Rectangle hitbox) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 3ec4cf0ddf..f78091166a 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -3251,81 +3251,6 @@ namespace CalamityMod.NPCs } #endregion - #region On Hit By Item - public override void OnHitByItem(NPC npc, Player player, Item item, int damage, float knockback, bool crit) - { - if (player.Calamity().bloodflareSet) - { - if (!npc.SpawnedFromStatue && npc.damage > 0 && (npc.life < npc.lifeMax * 0.5) && - player.Calamity().bloodflareHeartTimer <= 0) - { - player.Calamity().bloodflareHeartTimer = 180; - DropHelper.DropItem(npc, ItemID.Heart); - } - else if (!npc.SpawnedFromStatue && npc.damage > 0 && (npc.life > npc.lifeMax * 0.5) && - player.Calamity().bloodflareManaTimer <= 0) - { - player.Calamity().bloodflareManaTimer = 180; - DropHelper.DropItem(npc, ItemID.Star); - } - } - } - #endregion - - #region On Hit By Projectile - public override void OnHitByProjectile(NPC npc, Projectile projectile, int damage, float knockback, bool crit) - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - - bool isSummon = projectile.IsSummon(); - - if (modPlayer.sGenerator) - { - if (isSummon && (npc.damage > 0 || npc.boss)) - { - int buffType = Utils.SelectRandom(Main.rand, new int[] - { - BuffType(), - BuffType(), - BuffType() - }); - player.AddBuff(buffType, 120); - } - } - - if (modPlayer.hallowedRune) - { - if (isSummon && (npc.damage > 0 || npc.boss)) - { - int buffType = Utils.SelectRandom(Main.rand, new int[] - { - BuffType(), - BuffType(), - BuffType() - }); - player.AddBuff(buffType, 120); - } - } - - if (modPlayer.bloodflareSet) - { - if (!npc.SpawnedFromStatue && (npc.damage > 0 || npc.boss) && (npc.life < npc.lifeMax * 0.5) && - modPlayer.bloodflareHeartTimer <= 0) - { - modPlayer.bloodflareHeartTimer = 180; - DropHelper.DropItem(npc, ItemID.Heart); - } - else if (!npc.SpawnedFromStatue && (npc.damage > 0 || npc.boss) && (npc.life > npc.lifeMax * 0.5) && - modPlayer.bloodflareManaTimer <= 0) - { - modPlayer.bloodflareManaTimer = 180; - DropHelper.DropItem(npc, ItemID.Star); - } - } - } - #endregion - #region Check Dead public override bool CheckDead(NPC npc) { diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index bf1f34427b..bfc1b1860f 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -1333,663 +1333,6 @@ namespace CalamityMod.Projectiles } #endregion - #region OnHitNPC - public override void OnHitNPC(Projectile projectile, NPC target, int damage, float knockback, bool crit) - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - - if (projectile.owner == Main.myPlayer && !projectile.npcProj && !projectile.trap && projectile.friendly) - { - if (ProjectileID.Sets.StardustDragon[projectile.type]) - { - target.immune[projectile.owner] = 10; - } - - //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, target.velocity, ProjectileID.ConfettiMelee, 0, 0f, projectile.owner, 0f, 0f); - - if (rogue && stealthStrike && modPlayer.dragonScales && CalamityUtils.CountProjectiles(ProjectileType()) < 2) - { - int projTileX = (int)(projectile.Center.X / 16f); - int projTileY = (int)(projectile.Center.Y / 16f); - int distance = 100; - if (projTileX < 10) - { - projTileX = 10; - } - if (projTileX > Main.maxTilesX - 10) - { - projTileX = Main.maxTilesX - 10; - } - if (projTileY < 10) - { - projTileY = 10; - } - if (projTileY > Main.maxTilesY - distance - 10) - { - projTileY = Main.maxTilesY - distance - 10; - } - for (int x = projTileX; x < projTileX + distance; x++) - { - Tile tile = Main.tile[projTileX, projTileY]; - if (tile.active() && (Main.tileSolid[tile.type] || tile.liquid != 0)) - { - projTileX = x; - break; - } - } - int projectileIndex = Projectile.NewProjectile(projTileX * 16 + 8, projTileY * 16 - 24, 0f, 0f, ProjectileType(), 420, 15f, Main.myPlayer, 16f, 16f); - Main.projectile[projectileIndex].Calamity().forceRogue = true; - Main.projectile[projectileIndex].netUpdate = true; - Main.projectile[projectileIndex].localNPCHitCooldown = 1; - } - - // Spectre Damage set and Nebula set work on enemies which are "immune to lifesteal" - if (!target.canGhostHeal) - { - if (player.ghostHurt) - { - projectile.ghostHurt(damage, target.Center); - } - - if (player.setNebula && player.nebulaCD == 0 && Main.rand.Next(3) == 0) - { - player.nebulaCD = 30; - int boosterType = Utils.SelectRandom(Main.rand, new int[] - { - ItemID.NebulaPickup1, - ItemID.NebulaPickup2, - ItemID.NebulaPickup3 - }); - 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) - { - NetMessage.SendData(MessageID.SyncItem, -1, -1, null, nebulaBooster, 0f, 0f, 0f, 0, 0, 0); - } - } - } - - if (Main.player[Main.myPlayer].lifeSteal > 0f && target.canGhostHeal && target.type != NPCID.TargetDummy && target.type != NPCType() && !player.moonLeech) - { - // Increases the degree to which Spectre Healing set contributes to the lifesteal cap - if (player.ghostHeal) - { - float cooldownMult = 0.1f; - cooldownMult -= projectile.numHits * 0.025f; - if (cooldownMult < 0f) - cooldownMult = 0f; - - 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 cooldown = damage * 0.075f; - if (cooldown < 0f) - cooldown = 0f; - - Main.player[Main.myPlayer].lifeSteal -= cooldown; - } - - if (modPlayer.vampiricTalisman && rogue && crit) - { - float heal = MathHelper.Clamp(damage * 0.015f, 0f, 6f); - if ((int)heal > 0) - { - SpawnLifeStealProjectile(projectile, player, heal, ProjectileID.VampireHeal, 1200f, 2f); - } - } - - if ((modPlayer.bloodyGlove || modPlayer.electricianGlove) && rogue && stealthStrike) - { - player.statLife += 1; - 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; - healMult -= projectile.numHits * 0.025f; - float heal = projectile.damage * healMult; - - if (heal > 50) - heal = 50; - - if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) - goto OTHEREFFECTS; - - SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 3f); - } - else if (modPlayer.silvaSet) - { - float healMult = 0.03f; - healMult -= projectile.numHits * 0.015f; - float heal = projectile.damage * healMult; - - if (heal > 50) - heal = 50; - - if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) - goto OTHEREFFECTS; - - SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 3f); - } - 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; - healMult -= projectile.numHits * 0.015f; - float heal = projectile.damage * healMult; - - if (heal > 50) - heal = 50; - - if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) - goto OTHEREFFECTS; - - SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 2f); - } - else if (modPlayer.tarraMage) - { - if (modPlayer.tarraMageHealCooldown <= 0) - { - modPlayer.tarraMageHealCooldown = 90; - - float healMult = 0.1f; - healMult -= projectile.numHits * 0.05f; - float heal = projectile.damage * healMult; - - if (heal > 50) - heal = 50; - - if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) - goto OTHEREFFECTS; - - Main.player[Main.myPlayer].lifeSteal -= heal * 6f; - int healAmount = (int)heal; - player.statLife += healAmount; - player.HealEffect(healAmount); - - if (player.statLife > player.statLifeMax2) - player.statLife = player.statLifeMax2; - } - } - else if (modPlayer.ataxiaMage) - { - float healMult = 0.1f; - healMult -= projectile.numHits * 0.05f; - float heal = projectile.damage * healMult; - - if (heal > 50) - heal = 50; - - if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) - goto OTHEREFFECTS; - - SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 2f); - } - } - if (modPlayer.reaverDefense) - { - float healMult = 0.2f; - healMult -= projectile.numHits * 0.05f; - float heal = projectile.damage * healMult; - - if (heal > 50) - heal = 50; - if (Main.rand.Next(10) > 0) - heal = 0; - - if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) - goto OTHEREFFECTS; - - SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 2f); - } - } - - OTHEREFFECTS: - - if (modPlayer.alchFlask && - (projectile.magic || rogue || projectile.melee || projectile.IsSummon() || projectile.ranged) && - player.ownedProjectileCounts[ProjectileType()] < 6) - { - 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 (projectile.magic) - { - 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); - 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 *= 4; - projectile.localNPCHitCooldown = 10; - projectile.usesLocalNPCImmunity = true; - projectile.Damage(); - } - - if (modPlayer.ataxiaMage && modPlayer.ataxiaDmg <= 0) - { - int projDamage = CalamityUtils.DamageSoftCap(projectile.damage * 0.625, 100); - SpawnOrb(projectile, projDamage, ProjectileType(), 800f, 20f); - int cooldown = (int)(projDamage * 0.5); - modPlayer.ataxiaDmg += cooldown; - } - else if (modPlayer.godSlayerMage && modPlayer.godSlayerDmg <= 0) - { - int projDamage = CalamityUtils.DamageSoftCap(projectile.damage * 0.75, 225); - SpawnOrb(projectile, projDamage, ProjectileType(), 800f, 20f); - int cooldown = (int)(projDamage * 0.5); - modPlayer.godSlayerDmg += cooldown; - } - } - if (projectile.melee) - { - if (modPlayer.ataxiaGeyser && player.ownedProjectileCounts[ProjectileType()] < 3) - { - 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) - { - switch (Main.rand.Next(5)) - { - case 0: - - int projDamage = CalamityUtils.DamageSoftCap(projectile.damage * 0.8, 120); - SpawnOrb(projectile, projDamage, ProjectileType(), 800f, Main.rand.Next(15, 30)); - modPlayer.xerocDmg += (int)(projDamage * 0.5); - - break; - - case 1: - - int projDamage2 = CalamityUtils.DamageSoftCap(projectile.damage * 0.625, 100); - SpawnOrb(projectile, projDamage2, ProjectileType(), 800f, 30f); - modPlayer.xerocDmg += (int)(projDamage2 * 0.5); - - if (target.canGhostHeal && Main.player[Main.myPlayer].lifeSteal > 0f) - { - float healMult = 0.06f; - healMult -= projectile.numHits * 0.015f; - float heal = projectile.damage * healMult; - - if (!CanSpawnLifeStealProjectile(projectile, healMult, heal)) - goto SKIPXEROC; - - SpawnLifeStealProjectile(projectile, player, heal, ProjectileType(), 1200f, 1.5f); - } - - break; - - case 2: - - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.15, 30), 0f, projectile.owner, 0f, 0f); - - break; - - case 3: - - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.2, 40), 0f, projectile.owner, 0f, 0f); - - break; - - case 4: - - int projDamage3 = CalamityUtils.DamageSoftCap(projectile.damage * 0.6, 90); - SpawnOrb(projectile, projDamage3, ProjectileType(), 800f, 15f); - modPlayer.xerocDmg += (int)(projDamage3 * 0.5); - - break; - - default: - break; - } - } - - SKIPXEROC: - - if (modPlayer.featherCrown && stealthStrike && modPlayer.featherCrownCooldown <= 0 && stealthStrikeHitCount < 5) - { - for (int i = 0; i < 6; i++) - { - 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(source, velocity, ProjectileType(), dmg, 3f, projectile.owner); - Main.projectile[feather].Calamity().forceRogue = true; - modPlayer.featherCrownCooldown = 15; - } - } - - if (modPlayer.moonCrown && stealthStrike && modPlayer.moonCrownCooldown <= 0 && stealthStrikeHitCount < 5) - { - for (int i = 0; i < 6; i++) - { - 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(source, velocity, ProjectileID.LunarFlare, dmg, 3, projectile.owner); - Main.projectile[flare].Calamity().forceRogue = true; - modPlayer.moonCrownCooldown = 15; - } - } - - if (modPlayer.nanotech && stealthStrike && modPlayer.nanoFlareCooldown <= 0 && stealthStrikeHitCount < 5) - { - for (int i = 0; i < 6; i++) - { - 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(source, velocity, ProjectileType(),dmg, 3f, projectile.owner); - Main.projectile[flare].Calamity().rogue = true; - modPlayer.nanoFlareCooldown = 15; - } - } - - if (modPlayer.forbiddenCirclet && stealthStrike && modPlayer.forbiddenCooldown <= 0 && stealthStrikeHitCount < 5) - { - for (int index2 = 0; index2 < 6; index2++) - { - float xVector = Main.rand.Next(-35, 36) * 0.02f; - float yVector = Main.rand.Next(-35, 36) * 0.02f; - xVector *= 10f; - yVector *= 10f; - int dmg = (int)(75 + (projectile.damage * 0.05f)); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, xVector, yVector, ProjectileType(), dmg, projectile.knockBack, projectile.owner, 0f, 0f); - modPlayer.forbiddenCooldown = 15; - } - } - - if (modPlayer.titanHeartSet && stealthStrike && modPlayer.titanCooldown <= 0 && stealthStrikeHitCount < 5) - { - int dmg = (int)(100 + (projectile.damage * 0.01f)); - int boom = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), dmg, projectile.knockBack, projectile.owner, 1f, 0f); - Main.projectile[boom].Calamity().forceRogue = true; - Main.PlaySound(SoundID.Item14, projectile.Center); - for (int dustexplode = 0; dustexplode < 360; dustexplode++) - { - Vector2 dustd = new Vector2(17f, 17f).RotatedBy(MathHelper.ToRadians(dustexplode)); - int d = Dust.NewDust(projectile.Center, projectile.width, projectile.height, Main.rand.NextBool(2) ? DustType() : DustType(), dustd.X, dustd.Y, 100, default, 1f); - Main.dust[d].noGravity = true; - Main.dust[d].position = projectile.Center; - Main.dust[d].velocity *= 0.1f; - } - modPlayer.titanCooldown = 15; - } - - if (modPlayer.corrosiveSpine && projectile.type != ProjectileType() && projectile.type != ProjectileType() && projectile.type != ProjectileType() && stealthStrikeHitCount < 5) - { - for (int i = 0; i < 3; i++) - { - if (Main.rand.NextBool(2)) - { - int type = -1; - switch (Main.rand.Next(15)) - { - case 0: - type = ProjectileType(); - break; - case 1: - type = ProjectileType(); - break; - case 2: - type = ProjectileType(); - break; - } - // Should never happen, but just in case- - if (type != -1) - { - float speed = Main.rand.NextFloat(5f, 11f); - Projectile.NewProjectile(target.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * speed, - type, CalamityUtils.DamageSoftCap(projectile.damage * 0.6, 90), projectile.knockBack, player.whoAmI); - } - } - } - target.AddBuff(BuffID.Venom, 240); - } - - if (modPlayer.shadow && modPlayer.shadowPotCooldown <= 0 && stealthStrikeHitCount < 5) - { - if (CalamityLists.javelinProjList.Contains(projectile.type)) - { - int randrot = Main.rand.Next(-30, 391); - Vector2 SoulSpeed = new Vector2(13f, 13f).RotatedBy(MathHelper.ToRadians(randrot)); - Projectile.NewProjectile(projectile.Center, SoulSpeed, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.1, 60), 3f, projectile.owner, 0f, 0f); - modPlayer.shadowPotCooldown = 30; - } - if (CalamityLists.spikyBallProjList.Contains(projectile.type)) - { - int scythe = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.05, 60), 3f, projectile.owner, 1f, 0f); - Main.projectile[scythe].usesLocalNPCImmunity = true; - Main.projectile[scythe].localNPCHitCooldown = 10; - Main.projectile[scythe].penetrate = 2; - modPlayer.shadowPotCooldown = 30; - } - if (CalamityLists.daggerProjList.Contains(projectile.type)) - { - Vector2 shardVelocity = new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f)); - shardVelocity.Normalize(); - shardVelocity *= 5f; - int shard = Projectile.NewProjectile(projectile.Center, shardVelocity, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.15, 60), 0f, projectile.owner); - Main.projectile[shard].timeLeft = 150; - modPlayer.shadowPotCooldown = 30; - } - if (CalamityLists.boomerangProjList.Contains(projectile.type)) - { - int spiritDamage = CalamityUtils.DamageSoftCap(projectile.damage * 0.2, 60); - Projectile ghost = SpawnOrb(projectile, spiritDamage, ProjectileID.SpectreWrath, 800f, 4f); - ghost.Calamity().forceRogue = true; - ghost.penetrate = 1; - modPlayer.shadowPotCooldown = 30; - } - if (CalamityLists.flaskBombProjList.Contains(projectile.type)) - { - int blackhole = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.05, 60), 3f, projectile.owner, 0f, 0f); - Main.projectile[blackhole].Center = projectile.Center; - modPlayer.shadowPotCooldown = 30; - } - } - } - if (projectile.IsSummon()) - { - if (modPlayer.pArtifact && !modPlayer.profanedCrystal) - { - target.AddBuff(BuffType(), 300); - } - if (modPlayer.profanedCrystalBuffs) - { - target.AddBuff(Main.dayTime ? BuffType() : BuffType(), 600); - } - - if (modPlayer.tearMinions) - { - target.AddBuff(BuffType(), 60); - } - - if (modPlayer.shadowMinions) - { - target.AddBuff(BuffID.ShadowFlame, 300); - } - - if (modPlayer.voltaicJelly) - { - //100% chance for Star Tainted Generator or Nucleogenesis - //20% chance for Voltaic Jelly - if (Main.rand.NextBool(modPlayer.starTaintedGenerator ? 1 : 5)) - { - target.AddBuff(BuffID.Electrified, 60); - } - } - - if (modPlayer.starTaintedGenerator) - { - target.AddBuff(BuffType(), 180); - target.AddBuff(BuffType(), 180); - } - - // Fearmonger set's colossal life regeneration - if(modPlayer.fearmongerSet) - { - modPlayer.fearmongerRegenFrames += 20; - if (modPlayer.fearmongerRegenFrames > 180) - modPlayer.fearmongerRegenFrames = 180; - } - - if (modPlayer.godSlayerSummon && modPlayer.godSlayerDmg <= 0) - { - int projDamage = CalamityUtils.DamageSoftCap(projectile.damage, 300); - SpawnOrb(projectile, projDamage, ProjectileType(), 800f, 15f, true); - int cooldown = (int)(projDamage * 0.5f); - modPlayer.godSlayerDmg += cooldown; - } - - //Priorities: Nucleogenesis => Starbuster Core => Nuclear Rod => Jelly-Charged Battery - List summonExceptionList = new List() - { - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType() - }; - - if (summonExceptionList.TrueForAll(x => projectile.type != x)) - { - if (modPlayer.jellyDmg <= 0) - { - if (modPlayer.nucleogenesis) - { - if (Main.rand.NextBool(4)) - { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage * 0.25, 90), projectile.knockBack * 0.25f, projectile.owner); - modPlayer.jellyDmg = 25f; - } - } - else if (modPlayer.starbusterCore) - { - if (Main.rand.NextBool(3)) - { - int cap = modPlayer.starTaintedGenerator ? 75 : 60; - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), - CalamityUtils.DamageSoftCap(projectile.damage * 0.5, cap), 3f, projectile.owner); - modPlayer.jellyDmg = 20f; - } - } - else if (modPlayer.nuclearRod) - { - if (Main.rand.NextBool(3)) - { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), - CalamityUtils.DamageSoftCap(projectile.damage * 0.25, 40), 0f, projectile.owner); - modPlayer.jellyDmg = 20f; - } - } - else if (modPlayer.jellyChargedBattery) - { - int projDamage = CalamityUtils.DamageSoftCap(projectile.damage * 0.525, 50); - SpawnOrb(projectile, projDamage, ProjectileType(), 800f, 15f); - int cooldown = (int)(projDamage * 0.5f); - modPlayer.jellyDmg += cooldown; - } - } - - if (modPlayer.hallowedPower) - { - if (Main.rand.NextBool(3) && modPlayer.hallowedRuneCooldown <= 0) - { - modPlayer.hallowedRuneCooldown = 60; - Vector2 spawnPosition = target.Center - new Vector2(0f, 920f).RotatedByRandom(0.3f); - float speed = Main.rand.NextFloat(17f, 23f); - Projectile.NewProjectile(spawnPosition, Vector2.Normalize(target.Center - spawnPosition) * speed, - ProjectileType(), CalamityUtils.DamageSoftCap(projectile.damage / 3, 50), 3f, projectile.owner); - } - } - } - } - - if (projectile.ranged) - { - if (modPlayer.tarraRanged && Main.rand.Next(0, 100) >= 88 && player.ownedProjectileCounts[ProjectileType()] <= 20 && (projectile.timeLeft <= 2 || projectile.penetrate <= 1)) - { - int projAmt = Main.rand.Next(2, 4); - for (int projCount = 0; projCount < projAmt; projCount++) - { - 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); - } - } - } - if (modPlayer.reaverDefense) - player.lifeRegenTime += 1; - } - } - #endregion - #region CanDamage public override bool CanDamage(Projectile projectile) { diff --git a/Projectiles/Rogue/BlastBarrelProjectile.cs b/Projectiles/Rogue/BlastBarrelProjectile.cs index 539c13d50b..c4a70d1fa6 100644 --- a/Projectiles/Rogue/BlastBarrelProjectile.cs +++ b/Projectiles/Rogue/BlastBarrelProjectile.cs @@ -66,21 +66,24 @@ namespace CalamityMod.Projectiles.Rogue { projectileCount += 4; // More shit the closer we are to death } - for (int i = 0; i < projectileCount; i++) - { - if (Main.rand.NextBool(3)) - { - Vector2 shrapnelVelocity = (Vector2.UnitY * Main.rand.NextFloat(-19f, -4f)).RotatedByRandom(MathHelper.ToRadians(30f)); - Projectile.NewProjectile(projectile.Center, projectile.velocity + shrapnelVelocity, ModContent.ProjectileType(), projectile.damage, 3f, projectile.owner); - } - else - { - Vector2 fireVelocity = (Vector2.UnitY * Main.rand.NextFloat(-19f, -4f)).RotatedByRandom(MathHelper.ToRadians(40f)); - Projectile fire = Projectile.NewProjectileDirect(projectile.Center, projectile.velocity + fireVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.75f), 1f, projectile.owner); - fire.timeLeft = 300; - fire.penetrate = 3; - } - } + if (projectile.owner == Main.myPlayer) + { + for (int i = 0; i < projectileCount; i++) + { + if (Main.rand.NextBool(3)) + { + Vector2 shrapnelVelocity = (Vector2.UnitY * Main.rand.NextFloat(-19f, -4f)).RotatedByRandom(MathHelper.ToRadians(30f)); + Projectile.NewProjectile(projectile.Center, projectile.velocity + shrapnelVelocity, ModContent.ProjectileType(), projectile.damage, 3f, projectile.owner); + } + else + { + Vector2 fireVelocity = (Vector2.UnitY * Main.rand.NextFloat(-19f, -4f)).RotatedByRandom(MathHelper.ToRadians(40f)); + Projectile fire = Projectile.NewProjectileDirect(projectile.Center, projectile.velocity + fireVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.75f), 1f, projectile.owner); + fire.timeLeft = 300; + fire.penetrate = 3; + } + } + } RemainingBounces--; BounceEffectCooldown = 15; if (RemainingBounces <= 0) diff --git a/Projectiles/Rogue/BouncingBettyProjectile.cs b/Projectiles/Rogue/BouncingBettyProjectile.cs index 662a1209ff..1bab8db5f8 100644 --- a/Projectiles/Rogue/BouncingBettyProjectile.cs +++ b/Projectiles/Rogue/BouncingBettyProjectile.cs @@ -23,25 +23,28 @@ namespace CalamityMod.Projectiles.Rogue private void Explode() { Main.PlaySound(SoundID.Item14, projectile.Center); - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 8f, projectile.owner); - if (projectile.Calamity().stealthStrike) - { - int projectileCount = 12; - for (int i = 0; i < projectileCount; i++) - { - if (Main.rand.NextBool(2)) - { - Vector2 shrapnelVelocity = (Vector2.UnitY * Main.rand.NextFloat(-12f, -4f)).RotatedByRandom(MathHelper.ToRadians(30f)); - Projectile.NewProjectile(projectile.Center, projectile.velocity + shrapnelVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5f), 3f, projectile.owner); - } - else - { - Vector2 fireVelocity = (Vector2.UnitY * Main.rand.NextFloat(-12f, -4f)).RotatedByRandom(MathHelper.ToRadians(40f)); - Projectile fire = Projectile.NewProjectileDirect(projectile.Center, projectile.velocity + fireVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.6f), 1f, projectile.owner); - fire.localNPCHitCooldown = 9; - fire.timeLeft = 240; - } - } + if (Main.myPlayer == projectile.owner) + { + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 8f, projectile.owner); + if (projectile.Calamity().stealthStrike) + { + int projectileCount = 12; + for (int i = 0; i < projectileCount; i++) + { + if (Main.rand.NextBool(2)) + { + Vector2 shrapnelVelocity = (Vector2.UnitY * Main.rand.NextFloat(-12f, -4f)).RotatedByRandom(MathHelper.ToRadians(30f)); + Projectile.NewProjectile(projectile.Center, projectile.velocity + shrapnelVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.5f), 3f, projectile.owner); + } + else + { + Vector2 fireVelocity = (Vector2.UnitY * Main.rand.NextFloat(-12f, -4f)).RotatedByRandom(MathHelper.ToRadians(40f)); + Projectile fire = Projectile.NewProjectileDirect(projectile.Center, projectile.velocity + fireVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.6f), 1f, projectile.owner); + fire.localNPCHitCooldown = 9; + fire.timeLeft = 240; + } + } + } } } public override void AI() From b2a50365e3122e48f741e33d5fa6a7e1364d14fc Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Thu, 10 Dec 2020 09:02:43 -0500 Subject: [PATCH 41/66] removed dragon scales world bool since it's not used --- CalPlayer/CalamityPlayer.cs | 21 --------------------- World/CalamityWorld.cs | 11 +++-------- 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 9a7bb4d586..7dfddac78c 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -3834,27 +3834,8 @@ namespace CalamityMod.CalPlayer } } - #region Dragon Scale Logic - /*public override void PostBuyItem(NPC vendor, Item[] shopInventory, Item item) - { - if (item.type == ModContent.ItemType() && !CalamityWorld.dragonScalesBought) - { - CalamityWorld.dragonScalesBought = true; - } - }*/ - #endregion - #region Shop Restrictions - public override bool CanBuyItem(NPC vendor, Item[] shopInventory, Item item) - { - if (item.type == ModContent.ItemType()) - { - return !CalamityWorld.dragonScalesBought; - } - return base.CanBuyItem(vendor, shopInventory, item); - } - public override bool CanSellItem(NPC vendor, Item[] shopInventory, Item item) { if (item.type == ModContent.ItemType()) @@ -4090,9 +4071,7 @@ namespace CalamityMod.CalPlayer } NetMessage.SendData(MessageID.Dodge, -1, -1, null, player.whoAmI, 1f, 0f, 0f, 0, 0, 0); } - #endregion - #region Rogue Mirrors public void AbyssMirrorEvade() { if (player.whoAmI == Main.myPlayer && abyssalMirror && !abyssalMirrorCooldown && !eclipseMirror) diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index 53b5f35418..165faa28ff 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -47,7 +47,6 @@ namespace CalamityMod.World { #region Vars public static int DoGSecondStageCountdown = 0; - public static bool dragonScalesBought = false; private const int saveVersion = 0; public static int ArmoredDiggerSpawnCooldown = 0; public static int MoneyStolenByBandit = 0; @@ -297,7 +296,6 @@ namespace CalamityMod.World defiled = false; armageddon = false; ironHeart = false; - dragonScalesBought = false; rainingAcid = false; downedEoCAcidRain = false; downedAquaticScourgeAcidRain = false; @@ -391,8 +389,6 @@ namespace CalamityMod.World downed.Add("clam"); if (downedCLAMHardMode) downed.Add("clamHardmode"); - if (dragonScalesBought) - downed.Add("scales"); if (rainingAcid) downed.Add("acidRain"); if (spawnedBandit) @@ -530,7 +526,6 @@ namespace CalamityMod.World BossRushEvent.BossRushActive = downed.Contains("bossRushActive"); downedCLAM = downed.Contains("clam"); downedCLAMHardMode = downed.Contains("clamHardmode"); - dragonScalesBought = downed.Contains("scales"); rainingAcid = downed.Contains("acidRain"); spawnedBandit = downed.Contains("bandit"); @@ -653,7 +648,7 @@ namespace CalamityMod.World BossRushEvent.BossRushActive = flags7[0]; downedBoomerDuke = flags7[1]; downedCLAM = flags7[2]; - dragonScalesBought = flags7[3]; + _ = flags7[3]; rainingAcid = flags7[4]; downedEoCAcidRain = flags7[5]; downedAquaticScourgeAcidRain = flags7[6]; @@ -764,7 +759,7 @@ namespace CalamityMod.World flags7[0] = BossRushEvent.BossRushActive; flags7[1] = downedBoomerDuke; flags7[2] = downedCLAM; - flags7[3] = dragonScalesBought; + flags7[3] = false; flags7[4] = rainingAcid; flags7[5] = downedEoCAcidRain; flags7[6] = downedAquaticScourgeAcidRain; @@ -885,7 +880,7 @@ namespace CalamityMod.World BossRushEvent.BossRushActive = flags7[0]; downedBoomerDuke = flags7[1]; downedCLAM = flags7[2]; - dragonScalesBought = flags7[3]; + _ = flags7[3]; rainingAcid = flags7[4]; downedEoCAcidRain = flags7[5]; downedAquaticScourgeAcidRain = flags7[6]; From 9458cc59ee2b2151bd802ec998dc3418dd965225 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Thu, 10 Dec 2020 09:27:13 -0500 Subject: [PATCH 42/66] fixed alpha ray still being violet, 15 rarity/sell price --- Items/Weapons/Magic/AlphaRay.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Items/Weapons/Magic/AlphaRay.cs b/Items/Weapons/Magic/AlphaRay.cs index 10c235f734..3af31665cd 100644 --- a/Items/Weapons/Magic/AlphaRay.cs +++ b/Items/Weapons/Magic/AlphaRay.cs @@ -30,13 +30,13 @@ namespace CalamityMod.Items.Weapons.Magic item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 1.5f; - item.value = Item.buyPrice(2, 50, 0, 0); + item.value = CalamityGlobalItem.Rarity14BuyPrice; item.rare = 10; item.UseSound = SoundID.Item33; item.autoReuse = true; item.shootSpeed = 6f; item.shoot = ModContent.ProjectileType(); - item.Calamity().customRarity = CalamityRarity.Violet; + item.Calamity().customRarity = CalamityRarity.DarkBlue; } public override Vector2? HoldoutOffset() => new Vector2(-5, 0); From df47c472fddbf44fef3a288b4771781144e172a2 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Thu, 10 Dec 2020 10:25:32 -0500 Subject: [PATCH 43/66] Fixed Ultima and Rubico Prime sell prices --- Items/Weapons/Ranged/RubicoPrime.cs | 2 +- Items/Weapons/Ranged/Ultima.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Items/Weapons/Ranged/RubicoPrime.cs b/Items/Weapons/Ranged/RubicoPrime.cs index 9a41a5dd4e..2613480b75 100644 --- a/Items/Weapons/Ranged/RubicoPrime.cs +++ b/Items/Weapons/Ranged/RubicoPrime.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.shootSpeed = 12f; item.useAmmo = AmmoID.Bullet; - item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.value = CalamityGlobalItem.Rarity14BuyPrice; item.rare = 10; item.Calamity().customRarity = CalamityRarity.Dedicated; } diff --git a/Items/Weapons/Ranged/Ultima.cs b/Items/Weapons/Ranged/Ultima.cs index 4ac1d21e23..ab0daa4c62 100644 --- a/Items/Weapons/Ranged/Ultima.cs +++ b/Items/Weapons/Ranged/Ultima.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 2f; - item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.value = CalamityGlobalItem.Rarity14BuyPrice; item.rare = 10; item.UseSound = SoundID.Item33; item.autoReuse = true; From 6d0df2ffc9f826de3355900312a29bb3e82fba21 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Thu, 10 Dec 2020 10:30:11 -0500 Subject: [PATCH 44/66] fixed yharim's gift sell price --- Items/Accessories/YharimsGift.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Accessories/YharimsGift.cs b/Items/Accessories/YharimsGift.cs index b832b69edf..9e41903da9 100644 --- a/Items/Accessories/YharimsGift.cs +++ b/Items/Accessories/YharimsGift.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Accessories { item.width = 20; item.height = 22; - item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.value = CalamityGlobalItem.Rarity15BuyPrice; item.accessory = true; item.expert = true; item.rare = 10; From 096ad67b1b2b594155fb8d6ef0c82fd426722cf8 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Thu, 10 Dec 2020 10:31:35 -0500 Subject: [PATCH 45/66] fixed nebulous core sell price --- Items/Accessories/BlazingCore.cs | 1 - Items/Accessories/NebulousCore.cs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Items/Accessories/BlazingCore.cs b/Items/Accessories/BlazingCore.cs index 0e8227a702..4358680b98 100644 --- a/Items/Accessories/BlazingCore.cs +++ b/Items/Accessories/BlazingCore.cs @@ -29,7 +29,6 @@ namespace CalamityMod.Items.Accessories item.accessory = true; item.expert = true; item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; item.value = CalamityGlobalItem.Rarity12BuyPrice; } diff --git a/Items/Accessories/NebulousCore.cs b/Items/Accessories/NebulousCore.cs index 36e10f9c87..a999f52505 100644 --- a/Items/Accessories/NebulousCore.cs +++ b/Items/Accessories/NebulousCore.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Accessories { item.width = 16; item.height = 14; - item.value = CalamityGlobalItem.Rarity13BuyPrice; + item.value = CalamityGlobalItem.Rarity14BuyPrice; item.accessory = true; item.expert = true; item.rare = 10; From b1c513c917c1367cd26538152cd03fffc164d92f Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Thu, 10 Dec 2020 10:35:33 -0500 Subject: [PATCH 46/66] yharim's gift code cleanup --- Items/Accessories/YharimsGift.cs | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/Items/Accessories/YharimsGift.cs b/Items/Accessories/YharimsGift.cs index 9e41903da9..91909e16f7 100644 --- a/Items/Accessories/YharimsGift.cs +++ b/Items/Accessories/YharimsGift.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Accessories { player.allDamage += 0.15f; player.statDefense += 30; - if ((double)player.velocity.X > 0 || (double)player.velocity.Y > 0 || (double)player.velocity.X < -0.1 || (double)player.velocity.Y < -0.1) + if (!player.StandingStill()) { dragonTimer--; if (dragonTimer <= 0) @@ -56,24 +56,7 @@ 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)(750 * player.AverageDamage()), 9f, player.whoAmI, 0f, 0f); - Main.projectile[num19].ai[1] = player.position.Y; - Main.projectile[num19].hostile = false; - Main.projectile[num19].friendly = true; - } + CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(750 * player.AverageDamage()), 9f, player.whoAmI); } } } From 600a750578b3c9ba71f4a786a08803cd362af20b Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Thu, 10 Dec 2020 15:21:24 -0500 Subject: [PATCH 47/66] minor cleanup thing --- Items/Accessories/YharimsGift.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Accessories/YharimsGift.cs b/Items/Accessories/YharimsGift.cs index 91909e16f7..5c57c67658 100644 --- a/Items/Accessories/YharimsGift.cs +++ b/Items/Accessories/YharimsGift.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Accessories { if (player.whoAmI == Main.myPlayer) { - int projectile1 = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(350 * player.AverageDamage()), 5f, player.whoAmI, 0f, 0f); + int projectile1 = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(350 * player.AverageDamage()), 5f, player.whoAmI, 0f, 0f); Main.projectile[projectile1].timeLeft = 60; } dragonTimer = 60; From 0db9144dda2f68ad6c6f4144ba1b1f77272d64e4 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Thu, 10 Dec 2020 15:36:17 -0500 Subject: [PATCH 48/66] minor fix --- CalPlayer/CalamityPlayerOnHit.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index e15b132107..2118fc1526 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -512,16 +512,6 @@ namespace CalamityMod.CalPlayer { modPlayer.tarraThrowingCrits++; } - if (modPlayer.electricianGlove && modProj.stealthStrike && modProj.stealthStrikeHitCount < 5) - { - for (int s = 0; s < 3; s++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); - int spark = Projectile.NewProjectile(position, velocity, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.1, 30), 0f, player.whoAmI); - Main.projectile[spark].Calamity().forceRogue = true; - Main.projectile[spark].localNPCHitCooldown = -1; - } - } if (modPlayer.xerocSet && modPlayer.xerocDmg <= 0 && player.ownedProjectileCounts[ProjectileType()] < 3 && player.ownedProjectileCounts[ProjectileType()] < 3) { switch (Main.rand.Next(5)) @@ -711,6 +701,16 @@ namespace CalamityMod.CalPlayer modPlayer.raiderStack++; modPlayer.raiderCooldown = 30; } + if (modPlayer.electricianGlove && modProj.stealthStrike && modProj.stealthStrikeHitCount < 5) + { + for (int s = 0; s < 3; s++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); + int spark = Projectile.NewProjectile(position, velocity, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.1, 30), 0f, player.whoAmI); + Main.projectile[spark].Calamity().forceRogue = true; + Main.projectile[spark].localNPCHitCooldown = -1; + } + } } modProj.stealthStrikeHitCount++; } From bc20d3dc6be2a20d009c82bedf0c1550b2ea3f8e Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Fri, 11 Dec 2020 16:17:45 -0500 Subject: [PATCH 49/66] Fixed those stupid potential out of bounds errors,.,.,.,......... Also fixed a few other bugs like with Web Balls, Jaws of Oblivion, Dune Hopper, Cobalt Kunai, Frostcrush Valari, Plaguenades, and Time Bolt --- CalPlayer/CalamityPlayer.cs | 67 +++++++++--- CalPlayer/CalamityPlayerMiscEffects.cs | 11 +- CalPlayer/CalamityPlayerOnHit.cs | 60 +++++++---- Items/Accessories/AmalgamatedBrain.cs | 10 +- Items/Accessories/RottenBrain.cs | 10 +- Items/Accessories/TheAmalgam.cs | 8 +- Items/Accessories/VoidofExtinction.cs | 7 +- Items/Accessories/Wings/SoulofCryogen.cs | 7 +- Items/Armor/PlagueReaperMask.cs | 4 +- Items/CalamityGlobalItem.cs | 81 ++++++++------ Items/Mounts/BUMBLEDOGE.cs | 3 +- Items/Tools/InfernaCutter.cs | 10 +- Items/Weapons/Magic/BelchingSaxophone.cs | 9 +- Items/Weapons/Magic/ClothiersWrath.cs | 5 +- Items/Weapons/Magic/HyphaeRod.cs | 7 +- Items/Weapons/Magic/TheSwarmer.cs | 18 ++-- Items/Weapons/Magic/WintersFury.cs | 3 +- Items/Weapons/Melee/ArkoftheAncients.cs | 3 +- Items/Weapons/Melee/FlameburstShortsword.cs | 10 +- Items/Weapons/Melee/Floodtide.cs | 3 +- Items/Weapons/Melee/GalaxySmasherMelee.cs | 3 +- Items/Weapons/Melee/LionHeart.cs | 10 +- Items/Weapons/Melee/PhoenixBlade.cs | 27 ++--- Items/Weapons/Melee/PlagueKeeper.cs | 18 ++-- Items/Weapons/Melee/SporeKnife.cs | 10 +- Items/Weapons/Melee/StellarStriker.cs | 3 +- Items/Weapons/Melee/Trinity.cs | 25 ++--- Items/Weapons/Melee/TrueArkoftheAncients.cs | 17 ++- Items/Weapons/Ranged/Alluvion.cs | 13 ++- Items/Weapons/Ranged/BladedgeGreatbow.cs | 5 +- Items/Weapons/Ranged/FirestormCannon.cs | 44 +++----- Items/Weapons/Ranged/Goobow.cs | 9 +- Items/Weapons/Ranged/Monsoon.cs | 13 ++- Items/Weapons/Ranged/SpectralstormCannon.cs | 16 ++- Items/Weapons/Ranged/SpectreRifle.cs | 3 +- Items/Weapons/Ranged/StarCannonEX.cs | 28 ++--- Items/Weapons/Rogue/AccretionDisk.cs | 9 +- Items/Weapons/Rogue/AcidicRainBarrel.cs | 3 +- Items/Weapons/Rogue/AdamantiteThrowingAxe.cs | 9 +- Items/Weapons/Rogue/AlphaVirus.cs | 3 +- Items/Weapons/Rogue/Apoctolith.cs | 3 +- Items/Weapons/Rogue/AshenStalactite.cs | 3 +- Items/Weapons/Rogue/AuroradicalThrow.cs | 5 +- Items/Weapons/Rogue/BallisticPoisonBomb.cs | 5 +- Items/Weapons/Rogue/BlastBarrel.cs | 2 +- Items/Weapons/Rogue/BlazingStar.cs | 13 ++- Items/Weapons/Rogue/BloodsoakedCrasher.cs | 3 +- Items/Weapons/Rogue/BouncingBetty.cs | 2 +- Items/Weapons/Rogue/BouncingEyeball.cs | 3 +- Items/Weapons/Rogue/BouncySpikyBall.cs | 5 +- Items/Weapons/Rogue/BrackishFlask.cs | 5 +- Items/Weapons/Rogue/Brimblade.cs | 10 +- Items/Weapons/Rogue/BurningStrife.cs | 4 +- Items/Weapons/Rogue/CelestialReaper.cs | 2 +- Items/Weapons/Rogue/Celestus.cs | 3 +- Items/Weapons/Rogue/Cinquedea.cs | 3 +- Items/Weapons/Rogue/CobaltKunai.cs | 4 +- Items/Weapons/Rogue/ConsecratedWater.cs | 2 +- Items/Weapons/Rogue/ContaminatedBile.cs | 3 +- Items/Weapons/Rogue/CorpusAvertor.cs | 3 +- Items/Weapons/Rogue/CosmicKunai.cs | 2 +- Items/Weapons/Rogue/CraniumSmasher.cs | 5 +- Items/Weapons/Rogue/CrushsawCrasher.cs | 11 +- Items/Weapons/Rogue/CrystalPiercer.cs | 13 ++- Items/Weapons/Rogue/Crystalline.cs | 5 +- Items/Weapons/Rogue/CursedDagger.cs | 9 +- Items/Weapons/Rogue/DeepSeaDumbbell.cs | 7 +- Items/Weapons/Rogue/DeepWounder.cs | 5 +- Items/Weapons/Rogue/DefectiveSphere.cs | 20 ++-- Items/Weapons/Rogue/DeificThunderbolt.cs | 2 +- Items/Weapons/Rogue/DesecratedWater.cs | 5 +- Items/Weapons/Rogue/DuneHopper.cs | 4 +- Items/Weapons/Rogue/DuststormInABottle.cs | 5 +- Items/Weapons/Rogue/EclipsesFall.cs | 3 +- Items/Weapons/Rogue/EnchantedAxe.cs | 3 +- Items/Weapons/Rogue/EpidemicShredder.cs | 2 +- Items/Weapons/Rogue/Equanimity.cs | 3 +- Items/Weapons/Rogue/Eradicator.cs | 2 +- Items/Weapons/Rogue/ExecutionersBlade.cs | 2 +- Items/Weapons/Rogue/Exorcism.cs | 3 +- Items/Weapons/Rogue/FantasyTalisman.cs | 5 +- Items/Weapons/Rogue/FeatherKnife.cs | 5 +- Items/Weapons/Rogue/FlameScythe.cs | 3 +- Items/Weapons/Rogue/FrostcrushValari.cs | 10 +- Items/Weapons/Rogue/FrostyFlare.cs | 5 +- Items/Weapons/Rogue/GelDart.cs | 13 ++- Items/Weapons/Rogue/GhoulishGouger.cs | 5 +- Items/Weapons/Rogue/GildedDagger.cs | 7 +- Items/Weapons/Rogue/Glaive.cs | 2 +- Items/Weapons/Rogue/GleamingDagger.cs | 7 +- Items/Weapons/Rogue/GodsParanoia.cs | 5 +- Items/Weapons/Rogue/HardenedHoneycomb.cs | 9 +- Items/Weapons/Rogue/HeavenfallenStardisk.cs | 7 +- Items/Weapons/Rogue/HellsSun.cs | 11 +- Items/Weapons/Rogue/Hypothermia.cs | 3 +- Items/Weapons/Rogue/IceStar.cs | 5 +- Items/Weapons/Rogue/Icebreaker.cs | 5 +- Items/Weapons/Rogue/IchorSpear.cs | 9 +- Items/Weapons/Rogue/InfernalKris.cs | 3 +- Items/Weapons/Rogue/IronFrancisca.cs | 3 +- Items/Weapons/Rogue/JawsOfOblivion.cs | 9 +- Items/Weapons/Rogue/KelvinCatalyst.cs | 3 +- Items/Weapons/Rogue/Kylie.cs | 5 +- Items/Weapons/Rogue/LatcherMine.cs | 3 +- Items/Weapons/Rogue/LeadTomahawk.cs | 3 +- Items/Weapons/Rogue/LeonidProgenitor.cs | 7 +- Items/Weapons/Rogue/LeviathanTeeth.cs | 14 ++- Items/Weapons/Rogue/Lionfish.cs | 5 +- Items/Weapons/Rogue/LunarKunai.cs | 3 +- Items/Weapons/Rogue/Malachite.cs | 7 +- Items/Weapons/Rogue/MangroveChakram.cs | 3 +- Items/Weapons/Rogue/MetalMonstrosity.cs | 4 +- Items/Weapons/Rogue/MeteorFist.cs | 3 +- Items/Weapons/Rogue/MoltenAmputator.cs | 5 +- Items/Weapons/Rogue/MonkeyDarts.cs | 5 +- Items/Weapons/Rogue/Mycoroot.cs | 5 +- Items/Weapons/Rogue/MythrilKnife.cs | 5 +- Items/Weapons/Rogue/NanoblackReaperRogue.cs | 3 +- Items/Weapons/Rogue/NastyCholla.cs | 5 +- Items/Weapons/Rogue/NightsGaze.cs | 5 +- Items/Weapons/Rogue/Nychthemeron.cs | 21 ++-- .../Weapons/Rogue/OrichalcumSpikedGemstone.cs | 13 ++- Items/Weapons/Rogue/PalladiumJavelin.cs | 11 +- Items/Weapons/Rogue/Penumbra.cs | 3 +- Items/Weapons/Rogue/PhantasmalRuin.cs | 5 +- Items/Weapons/Rogue/PhantomLance.cs | 5 +- Items/Weapons/Rogue/Plaguenade.cs | 4 +- Items/Weapons/Rogue/PoisonPack.cs | 5 +- Items/Weapons/Rogue/Prismalline.cs | 5 +- Items/Weapons/Rogue/ProfanedPartisan.cs | 5 +- Items/Weapons/Rogue/ProfanedTrident.cs | 5 +- Items/Weapons/Rogue/Quasar.cs | 5 +- Items/Weapons/Rogue/RadiantStar.cs | 5 +- Items/Weapons/Rogue/RegulusRiot.cs | 5 +- Items/Weapons/Rogue/RotBall.cs | 9 +- Items/Weapons/Rogue/SandDollar.cs | 5 +- Items/Weapons/Rogue/Sandslasher.cs | 5 +- Items/Weapons/Rogue/ScourgeoftheDesert.cs | 5 +- Items/Weapons/Rogue/ScourgeoftheSeas.cs | 3 +- Items/Weapons/Rogue/SeafoamBomb.cs | 5 +- Items/Weapons/Rogue/SealedSingularity.cs | 5 +- Items/Weapons/Rogue/SeashellBoomerang.cs | 3 +- Items/Weapons/Rogue/ShatteredSun.cs | 5 +- Items/Weapons/Rogue/ShinobiBlade.cs | 5 +- Items/Weapons/Rogue/ShockGrenade.cs | 5 +- Items/Weapons/Rogue/Shroomerang.cs | 5 +- Items/Weapons/Rogue/SkyStabber.cs | 5 +- Items/Weapons/Rogue/SkyfinBombers.cs | 5 +- Items/Weapons/Rogue/SlickCane.cs | 3 +- Items/Weapons/Rogue/SludgeSplotch.cs | 3 +- Items/Weapons/Rogue/SnapClam.cs | 5 +- Items/Weapons/Rogue/SpearofDestiny.cs | 5 +- Items/Weapons/Rogue/SpearofPaleolith.cs | 5 +- Items/Weapons/Rogue/SpentFuelContainer.cs | 2 +- Items/Weapons/Rogue/StarofDestruction.cs | 3 +- Items/Weapons/Rogue/StellarKnife.cs | 6 +- Items/Weapons/Rogue/StickySpikyBall.cs | 11 +- Items/Weapons/Rogue/StormfrontRazor.cs | 3 +- Items/Weapons/Rogue/Supernova.cs | 5 +- Items/Weapons/Rogue/SylvanSlasher.cs | 2 +- Items/Weapons/Rogue/TarragonThrowingDart.cs | 11 +- Items/Weapons/Rogue/TerraDisk.cs | 2 +- Items/Weapons/Rogue/TerrorTalons.cs | 5 +- Items/Weapons/Rogue/TheReaper.cs | 9 +- Items/Weapons/Rogue/TheSyringe.cs | 5 +- Items/Weapons/Rogue/ThrowingBrick.cs | 3 +- Items/Weapons/Rogue/TimeBolt.cs | 9 +- Items/Weapons/Rogue/TitaniumShuriken.cs | 13 ++- Items/Weapons/Rogue/ToothBall.cs | 9 +- Items/Weapons/Rogue/TotalityBreakers.cs | 5 +- Items/Weapons/Rogue/ToxicantTwister.cs | 5 +- Items/Weapons/Rogue/Turbulance.cs | 5 +- Items/Weapons/Rogue/UtensilPoker.cs | 3 +- Items/Weapons/Rogue/Valediction.cs | 5 +- Items/Weapons/Rogue/WebBall.cs | 5 +- Items/Weapons/Rogue/WulfrumKnife.cs | 11 +- Items/Weapons/Rogue/XerocPitchfork.cs | 3 +- Projectiles/CalamityGlobalProjectile.cs | 14 ++- .../DraedonsArsenal/PulseDragonProjectile.cs | 11 +- Projectiles/Environment/LightningMark.cs | 9 +- Projectiles/Magic/HolyLaser.cs | 5 +- Projectiles/Magic/IceBarrageMain.cs | 9 +- Projectiles/Magic/InfernadoFriendly.cs | 15 +-- Projectiles/Magic/SolarBeam2.cs | 5 +- Projectiles/Magic/SparklingBeam.cs | 7 +- Projectiles/Magic/ThunderstormShot.cs | 2 +- Projectiles/Melee/CometQuasherMeteor.cs | 7 +- Projectiles/Melee/DragonPowFlail.cs | 11 +- Projectiles/Melee/FallenPaladinsHammerProj.cs | 16 +-- Projectiles/Melee/Galaxia.cs | 102 +++++++++++------- Projectiles/Melee/Galaxia2.cs | 102 +++++++++++------- Projectiles/Melee/GalaxySmasherHammer.cs | 88 ++++----------- Projectiles/Melee/HellionSpike.cs | 7 +- Projectiles/Melee/IceBombFriendly.cs | 6 +- Projectiles/Melee/LaserFountain.cs | 7 +- Projectiles/Melee/LightningThing.cs | 13 ++- Projectiles/Melee/PlagueBeeDust.cs | 9 +- Projectiles/Melee/Spears/AstralPikeProj.cs | 19 ++-- Projectiles/Melee/Spears/EarthenPikeSpear.cs | 3 +- .../Spears/ExsanguinationLanceProjectile.cs | 5 +- .../Spears/HellionFlowerSpearProjectile.cs | 7 +- Projectiles/Melee/StellarContemptHammer.cs | 65 +++-------- Projectiles/Melee/Yoyos/ChaotrixYoyo.cs | 3 +- Projectiles/Melee/Yoyos/ObliteratorYoyo.cs | 3 +- Projectiles/Melee/Yoyos/OracleYoyo.cs | 7 +- Projectiles/Melee/Yoyos/QuagmireYoyo.cs | 33 +++--- Projectiles/Melee/Yoyos/SolarFlareYoyo.cs | 5 +- Projectiles/Ranged/BeeRPG.cs | 14 +-- Projectiles/Ranged/CorrodedShell.cs | 9 +- Projectiles/Ranged/DWArrow.cs | 6 -- Projectiles/Ranged/DragonBurst.cs | 20 ++-- Projectiles/Ranged/ExplodingStake.cs | 5 +- .../Ranged/FlurrystormCannonShooting.cs | 11 +- Projectiles/Ranged/GoliathRocket.cs | 14 +-- Projectiles/Ranged/HiveBomb.cs | 14 +-- Projectiles/Ranged/HiveMissile.cs | 14 +-- Projectiles/Ranged/HolyFireBulletProj.cs | 3 +- Projectiles/Ranged/NapalmArrowProj.cs | 28 ++--- Projectiles/Ranged/PlagueArrow.cs | 9 +- Projectiles/Ranged/SeaDragonRocket.cs | 14 +-- Projectiles/Ranged/SporeBomb.cs | 11 +- Projectiles/Ranged/StarfleetMK2Gun.cs | 11 +- Projectiles/Rogue/AuroradicalStar.cs | 28 ++--- Projectiles/Rogue/BloodsoakedCrashax.cs | 5 +- Projectiles/Rogue/ContaminatedBileFlask.cs | 7 +- Projectiles/Rogue/Crystalline2.cs | 3 +- Projectiles/Rogue/CursedDaggerProj.cs | 11 +- Projectiles/Rogue/DuneHopperProjectile.cs | 3 +- .../Rogue/EpidemicShredderProjectile.cs | 12 ++- Projectiles/Rogue/EradicatorProjectile.cs | 13 ++- Projectiles/Rogue/FantasyTalismanProj.cs | 7 +- Projectiles/Rogue/FantasyTalismanStealth.cs | 7 +- Projectiles/Rogue/FeatherKnifeProjectile.cs | 6 +- Projectiles/Rogue/FlameScytheProjectile.cs | 3 +- Projectiles/Rogue/FrostyFlareStealth.cs | 9 +- Projectiles/Rogue/GacruxianHome.cs | 18 ++-- Projectiles/Rogue/GacruxianProj.cs | 20 ++-- Projectiles/Rogue/GelDartProjectile.cs | 11 +- Projectiles/Rogue/GreenDonkeyKongReference.cs | 18 ++-- Projectiles/Rogue/IcebreakerHammer.cs | 6 +- Projectiles/Rogue/IchorSpearProj.cs | 13 ++- Projectiles/Rogue/JewelSpike.cs | 3 +- .../Rogue/LeonidProgenitorBombshell.cs | 35 +++--- Projectiles/Rogue/LionfishProj.cs | 3 +- Projectiles/Rogue/LostSoulFriendly.cs | 3 +- .../OrichalcumSpikedGemstoneProjectile.cs | 33 ++---- .../Rogue/PalladiumJavelinProjectile.cs | 18 ++-- Projectiles/Rogue/PhantasmalRuinProj.cs | 52 +++------ Projectiles/Rogue/PhantomLanceProj.cs | 29 ++--- Projectiles/Rogue/PoisonBol.cs | 31 +++--- Projectiles/Rogue/Prismalline3.cs | 9 +- Projectiles/Rogue/PrismallineProj.cs | 20 ++-- Projectiles/Rogue/Quasar2.cs | 9 +- Projectiles/Rogue/RadiantExplosion.cs | 75 ++++--------- Projectiles/Rogue/RadiantStarKnife.cs | 6 +- Projectiles/Rogue/SandDollarStealth.cs | 5 +- Projectiles/Rogue/SealedSingularityProj.cs | 7 +- Projectiles/Rogue/SkyStabberProj.cs | 4 +- .../Rogue/SpentFuelContainerProjectile.cs | 3 +- Projectiles/Rogue/UrchinStingerProj.cs | 5 +- Projectiles/Rogue/ValedictionBoomerang.cs | 9 +- Projectiles/Summon/AstrageldonSummon.cs | 2 +- Projectiles/Summon/BabyBloodCrawler.cs | 42 ++------ Projectiles/Summon/GiantIbanRobotOfDoom.cs | 2 +- Projectiles/Typeless/DemonshadeRedDevil.cs | 49 +++------ Utilities/CalamityUtils.cs | 58 ++-------- 266 files changed, 1541 insertions(+), 1299 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 64dad7db40..6ae939feef 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -3213,7 +3213,8 @@ namespace CalamityMod.CalPlayer if (sulphurBubbleCooldown <= 0) { int bubble = Projectile.NewProjectile(new Vector2(player.position.X, player.position.Y + (player.gravDir == -1f ? 20 : -20)), Vector2.Zero, ModContent.ProjectileType(), (int)(20f * player.RogueDamage()), 0f, player.whoAmI, 1f, 0f); - Main.projectile[bubble].Calamity().forceRogue = true; + if (bubble.WithinBounds(Main.maxProjectiles)) + Main.projectile[bubble].Calamity().forceRogue = true; sulphurBubbleCooldown = 20; } } @@ -6785,7 +6786,8 @@ namespace CalamityMod.CalPlayer 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, CalamityUtils.DamageSoftCap(damage * 0.15, 75), knockBack * 0.5f, player.whoAmI); - Main.projectile[p].Calamity().forceRogue = true; //in case melee/rogue variants bug out + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().forceRogue = true; //in case melee/rogue variants bug out if (item.type == ModContent.ItemType()) { Main.projectile[p].ai[1] = 1f; @@ -7438,7 +7440,13 @@ namespace CalamityMod.CalPlayer { for (int n = 0; n < 3; n++) { - CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 29f, ProjectileID.HallowStar, (int)(130 * player.AverageDamage()), 4f, player.whoAmI, 6, 1, 5); + Projectile star = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 29f, ProjectileID.HallowStar, (int)(130 * player.AverageDamage()), 4f, player.whoAmI); + if (star.whoAmI.WithinBounds(Main.maxProjectiles)) + { + star.Calamity().forceTypeless = true; + star.usesLocalNPCImmunity = true; + star.localNPCHitCooldown = 5; + } } /*int num = 1; @@ -7459,7 +7467,13 @@ namespace CalamityMod.CalPlayer { for (int n = 0; n < 3; n++) { - CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 29f, ProjectileID.HallowStar, (int)(150 * player.AverageDamage()), 4f, player.whoAmI, 6, 1, 5); + Projectile star = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 29f, ProjectileID.HallowStar, (int)(150 * player.AverageDamage()), 4f, player.whoAmI); + if (star.whoAmI.WithinBounds(Main.maxProjectiles)) + { + star.Calamity().forceTypeless = true; + star.usesLocalNPCImmunity = true; + star.localNPCHitCooldown = 5; + } } int num = 1; if (Main.rand.NextBool(3)) @@ -7520,10 +7534,16 @@ namespace CalamityMod.CalPlayer 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); int spark2 = 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); - Main.projectile[spark1].timeLeft = 120; - Main.projectile[spark2].timeLeft = 120; - Main.projectile[spark1].Calamity().forceTypeless = true; - Main.projectile[spark2].Calamity().forceTypeless = true; + if (spark1.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[spark1].timeLeft = 120; + Main.projectile[spark1].Calamity().forceTypeless = true; + } + if (spark2.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[spark2].timeLeft = 120; + Main.projectile[spark2].Calamity().forceTypeless = true; + } } } } @@ -7588,8 +7608,10 @@ namespace CalamityMod.CalPlayer 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, 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; + if (shard.WithinBounds(Main.maxProjectiles)) + Main.projectile[shard].Calamity().forceTypeless = true; + if (shard2.WithinBounds(Main.maxProjectiles)) + Main.projectile[shard2].Calamity().forceTypeless = true; } } } @@ -7642,11 +7664,23 @@ namespace CalamityMod.CalPlayer { for (int l = 0; l < 2; l++) { - CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ProjectileID.ShadowBeamFriendly, (int)(3000 * player.AverageDamage()), 7f, player.whoAmI, 6, 1); + Projectile beam = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ProjectileID.ShadowBeamFriendly, (int)(3000 * player.AverageDamage()), 7f, player.whoAmI); + if (beam.whoAmI.WithinBounds(Main.maxProjectiles)) + { + beam.Calamity().forceTypeless = true; + beam.usesLocalNPCImmunity = true; + beam.localNPCHitCooldown = 10; + } } for (int l = 0; l < 5; l++) { - CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ProjectileID.DemonScythe, (int)(5000 * player.AverageDamage()), 7f, player.whoAmI, 6, 1); + Projectile scythe = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ProjectileID.DemonScythe, (int)(5000 * player.AverageDamage()), 7f, player.whoAmI); + if (scythe.whoAmI.WithinBounds(Main.maxProjectiles)) + { + scythe.Calamity().forceTypeless = true; + scythe.usesLocalNPCImmunity = true; + scythe.localNPCHitCooldown = 10; + } } } } @@ -8203,9 +8237,12 @@ namespace CalamityMod.CalPlayer if (statisTimer % 5 == 0) { int scythe = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(500 * player.AverageDamage()), 5f, player.whoAmI); - Main.projectile[scythe].Calamity().forceTypeless = true; - Main.projectile[scythe].usesIDStaticNPCImmunity = true; - Main.projectile[scythe].idStaticNPCHitCooldown = 10; + if (scythe.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[scythe].Calamity().forceTypeless = true; + Main.projectile[scythe].usesIDStaticNPCImmunity = true; + Main.projectile[scythe].idStaticNPCHitCooldown = 10; + } } } else if (dashMod == 8) //Plaguebringer armor diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index e37bd4e615..dee5af121a 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -3367,10 +3367,13 @@ namespace CalamityMod.CalPlayer if (Main.rand.NextBool(10)) { Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); - 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; + int spark = Projectile.NewProjectile(npc.Center, velocity, ModContent.ProjectileType(), damage / 2, 0f, player.whoAmI); + if (spark.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[spark].Calamity().forceTypeless = true; + Main.projectile[spark].localNPCHitCooldown = -2; + Main.projectile[spark].penetrate = 5; + } } } } diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index 2118fc1526..eadb2ed090 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -76,7 +76,9 @@ namespace CalamityMod.CalPlayer ProjectileID.HallowStar, ProjectileType() }); - CalamityUtils.ProjectileRain(position, 400f, 100f, 500f, 800f, 12f, projectileType, (int)(120 * player.AverageDamage()), 5f, player.whoAmI, 6, 0, 10, 2); + Projectile star = CalamityUtils.ProjectileRain(position, 400f, 100f, 500f, 800f, 12f, projectileType, (int)(120 * player.AverageDamage()), 5f, player.whoAmI); + if (star.whoAmI.WithinBounds(Main.maxProjectiles)) + star.Calamity().forceTypeless = true; } } } @@ -146,7 +148,8 @@ namespace CalamityMod.CalPlayer if (modPlayer.alchFlask && player.ownedProjectileCounts[ProjectileType()] < 6 && hasClass) { int plague = Projectile.NewProjectile(proj.Center, Vector2.Zero, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.25, 30), 0f, proj.owner); - Main.projectile[plague].Calamity().forceTypeless = true; + if (plague.WithinBounds(Main.maxProjectiles)) + Main.projectile[plague].Calamity().forceTypeless = true; } if (modPlayer.theBee && player.statLife >= player.statLifeMax2) { @@ -175,7 +178,9 @@ namespace CalamityMod.CalPlayer ProjectileID.HallowStar, ProjectileType() }); - CalamityUtils.ProjectileRain(position, 400f, 100f, 500f, 800f, 25f, projectileType, (int)(120 * player.AverageDamage()), 5f, player.whoAmI, 6); + Projectile star = CalamityUtils.ProjectileRain(position, 400f, 100f, 500f, 800f, 25f, projectileType, (int)(120 * player.AverageDamage()), 5f, player.whoAmI); + if (star.whoAmI.WithinBounds(Main.maxProjectiles)) + star.Calamity().forceTypeless = true; } } } @@ -291,8 +296,11 @@ namespace CalamityMod.CalPlayer { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); int FUCKYOU = Projectile.NewProjectile(position, velocity, ProjectileID.Leaf, CalamityUtils.DamageSoftCap(proj.damage * 0.25, 60), 0f, player.whoAmI); - Main.projectile[FUCKYOU].Calamity().forceTypeless = true; - Main.projectile[FUCKYOU].netUpdate = true; + if (FUCKYOU.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[FUCKYOU].Calamity().forceTypeless = true; + Main.projectile[FUCKYOU].netUpdate = true; + } } } if (proj.type == ProjectileType()) @@ -333,8 +341,11 @@ namespace CalamityMod.CalPlayer { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); int fire = Projectile.NewProjectile(position, velocity, ProjectileID.BallofFire, CalamityUtils.DamageSoftCap(proj.damage * 0.5, 120), 0f, player.whoAmI); - Main.projectile[fire].Calamity().forceTypeless = true; - Main.projectile[fire].netUpdate = true; + if (fire.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[fire].Calamity().forceTypeless = true; + Main.projectile[fire].netUpdate = true; + } } } } @@ -504,9 +515,12 @@ namespace CalamityMod.CalPlayer } } int projectileIndex = Projectile.NewProjectile(projTileX * 16 + 8, projTileY * 16 - 24, 0f, 0f, ProjectileType(), 420, 15f, Main.myPlayer, 16f, 16f); - Main.projectile[projectileIndex].Calamity().forceRogue = true; - Main.projectile[projectileIndex].netUpdate = true; - Main.projectile[projectileIndex].localNPCHitCooldown = 1; + if (projectileIndex.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[projectileIndex].Calamity().forceRogue = true; + Main.projectile[projectileIndex].netUpdate = true; + Main.projectile[projectileIndex].localNPCHitCooldown = 1; + } } if (modPlayer.tarraThrowing && !modPlayer.tarragonImmunity && !modPlayer.tarragonImmunityCooldown && modPlayer.tarraThrowingCrits < 25 && crit) { @@ -557,7 +571,8 @@ namespace CalamityMod.CalPlayer Vector2 velocity = new Vector2(speedX, speedY); int dmg = (int)(15 + (proj.damage * 0.05f)); int feather = Projectile.NewProjectile(source, velocity, ProjectileType(), dmg, 3f, proj.owner); - Main.projectile[feather].Calamity().forceRogue = true; + if (feather.WithinBounds(Main.maxProjectiles)) + Main.projectile[feather].Calamity().forceRogue = true; modPlayer.featherCrownCooldown = 15; } } @@ -570,7 +585,8 @@ namespace CalamityMod.CalPlayer Vector2 velocity = (position - source) / 10f; int dmg = (int)(150 + (proj.damage * 0.05f)); int flare = Projectile.NewProjectile(source, velocity, ProjectileID.LunarFlare, dmg, 3, proj.owner); - Main.projectile[flare].Calamity().forceRogue = true; + if (flare.WithinBounds(Main.maxProjectiles)) + Main.projectile[flare].Calamity().forceRogue = true; modPlayer.moonCrownCooldown = 15; } } @@ -583,7 +599,8 @@ namespace CalamityMod.CalPlayer Vector2 velocity = (position - source) / 40f; int dmg = (int)(1000 + (proj.damage * 0.05f)); int flare = Projectile.NewProjectile(source, velocity, ProjectileType(),dmg, 3f, proj.owner); - Main.projectile[flare].Calamity().rogue = true; + if (flare.WithinBounds(Main.maxProjectiles)) + Main.projectile[flare].Calamity().rogue = true; modPlayer.nanoFlareCooldown = 15; } } @@ -606,7 +623,8 @@ namespace CalamityMod.CalPlayer { int dmg = (int)(100 + (proj.damage * 0.01f)); int boom = Projectile.NewProjectile(proj.Center, Vector2.Zero, ProjectileType(), dmg, proj.knockBack, proj.owner, 1f, 0f); - Main.projectile[boom].Calamity().forceRogue = true; + if (boom.WithinBounds(Main.maxProjectiles)) + Main.projectile[boom].Calamity().forceRogue = true; Main.PlaySound(SoundID.Item14, proj.Center); for (int dustexplode = 0; dustexplode < 360; dustexplode++) { @@ -679,8 +697,11 @@ namespace CalamityMod.CalPlayer { int spiritDamage = CalamityUtils.DamageSoftCap(proj.damage * 0.2, 60); Projectile ghost = CalamityGlobalProjectile.SpawnOrb(proj, spiritDamage, ProjectileID.SpectreWrath, 800f, 4f); - ghost.Calamity().forceRogue = true; - ghost.penetrate = 1; + if (ghost.whoAmI.WithinBounds(Main.maxProjectiles)) + { + ghost.Calamity().forceRogue = true; + ghost.penetrate = 1; + } modPlayer.shadowPotCooldown = 30; } if (CalamityLists.flaskBombProjList.Contains(proj.type)) @@ -707,8 +728,11 @@ namespace CalamityMod.CalPlayer { Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); int spark = Projectile.NewProjectile(position, velocity, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.1, 30), 0f, player.whoAmI); - Main.projectile[spark].Calamity().forceRogue = true; - Main.projectile[spark].localNPCHitCooldown = -1; + if (spark.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[spark].Calamity().forceRogue = true; + Main.projectile[spark].localNPCHitCooldown = -1; + } } } } diff --git a/Items/Accessories/AmalgamatedBrain.cs b/Items/Accessories/AmalgamatedBrain.cs index c02000d7b2..c369ddb055 100644 --- a/Items/Accessories/AmalgamatedBrain.cs +++ b/Items/Accessories/AmalgamatedBrain.cs @@ -38,9 +38,13 @@ namespace CalamityMod.Items.Accessories { if (player.whoAmI == Main.myPlayer) { - 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; - rain.penetrate = 1; + Projectile rain = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(60 * player.AverageDamage()), 2f, player.whoAmI); + if (rain.whoAmI.WithinBounds(Main.maxProjectiles)) + { + rain.Calamity().forceTypeless = true; + rain.tileCollide = false; + rain.penetrate = 1; + } } } } diff --git a/Items/Accessories/RottenBrain.cs b/Items/Accessories/RottenBrain.cs index c37f35e137..42e82bb58b 100644 --- a/Items/Accessories/RottenBrain.cs +++ b/Items/Accessories/RottenBrain.cs @@ -33,9 +33,13 @@ namespace CalamityMod.Items.Accessories { if (player.whoAmI == Main.myPlayer) { - 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; - rain.penetrate = 1; + Projectile rain = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(18 * player.AverageDamage()), 2f, player.whoAmI); + if (rain.whoAmI.WithinBounds(Main.maxProjectiles)) + { + rain.Calamity().forceTypeless = true; + rain.tileCollide = false; + rain.penetrate = 1; + } } } } diff --git a/Items/Accessories/TheAmalgam.cs b/Items/Accessories/TheAmalgam.cs index 7eea1a7e89..a8400d6235 100644 --- a/Items/Accessories/TheAmalgam.cs +++ b/Items/Accessories/TheAmalgam.cs @@ -104,7 +104,13 @@ namespace CalamityMod.Items.Accessories if (player.whoAmI == Main.myPlayer) { int type = Main.rand.NextBool(2) ? ProjectileType() : ProjectileType(); - Projectile rain = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, type, (int)(ProjectileDamage * player.AverageDamage()), 5f, player.whoAmI, 6, 1); + Projectile rain = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, type, (int)(ProjectileDamage * player.AverageDamage()), 5f, player.whoAmI); + if (rain.whoAmI.WithinBounds(Main.maxProjectiles)) + { + rain.Calamity().forceTypeless = true; + rain.usesLocalNPCImmunity = true; + rain.localNPCHitCooldown = 10; + } if (type == ProjectileType()) { rain.tileCollide = false; diff --git a/Items/Accessories/VoidofExtinction.cs b/Items/Accessories/VoidofExtinction.cs index a7a65f2cf0..1910acb722 100644 --- a/Items/Accessories/VoidofExtinction.cs +++ b/Items/Accessories/VoidofExtinction.cs @@ -85,7 +85,12 @@ namespace CalamityMod.Items.Accessories { if (player.whoAmI == Main.myPlayer) { - CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(30 * player.AverageDamage()), 5f, player.whoAmI, 0, 1, 60); + Projectile fire = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(30 * player.AverageDamage()), 5f, player.whoAmI); + if (fire.whoAmI.WithinBounds(Main.maxProjectiles)) + { + fire.usesLocalNPCImmunity = true; + fire.localNPCHitCooldown = 60; + } } } } diff --git a/Items/Accessories/Wings/SoulofCryogen.cs b/Items/Accessories/Wings/SoulofCryogen.cs index 4edba47e34..51afff3f8e 100644 --- a/Items/Accessories/Wings/SoulofCryogen.cs +++ b/Items/Accessories/Wings/SoulofCryogen.cs @@ -84,8 +84,11 @@ namespace CalamityMod.Items.Accessories.Wings if (player.controlJump && !player.jumpAgainCloud && player.jump == 0 && player.velocity.Y != 0f && !player.mount.Active && !player.mount.Cart) { int p = Projectile.NewProjectile(player.Center.X, player.Center.Y, player.velocity.X * 0f, 2f, ModContent.ProjectileType(), (int)(25 * player.AverageDamage()), 3f, player.whoAmI, 1f); - Main.projectile[p].Calamity().forceTypeless = true; - Main.projectile[p].frame = Main.rand.Next(5); + if (p.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[p].Calamity().forceTypeless = true; + Main.projectile[p].frame = Main.rand.Next(5); + } modPlayer.icicleCooldown = 10; } } diff --git a/Items/Armor/PlagueReaperMask.cs b/Items/Armor/PlagueReaperMask.cs index 5201e98c4a..9398adf7f6 100644 --- a/Items/Armor/PlagueReaperMask.cs +++ b/Items/Armor/PlagueReaperMask.cs @@ -79,7 +79,9 @@ namespace CalamityMod.Items.Armor { if (Main.rand.NextBool(10)) { - CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(40 * player.RangedDamage()), 4f, player.whoAmI, 6); + Projectile cinder = CalamityUtils.ProjectileRain(player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), (int)(40 * player.RangedDamage()), 4f, player.whoAmI); + if (cinder.whoAmI.WithinBounds(Main.maxProjectiles)) + cinder.Calamity().forceTypeless = true; } } } diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index b3c0f51740..14df3f0e30 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -391,7 +391,8 @@ namespace CalamityMod.Items { Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i)); int rocket = Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(damage * 0.8, 200), 2f, player.whoAmI); - Main.projectile[rocket].Calamity().forceTypeless = true; + if (rocket.WithinBounds(Main.maxProjectiles)) + Main.projectile[rocket].Calamity().forceTypeless = true; } } } @@ -406,9 +407,12 @@ namespace CalamityMod.Items float spreadX = speedX + Main.rand.NextFloat(-0.75f, 0.75f); float spreadY = speedY + Main.rand.NextFloat(-0.75f, 0.75f); int feather = Projectile.NewProjectile(position, new Vector2(spreadX, spreadY) * 1.25f, ModContent.ProjectileType(), CalamityUtils.DamageSoftCap(damage * 0.5, 75), 2f, player.whoAmI); - Main.projectile[feather].usesLocalNPCImmunity = true; - Main.projectile[feather].localNPCHitCooldown = 10; - Main.projectile[feather].Calamity().forceTypeless = true; + if (feather.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[feather].usesLocalNPCImmunity = true; + Main.projectile[feather].localNPCHitCooldown = 10; + Main.projectile[feather].Calamity().forceTypeless = true; + } } } } @@ -608,11 +612,13 @@ namespace CalamityMod.Items case 1: //big boomer case 2: //boomer int proj = Projectile.NewProjectile(player.Center, perturbedspeed, ModContent.ProjectileType(), dam, 0f, player.whoAmI, projType == 1 ? 1f : 0f); - Main.projectile[proj].Calamity().forceMinion = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMinion = true; break; case 3: //bab boomer int proj2 = Projectile.NewProjectile(player.Center, perturbedspeed, ModContent.ProjectileType(), dam, 0f, player.whoAmI, 0f); - Main.projectile[proj2].Calamity().forceMinion = true; + if (proj2.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj2].Calamity().forceMinion = true; break; } if (projType > 1) @@ -648,7 +654,8 @@ namespace CalamityMod.Items dam -= sickPenalty; } int proj = Projectile.NewProjectile(player.position, correctedVelocity, ModContent.ProjectileType(), dam, 1f, player.whoAmI, enrage ? 1f : 0f); - Main.projectile[proj].Calamity().forceMinion = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMinion = true; player.Calamity().profanedSoulWeaponUsage = enrage ? 20 : 25; } if (player.Calamity().profanedSoulWeaponUsage > 0) @@ -667,7 +674,8 @@ namespace CalamityMod.Items { float angle = MathHelper.TwoPi / crystalCount * i; int proj = Projectile.NewProjectile(player.Center, angle.ToRotationVector2() * 8f, ModContent.ProjectileType(), (int)((shouldNerf ? 300 : 880) * player.MinionDamage()), 1f, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().forceMinion = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMinion = true; Main.PlaySound(SoundID.Item20, player.Center); } player.Calamity().profanedSoulWeaponUsage = 0; @@ -676,7 +684,8 @@ namespace CalamityMod.Items { float angle = MathHelper.TwoPi / (enrage ? 9 : 18) * (player.Calamity().profanedSoulWeaponUsage / (enrage ? 1 : 10)); int proj = Projectile.NewProjectile(player.Center, angle.ToRotationVector2() * 8f, ModContent.ProjectileType(), (int)((shouldNerf ? 400 : 1100) * player.MinionDamage()), 1f, player.whoAmI, 1f, 0f); - Main.projectile[proj].Calamity().forceMinion = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMinion = true; Main.PlaySound(SoundID.Item20, player.Center); } player.Calamity().profanedSoulWeaponUsage += enrage ? 1 : 2; @@ -740,26 +749,29 @@ namespace CalamityMod.Items Projectile blade = Projectile.NewProjectileDirect(robot.Center + (robot.spriteDirection > 0).ToDirectionInt() * robot.width / 2 * Vector2.UnitX, Vector2.Zero, ModContent.ProjectileType(), damage, 15f, player.whoAmI, Projectile.GetByUUID(robot.owner, robot.whoAmI)); - if (item.Calamity().rogue) - { - blade.Calamity().forceRogue = true; - } - if (item.melee) - { - blade.Calamity().forceMelee = true; - } - if (item.ranged) - { - blade.Calamity().forceRanged = true; - } - if (item.magic) - { - blade.Calamity().forceMagic = true; - } - if (item.summon) - { - blade.Calamity().forceMinion = true; - } + if (blade.whoAmI.WithinBounds(Main.maxProjectiles)) + { + if (item.Calamity().rogue) + { + blade.Calamity().forceRogue = true; + } + if (item.melee) + { + blade.Calamity().forceMelee = true; + } + if (item.ranged) + { + blade.Calamity().forceRanged = true; + } + if (item.magic) + { + blade.Calamity().forceMagic = true; + } + if (item.summon) + { + blade.Calamity().forceMinion = true; + } + } } if (!robotModProjectile.TopIconActive && @@ -3384,10 +3396,13 @@ Grants immunity to fire blocks, and temporary immunity to lava"; { if (player.controlJump && !player.jumpAgainCloud && player.jump == 0 && player.velocity.Y != 0f && !player.mount.Active && !player.mount.Cart) { - int p = Projectile.NewProjectile(player.Center.X, player.Center.Y, player.velocity.X * 0f, 2f, ProjectileID.OrnamentFriendly, (int)(100 * player.AverageDamage()), 5f, player.whoAmI); - Main.projectile[p].Calamity().forceTypeless = true; - Main.projectile[p].Calamity().lineColor = 1; - modPlayer.icicleCooldown = 10; + int p = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 2f, ProjectileID.OrnamentFriendly, (int)(100 * player.AverageDamage()), 5f, player.whoAmI); + if (p.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[p].Calamity().forceTypeless = true; + Main.projectile[p].Calamity().lineColor = 1; + modPlayer.icicleCooldown = 10; + } } } } diff --git a/Items/Mounts/BUMBLEDOGE.cs b/Items/Mounts/BUMBLEDOGE.cs index de988373b3..8e61ba969f 100644 --- a/Items/Mounts/BUMBLEDOGE.cs +++ b/Items/Mounts/BUMBLEDOGE.cs @@ -79,7 +79,8 @@ namespace CalamityMod.Items.Mounts int damage = (int)(180 * player.AverageDamage()); float kb = 1f; Projectile birb = Projectile.NewProjectileDirect(pos, vel, ModContent.ProjectileType(), damage, kb, player.whoAmI); - birb.Calamity().forceTypeless = true; + if (birb.whoAmI.WithinBounds(Main.maxProjectiles)) + birb.Calamity().forceTypeless = true; } } } diff --git a/Items/Tools/InfernaCutter.cs b/Items/Tools/InfernaCutter.cs index 23ba9cc9b5..d072d03c62 100644 --- a/Items/Tools/InfernaCutter.cs +++ b/Items/Tools/InfernaCutter.cs @@ -117,8 +117,9 @@ namespace CalamityMod.Items.Tools num340 *= 1.5f; num342 *= (float)player.direction; num341 *= player.gravDir; - int spark = Projectile.NewProjectile((float)(hitbox.X + hitbox.Width / 2) + num342, (float)(hitbox.Y + hitbox.Height / 2) + num341, (float)player.direction * num340, num339 * player.gravDir, ProjectileID.Spark, (int)(item.damage * 0.2f * player.MeleeDamage()), 0f, player.whoAmI, 0f, 0f); - Main.projectile[spark].Calamity().forceMelee = true; + int spark = Projectile.NewProjectile((float)(hitbox.X + hitbox.Width / 2) + num342, (float)(hitbox.Y + hitbox.Height / 2) + num341, (float)player.direction * num340, num339 * player.gravDir, ProjectileID.Spark, (int)(item.damage * 0.2f * player.MeleeDamage()), 0f, player.whoAmI); + if (spark.WithinBounds(Main.maxProjectiles)) + Main.projectile[spark].Calamity().forceMelee = true; } } if (Main.rand.NextBool(4)) @@ -131,8 +132,9 @@ namespace CalamityMod.Items.Tools { if (crit) { - int boom = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), knockback, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - Main.projectile[boom].Calamity().forceMelee = true; + int boom = Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), knockback, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (boom.WithinBounds(Main.maxProjectiles)) + Main.projectile[boom].Calamity().forceMelee = true; } target.AddBuff(BuffID.OnFire, 300); target.AddBuff(ModContent.BuffType(), 300); diff --git a/Items/Weapons/Magic/BelchingSaxophone.cs b/Items/Weapons/Magic/BelchingSaxophone.cs index 8fc26474c8..663fbb996a 100644 --- a/Items/Weapons/Magic/BelchingSaxophone.cs +++ b/Items/Weapons/Magic/BelchingSaxophone.cs @@ -65,9 +65,12 @@ namespace CalamityMod.Items.Weapons.Magic ProjectileID.TiedEighthNote }); int note = Projectile.NewProjectile(position.X, position.Y, speedX * 0.75f, speedY * 0.75f, noteProj, (int)(damage * 0.75), knockBack, player.whoAmI); - Main.projectile[note].Calamity().forceMagic = true; //why are these notes also internally ranged - Main.projectile[note].usesLocalNPCImmunity = true; - Main.projectile[note].localNPCHitCooldown = 10; + if (note.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[note].Calamity().forceMagic = true; //why are these notes also internally ranged + Main.projectile[note].usesLocalNPCImmunity = true; + Main.projectile[note].localNPCHitCooldown = 10; + } } return false; } diff --git a/Items/Weapons/Magic/ClothiersWrath.cs b/Items/Weapons/Magic/ClothiersWrath.cs index b34f78eb91..cd833de5be 100644 --- a/Items/Weapons/Magic/ClothiersWrath.cs +++ b/Items/Weapons/Magic/ClothiersWrath.cs @@ -40,8 +40,9 @@ namespace CalamityMod.Items.Weapons.Magic for (int i = 0; i < numProj + 1; i++) { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); - int proj = Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().forceMagic = true; + int proj = Projectile.NewProjectile(position, perturbedSpeed, type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMagic = true; } return false; } diff --git a/Items/Weapons/Magic/HyphaeRod.cs b/Items/Weapons/Magic/HyphaeRod.cs index 45500e343c..801e9d3988 100644 --- a/Items/Weapons/Magic/HyphaeRod.cs +++ b/Items/Weapons/Magic/HyphaeRod.cs @@ -83,8 +83,11 @@ namespace CalamityMod.Items.Weapons.Magic spawnVec.X += (float)Main.rand.Next(-180, 181) * 0.02f; spawnVec.Y += (float)Main.rand.Next(-180, 181) * 0.02f; int proj = Projectile.NewProjectile(source, spawnVec, type, damage, knockBack, player.whoAmI, 0f, Main.rand.Next(3)); - Main.projectile[proj].Calamity().forceMagic = true; - Main.projectile[proj].timeLeft = CalamityUtils.SecondsToFrames(8f); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMagic = true; + Main.projectile[proj].timeLeft = CalamityUtils.SecondsToFrames(8f); + } } return false; } diff --git a/Items/Weapons/Magic/TheSwarmer.cs b/Items/Weapons/Magic/TheSwarmer.cs index 8618c2cbdc..da7207fe72 100644 --- a/Items/Weapons/Magic/TheSwarmer.cs +++ b/Items/Weapons/Magic/TheSwarmer.cs @@ -54,17 +54,23 @@ namespace CalamityMod.Items.Weapons.Magic { float SpeedX = speedX + (float)Main.rand.Next(-35, 36) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-35, 36) * 0.05f; - int wasps = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, 0f, player.whoAmI, 0f, 0f); - Main.projectile[wasps].penetrate = 1; - Main.projectile[wasps].Calamity().forceMagic = true; + int wasps = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, 0f, player.whoAmI); + if (wasps.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[wasps].penetrate = 1; + Main.projectile[wasps].Calamity().forceMagic = true; + } } for (int i = 0; i <= 3; i++) { float SpeedX2 = speedX + (float)Main.rand.Next(-35, 36) * 0.05f; float SpeedY2 = speedY + (float)Main.rand.Next(-35, 36) * 0.05f; - int bees = Projectile.NewProjectile(position.X, position.Y, SpeedX2, SpeedY2, player.beeType(), player.beeDamage(item.damage), player.beeKB(0f), player.whoAmI, 0f, 0f); - Main.projectile[bees].penetrate = 1; - Main.projectile[bees].Calamity().forceMagic = true; + int bees = Projectile.NewProjectile(position.X, position.Y, SpeedX2, SpeedY2, player.beeType(), player.beeDamage(item.damage), player.beeKB(0f), player.whoAmI); + if (bees.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bees].penetrate = 1; + Main.projectile[bees].Calamity().forceMagic = true; + } } return false; } diff --git a/Items/Weapons/Magic/WintersFury.cs b/Items/Weapons/Magic/WintersFury.cs index 5803b47218..5ea984a4a3 100644 --- a/Items/Weapons/Magic/WintersFury.cs +++ b/Items/Weapons/Magic/WintersFury.cs @@ -45,7 +45,8 @@ namespace CalamityMod.Items.Weapons.Magic speed *= 15f; speed.Y -= Math.Abs(speed.X) * 0.2f; int p = Projectile.NewProjectile(position, speed, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - Main.projectile[p].Calamity().forceMagic = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().forceMagic = true; } if (Main.rand.NextBool(4)) { diff --git a/Items/Weapons/Melee/ArkoftheAncients.cs b/Items/Weapons/Melee/ArkoftheAncients.cs index 256fdfa4e5..f1b2f5eb96 100644 --- a/Items/Weapons/Melee/ArkoftheAncients.cs +++ b/Items/Weapons/Melee/ArkoftheAncients.cs @@ -91,7 +91,8 @@ namespace CalamityMod.Items.Weapons.Melee float speedX4 = num78 + (float)Main.rand.Next(-120, 121) * 0.02f; float speedY5 = num79 + (float)Main.rand.Next(-120, 121) * 0.02f; int proj = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, ProjectileID.HallowStar, damage / 3, knockBack, player.whoAmI, 0f, (float)Main.rand.Next(5)); - Main.projectile[proj].Calamity().forceMelee = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } return false; } diff --git a/Items/Weapons/Melee/FlameburstShortsword.cs b/Items/Weapons/Melee/FlameburstShortsword.cs index d22f20615d..2861107897 100644 --- a/Items/Weapons/Melee/FlameburstShortsword.cs +++ b/Items/Weapons/Melee/FlameburstShortsword.cs @@ -53,8 +53,9 @@ namespace CalamityMod.Items.Weapons.Melee { if (target.life <= (target.lifeMax * 0.5f)) { - int boom = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), knockback, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - Main.projectile[boom].Calamity().forceMelee = true; + int boom = Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), knockback, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (boom.WithinBounds(Main.maxProjectiles)) + Main.projectile[boom].Calamity().forceMelee = true; } } @@ -62,8 +63,9 @@ namespace CalamityMod.Items.Weapons.Melee { if (target.statLife <= (target.statLifeMax2 * 0.5f)) { - int boom = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), item.knockBack, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - Main.projectile[boom].Calamity().forceMelee = true; + int boom = Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), item.knockBack, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (boom.WithinBounds(Main.maxProjectiles)) + Main.projectile[boom].Calamity().forceMelee = true; } } } diff --git a/Items/Weapons/Melee/Floodtide.cs b/Items/Weapons/Melee/Floodtide.cs index e05786c86e..6690168543 100644 --- a/Items/Weapons/Melee/Floodtide.cs +++ b/Items/Weapons/Melee/Floodtide.cs @@ -42,7 +42,8 @@ namespace CalamityMod.Items.Weapons.Melee float SpeedX = speedX + (float)Main.rand.Next(-20, 21) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-20, 21) * 0.05f; int proj = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } return false; } diff --git a/Items/Weapons/Melee/GalaxySmasherMelee.cs b/Items/Weapons/Melee/GalaxySmasherMelee.cs index 20bef3f193..e1468ca3cd 100644 --- a/Items/Weapons/Melee/GalaxySmasherMelee.cs +++ b/Items/Weapons/Melee/GalaxySmasherMelee.cs @@ -45,8 +45,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) { - int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - Main.projectile[proj].Calamity().forceMelee = true; + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); return false; } diff --git a/Items/Weapons/Melee/LionHeart.cs b/Items/Weapons/Melee/LionHeart.cs index ab70b17bb0..4be535da75 100644 --- a/Items/Weapons/Melee/LionHeart.cs +++ b/Items/Weapons/Melee/LionHeart.cs @@ -79,14 +79,16 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - int explosion = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), knockback, player.whoAmI, 0f, 0f); - Main.projectile[explosion].Calamity().forceMelee = true; + int explosion = Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), knockback, player.whoAmI); + if (explosion.WithinBounds(Main.maxProjectiles)) + Main.projectile[explosion].Calamity().forceMelee = true; } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - int explosion = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), item.knockBack, player.whoAmI, 0f, 0f); - Main.projectile[explosion].Calamity().forceMelee = true; + int explosion = Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), item.knockBack, player.whoAmI); + if (explosion.WithinBounds(Main.maxProjectiles)) + Main.projectile[explosion].Calamity().forceMelee = true; } public override void MeleeEffects(Player player, Rectangle hitbox) diff --git a/Items/Weapons/Melee/PhoenixBlade.cs b/Items/Weapons/Melee/PhoenixBlade.cs index 7a16c00a43..b05790e659 100644 --- a/Items/Weapons/Melee/PhoenixBlade.cs +++ b/Items/Weapons/Melee/PhoenixBlade.cs @@ -38,12 +38,7 @@ namespace CalamityMod.Items.Weapons.Melee { if (target.life <= 0) { - int boom = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), knockback, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - Main.projectile[boom].Calamity().forceMelee = true; - float randomSpeedX = (float)Main.rand.Next(5); - float randomSpeedY = (float)Main.rand.Next(3, 7); - Projectile.NewProjectile(target.Center.X, target.Center.Y, -randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), knockback, player.whoAmI); - Projectile.NewProjectile(target.Center.X, target.Center.Y, randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), knockback, player.whoAmI); + OnHitEffects(player, target.Center, knockback); } } @@ -51,13 +46,19 @@ namespace CalamityMod.Items.Weapons.Melee { if (target.statLife <= 0) { - int boom = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), item.knockBack, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - Main.projectile[boom].Calamity().forceMelee = true; - float randomSpeedX = (float)Main.rand.Next(5); - float randomSpeedY = (float)Main.rand.Next(3, 7); - Projectile.NewProjectile(target.Center.X, target.Center.Y, -randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), item.knockBack, player.whoAmI); - Projectile.NewProjectile(target.Center.X, target.Center.Y, randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), item.knockBack, player.whoAmI); - } + OnHitEffects(player, target.Center, item.knockBack); + } + } + + private void OnHitEffects(Player player, Vector2 targetPos, float kBack) + { + int boom = Projectile.NewProjectile(targetPos, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), kBack, player.whoAmI, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (boom.WithinBounds(Main.maxProjectiles)) + Main.projectile[boom].Calamity().forceMelee = true; + float randomSpeedX = (float)Main.rand.Next(5); + float randomSpeedY = (float)Main.rand.Next(3, 7); + Projectile.NewProjectile(targetPos.X, targetPos.Y, -randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), kBack, player.whoAmI); + Projectile.NewProjectile(targetPos.X, targetPos.Y, randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), kBack, player.whoAmI); } public override void MeleeEffects(Player player, Rectangle hitbox) diff --git a/Items/Weapons/Melee/PlagueKeeper.cs b/Items/Weapons/Melee/PlagueKeeper.cs index 52f34b37a3..0a8dc4f232 100644 --- a/Items/Weapons/Melee/PlagueKeeper.cs +++ b/Items/Weapons/Melee/PlagueKeeper.cs @@ -53,9 +53,12 @@ namespace CalamityMod.Items.Weapons.Melee for (int i = 0; i < 3; i++) { int bee = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, player.beeType(), - player.beeDamage((int)(item.damage * player.MeleeDamage()) / 3), player.beeKB(0f), player.whoAmI, 0f, 0f); - Main.projectile[bee].penetrate = 1; - Main.projectile[bee].Calamity().forceMelee = true; + player.beeDamage((int)(item.damage * player.MeleeDamage()) / 3), player.beeKB(0f), player.whoAmI); + if (bee.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bee].penetrate = 1; + Main.projectile[bee].Calamity().forceMelee = true; + } } } @@ -65,9 +68,12 @@ namespace CalamityMod.Items.Weapons.Melee for (int i = 0; i < 3; i++) { int bee = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, player.beeType(), - player.beeDamage((int)(item.damage * player.MeleeDamage()) / 3), player.beeKB(0f), player.whoAmI, 0f, 0f); - Main.projectile[bee].penetrate = 1; - Main.projectile[bee].Calamity().forceMelee = true; + player.beeDamage((int)(item.damage * player.MeleeDamage()) / 3), player.beeKB(0f), player.whoAmI); + if (bee.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bee].penetrate = 1; + Main.projectile[bee].Calamity().forceMelee = true; + } } } } diff --git a/Items/Weapons/Melee/SporeKnife.cs b/Items/Weapons/Melee/SporeKnife.cs index feb2b1eb20..8fae02f658 100644 --- a/Items/Weapons/Melee/SporeKnife.cs +++ b/Items/Weapons/Melee/SporeKnife.cs @@ -53,8 +53,9 @@ namespace CalamityMod.Items.Weapons.Melee { if (target.life <= 0) { - int proj = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, Main.rand.Next(569, 572), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), knockback, Main.myPlayer); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(target.Center, Vector2.Zero, Main.rand.Next(569, 572), (int)(item.damage * player.MeleeDamage()), knockback, Main.myPlayer); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } } @@ -62,8 +63,9 @@ namespace CalamityMod.Items.Weapons.Melee { if (target.statLife <= 0) { - int proj = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, Main.rand.Next(569, 572), (int)(item.damage * (player.allDamage + player.meleeDamage - 1f)), item.knockBack, Main.myPlayer); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(target.Center, Vector2.Zero, Main.rand.Next(569, 572), (int)(item.damage * player.MeleeDamage()), item.knockBack, Main.myPlayer); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } } } diff --git a/Items/Weapons/Melee/StellarStriker.cs b/Items/Weapons/Melee/StellarStriker.cs index 9efdf376b8..17fff21802 100644 --- a/Items/Weapons/Melee/StellarStriker.cs +++ b/Items/Weapons/Melee/StellarStriker.cs @@ -96,7 +96,8 @@ namespace CalamityMod.Items.Weapons.Melee 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 (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } } diff --git a/Items/Weapons/Melee/Trinity.cs b/Items/Weapons/Melee/Trinity.cs index f12d436eb6..5a5b2cd628 100644 --- a/Items/Weapons/Melee/Trinity.cs +++ b/Items/Weapons/Melee/Trinity.cs @@ -35,26 +35,19 @@ 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) { - switch (Main.rand.Next(3)) - { - case 0: - type = ProjectileID.RubyBolt; - break; - case 1: - type = ProjectileID.SapphireBolt; - break; - case 2: - type = ProjectileID.AmethystBolt; - break; - default: - break; - } + type = Utils.SelectRandom(Main.rand, new int[] + { + ProjectileID.RubyBolt, + ProjectileID.SapphireBolt, + ProjectileID.AmethystBolt + }); for (int projectiles = 0; projectiles <= 3; projectiles++) { float SpeedX = speedX + (float)Main.rand.Next(-30, 31) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-30, 31) * 0.05f; - int proj = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)((double)damage * 0.6), knockBack, Main.myPlayer, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)(damage * 0.6), knockBack, Main.myPlayer, 0f, 0f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } return false; } diff --git a/Items/Weapons/Melee/TrueArkoftheAncients.cs b/Items/Weapons/Melee/TrueArkoftheAncients.cs index 75f7020e26..6f3e43e00a 100644 --- a/Items/Weapons/Melee/TrueArkoftheAncients.cs +++ b/Items/Weapons/Melee/TrueArkoftheAncients.cs @@ -38,15 +38,11 @@ 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) { - switch (Main.rand.Next(2)) - { - case 0: - type = ModContent.ProjectileType(); - break; - case 1: - type = ModContent.ProjectileType(); - break; - } + type = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.ProjectileType(), + ModContent.ProjectileType() + }); int beam = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, (int)(damage * 0.75), knockBack, Main.myPlayer, 1f); Main.projectile[beam].localNPCHitCooldown = 14; int i = Main.myPlayer; @@ -98,7 +94,8 @@ namespace CalamityMod.Items.Weapons.Melee float speedX2 = num78 + (float)Main.rand.Next(-160, 161) * 0.02f; float speedY2 = num79 + (float)Main.rand.Next(-160, 161) * 0.02f; int proj = Projectile.NewProjectile(vector2.X, vector2.Y, speedX2, speedY2, ProjectileID.HallowStar, damage / 3, num74, i, 0f, (float)Main.rand.Next(10)); - Main.projectile[proj].Calamity().forceMelee = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; speedX2 = num78 + (float)Main.rand.Next(-80, 81) * 0.02f; speedY2 = num79 + (float)Main.rand.Next(-80, 81) * 0.02f; diff --git a/Items/Weapons/Ranged/Alluvion.cs b/Items/Weapons/Ranged/Alluvion.cs index 96095e94b7..bb80be6e3c 100644 --- a/Items/Weapons/Ranged/Alluvion.cs +++ b/Items/Weapons/Ranged/Alluvion.cs @@ -72,14 +72,17 @@ namespace CalamityMod.Items.Weapons.Ranged { type = ModContent.ProjectileType(); } - int proj = Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().forceRanged = true; - Main.projectile[proj].noDropItem = true; - Main.projectile[proj].arrow = true; + int proj = Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceRanged = true; + Main.projectile[proj].noDropItem = true; + Main.projectile[proj].arrow = true; + } } else { - int proj = Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); + int proj = Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); Main.projectile[proj].noDropItem = true; } } diff --git a/Items/Weapons/Ranged/BladedgeGreatbow.cs b/Items/Weapons/Ranged/BladedgeGreatbow.cs index a6f3e2b2c2..3073f46944 100644 --- a/Items/Weapons/Ranged/BladedgeGreatbow.cs +++ b/Items/Weapons/Ranged/BladedgeGreatbow.cs @@ -64,8 +64,9 @@ namespace CalamityMod.Items.Weapons.Ranged { value9 -= vector7; } - int projectile = Projectile.NewProjectile(vector2.X + value9.X, vector2.Y + value9.Y, speedX, speedY, ProjectileID.Leaf, damage / 2, 0f, player.whoAmI, 0f, 0f); - Main.projectile[projectile].Calamity().forceRanged = true; + int projectile = Projectile.NewProjectile(vector2.X + value9.X, vector2.Y + value9.Y, speedX, speedY, ProjectileID.Leaf, damage / 2, 0f, player.whoAmI); + if (projectile.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile].Calamity().forceRanged = true; } return false; } diff --git a/Items/Weapons/Ranged/FirestormCannon.cs b/Items/Weapons/Ranged/FirestormCannon.cs index 9ea356fd46..b4e3e36e1e 100644 --- a/Items/Weapons/Ranged/FirestormCannon.cs +++ b/Items/Weapons/Ranged/FirestormCannon.cs @@ -35,27 +35,11 @@ namespace CalamityMod.Items.Weapons.Ranged item.useAmmo = AmmoID.Flare; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - public override bool ConsumeAmmo(Player player) - { - if (Main.rand.Next(0, 100) < 70) - return false; - return true; - } + public override bool ConsumeAmmo(Player player) => Main.rand.Next(100) >= 70; - public override bool AltFunctionUse(Player player) - { - return true; - } - - public override bool CanUseItem(Player player) - { - return base.CanUseItem(player); - } + public override bool AltFunctionUse(Player player) => true; public override float UseTimeMultiplier (Player player) { @@ -73,10 +57,13 @@ namespace CalamityMod.Items.Weapons.Ranged { float SpeedX = speedX + (float)Main.rand.Next(-50, 51) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-50, 51) * 0.05f; - int flare = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)((double)damage * 1.4), knockBack, player.whoAmI, 0.0f, 0.0f); - Main.projectile[flare].penetrate = 1; - Main.projectile[flare].timeLeft = 600; - Main.projectile[flare].Calamity().forceRanged = true; + int flare = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)((double)damage * 1.4), knockBack, player.whoAmI); + if (flare.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[flare].penetrate = 1; + Main.projectile[flare].timeLeft = 600; + Main.projectile[flare].Calamity().forceRanged = true; + } } return false; } @@ -87,10 +74,13 @@ namespace CalamityMod.Items.Weapons.Ranged { float SpeedX = speedX + (float)Main.rand.Next(-40, 41) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-40, 41) * 0.05f; - int projectile = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0.0f, 0.0f); - Main.projectile[projectile].Calamity().forceRanged = true; - Main.projectile[projectile].timeLeft = 200; - Main.projectile[projectile].penetrate = 3; + int flare = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); + if (flare.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[flare].Calamity().forceRanged = true; + Main.projectile[flare].timeLeft = 200; + Main.projectile[flare].penetrate = 3; + } } return false; } diff --git a/Items/Weapons/Ranged/Goobow.cs b/Items/Weapons/Ranged/Goobow.cs index ad9f925dc3..b0dee2b899 100644 --- a/Items/Weapons/Ranged/Goobow.cs +++ b/Items/Weapons/Ranged/Goobow.cs @@ -53,9 +53,12 @@ namespace CalamityMod.Items.Weapons.Ranged offset -= velocity; } int index = Projectile.NewProjectile(source + offset, new Vector2(speedX, speedY) * 0.6f, ProjectileID.SlimeGun, damage / 4, 0f, player.whoAmI); - Main.projectile[index].Calamity().forceRanged = true; - Main.projectile[index].usesLocalNPCImmunity = true; - Main.projectile[index].localNPCHitCooldown = 10; + if (index.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[index].Calamity().forceRanged = true; + Main.projectile[index].usesLocalNPCImmunity = true; + Main.projectile[index].localNPCHitCooldown = 10; + } } return true; } diff --git a/Items/Weapons/Ranged/Monsoon.cs b/Items/Weapons/Ranged/Monsoon.cs index 3632934b4d..d52a1df340 100644 --- a/Items/Weapons/Ranged/Monsoon.cs +++ b/Items/Weapons/Ranged/Monsoon.cs @@ -65,14 +65,17 @@ namespace CalamityMod.Items.Weapons.Ranged type = ModContent.ProjectileType(); } int arrow = Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, type, (int)(damage * 1.1f), knockBack, player.whoAmI); - Main.projectile[arrow].Calamity().forceRanged = true; - Main.projectile[arrow].noDropItem = true; - Main.projectile[arrow].arrow = true; - Main.projectile[arrow].extraUpdates += 1; + if (arrow.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[arrow].Calamity().forceRanged = true; + Main.projectile[arrow].noDropItem = true; + Main.projectile[arrow].arrow = true; + Main.projectile[arrow].extraUpdates += 1; + } } else { - int arrow = Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); + int arrow = Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); Main.projectile[arrow].noDropItem = true; } } diff --git a/Items/Weapons/Ranged/SpectralstormCannon.cs b/Items/Weapons/Ranged/SpectralstormCannon.cs index 5c4b23f00b..be0fa2332b 100644 --- a/Items/Weapons/Ranged/SpectralstormCannon.cs +++ b/Items/Weapons/Ranged/SpectralstormCannon.cs @@ -49,15 +49,21 @@ namespace CalamityMod.Items.Weapons.Ranged float SpeedX = speedX + (float)Main.rand.Next(-40, 41) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-40, 41) * 0.05f; int flare = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); - Main.projectile[flare].timeLeft = 200; - Main.projectile[flare].Calamity().forceRanged = true; + if (flare.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[flare].timeLeft = 200; + Main.projectile[flare].Calamity().forceRanged = true; + } float SpeedX2 = speedX + (float)Main.rand.Next(-20, 21) * 0.05f; float SpeedY2 = speedY + (float)Main.rand.Next(-20, 21) * 0.05f; int soul = Projectile.NewProjectile(position.X, position.Y, SpeedX2, SpeedY2, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - Main.projectile[soul].timeLeft = 600; - Main.projectile[soul].Calamity().forceRanged = true; - Main.projectile[soul].frame = Main.rand.Next(4); + if (soul.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[soul].timeLeft = 600; + Main.projectile[soul].Calamity().forceRanged = true; + Main.projectile[soul].frame = Main.rand.Next(4); + } return false; } diff --git a/Items/Weapons/Ranged/SpectreRifle.cs b/Items/Weapons/Ranged/SpectreRifle.cs index 5a30f1abec..7ad9d1d63f 100644 --- a/Items/Weapons/Ranged/SpectreRifle.cs +++ b/Items/Weapons/Ranged/SpectreRifle.cs @@ -1,4 +1,5 @@ using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -42,7 +43,7 @@ namespace CalamityMod.Items.Weapons.Ranged 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.X, position.Y, speedX, speedY, ProjectileID.LostSoulFriendly, damage, knockBack, player.whoAmI, 0f, 0f); + int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); Main.projectile[proj].Calamity().forceRanged = true; return false; } diff --git a/Items/Weapons/Ranged/StarCannonEX.cs b/Items/Weapons/Ranged/StarCannonEX.cs index 69ae9cc5aa..e6d03d27c2 100644 --- a/Items/Weapons/Ranged/StarCannonEX.cs +++ b/Items/Weapons/Ranged/StarCannonEX.cs @@ -37,10 +37,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.useAmmo = AmmoID.FallenStar; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-5, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-5, 0); public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { @@ -49,20 +46,15 @@ namespace CalamityMod.Items.Weapons.Ranged { float SpeedX = speedX + (float)Main.rand.Next(-15, 16) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-15, 16) * 0.05f; - switch (Main.rand.Next(3)) - { - case 0: - type = ModContent.ProjectileType(); - break; - case 1: - type = ProjectileID.Starfury; - break; - case 2: - type = ModContent.ProjectileType(); - break; - } - int star = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[star].Calamity().forceRanged = true; + type = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.ProjectileType(), + ProjectileID.Starfury, + ModContent.ProjectileType() + }); + int star = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); + if (star.WithinBounds(Main.maxProjectiles)) + Main.projectile[star].Calamity().forceRanged = true; } return false; } diff --git a/Items/Weapons/Rogue/AccretionDisk.cs b/Items/Weapons/Rogue/AccretionDisk.cs index cbe7e8dfb2..ecb0466b2b 100644 --- a/Items/Weapons/Rogue/AccretionDisk.cs +++ b/Items/Weapons/Rogue/AccretionDisk.cs @@ -43,9 +43,12 @@ namespace CalamityMod.Items.Weapons.Rogue speedX *= 0.7f; speedY *= 0.7f; int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - Main.projectile[proj].Calamity().stealthStrike = true; - Main.projectile[proj].timeLeft *= 3; - Main.projectile[proj].localNPCHitCooldown *= 2; + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().stealthStrike = true; + Main.projectile[proj].timeLeft *= 3; + Main.projectile[proj].localNPCHitCooldown *= 2; + } return false; } return true; diff --git a/Items/Weapons/Rogue/AcidicRainBarrel.cs b/Items/Weapons/Rogue/AcidicRainBarrel.cs index 37b7463dcd..7d9ccd8aaa 100644 --- a/Items/Weapons/Rogue/AcidicRainBarrel.cs +++ b/Items/Weapons/Rogue/AcidicRainBarrel.cs @@ -41,7 +41,8 @@ namespace CalamityMod.Items.Weapons.Rogue Vector2 initialVelocity = new Vector2(speedX, speedY); int p = Projectile.NewProjectile(position - Vector2.UnitY * 12f, initialVelocity, type, damage, knockBack, player.whoAmI); - Main.projectile[p].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } public override void AddRecipes() diff --git a/Items/Weapons/Rogue/AdamantiteThrowingAxe.cs b/Items/Weapons/Rogue/AdamantiteThrowingAxe.cs index 771fcdcee7..4572ef2993 100644 --- a/Items/Weapons/Rogue/AdamantiteThrowingAxe.cs +++ b/Items/Weapons/Rogue/AdamantiteThrowingAxe.cs @@ -39,9 +39,12 @@ 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); - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].usesLocalNPCImmunity = true; + } return false; } return true; diff --git a/Items/Weapons/Rogue/AlphaVirus.cs b/Items/Weapons/Rogue/AlphaVirus.cs index 40b470d287..91fc6a9860 100644 --- a/Items/Weapons/Rogue/AlphaVirus.cs +++ b/Items/Weapons/Rogue/AlphaVirus.cs @@ -43,7 +43,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, item.shootSpeed, 0f); - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/Apoctolith.cs b/Items/Weapons/Rogue/Apoctolith.cs index c6e90e69b0..0a7a224f68 100644 --- a/Items/Weapons/Rogue/Apoctolith.cs +++ b/Items/Weapons/Rogue/Apoctolith.cs @@ -46,7 +46,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/AshenStalactite.cs b/Items/Weapons/Rogue/AshenStalactite.cs index e7ddae13ff..3932b5f5a8 100644 --- a/Items/Weapons/Rogue/AshenStalactite.cs +++ b/Items/Weapons/Rogue/AshenStalactite.cs @@ -45,7 +45,8 @@ namespace CalamityMod.Items.Weapons.Rogue float stealthDamageMult = 1.15f; float stealthKnockbackMult = 2.5f; int p = Projectile.NewProjectile(position.X, position.Y, speedX * stealthSpeedMult, speedY * stealthSpeedMult, stealthType, (int)(damage * stealthDamageMult), (int)(knockBack * stealthKnockbackMult), player.whoAmI, 0f, 1f); - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/AuroradicalThrow.cs b/Items/Weapons/Rogue/AuroradicalThrow.cs index 3a5c4653ed..ad23993fca 100644 --- a/Items/Weapons/Rogue/AuroradicalThrow.cs +++ b/Items/Weapons/Rogue/AuroradicalThrow.cs @@ -39,8 +39,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) { - int star = Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[star].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + int star = Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (star.WithinBounds(Main.maxProjectiles)) + Main.projectile[star].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/Rogue/BallisticPoisonBomb.cs b/Items/Weapons/Rogue/BallisticPoisonBomb.cs index 45d20c00b4..ba67fa0161 100644 --- a/Items/Weapons/Rogue/BallisticPoisonBomb.cs +++ b/Items/Weapons/Rogue/BallisticPoisonBomb.cs @@ -45,8 +45,9 @@ namespace CalamityMod.Items.Weapons.Rogue for (int i = 0; i < 3; i++) { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-3,4), speedY + Main.rand.Next(-3,4)).RotatedBy(MathHelper.ToRadians(spread)); - int proj = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X, perturbedspeed.Y, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = true; + int proj = Projectile.NewProjectile(position, perturbedspeed, type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; spread -= Main.rand.Next(2,6); } return false; diff --git a/Items/Weapons/Rogue/BlastBarrel.cs b/Items/Weapons/Rogue/BlastBarrel.cs index 38c339e34b..941f2396fe 100644 --- a/Items/Weapons/Rogue/BlastBarrel.cs +++ b/Items/Weapons/Rogue/BlastBarrel.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Weapons.Rogue //unitY additive is do it doesn't exploe initially int p = Projectile.NewProjectile(position - Vector2.UnitY * 12f, initialVelocity, type, damage, knockBack, player.whoAmI); - if (player.Calamity().StealthStrikeAvailable()) + if (player.Calamity().StealthStrikeAvailable() && p.WithinBounds(Main.maxProjectiles)) Main.projectile[p].Calamity().stealthStrike = true; return false; } diff --git a/Items/Weapons/Rogue/BlazingStar.cs b/Items/Weapons/Rogue/BlazingStar.cs index 43c7d1e52f..3ddb75dfa1 100644 --- a/Items/Weapons/Rogue/BlazingStar.cs +++ b/Items/Weapons/Rogue/BlazingStar.cs @@ -48,11 +48,16 @@ namespace CalamityMod.Items.Weapons.Rogue for (int i = 0; i < item.stack; i++) { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.Lerp(-MathHelper.ToRadians(8f), MathHelper.ToRadians(8f), i / (float)(item.stack - 1))); - Projectile.NewProjectileDirect(position, perturbedSpeed, type, damage, knockBack, player.whoAmI, 0f, 0f).Calamity().stealthStrike = true; + Projectile proj = Projectile.NewProjectileDirect(position, perturbedSpeed, type, damage, knockBack, player.whoAmI); + if (proj.whoAmI.WithinBounds(Main.maxProjectiles)) + proj.Calamity().stealthStrike = true; - Projectile projectile = Projectile.NewProjectileDirect(position, perturbedSpeed, type, damage, knockBack, player.whoAmI, 0f); - projectile.penetrate = -1; - projectile.Calamity().stealthStrike = true; + Projectile projectile = Projectile.NewProjectileDirect(position, perturbedSpeed, type, damage, knockBack, player.whoAmI); + if (projectile.whoAmI.WithinBounds(Main.maxProjectiles)) + { + projectile.penetrate = -1; + projectile.Calamity().stealthStrike = true; + } } return false; diff --git a/Items/Weapons/Rogue/BloodsoakedCrasher.cs b/Items/Weapons/Rogue/BloodsoakedCrasher.cs index cc9c127bf3..4a94480ecb 100644 --- a/Items/Weapons/Rogue/BloodsoakedCrasher.cs +++ b/Items/Weapons/Rogue/BloodsoakedCrasher.cs @@ -41,7 +41,8 @@ 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) { 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 + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); //setting the stealth strike return false; } diff --git a/Items/Weapons/Rogue/BouncingBetty.cs b/Items/Weapons/Rogue/BouncingBetty.cs index 3972c1f479..c0c57d5475 100644 --- a/Items/Weapons/Rogue/BouncingBetty.cs +++ b/Items/Weapons/Rogue/BouncingBetty.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Vector2 velocity = new Vector2(speedX, speedY); int projectileIndex = Projectile.NewProjectile(position, velocity, type, damage, knockBack, player.whoAmI); - if (player.Calamity().StealthStrikeAvailable()) + if (player.Calamity().StealthStrikeAvailable() && projectileIndex.WithinBounds(Main.maxProjectiles)) { Main.projectile[projectileIndex].Calamity().stealthStrike = true; } diff --git a/Items/Weapons/Rogue/BouncingEyeball.cs b/Items/Weapons/Rogue/BouncingEyeball.cs index a38e49554a..af3c413f3c 100644 --- a/Items/Weapons/Rogue/BouncingEyeball.cs +++ b/Items/Weapons/Rogue/BouncingEyeball.cs @@ -46,7 +46,8 @@ namespace CalamityMod.Items.Weapons.Rogue { initialVelocity *= 2f; int p = Projectile.NewProjectile(position, initialVelocity, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; } else { diff --git a/Items/Weapons/Rogue/BouncySpikyBall.cs b/Items/Weapons/Rogue/BouncySpikyBall.cs index e7ea6bde8c..5f90d5f232 100644 --- a/Items/Weapons/Rogue/BouncySpikyBall.cs +++ b/Items/Weapons/Rogue/BouncySpikyBall.cs @@ -42,8 +42,9 @@ Stealth strikes provide a bigger boost after richocheting"); { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/BrackishFlask.cs b/Items/Weapons/Rogue/BrackishFlask.cs index 1f63de6c31..54d9a00eab 100644 --- a/Items/Weapons/Rogue/BrackishFlask.cs +++ b/Items/Weapons/Rogue/BrackishFlask.cs @@ -39,8 +39,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/Brimblade.cs b/Items/Weapons/Rogue/Brimblade.cs index 07aa7437e5..d8bc52b119 100644 --- a/Items/Weapons/Rogue/Brimblade.cs +++ b/Items/Weapons/Rogue/Brimblade.cs @@ -41,14 +41,16 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int blade = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[blade].Calamity().stealthStrike = true; + int blade = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (blade.WithinBounds(Main.maxProjectiles)) + Main.projectile[blade].Calamity().stealthStrike = true; for (int i = -6; i <= 6; i += 4) { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); - int dart = Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), damage, knockBack * 0.5f, player.whoAmI, 0f, 0f); - Main.projectile[dart].Calamity().forceRogue = true; + int dart = Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), damage, knockBack * 0.5f, player.whoAmI); + if (dart.WithinBounds(Main.maxProjectiles)) + Main.projectile[dart].Calamity().forceRogue = true; } return false; } diff --git a/Items/Weapons/Rogue/BurningStrife.cs b/Items/Weapons/Rogue/BurningStrife.cs index b74e338755..4904e0ae1d 100644 --- a/Items/Weapons/Rogue/BurningStrife.cs +++ b/Items/Weapons/Rogue/BurningStrife.cs @@ -45,8 +45,8 @@ namespace CalamityMod.Items.Weapons.Rogue { speedMult = 1.25f; } - int proj = Projectile.NewProjectile(position, new Vector2(speedX * speedMult, speedY * speedMult), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - if (player.Calamity().StealthStrikeAvailable()) + int proj = Projectile.NewProjectile(position, new Vector2(speedX * speedMult, speedY * speedMult), type, damage, knockBack, player.whoAmI); + if (player.Calamity().StealthStrikeAvailable() && proj.WithinBounds(Main.maxProjectiles)) { Main.projectile[proj].Calamity().stealthStrike = true; Main.projectile[proj].penetrate = 5; diff --git a/Items/Weapons/Rogue/CelestialReaper.cs b/Items/Weapons/Rogue/CelestialReaper.cs index c856f46b9b..8a90c29364 100644 --- a/Items/Weapons/Rogue/CelestialReaper.cs +++ b/Items/Weapons/Rogue/CelestialReaper.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Weapons.Rogue Vector2 velocity = new Vector2(speedX, speedY); float strikeValue = player.Calamity().StealthStrikeAvailable().ToInt(); //0 if false, 1 if true int p = Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, strikeValue); - if (player.Calamity().StealthStrikeAvailable()) + if (player.Calamity().StealthStrikeAvailable() && p.WithinBounds(Main.maxProjectiles)) Main.projectile[p].Calamity().stealthStrike = true; return false; } diff --git a/Items/Weapons/Rogue/Celestus.cs b/Items/Weapons/Rogue/Celestus.cs index 16f99eb217..3fe4c1eb75 100644 --- a/Items/Weapons/Rogue/Celestus.cs +++ b/Items/Weapons/Rogue/Celestus.cs @@ -42,7 +42,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; } return true; } diff --git a/Items/Weapons/Rogue/Cinquedea.cs b/Items/Weapons/Rogue/Cinquedea.cs index 94dde06ab3..7ce6923b15 100644 --- a/Items/Weapons/Rogue/Cinquedea.cs +++ b/Items/Weapons/Rogue/Cinquedea.cs @@ -44,7 +44,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/CobaltKunai.cs b/Items/Weapons/Rogue/CobaltKunai.cs index ce7d94d42c..7bca0f0ee0 100644 --- a/Items/Weapons/Rogue/CobaltKunai.cs +++ b/Items/Weapons/Rogue/CobaltKunai.cs @@ -42,7 +42,9 @@ namespace CalamityMod.Items.Weapons.Rogue for (int i = -6; i <= 6; i += 6) { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); - Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + int stealth = Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; } return false; } diff --git a/Items/Weapons/Rogue/ConsecratedWater.cs b/Items/Weapons/Rogue/ConsecratedWater.cs index 4a6cabf8ee..1c3b420e1c 100644 --- a/Items/Weapons/Rogue/ConsecratedWater.cs +++ b/Items/Weapons/Rogue/ConsecratedWater.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Rogue Vector2 velocity = new Vector2(speedX, speedY); float strikeValue = player.Calamity().StealthStrikeAvailable().ToInt(); //0 if false, 1 if true int p = Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, ai1: strikeValue); - if (player.Calamity().StealthStrikeAvailable()) + if (player.Calamity().StealthStrikeAvailable() && p.WithinBounds(Main.maxProjectiles)) Main.projectile[p].Calamity().stealthStrike = true; return false; } diff --git a/Items/Weapons/Rogue/ContaminatedBile.cs b/Items/Weapons/Rogue/ContaminatedBile.cs index 72e58d750e..95330f5e1e 100644 --- a/Items/Weapons/Rogue/ContaminatedBile.cs +++ b/Items/Weapons/Rogue/ContaminatedBile.cs @@ -37,7 +37,8 @@ namespace CalamityMod.Items.Weapons.Rogue { Vector2 velocity = new Vector2(speedX, speedY); int p = Projectile.NewProjectile(position, velocity, type, damage, knockBack, player.whoAmI); - Main.projectile[p].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } public override void AddRecipes() diff --git a/Items/Weapons/Rogue/CorpusAvertor.cs b/Items/Weapons/Rogue/CorpusAvertor.cs index 91b3a2ec7e..15fafdb9ae 100644 --- a/Items/Weapons/Rogue/CorpusAvertor.cs +++ b/Items/Weapons/Rogue/CorpusAvertor.cs @@ -52,7 +52,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int dagger = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage * 2, knockBack * 2f, player.whoAmI); - Main.projectile[dagger].Calamity().stealthStrike = true; + if (dagger.WithinBounds(Main.maxProjectiles)) + Main.projectile[dagger].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/CosmicKunai.cs b/Items/Weapons/Rogue/CosmicKunai.cs index b176fb4505..c825c6810e 100644 --- a/Items/Weapons/Rogue/CosmicKunai.cs +++ b/Items/Weapons/Rogue/CosmicKunai.cs @@ -42,7 +42,7 @@ 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) { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (player.Calamity().StealthStrikeAvailable() && player.ownedProjectileCounts[ModContent.ProjectileType()] < 10 && counter == 0) + if (player.Calamity().StealthStrikeAvailable() && player.ownedProjectileCounts[ModContent.ProjectileType()] < 10 && counter == 0 && stealth.WithinBounds(Main.maxProjectiles)) { Main.projectile[stealth].Calamity().stealthStrike = true; Main.PlaySound(SoundID.Item73, player.position); diff --git a/Items/Weapons/Rogue/CraniumSmasher.cs b/Items/Weapons/Rogue/CraniumSmasher.cs index 2a1e7a4ca2..232959fa3a 100644 --- a/Items/Weapons/Rogue/CraniumSmasher.cs +++ b/Items/Weapons/Rogue/CraniumSmasher.cs @@ -50,8 +50,9 @@ namespace CalamityMod.Items.Weapons.Rogue { type = ModContent.ProjectileType(); } - int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } } diff --git a/Items/Weapons/Rogue/CrushsawCrasher.cs b/Items/Weapons/Rogue/CrushsawCrasher.cs index d1adf9c3dd..de6eca194d 100644 --- a/Items/Weapons/Rogue/CrushsawCrasher.cs +++ b/Items/Weapons/Rogue/CrushsawCrasher.cs @@ -42,10 +42,13 @@ namespace CalamityMod.Items.Weapons.Rogue for (int i = 0; i < 5; i++) { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-3,4), speedY + Main.rand.Next(-3,4)).RotatedBy(MathHelper.ToRadians(spread)); - int proj = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X, perturbedspeed.Y, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = true; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = 10; + int proj = Projectile.NewProjectile(position, perturbedspeed, type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().stealthStrike = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 10; + } spread -= Main.rand.Next(1,4); } return false; diff --git a/Items/Weapons/Rogue/CrystalPiercer.cs b/Items/Weapons/Rogue/CrystalPiercer.cs index f27d2da7f3..782c077d57 100644 --- a/Items/Weapons/Rogue/CrystalPiercer.cs +++ b/Items/Weapons/Rogue/CrystalPiercer.cs @@ -42,11 +42,14 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].aiStyle = -1; - Main.projectile[stealth].tileCollide = false; - Main.projectile[stealth].usesLocalNPCImmunity = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].aiStyle = -1; + Main.projectile[stealth].tileCollide = false; + Main.projectile[stealth].usesLocalNPCImmunity = true; + } return false; } return true; diff --git a/Items/Weapons/Rogue/Crystalline.cs b/Items/Weapons/Rogue/Crystalline.cs index 675602ca33..9088be5abc 100644 --- a/Items/Weapons/Rogue/Crystalline.cs +++ b/Items/Weapons/Rogue/Crystalline.cs @@ -51,8 +51,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = true; + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/CursedDagger.cs b/Items/Weapons/Rogue/CursedDagger.cs index 9cee3f0275..218b7e23b5 100644 --- a/Items/Weapons/Rogue/CursedDagger.cs +++ b/Items/Weapons/Rogue/CursedDagger.cs @@ -39,9 +39,12 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].usesLocalNPCImmunity = true; + } return false; } return true; diff --git a/Items/Weapons/Rogue/DeepSeaDumbbell.cs b/Items/Weapons/Rogue/DeepSeaDumbbell.cs index 7bf797548d..327293d5e8 100644 --- a/Items/Weapons/Rogue/DeepSeaDumbbell.cs +++ b/Items/Weapons/Rogue/DeepSeaDumbbell.cs @@ -43,10 +43,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().customRarity = CalamityRarity.Dedicated; } - public override bool AltFunctionUse(Player player) - { - return true; - } + public override bool AltFunctionUse(Player player) => true; public override bool CanUseItem(Player player) { @@ -107,7 +104,7 @@ namespace CalamityMod.Items.Weapons.Rogue } int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - if (player.Calamity().StealthStrikeAvailable()) + if (player.Calamity().StealthStrikeAvailable() && proj.WithinBounds(Main.maxProjectiles)) { Main.projectile[proj].Calamity().stealthStrike = true; flexBonusDamageMult = 0f; diff --git a/Items/Weapons/Rogue/DeepWounder.cs b/Items/Weapons/Rogue/DeepWounder.cs index 75e9dbdf5c..68c0b5a21e 100644 --- a/Items/Weapons/Rogue/DeepWounder.cs +++ b/Items/Weapons/Rogue/DeepWounder.cs @@ -45,8 +45,9 @@ namespace CalamityMod.Items.Weapons.Rogue velocity.Normalize(); velocity *= item.shootSpeed * stealthSpeedMult; - int p = Projectile.NewProjectile(position.X, position.Y, velocity.X, velocity.Y, type, damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[p].Calamity().stealthStrike = true; + int p = Projectile.NewProjectile(position, velocity, type, damage, knockBack, player.whoAmI, 0f, 1f); + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/DefectiveSphere.cs b/Items/Weapons/Rogue/DefectiveSphere.cs index 57524c28af..7002ff039d 100644 --- a/Items/Weapons/Rogue/DefectiveSphere.cs +++ b/Items/Weapons/Rogue/DefectiveSphere.cs @@ -83,14 +83,18 @@ Stealth strikes launch all 4 sphere types at once"); if (player.Calamity().StealthStrikeAvailable()) { - int stealth = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage / 2, knockBack, player.whoAmI, 0f, 0f); - int stealth2 = Projectile.NewProjectile(position.X, position.Y, SpeedX2, SpeedY2, ProjectileType(), damage / 2, knockBack, player.whoAmI, 0f, 0f); - int stealth3 = Projectile.NewProjectile(position.X, position.Y, SpeedX3, SpeedY3, ProjectileType(), damage / 2, knockBack, player.whoAmI, 0f, 0f); - int stealth4 = Projectile.NewProjectile(position.X, position.Y, SpeedX4, SpeedY4, ProjectileType(), damage / 2, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth2].Calamity().stealthStrike = true; - Main.projectile[stealth3].Calamity().stealthStrike = true; - Main.projectile[stealth4].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage / 2, knockBack, player.whoAmI); + int stealth2 = Projectile.NewProjectile(position.X, position.Y, SpeedX2, SpeedY2, ProjectileType(), damage / 2, knockBack, player.whoAmI); + int stealth3 = Projectile.NewProjectile(position.X, position.Y, SpeedX3, SpeedY3, ProjectileType(), damage / 2, knockBack, player.whoAmI); + int stealth4 = Projectile.NewProjectile(position.X, position.Y, SpeedX4, SpeedY4, ProjectileType(), damage / 2, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth2.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth2].Calamity().stealthStrike = true; + if (stealth3.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth3].Calamity().stealthStrike = true; + if (stealth4.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth4].Calamity().stealthStrike = true; } else { diff --git a/Items/Weapons/Rogue/DeificThunderbolt.cs b/Items/Weapons/Rogue/DeificThunderbolt.cs index 725d5b9135..2b59a23dbc 100644 --- a/Items/Weapons/Rogue/DeificThunderbolt.cs +++ b/Items/Weapons/Rogue/DeificThunderbolt.cs @@ -52,7 +52,7 @@ Stealth strikes summon more lightning and travel faster"); rainSpeedMult = 1.5f; int thunder = Projectile.NewProjectile(position.X, position.Y, speedX * rainSpeedMult * stealthSpeedMult, speedY * rainSpeedMult * stealthSpeedMult, type, damage, knockBack, player.whoAmI, 0f, 0f); - if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike + if (player.Calamity().StealthStrikeAvailable() && thunder.WithinBounds(Main.maxProjectiles)) //setting the stealth strike { Main.projectile[thunder].Calamity().stealthStrike = true; } diff --git a/Items/Weapons/Rogue/DesecratedWater.cs b/Items/Weapons/Rogue/DesecratedWater.cs index fb8ef41490..77a10e93a0 100644 --- a/Items/Weapons/Rogue/DesecratedWater.cs +++ b/Items/Weapons/Rogue/DesecratedWater.cs @@ -40,8 +40,9 @@ Stealth strikes spawn additional bubbles that inflict Ichor and Cursed Inferno") { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/DuneHopper.cs b/Items/Weapons/Rogue/DuneHopper.cs index 9c44f3eb67..f3aec20c73 100644 --- a/Items/Weapons/Rogue/DuneHopper.cs +++ b/Items/Weapons/Rogue/DuneHopper.cs @@ -45,7 +45,9 @@ Stealth strikes throw three high speed spears"); for (int i = 0; i < numProj + 1; i++) { Vector2 perturbedSpeed = new Vector2(speedX - 3f, speedY - 3f).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); - Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + int stealth = Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; } return false; } diff --git a/Items/Weapons/Rogue/DuststormInABottle.cs b/Items/Weapons/Rogue/DuststormInABottle.cs index a01a81e3f0..72c84da192 100644 --- a/Items/Weapons/Rogue/DuststormInABottle.cs +++ b/Items/Weapons/Rogue/DuststormInABottle.cs @@ -40,8 +40,9 @@ 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); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/EclipsesFall.cs b/Items/Weapons/Rogue/EclipsesFall.cs index a0fbe7bfc9..142b3cc07c 100644 --- a/Items/Weapons/Rogue/EclipsesFall.cs +++ b/Items/Weapons/Rogue/EclipsesFall.cs @@ -45,7 +45,8 @@ namespace CalamityMod.Items.Weapons.Rogue 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(); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/Rogue/EnchantedAxe.cs b/Items/Weapons/Rogue/EnchantedAxe.cs index f5f217b07c..d1bbdcf263 100644 --- a/Items/Weapons/Rogue/EnchantedAxe.cs +++ b/Items/Weapons/Rogue/EnchantedAxe.cs @@ -44,7 +44,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/EpidemicShredder.cs b/Items/Weapons/Rogue/EpidemicShredder.cs index 220cb62a14..9c73488ec1 100644 --- a/Items/Weapons/Rogue/EpidemicShredder.cs +++ b/Items/Weapons/Rogue/EpidemicShredder.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Weapons.Rogue Vector2 velocity = new Vector2(speedX, speedY); float strikeValue = player.Calamity().StealthStrikeAvailable().ToInt(); //0 if false, 1 if true int projectileIndex = Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, ai1: strikeValue); - if (player.Calamity().StealthStrikeAvailable()) + if (player.Calamity().StealthStrikeAvailable() && projectileIndex.WithinBounds(Main.maxProjectiles)) { Main.projectile[projectileIndex].Calamity().stealthStrike = strikeValue == 1f; } diff --git a/Items/Weapons/Rogue/Equanimity.cs b/Items/Weapons/Rogue/Equanimity.cs index 1edee00726..88517b6f66 100644 --- a/Items/Weapons/Rogue/Equanimity.cs +++ b/Items/Weapons/Rogue/Equanimity.cs @@ -42,7 +42,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/Eradicator.cs b/Items/Weapons/Rogue/Eradicator.cs index fb059737bb..b97a0b7671 100644 --- a/Items/Weapons/Rogue/Eradicator.cs +++ b/Items/Weapons/Rogue/Eradicator.cs @@ -40,7 +40,7 @@ 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) { int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (player.Calamity().StealthStrikeAvailable()) + if (player.Calamity().StealthStrikeAvailable() && proj.WithinBounds(Main.maxProjectiles)) { Main.projectile[proj].Calamity().stealthStrike = true; Main.projectile[proj].timeLeft *= 2; diff --git a/Items/Weapons/Rogue/ExecutionersBlade.cs b/Items/Weapons/Rogue/ExecutionersBlade.cs index 32601c3bca..b0847a1d7c 100644 --- a/Items/Weapons/Rogue/ExecutionersBlade.cs +++ b/Items/Weapons/Rogue/ExecutionersBlade.cs @@ -59,7 +59,7 @@ 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) { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (player.Calamity().StealthStrikeAvailable() && counter == 0) + if (player.Calamity().StealthStrikeAvailable() && counter == 0 && stealth.WithinBounds(Main.maxProjectiles)) { Main.projectile[stealth].Calamity().stealthStrike = true; } diff --git a/Items/Weapons/Rogue/Exorcism.cs b/Items/Weapons/Rogue/Exorcism.cs index f5e8a70cdc..7369d0d82b 100644 --- a/Items/Weapons/Rogue/Exorcism.cs +++ b/Items/Weapons/Rogue/Exorcism.cs @@ -42,7 +42,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 2f, damage); - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; } else { diff --git a/Items/Weapons/Rogue/FantasyTalisman.cs b/Items/Weapons/Rogue/FantasyTalisman.cs index 22df27c2bb..232fec546e 100644 --- a/Items/Weapons/Rogue/FantasyTalisman.cs +++ b/Items/Weapons/Rogue/FantasyTalisman.cs @@ -43,8 +43,9 @@ Stealth strikes release more souls and leave behind souls as they travel"); { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/FeatherKnife.cs b/Items/Weapons/Rogue/FeatherKnife.cs index ae706ef4a0..1626d4d8a3 100644 --- a/Items/Weapons/Rogue/FeatherKnife.cs +++ b/Items/Weapons/Rogue/FeatherKnife.cs @@ -55,8 +55,9 @@ Stealth strike throws a volley of knives"); for (int i = 0; i < 5; i++) { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-3, 4), speedY + Main.rand.Next(-3, 4)).RotatedBy(MathHelper.ToRadians(spread)); - int proj = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X, perturbedspeed.Y, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = true; + int proj = Projectile.NewProjectile(position, perturbedspeed, type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; spread -= Main.rand.Next(2, 6); } return false; diff --git a/Items/Weapons/Rogue/FlameScythe.cs b/Items/Weapons/Rogue/FlameScythe.cs index 8d1ae39829..ee85b8edcd 100644 --- a/Items/Weapons/Rogue/FlameScythe.cs +++ b/Items/Weapons/Rogue/FlameScythe.cs @@ -39,7 +39,8 @@ 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) { int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/Rogue/FrostcrushValari.cs b/Items/Weapons/Rogue/FrostcrushValari.cs index bd9f0a5943..80bcccc4bb 100644 --- a/Items/Weapons/Rogue/FrostcrushValari.cs +++ b/Items/Weapons/Rogue/FrostcrushValari.cs @@ -51,15 +51,17 @@ Stealth strikes throw three short ranged boomerangs along with a spread of icicl for (int i = 0; i < 3; i++) { Vector2 perturbedspeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(spread)); - int proj = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X, perturbedspeed.Y, type, damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[proj].Calamity().stealthStrike = true; + int proj = Projectile.NewProjectile(position, perturbedspeed, type, damage, knockBack, player.whoAmI, 0f, 1f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; spread -= 10; } int spread2 = 3; - for (int i = 0; i < Main.rand.Next(6,11); i++) + int icicleAmt = Main.rand.Next(6,11); + for (int i = 0; i < icicleAmt; i++) { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-3,4), speedY + Main.rand.Next(-3,4)).RotatedBy(MathHelper.ToRadians(spread2)); - Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X, perturbedspeed.Y, (Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType()), damage / 2, 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position, perturbedspeed, (Main.rand.NextBool(2) ? ModContent.ProjectileType() : ModContent.ProjectileType()), damage / 2, 0f, player.whoAmI, 0f, 0f); spread2 -= Main.rand.Next(1,4); } return false; diff --git a/Items/Weapons/Rogue/FrostyFlare.cs b/Items/Weapons/Rogue/FrostyFlare.cs index 8aa60e0f39..fe365030dc 100644 --- a/Items/Weapons/Rogue/FrostyFlare.cs +++ b/Items/Weapons/Rogue/FrostyFlare.cs @@ -44,8 +44,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int gemstone = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[gemstone].Calamity().stealthStrike = true; + int flare = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + if (flare.WithinBounds(Main.maxProjectiles)) + Main.projectile[flare].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/GelDart.cs b/Items/Weapons/Rogue/GelDart.cs index dc0f702264..c647325f51 100644 --- a/Items/Weapons/Rogue/GelDart.cs +++ b/Items/Weapons/Rogue/GelDart.cs @@ -42,11 +42,14 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; - Main.projectile[stealth].penetrate = 6; - Main.projectile[stealth].aiStyle = -1; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].usesLocalNPCImmunity = true; + Main.projectile[stealth].penetrate = 6; + Main.projectile[stealth].aiStyle = -1; + } return false; } return true; diff --git a/Items/Weapons/Rogue/GhoulishGouger.cs b/Items/Weapons/Rogue/GhoulishGouger.cs index b380c92430..836258c5da 100644 --- a/Items/Weapons/Rogue/GhoulishGouger.cs +++ b/Items/Weapons/Rogue/GhoulishGouger.cs @@ -46,8 +46,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = true; + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; } return true; } diff --git a/Items/Weapons/Rogue/GildedDagger.cs b/Items/Weapons/Rogue/GildedDagger.cs index 81f5cbe475..24ed00db91 100644 --- a/Items/Weapons/Rogue/GildedDagger.cs +++ b/Items/Weapons/Rogue/GildedDagger.cs @@ -42,8 +42,11 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[p].Calamity().stealthStrike = true; - Main.projectile[p].penetrate = 4; + if (p.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[p].Calamity().stealthStrike = true; + Main.projectile[p].penetrate = 4; + } return false; } return true; diff --git a/Items/Weapons/Rogue/Glaive.cs b/Items/Weapons/Rogue/Glaive.cs index aba7b11d9a..7be8f8762b 100644 --- a/Items/Weapons/Rogue/Glaive.cs +++ b/Items/Weapons/Rogue/Glaive.cs @@ -53,7 +53,7 @@ Stealth strikes are super fast and pierce infinitely"); } int p = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, ai1); - if (player.Calamity().StealthStrikeAvailable()) + if (player.Calamity().StealthStrikeAvailable() && p.WithinBounds(Main.maxProjectiles)) Main.projectile[p].Calamity().stealthStrike = true; return false; } diff --git a/Items/Weapons/Rogue/GleamingDagger.cs b/Items/Weapons/Rogue/GleamingDagger.cs index b39b386ae2..576019b434 100644 --- a/Items/Weapons/Rogue/GleamingDagger.cs +++ b/Items/Weapons/Rogue/GleamingDagger.cs @@ -42,8 +42,11 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[p].Calamity().stealthStrike = true; - Main.projectile[p].penetrate = 4; + if (p.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[p].Calamity().stealthStrike = true; + Main.projectile[p].penetrate = 4; + } return false; } return true; diff --git a/Items/Weapons/Rogue/GodsParanoia.cs b/Items/Weapons/Rogue/GodsParanoia.cs index 286efddbcf..5e26769048 100644 --- a/Items/Weapons/Rogue/GodsParanoia.cs +++ b/Items/Weapons/Rogue/GodsParanoia.cs @@ -70,8 +70,9 @@ Right click to delete all existing spiky balls"); modPlayer.killSpikyBalls = false; if (modPlayer.StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/HardenedHoneycomb.cs b/Items/Weapons/Rogue/HardenedHoneycomb.cs index 1838cbd016..d7c78fc17e 100644 --- a/Items/Weapons/Rogue/HardenedHoneycomb.cs +++ b/Items/Weapons/Rogue/HardenedHoneycomb.cs @@ -42,9 +42,12 @@ Stealth strikes can bounce off walls and enemies"); { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].penetrate = 3; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].penetrate = 3; + } return false; } return true; diff --git a/Items/Weapons/Rogue/HeavenfallenStardisk.cs b/Items/Weapons/Rogue/HeavenfallenStardisk.cs index 95ec66c1ef..c61f336ca6 100644 --- a/Items/Weapons/Rogue/HeavenfallenStardisk.cs +++ b/Items/Weapons/Rogue/HeavenfallenStardisk.cs @@ -41,12 +41,13 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int proj = Projectile.NewProjectile(position.X, position.Y, 0f, -10f, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = true; + int proj = Projectile.NewProjectile(position.X, position.Y, 0f, -10f, type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; } else { - Projectile.NewProjectile(position.X, position.Y, 0f, -10f, type, damage, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position.X, position.Y, 0f, -10f, type, damage, knockBack, player.whoAmI); } return false; } diff --git a/Items/Weapons/Rogue/HellsSun.cs b/Items/Weapons/Rogue/HellsSun.cs index 9cdd86c550..d5e790ac47 100644 --- a/Items/Weapons/Rogue/HellsSun.cs +++ b/Items/Weapons/Rogue/HellsSun.cs @@ -69,10 +69,13 @@ namespace CalamityMod.Items.Weapons.Rogue modPlayer.killSpikyBalls = false; if (modPlayer.StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), (int)(damage * SdamageMult), knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].penetrate = -1; - Main.projectile[stealth].timeLeft = 2400; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), (int)(damage * SdamageMult), knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].penetrate = -1; + Main.projectile[stealth].timeLeft = 2400; + } return false; } return true; diff --git a/Items/Weapons/Rogue/Hypothermia.cs b/Items/Weapons/Rogue/Hypothermia.cs index 5569f099ab..27bae8f060 100644 --- a/Items/Weapons/Rogue/Hypothermia.cs +++ b/Items/Weapons/Rogue/Hypothermia.cs @@ -49,7 +49,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable() && counter == 0) //setting up the stealth strikes { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; } int projAmt = Main.rand.Next(1, 3); for (int index = 0; index < projAmt; ++index) diff --git a/Items/Weapons/Rogue/IceStar.cs b/Items/Weapons/Rogue/IceStar.cs index 4a082ccfeb..5f953ae28c 100644 --- a/Items/Weapons/Rogue/IceStar.cs +++ b/Items/Weapons/Rogue/IceStar.cs @@ -43,8 +43,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = true; + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/Icebreaker.cs b/Items/Weapons/Rogue/Icebreaker.cs index a1aa6a5137..378166ed4f 100644 --- a/Items/Weapons/Rogue/Icebreaker.cs +++ b/Items/Weapons/Rogue/Icebreaker.cs @@ -38,8 +38,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/IchorSpear.cs b/Items/Weapons/Rogue/IchorSpear.cs index fa902a23b9..84a9b351e7 100644 --- a/Items/Weapons/Rogue/IchorSpear.cs +++ b/Items/Weapons/Rogue/IchorSpear.cs @@ -39,9 +39,12 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].usesLocalNPCImmunity = true; + } return false; } return true; diff --git a/Items/Weapons/Rogue/InfernalKris.cs b/Items/Weapons/Rogue/InfernalKris.cs index 7b369ce570..0aa15b8675 100644 --- a/Items/Weapons/Rogue/InfernalKris.cs +++ b/Items/Weapons/Rogue/InfernalKris.cs @@ -42,7 +42,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/IronFrancisca.cs b/Items/Weapons/Rogue/IronFrancisca.cs index 810a99d3e8..8fa383dfb1 100644 --- a/Items/Weapons/Rogue/IronFrancisca.cs +++ b/Items/Weapons/Rogue/IronFrancisca.cs @@ -42,7 +42,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/JawsOfOblivion.cs b/Items/Weapons/Rogue/JawsOfOblivion.cs index ec15ef1d98..a6feecad74 100644 --- a/Items/Weapons/Rogue/JawsOfOblivion.cs +++ b/Items/Weapons/Rogue/JawsOfOblivion.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { item.width = 42; - item.damage = 195; + item.damage = 292; item.noMelee = true; item.noUseGraphic = true; item.useAnimation = 15; @@ -52,12 +52,13 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { - int p = Projectile.NewProjectile(position.X, position.Y, currentDirection.X, currentDirection.Y, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[p].Calamity().stealthStrike = true; + int p = Projectile.NewProjectile(position, currentDirection, type, (int)(damage * 0.67), knockBack * 2f, player.whoAmI); + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; } else { - int p = Projectile.NewProjectile(position.X, position.Y, currentDirection.X, currentDirection.Y, type, (int)(damage * 1.5f), 10, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position, currentDirection, type, damage, knockBack, player.whoAmI); } } return false; diff --git a/Items/Weapons/Rogue/KelvinCatalyst.cs b/Items/Weapons/Rogue/KelvinCatalyst.cs index b984d71e0e..8acf4bb078 100644 --- a/Items/Weapons/Rogue/KelvinCatalyst.cs +++ b/Items/Weapons/Rogue/KelvinCatalyst.cs @@ -45,7 +45,8 @@ 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) { int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/Rogue/Kylie.cs b/Items/Weapons/Rogue/Kylie.cs index 046cc17f12..54e5e3ff57 100644 --- a/Items/Weapons/Rogue/Kylie.cs +++ b/Items/Weapons/Rogue/Kylie.cs @@ -47,8 +47,9 @@ namespace CalamityMod.Items.Weapons.Rogue for (int i = 0; i < 3; i++) { Vector2 perturbedspeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(spread)); - int proj = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X, perturbedspeed.Y, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[proj].Calamity().stealthStrike = true; + int proj = Projectile.NewProjectile(position, perturbedspeed, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 1f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; spread -= 10; } return false; diff --git a/Items/Weapons/Rogue/LatcherMine.cs b/Items/Weapons/Rogue/LatcherMine.cs index f2437be008..ff621da8e9 100644 --- a/Items/Weapons/Rogue/LatcherMine.cs +++ b/Items/Weapons/Rogue/LatcherMine.cs @@ -42,7 +42,8 @@ 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) { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - Main.projectile[stealth].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } } diff --git a/Items/Weapons/Rogue/LeadTomahawk.cs b/Items/Weapons/Rogue/LeadTomahawk.cs index fa1580de50..6f954cccac 100644 --- a/Items/Weapons/Rogue/LeadTomahawk.cs +++ b/Items/Weapons/Rogue/LeadTomahawk.cs @@ -42,7 +42,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/LeonidProgenitor.cs b/Items/Weapons/Rogue/LeonidProgenitor.cs index 8c62e55f99..d0d3138ce0 100644 --- a/Items/Weapons/Rogue/LeonidProgenitor.cs +++ b/Items/Weapons/Rogue/LeonidProgenitor.cs @@ -70,8 +70,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable() || player.altFunctionUse != 2) { - int bomb = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[bomb].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + int bomb = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (bomb.WithinBounds(Main.maxProjectiles)) + Main.projectile[bomb].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } else @@ -80,7 +81,7 @@ namespace CalamityMod.Items.Weapons.Rogue for (float i = -2.5f; i < 3f; ++i) { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); - Projectile.NewProjectile(position, perturbedSpeed, type, (int)(damage * dmgMult), knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position, perturbedSpeed, type, (int)(damage * dmgMult), knockBack, player.whoAmI); } } return false; diff --git a/Items/Weapons/Rogue/LeviathanTeeth.cs b/Items/Weapons/Rogue/LeviathanTeeth.cs index 4bde96dd81..a95c193d40 100644 --- a/Items/Weapons/Rogue/LeviathanTeeth.cs +++ b/Items/Weapons/Rogue/LeviathanTeeth.cs @@ -59,14 +59,18 @@ namespace CalamityMod.Items.Weapons.Rogue if (stealthStrike) { - int tooth = Projectile.NewProjectile(position.X, position.Y, offsetSpeedX * 1.5f, offsetSpeedY * 1.5f, type, damage, knockBack * 10f, player.whoAmI, 0f, 0f); - Main.projectile[tooth].Calamity().stealthStrike = true; - Main.projectile[tooth].Calamity().lineColor = Main.rand.Next(3); + int tooth = Projectile.NewProjectile(position.X, position.Y, offsetSpeedX * 1.5f, offsetSpeedY * 1.5f, type, damage, knockBack * 10f, player.whoAmI); + if (tooth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[tooth].Calamity().stealthStrike = true; + Main.projectile[tooth].Calamity().lineColor = Main.rand.Next(3); + } } else { - int tooth = Projectile.NewProjectile(position.X, position.Y, offsetSpeedX, offsetSpeedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[tooth].Calamity().lineColor = Main.rand.Next(3); + int tooth = Projectile.NewProjectile(position.X, position.Y, offsetSpeedX, offsetSpeedY, type, damage, knockBack, player.whoAmI); + if (tooth.WithinBounds(Main.maxProjectiles)) + Main.projectile[tooth].Calamity().lineColor = Main.rand.Next(3); } } return false; diff --git a/Items/Weapons/Rogue/Lionfish.cs b/Items/Weapons/Rogue/Lionfish.cs index 28db5d8cd3..a293b606d8 100644 --- a/Items/Weapons/Rogue/Lionfish.cs +++ b/Items/Weapons/Rogue/Lionfish.cs @@ -39,8 +39,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/LunarKunai.cs b/Items/Weapons/Rogue/LunarKunai.cs index dfb3b2071b..3b87eed575 100644 --- a/Items/Weapons/Rogue/LunarKunai.cs +++ b/Items/Weapons/Rogue/LunarKunai.cs @@ -78,7 +78,8 @@ namespace CalamityMod.Items.Weapons.Rogue float x4 = vector2.X; float y4 = vector2.Y; int stealth = Projectile.NewProjectile(x4, y4, num148, num149, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; } } else diff --git a/Items/Weapons/Rogue/Malachite.cs b/Items/Weapons/Rogue/Malachite.cs index 9cf65f1c0e..cfcb3d6e5a 100644 --- a/Items/Weapons/Rogue/Malachite.cs +++ b/Items/Weapons/Rogue/Malachite.cs @@ -75,8 +75,9 @@ namespace CalamityMod.Items.Weapons.Rogue for (float i = -6.5f; i <= 6.5f; i += 6.5f) { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); - int stealth = Projectile.NewProjectile(position, perturbedSpeed, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, perturbedSpeed, type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; } return false; } @@ -88,7 +89,7 @@ namespace CalamityMod.Items.Weapons.Rogue { dmgMult = 1f; } - Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * dmgMult), knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * dmgMult), knockBack, player.whoAmI); return false; } } diff --git a/Items/Weapons/Rogue/MangroveChakram.cs b/Items/Weapons/Rogue/MangroveChakram.cs index b8f9498dcd..f97f8811a0 100644 --- a/Items/Weapons/Rogue/MangroveChakram.cs +++ b/Items/Weapons/Rogue/MangroveChakram.cs @@ -38,7 +38,8 @@ 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) { int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/Rogue/MetalMonstrosity.cs b/Items/Weapons/Rogue/MetalMonstrosity.cs index 1062543202..c0f05723db 100644 --- a/Items/Weapons/Rogue/MetalMonstrosity.cs +++ b/Items/Weapons/Rogue/MetalMonstrosity.cs @@ -40,8 +40,8 @@ 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) { - int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - if (player.Calamity().StealthStrikeAvailable()) + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + if (player.Calamity().StealthStrikeAvailable() && proj.WithinBounds(Main.maxProjectiles)) Main.projectile[proj].Calamity().stealthStrike = true; return false; } diff --git a/Items/Weapons/Rogue/MeteorFist.cs b/Items/Weapons/Rogue/MeteorFist.cs index 52455782c0..14601e799c 100644 --- a/Items/Weapons/Rogue/MeteorFist.cs +++ b/Items/Weapons/Rogue/MeteorFist.cs @@ -50,7 +50,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 4f); - Main.projectile[proj].Calamity().stealthStrike = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/MoltenAmputator.cs b/Items/Weapons/Rogue/MoltenAmputator.cs index e64c29892c..e589d13102 100644 --- a/Items/Weapons/Rogue/MoltenAmputator.cs +++ b/Items/Weapons/Rogue/MoltenAmputator.cs @@ -40,8 +40,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int boomer = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[boomer].Calamity().stealthStrike = true; + int boomer = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (boomer.WithinBounds(Main.maxProjectiles)) + Main.projectile[boomer].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/MonkeyDarts.cs b/Items/Weapons/Rogue/MonkeyDarts.cs index b098270914..e93949b1fb 100644 --- a/Items/Weapons/Rogue/MonkeyDarts.cs +++ b/Items/Weapons/Rogue/MonkeyDarts.cs @@ -46,8 +46,9 @@ namespace CalamityMod.Items.Weapons.Rogue for (int i = 0; i < 3; i++) { Vector2 perturbedspeed = new Vector2(speedX * 1.25f, speedY * 1.25f).RotatedBy(MathHelper.ToRadians(spread)); - int p = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X, perturbedspeed.Y, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 1); - Main.projectile[p].Calamity().stealthStrike = true; + int p = Projectile.NewProjectile(position, perturbedspeed, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 1); + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; spread -= 7; } return false; diff --git a/Items/Weapons/Rogue/Mycoroot.cs b/Items/Weapons/Rogue/Mycoroot.cs index 74f9c4f3f8..d66eb957df 100644 --- a/Items/Weapons/Rogue/Mycoroot.cs +++ b/Items/Weapons/Rogue/Mycoroot.cs @@ -40,14 +40,15 @@ namespace CalamityMod.Items.Weapons.Rogue float SpeedX = speedX + Main.rand.NextFloat(-1.5f, 1.5f); float SpeedY = speedY + Main.rand.NextFloat(-1.5f, 1.5f); int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - if (player.Calamity().StealthStrikeAvailable() && player.ownedProjectileCounts[ModContent.ProjectileType()] < 20) + if (player.Calamity().StealthStrikeAvailable() && player.ownedProjectileCounts[ModContent.ProjectileType()] < 20 && stealth.WithinBounds(Main.maxProjectiles)) { Main.projectile[stealth].Calamity().stealthStrike = true; for (float i = 0; i < Main.rand.Next(7,11); i++) { Vector2 velocity = CalamityUtils.RandomVelocity(50f, 10f, 50f, 0.01f); int spore = Projectile.NewProjectile(player.Center, velocity, ModContent.ProjectileType(), (int)(damage * 0.5f), knockBack, player.whoAmI); - Main.projectile[spore].Calamity().lineColor = 1; + if (spore.WithinBounds(Main.maxProjectiles)) + Main.projectile[spore].Calamity().lineColor = 1; } } return false; diff --git a/Items/Weapons/Rogue/MythrilKnife.cs b/Items/Weapons/Rogue/MythrilKnife.cs index 032f75a77d..2c52c5d699 100644 --- a/Items/Weapons/Rogue/MythrilKnife.cs +++ b/Items/Weapons/Rogue/MythrilKnife.cs @@ -39,8 +39,9 @@ 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); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/NanoblackReaperRogue.cs b/Items/Weapons/Rogue/NanoblackReaperRogue.cs index 9fa59efe25..a504e2e86d 100644 --- a/Items/Weapons/Rogue/NanoblackReaperRogue.cs +++ b/Items/Weapons/Rogue/NanoblackReaperRogue.cs @@ -48,7 +48,8 @@ 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) { int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/Rogue/NastyCholla.cs b/Items/Weapons/Rogue/NastyCholla.cs index 95cea7ae77..e7f98653c2 100644 --- a/Items/Weapons/Rogue/NastyCholla.cs +++ b/Items/Weapons/Rogue/NastyCholla.cs @@ -48,8 +48,9 @@ Stealth strikes throw five at once"); for (int i = 0; i < 5; i++) { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-3,4), speedY + Main.rand.Next(-3,4)).RotatedBy(MathHelper.ToRadians(spread)); - int proj = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X, perturbedspeed.Y, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = true; + int proj = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X, perturbedspeed.Y, type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; spread -= Main.rand.Next(1,4); } return false; diff --git a/Items/Weapons/Rogue/NightsGaze.cs b/Items/Weapons/Rogue/NightsGaze.cs index 011aac2cbb..ce13b3e0f8 100644 --- a/Items/Weapons/Rogue/NightsGaze.cs +++ b/Items/Weapons/Rogue/NightsGaze.cs @@ -45,8 +45,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[p].Calamity().stealthStrike = true; + int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/Nychthemeron.cs b/Items/Weapons/Rogue/Nychthemeron.cs index 98d600c4ae..6effac672c 100644 --- a/Items/Weapons/Rogue/Nychthemeron.cs +++ b/Items/Weapons/Rogue/Nychthemeron.cs @@ -63,7 +63,8 @@ namespace CalamityMod.Items.Weapons.Rogue float spread = 2; int pIndex = Projectile.NewProjectile(position.X, position.Y, speedX + Main.rand.NextFloat(-spread, spread), speedY + Main.rand.NextFloat(-spread, spread), type, damage, knockBack, player.whoAmI, 0f, 1f); Projectile p = Main.projectile[pIndex]; - p.Calamity().stealthStrike = true; + if (pIndex.WithinBounds(Main.maxProjectiles)) + p.Calamity().stealthStrike = true; int pID = p.identity; CreateOrbs(position, orbDamage, knockBack, pID, player, true); @@ -157,12 +158,18 @@ namespace CalamityMod.Items.Weapons.Rogue float mult = stealth ? 0.75f : 1f; int orb1 = Projectile.NewProjectile(position, Vector2.Zero, ModContent.ProjectileType(), (int)(damage * mult), knockBack, player.whoAmI, orb1Col, projectileID); int orb2 = Projectile.NewProjectile(position, Vector2.Zero, ModContent.ProjectileType(), (int)(damage * mult), knockBack, player.whoAmI, orb2Col, projectileID); - Main.projectile[orb1].localAI[1] = pos; - Main.projectile[orb2].localAI[1] = pos; - Main.projectile[orb1].rotation = rotationOffset; - Main.projectile[orb2].rotation = rotationOffset + MathHelper.ToRadians(180f); - Main.projectile[orb1].Calamity().lineColor = stealth ? 1 : 0; - Main.projectile[orb2].Calamity().lineColor = stealth ? 1 : 0; + if (orb1.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[orb1].localAI[1] = pos; + Main.projectile[orb1].rotation = rotationOffset; + Main.projectile[orb1].Calamity().lineColor = stealth ? 1 : 0; + } + if (orb2.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[orb2].localAI[1] = pos; + Main.projectile[orb2].rotation = rotationOffset + MathHelper.ToRadians(180f); + Main.projectile[orb2].Calamity().lineColor = stealth ? 1 : 0; + } } } } diff --git a/Items/Weapons/Rogue/OrichalcumSpikedGemstone.cs b/Items/Weapons/Rogue/OrichalcumSpikedGemstone.cs index 55afca0c10..01720373ed 100644 --- a/Items/Weapons/Rogue/OrichalcumSpikedGemstone.cs +++ b/Items/Weapons/Rogue/OrichalcumSpikedGemstone.cs @@ -40,11 +40,14 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int gemstone = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[gemstone].Calamity().stealthStrike = true; - Main.projectile[gemstone].usesLocalNPCImmunity = true; - Main.projectile[gemstone].timeLeft = 900; - Main.projectile[gemstone].penetrate = -1; + int gemstone = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (gemstone.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[gemstone].Calamity().stealthStrike = true; + Main.projectile[gemstone].usesLocalNPCImmunity = true; + Main.projectile[gemstone].timeLeft = 900; + Main.projectile[gemstone].penetrate = -1; + } return false; } return true; diff --git a/Items/Weapons/Rogue/PalladiumJavelin.cs b/Items/Weapons/Rogue/PalladiumJavelin.cs index ea6eb6f105..fd2f415622 100644 --- a/Items/Weapons/Rogue/PalladiumJavelin.cs +++ b/Items/Weapons/Rogue/PalladiumJavelin.cs @@ -38,10 +38,13 @@ 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) { - int javelin = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[javelin].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); - if (!player.Calamity().StealthStrikeAvailable()) - Main.projectile[javelin].usesLocalNPCImmunity = false; + int javelin = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (javelin.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[javelin].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (!player.Calamity().StealthStrikeAvailable()) + Main.projectile[javelin].usesLocalNPCImmunity = false; + } return false; } diff --git a/Items/Weapons/Rogue/Penumbra.cs b/Items/Weapons/Rogue/Penumbra.cs index 76c004631d..60dbe22cc1 100644 --- a/Items/Weapons/Rogue/Penumbra.cs +++ b/Items/Weapons/Rogue/Penumbra.cs @@ -60,7 +60,8 @@ namespace CalamityMod.Items.Weapons.Rogue } vector2 += new Vector2(num78, num79); int proj = Projectile.NewProjectile(vector2, new Vector2(0f,-0.5f), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[proj].Calamity().stealthStrike = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/PhantasmalRuin.cs b/Items/Weapons/Rogue/PhantasmalRuin.cs index a751f1a99d..3f77cec34f 100644 --- a/Items/Weapons/Rogue/PhantasmalRuin.cs +++ b/Items/Weapons/Rogue/PhantasmalRuin.cs @@ -45,8 +45,9 @@ Stealth strikes summon ghost clones instead of lost souls"); { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 0.2), knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 0.2), knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/PhantomLance.cs b/Items/Weapons/Rogue/PhantomLance.cs index 616cf7307c..e0f10bf60c 100644 --- a/Items/Weapons/Rogue/PhantomLance.cs +++ b/Items/Weapons/Rogue/PhantomLance.cs @@ -47,8 +47,9 @@ Stealth strikes don't slow down and souls always deal full damage"); { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/Plaguenade.cs b/Items/Weapons/Rogue/Plaguenade.cs index 8c162bf461..b3a0c424e7 100644 --- a/Items/Weapons/Rogue/Plaguenade.cs +++ b/Items/Weapons/Rogue/Plaguenade.cs @@ -44,7 +44,9 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; + return false; } return true; } diff --git a/Items/Weapons/Rogue/PoisonPack.cs b/Items/Weapons/Rogue/PoisonPack.cs index 16ffc490fa..04b3e2b665 100644 --- a/Items/Weapons/Rogue/PoisonPack.cs +++ b/Items/Weapons/Rogue/PoisonPack.cs @@ -65,8 +65,9 @@ namespace CalamityMod.Items.Weapons.Rogue modPlayer.killSpikyBalls = false; if (modPlayer.StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/Prismalline.cs b/Items/Weapons/Rogue/Prismalline.cs index 81ff9d8208..25170ec6d5 100644 --- a/Items/Weapons/Rogue/Prismalline.cs +++ b/Items/Weapons/Rogue/Prismalline.cs @@ -42,8 +42,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = true; + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/ProfanedPartisan.cs b/Items/Weapons/Rogue/ProfanedPartisan.cs index 39a2dcb009..593bc0d309 100644 --- a/Items/Weapons/Rogue/ProfanedPartisan.cs +++ b/Items/Weapons/Rogue/ProfanedPartisan.cs @@ -45,8 +45,9 @@ Stealth strikes spawn smaller spears to fly along side it"); { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/ProfanedTrident.cs b/Items/Weapons/Rogue/ProfanedTrident.cs index d3696d625c..a7ffa0d01e 100644 --- a/Items/Weapons/Rogue/ProfanedTrident.cs +++ b/Items/Weapons/Rogue/ProfanedTrident.cs @@ -38,8 +38,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) { - int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } } diff --git a/Items/Weapons/Rogue/Quasar.cs b/Items/Weapons/Rogue/Quasar.cs index 18d82acb66..8ba7186dd1 100644 --- a/Items/Weapons/Rogue/Quasar.cs +++ b/Items/Weapons/Rogue/Quasar.cs @@ -39,8 +39,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) { - int knife = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[knife].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + int knife = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (knife.WithinBounds(Main.maxProjectiles)) + Main.projectile[knife].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } } diff --git a/Items/Weapons/Rogue/RadiantStar.cs b/Items/Weapons/Rogue/RadiantStar.cs index 144a4ad26a..6c04f55b87 100644 --- a/Items/Weapons/Rogue/RadiantStar.cs +++ b/Items/Weapons/Rogue/RadiantStar.cs @@ -54,8 +54,9 @@ 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); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/RegulusRiot.cs b/Items/Weapons/Rogue/RegulusRiot.cs index f646a017cb..b0a143bed9 100644 --- a/Items/Weapons/Rogue/RegulusRiot.cs +++ b/Items/Weapons/Rogue/RegulusRiot.cs @@ -42,8 +42,9 @@ Stealth strikes explode into energy stars"); { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/RotBall.cs b/Items/Weapons/Rogue/RotBall.cs index 66ae3177ef..900a2e2ba1 100644 --- a/Items/Weapons/Rogue/RotBall.cs +++ b/Items/Weapons/Rogue/RotBall.cs @@ -42,9 +42,12 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].usesLocalNPCImmunity = true; + } return false; } return true; diff --git a/Items/Weapons/Rogue/SandDollar.cs b/Items/Weapons/Rogue/SandDollar.cs index 919b973711..902fa869e2 100644 --- a/Items/Weapons/Rogue/SandDollar.cs +++ b/Items/Weapons/Rogue/SandDollar.cs @@ -59,8 +59,9 @@ namespace CalamityMod.Items.Weapons.Rogue for (int i = 0; i < 2; i++) { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-2,3), speedY + Main.rand.Next(-2,3)).RotatedBy(MathHelper.ToRadians(spread)); - int stealth = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X * 1.5f, perturbedspeed.Y * 1.5f, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X * 1.5f, perturbedspeed.Y * 1.5f, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; spread -= Main.rand.Next(1,3); } return false; diff --git a/Items/Weapons/Rogue/Sandslasher.cs b/Items/Weapons/Rogue/Sandslasher.cs index e9d124a1bc..6913d8f12b 100644 --- a/Items/Weapons/Rogue/Sandslasher.cs +++ b/Items/Weapons/Rogue/Sandslasher.cs @@ -39,10 +39,11 @@ 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()) { int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - Main.projectile[proj].Calamity().stealthStrike = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/ScourgeoftheDesert.cs b/Items/Weapons/Rogue/ScourgeoftheDesert.cs index f921a3f08b..4c41a80ca5 100644 --- a/Items/Weapons/Rogue/ScourgeoftheDesert.cs +++ b/Items/Weapons/Rogue/ScourgeoftheDesert.cs @@ -39,8 +39,9 @@ Stealth strikes gain damage as they damage enemies"); { if (player.Calamity().StealthStrikeAvailable()) { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/ScourgeoftheSeas.cs b/Items/Weapons/Rogue/ScourgeoftheSeas.cs index 2eacb0374e..6662d3f8e3 100644 --- a/Items/Weapons/Rogue/ScourgeoftheSeas.cs +++ b/Items/Weapons/Rogue/ScourgeoftheSeas.cs @@ -40,7 +40,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/SeafoamBomb.cs b/Items/Weapons/Rogue/SeafoamBomb.cs index 3949f42128..c9587be049 100644 --- a/Items/Weapons/Rogue/SeafoamBomb.cs +++ b/Items/Weapons/Rogue/SeafoamBomb.cs @@ -50,8 +50,9 @@ Stealth strikes are faster and explode into 5 bubbles"); { if (player.Calamity().StealthStrikeAvailable()) { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX + speedX / 3, speedY + speedY / 3), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX + speedX / 3, speedY + speedY / 3), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/SealedSingularity.cs b/Items/Weapons/Rogue/SealedSingularity.cs index d56a78eca5..328ba524c8 100644 --- a/Items/Weapons/Rogue/SealedSingularity.cs +++ b/Items/Weapons/Rogue/SealedSingularity.cs @@ -39,8 +39,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/SeashellBoomerang.cs b/Items/Weapons/Rogue/SeashellBoomerang.cs index c336006edf..62d9630284 100644 --- a/Items/Weapons/Rogue/SeashellBoomerang.cs +++ b/Items/Weapons/Rogue/SeashellBoomerang.cs @@ -37,7 +37,8 @@ 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) { int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/Rogue/ShatteredSun.cs b/Items/Weapons/Rogue/ShatteredSun.cs index 5bd1692dad..78710165ad 100644 --- a/Items/Weapons/Rogue/ShatteredSun.cs +++ b/Items/Weapons/Rogue/ShatteredSun.cs @@ -52,8 +52,9 @@ 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); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/ShinobiBlade.cs b/Items/Weapons/Rogue/ShinobiBlade.cs index 49d9401678..46e372ee0b 100644 --- a/Items/Weapons/Rogue/ShinobiBlade.cs +++ b/Items/Weapons/Rogue/ShinobiBlade.cs @@ -48,8 +48,9 @@ namespace CalamityMod.Items.Weapons.Rogue { Vector2 currentDirection = baseDirection.RotatedBy(spreadAngle * i); - int p = Projectile.NewProjectile(position.X, position.Y, currentDirection.X, currentDirection.Y, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[p].Calamity().stealthStrike = true; + int p = Projectile.NewProjectile(position, currentDirection, type, damage, knockBack, player.whoAmI); + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; } return false; } diff --git a/Items/Weapons/Rogue/ShockGrenade.cs b/Items/Weapons/Rogue/ShockGrenade.cs index ac9ad74334..4e8d3054da 100644 --- a/Items/Weapons/Rogue/ShockGrenade.cs +++ b/Items/Weapons/Rogue/ShockGrenade.cs @@ -41,8 +41,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[p].Calamity().stealthStrike = true; + int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/Shroomerang.cs b/Items/Weapons/Rogue/Shroomerang.cs index 77e213a379..9f29a2c245 100644 --- a/Items/Weapons/Rogue/Shroomerang.cs +++ b/Items/Weapons/Rogue/Shroomerang.cs @@ -38,8 +38,9 @@ Stealth strikes grant the Mushy buff to the user on enemy hits and summon homing { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/SkyStabber.cs b/Items/Weapons/Rogue/SkyStabber.cs index a20ed6cf8f..0eb7c38518 100644 --- a/Items/Weapons/Rogue/SkyStabber.cs +++ b/Items/Weapons/Rogue/SkyStabber.cs @@ -66,8 +66,9 @@ namespace CalamityMod.Items.Weapons.Rogue modPlayer.killSpikyBalls = false; if (modPlayer.StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/SkyfinBombers.cs b/Items/Weapons/Rogue/SkyfinBombers.cs index 1b8e090f74..aa59f6ef0b 100644 --- a/Items/Weapons/Rogue/SkyfinBombers.cs +++ b/Items/Weapons/Rogue/SkyfinBombers.cs @@ -43,8 +43,9 @@ namespace CalamityMod.Items.Weapons.Rogue for (int i = -8; i <= 8; i += 8) { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); - int stealth = Projectile.NewProjectile(position, perturbedSpeed, type, (int)(damage * 0.75), knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, perturbedSpeed, type, (int)(damage * 0.75), knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; } return false; } diff --git a/Items/Weapons/Rogue/SlickCane.cs b/Items/Weapons/Rogue/SlickCane.cs index 74348f00f1..57b474e5d3 100644 --- a/Items/Weapons/Rogue/SlickCane.cs +++ b/Items/Weapons/Rogue/SlickCane.cs @@ -44,7 +44,8 @@ namespace CalamityMod.Items.Weapons.Rogue { float ai0 = Main.rand.NextFloat() * item.shootSpeed * 0.75f * (float)player.direction; int projectileIndex = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, ai0, 0f); - Main.projectile[projectileIndex].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (projectileIndex.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectileIndex].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } } diff --git a/Items/Weapons/Rogue/SludgeSplotch.cs b/Items/Weapons/Rogue/SludgeSplotch.cs index ee70d93302..0325d4582e 100644 --- a/Items/Weapons/Rogue/SludgeSplotch.cs +++ b/Items/Weapons/Rogue/SludgeSplotch.cs @@ -44,7 +44,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX * 1.2f, speedY * 1.2f, type, damage, knockBack * 3, player.whoAmI, 0f, 1f); - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/SnapClam.cs b/Items/Weapons/Rogue/SnapClam.cs index bce343461f..4b5e3c4962 100644 --- a/Items/Weapons/Rogue/SnapClam.cs +++ b/Items/Weapons/Rogue/SnapClam.cs @@ -44,8 +44,9 @@ namespace CalamityMod.Items.Weapons.Rogue for (int i = 0; i < 5; i++) { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-3,4), speedY + Main.rand.Next(-3,4)).RotatedBy(MathHelper.ToRadians(spread)); - int proj = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X, perturbedspeed.Y, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = true; + int proj = Projectile.NewProjectile(position, perturbedspeed, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; spread -= Main.rand.Next(1,3); } return false; diff --git a/Items/Weapons/Rogue/SpearofDestiny.cs b/Items/Weapons/Rogue/SpearofDestiny.cs index 8801178ce1..9bc9c092e1 100644 --- a/Items/Weapons/Rogue/SpearofDestiny.cs +++ b/Items/Weapons/Rogue/SpearofDestiny.cs @@ -43,8 +43,9 @@ namespace CalamityMod.Items.Weapons.Rogue { int projType = (i != 0 || player.Calamity().StealthStrikeAvailable()) ? type : ModContent.ProjectileType(); Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); - int spear = Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, projType, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[spear].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + int spear = Projectile.NewProjectile(position, perturbedSpeed, projType, damage, knockBack, player.whoAmI); + if (spear.WithinBounds(Main.maxProjectiles)) + Main.projectile[spear].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); } return false; } diff --git a/Items/Weapons/Rogue/SpearofPaleolith.cs b/Items/Weapons/Rogue/SpearofPaleolith.cs index bc6571ad50..b532ed2cef 100644 --- a/Items/Weapons/Rogue/SpearofPaleolith.cs +++ b/Items/Weapons/Rogue/SpearofPaleolith.cs @@ -50,8 +50,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int stabDevice = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stabDevice].Calamity().stealthStrike = true; + int stabDevice = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stabDevice.WithinBounds(Main.maxProjectiles)) + Main.projectile[stabDevice].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/SpentFuelContainer.cs b/Items/Weapons/Rogue/SpentFuelContainer.cs index 29b3d4c4b3..79315e34b4 100644 --- a/Items/Weapons/Rogue/SpentFuelContainer.cs +++ b/Items/Weapons/Rogue/SpentFuelContainer.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Rogue Vector2 velocity = new Vector2(speedX, speedY); bool stealthAvailable = player.Calamity().StealthStrikeAvailable(); int p = Projectile.NewProjectile(position, velocity, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, stealthAvailable ? 1f : 0f); - if (stealthAvailable) + if (stealthAvailable && p.WithinBounds(Main.maxProjectiles)) Main.projectile[p].Calamity().stealthStrike = true; return false; } diff --git a/Items/Weapons/Rogue/StarofDestruction.cs b/Items/Weapons/Rogue/StarofDestruction.cs index fb30175d44..349f38f98f 100644 --- a/Items/Weapons/Rogue/StarofDestruction.cs +++ b/Items/Weapons/Rogue/StarofDestruction.cs @@ -41,7 +41,8 @@ namespace CalamityMod.Items.Weapons.Rogue 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; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/StellarKnife.cs b/Items/Weapons/Rogue/StellarKnife.cs index b55072e2f3..bec3a51b64 100644 --- a/Items/Weapons/Rogue/StellarKnife.cs +++ b/Items/Weapons/Rogue/StellarKnife.cs @@ -49,7 +49,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (knifeAmt <= 0) { int knife = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - Main.projectile[knife].Calamity().stealthStrike = true; + if (knife.WithinBounds(Main.maxProjectiles)) + Main.projectile[knife].Calamity().stealthStrike = true; } int spread = 20; @@ -58,7 +59,8 @@ namespace CalamityMod.Items.Weapons.Rogue speedX *= 0.9f; Vector2 perturbedspeed = new Vector2(speedX, speedY + Main.rand.Next(-3, 4)).RotatedBy(MathHelper.ToRadians(spread)); int knife2 = Projectile.NewProjectile(position, perturbedspeed, type, damage, knockBack, player.whoAmI, 1f, i % 5 == 0 ? 1f : 0f); - Main.projectile[knife2].Calamity().stealthStrike = true; + if (knife2.WithinBounds(Main.maxProjectiles)) + Main.projectile[knife2].Calamity().stealthStrike = true; spread -= Main.rand.Next(1, 3); } return false; diff --git a/Items/Weapons/Rogue/StickySpikyBall.cs b/Items/Weapons/Rogue/StickySpikyBall.cs index 28f78f1baf..5827c99ae3 100644 --- a/Items/Weapons/Rogue/StickySpikyBall.cs +++ b/Items/Weapons/Rogue/StickySpikyBall.cs @@ -44,10 +44,13 @@ Stealth strikes throw seven at once and last a lot longer"); for (int i = 0; i < 7; i++) { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-3,4), speedY + Main.rand.Next(-3,4)).RotatedBy(MathHelper.ToRadians(spread)); - int proj = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X, perturbedspeed.Y, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = true; - Main.projectile[proj].timeLeft *= 4; - Main.projectile[proj].localNPCHitCooldown += 15; + int proj = Projectile.NewProjectile(position, perturbedspeed, type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().stealthStrike = true; + Main.projectile[proj].timeLeft *= 4; + Main.projectile[proj].localNPCHitCooldown += 15; + } spread -= Main.rand.Next(1,4); } return false; diff --git a/Items/Weapons/Rogue/StormfrontRazor.cs b/Items/Weapons/Rogue/StormfrontRazor.cs index 65e3b12d14..01a06291b7 100644 --- a/Items/Weapons/Rogue/StormfrontRazor.cs +++ b/Items/Weapons/Rogue/StormfrontRazor.cs @@ -57,7 +57,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position, new Vector2(speedX * 1.6f, speedY * 1.6f), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0, 40f); - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } else diff --git a/Items/Weapons/Rogue/Supernova.cs b/Items/Weapons/Rogue/Supernova.cs index b2b02583b7..3572665031 100644 --- a/Items/Weapons/Rogue/Supernova.cs +++ b/Items/Weapons/Rogue/Supernova.cs @@ -43,8 +43,9 @@ Stealth strikes release energy as they fly"); { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/SylvanSlasher.cs b/Items/Weapons/Rogue/SylvanSlasher.cs index 1f7169befb..86ba61433a 100644 --- a/Items/Weapons/Rogue/SylvanSlasher.cs +++ b/Items/Weapons/Rogue/SylvanSlasher.cs @@ -38,7 +38,7 @@ Does not consume stealth and cannot stealth strike"); 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.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); return false; } } diff --git a/Items/Weapons/Rogue/TarragonThrowingDart.cs b/Items/Weapons/Rogue/TarragonThrowingDart.cs index 0c40848ac3..99b7d247b7 100644 --- a/Items/Weapons/Rogue/TarragonThrowingDart.cs +++ b/Items/Weapons/Rogue/TarragonThrowingDart.cs @@ -42,10 +42,13 @@ Stealth strikes erupt into thorns on enemy hits"); { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; - Main.projectile[stealth].usesIDStaticNPCImmunity = false; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].usesLocalNPCImmunity = true; + Main.projectile[stealth].usesIDStaticNPCImmunity = false; + } return false; } return true; diff --git a/Items/Weapons/Rogue/TerraDisk.cs b/Items/Weapons/Rogue/TerraDisk.cs index cdadb1e610..4bdb033c8b 100644 --- a/Items/Weapons/Rogue/TerraDisk.cs +++ b/Items/Weapons/Rogue/TerraDisk.cs @@ -70,7 +70,7 @@ Stealth strikes travel slower and are rapidly orbited by the smaller disks"); speedY *= 0.75f; } int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (player.Calamity().StealthStrikeAvailable()) + if (player.Calamity().StealthStrikeAvailable() && proj.WithinBounds(Main.maxProjectiles)) { Main.projectile[proj].Calamity().stealthStrike = true; } diff --git a/Items/Weapons/Rogue/TerrorTalons.cs b/Items/Weapons/Rogue/TerrorTalons.cs index e465d03bfd..ece77312ec 100644 --- a/Items/Weapons/Rogue/TerrorTalons.cs +++ b/Items/Weapons/Rogue/TerrorTalons.cs @@ -42,8 +42,9 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { float stealthDamageMult = 3.25f; - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), (int)(damage * stealthDamageMult), knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), (int)(damage * stealthDamageMult), knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; } else { diff --git a/Items/Weapons/Rogue/TheReaper.cs b/Items/Weapons/Rogue/TheReaper.cs index 69bc7cb8c9..dc48eb43b6 100644 --- a/Items/Weapons/Rogue/TheReaper.cs +++ b/Items/Weapons/Rogue/TheReaper.cs @@ -44,9 +44,12 @@ namespace CalamityMod.Items.Weapons.Rogue for (int i = 0; i < 4; i++) { Vector2 perturbedspeed = new Vector2(speedX + Main.rand.Next(-3,4), speedY + Main.rand.Next(-3,4)).RotatedBy(MathHelper.ToRadians(spread)); - int proj = Projectile.NewProjectile(position.X, position.Y, perturbedspeed.X, perturbedspeed.Y, type, damage / 2, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = true; - Main.projectile[proj].penetrate = 6; + int proj = Projectile.NewProjectile(position, perturbedspeed, type, damage / 2, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().stealthStrike = true; + Main.projectile[proj].penetrate = 6; + } spread -= Main.rand.Next(5,8); } return false; diff --git a/Items/Weapons/Rogue/TheSyringe.cs b/Items/Weapons/Rogue/TheSyringe.cs index f1087d35ad..4773a6f22b 100644 --- a/Items/Weapons/Rogue/TheSyringe.cs +++ b/Items/Weapons/Rogue/TheSyringe.cs @@ -45,8 +45,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 1f); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/ThrowingBrick.cs b/Items/Weapons/Rogue/ThrowingBrick.cs index e797b52c1c..6d8c328fcd 100644 --- a/Items/Weapons/Rogue/ThrowingBrick.cs +++ b/Items/Weapons/Rogue/ThrowingBrick.cs @@ -40,7 +40,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int p = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 1); - Main.projectile[p].Calamity().stealthStrike = true; + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/TimeBolt.cs b/Items/Weapons/Rogue/TimeBolt.cs index 1303d6996d..9994f60486 100644 --- a/Items/Weapons/Rogue/TimeBolt.cs +++ b/Items/Weapons/Rogue/TimeBolt.cs @@ -39,9 +39,12 @@ 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) { - int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); - Main.projectile[proj].penetrate = 11; + int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (player.Calamity().StealthStrikeAvailable() && proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().stealthStrike = true; + Main.projectile[proj].penetrate = 11; + } return false; } diff --git a/Items/Weapons/Rogue/TitaniumShuriken.cs b/Items/Weapons/Rogue/TitaniumShuriken.cs index 5bf4de4d84..954105d265 100644 --- a/Items/Weapons/Rogue/TitaniumShuriken.cs +++ b/Items/Weapons/Rogue/TitaniumShuriken.cs @@ -40,11 +40,14 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; - Main.projectile[stealth].aiStyle = -1; - Main.projectile[stealth].extraUpdates = 1; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].usesLocalNPCImmunity = true; + Main.projectile[stealth].aiStyle = -1; + Main.projectile[stealth].extraUpdates = 1; + } return false; } return true; diff --git a/Items/Weapons/Rogue/ToothBall.cs b/Items/Weapons/Rogue/ToothBall.cs index 317dc13453..492530ec1e 100644 --- a/Items/Weapons/Rogue/ToothBall.cs +++ b/Items/Weapons/Rogue/ToothBall.cs @@ -42,9 +42,12 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].usesLocalNPCImmunity = true; + } return false; } return true; diff --git a/Items/Weapons/Rogue/TotalityBreakers.cs b/Items/Weapons/Rogue/TotalityBreakers.cs index d0c954ec52..075649f649 100644 --- a/Items/Weapons/Rogue/TotalityBreakers.cs +++ b/Items/Weapons/Rogue/TotalityBreakers.cs @@ -41,8 +41,9 @@ Stealth strikes leak tar as they fly"); { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/ToxicantTwister.cs b/Items/Weapons/Rogue/ToxicantTwister.cs index 3ca00f2b2b..dba39cba0f 100644 --- a/Items/Weapons/Rogue/ToxicantTwister.cs +++ b/Items/Weapons/Rogue/ToxicantTwister.cs @@ -39,8 +39,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) { double stealthMult = player.Calamity().StealthStrikeAvailable() ? 1.3333 : 1D; - int boomer = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * stealthMult), knockBack, player.whoAmI, 0f, 0f); - Main.projectile[boomer].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + int boomer = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * stealthMult), knockBack, player.whoAmI); + if (boomer.WithinBounds(Main.maxProjectiles)) + Main.projectile[boomer].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } } diff --git a/Items/Weapons/Rogue/Turbulance.cs b/Items/Weapons/Rogue/Turbulance.cs index 0d02193358..170c38404a 100644 --- a/Items/Weapons/Rogue/Turbulance.cs +++ b/Items/Weapons/Rogue/Turbulance.cs @@ -41,8 +41,9 @@ Stealth strikes are trailed by homing wind slashes"); { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/UtensilPoker.cs b/Items/Weapons/Rogue/UtensilPoker.cs index 7c0be53283..205043b0d1 100644 --- a/Items/Weapons/Rogue/UtensilPoker.cs +++ b/Items/Weapons/Rogue/UtensilPoker.cs @@ -44,7 +44,8 @@ namespace CalamityMod.Items.Weapons.Rogue 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, player.whoAmI); - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; } int utensil = item.shoot; double dmgMult = 1D; diff --git a/Items/Weapons/Rogue/Valediction.cs b/Items/Weapons/Rogue/Valediction.cs index f047e1a40b..e8a62bd997 100644 --- a/Items/Weapons/Rogue/Valediction.cs +++ b/Items/Weapons/Rogue/Valediction.cs @@ -40,8 +40,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[stealth].Calamity().stealthStrike = true; + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/WebBall.cs b/Items/Weapons/Rogue/WebBall.cs index d95e54c019..1728385701 100644 --- a/Items/Weapons/Rogue/WebBall.cs +++ b/Items/Weapons/Rogue/WebBall.cs @@ -40,8 +40,9 @@ Stealth strikes slow enemies down longer"); { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, item.damage, item.knockBack, player.whoAmI, 0f, 0f); - Main.projectile[proj].Calamity().stealthStrike = true; + int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/Rogue/WulfrumKnife.cs b/Items/Weapons/Rogue/WulfrumKnife.cs index 2eac7df65c..91c60d655c 100644 --- a/Items/Weapons/Rogue/WulfrumKnife.cs +++ b/Items/Weapons/Rogue/WulfrumKnife.cs @@ -52,10 +52,13 @@ namespace CalamityMod.Items.Weapons.Rogue { int p = Projectile.NewProjectile(position, new Vector2(speedX, speedY) * 1.3f, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); Projectile proj = Main.projectile[p]; - proj.Calamity().stealthStrike = true; - proj.penetrate = 4; - proj.usesLocalNPCImmunity = true; - proj.localNPCHitCooldown = 1; + if (p.WithinBounds(Main.maxProjectiles)) + { + proj.Calamity().stealthStrike = true; + proj.penetrate = 4; + proj.usesLocalNPCImmunity = true; + proj.localNPCHitCooldown = 1; + } return false; } return true; diff --git a/Items/Weapons/Rogue/XerocPitchfork.cs b/Items/Weapons/Rogue/XerocPitchfork.cs index 86bd16da89..5636875c49 100644 --- a/Items/Weapons/Rogue/XerocPitchfork.cs +++ b/Items/Weapons/Rogue/XerocPitchfork.cs @@ -42,7 +42,8 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; } return !player.Calamity().StealthStrikeAvailable(); } diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 229b047a74..7fbc6a34f3 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -1137,8 +1137,9 @@ namespace CalamityMod.Projectiles for (int i = 0; i < 2; i++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int shard = Projectile.NewProjectile(projectile.Center, velocity, ProjectileID.CrystalShard, CalamityUtils.DamageSoftCap(projectile.damage * 0.25, 30), 0f, projectile.owner, 0f, 0f); - Main.projectile[shard].Calamity().forceTypeless = true; + int shard = Projectile.NewProjectile(projectile.Center, velocity, ProjectileID.CrystalShard, CalamityUtils.DamageSoftCap(projectile.damage * 0.25, 30), 0f, projectile.owner); + if (shard.WithinBounds(Main.maxProjectiles)) + Main.projectile[shard].Calamity().forceTypeless = true; } } } @@ -1830,7 +1831,8 @@ namespace CalamityMod.Projectiles int projectile2 = Projectile.NewProjectile(value.X, value.Y, velocity.X, velocity.Y, spawnedProjectile, (int)(projectile.damage * damageMult), projectile.knockBack, projectile.owner, 0f, 0f); if (projectile.type == ProjectileType()) - Main.projectile[projectile2].Calamity().forceRogue = true; + if (projectile2.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile2].Calamity().forceRogue = true; } } @@ -1849,10 +1851,12 @@ namespace CalamityMod.Projectiles if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType() || projectile.type == ProjectileType()) - Main.projectile[projectile2].Calamity().forceMelee = true; + if (projectile2.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile2].Calamity().forceMelee = true; if (projectile.type == ProjectileType()) - Main.projectile[projectile2].Calamity().forceRogue = true; + if (projectile2.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile2].Calamity().forceRogue = true; } } } diff --git a/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs b/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs index 3e153fb70a..234ce8baa8 100644 --- a/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs +++ b/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs @@ -138,10 +138,13 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (Main.myPlayer != projectile.owner) return; Projectile field = Projectile.NewProjectileDirect(projectile.Center, Vector2.Zero, ProjectileID.Electrosphere, projectile.damage, projectile.knockBack, projectile.owner); - field.Calamity().forceMelee = true; - field.usesLocalNPCImmunity = true; - field.localNPCHitCooldown = 3; - field.timeLeft = 12; + if (field.whoAmI.WithinBounds(Main.maxProjectiles)) + { + field.Calamity().forceMelee = true; + field.usesLocalNPCImmunity = true; + field.localNPCHitCooldown = 3; + field.timeLeft = 12; + } } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Environment/LightningMark.cs b/Projectiles/Environment/LightningMark.cs index 89d97820f3..a4b81b6491 100644 --- a/Projectiles/Environment/LightningMark.cs +++ b/Projectiles/Environment/LightningMark.cs @@ -50,9 +50,12 @@ namespace CalamityMod.Projectiles.Environment int damage = NPC.downedMoonlord ? 80 : NPC.downedPlantBoss ? 40 : Main.hardMode ? 20 : 10; int proj = Projectile.NewProjectile(fireFrom, velocity, ProjectileID.CultistBossLightningOrbArc, damage, 0f, projectile.owner, ai0.ToRotation(), ai); - Main.projectile[proj].extraUpdates += 11; - Main.projectile[proj].friendly = true; - Main.projectile[proj].Calamity().lineColor = 1; + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].extraUpdates += 11; + Main.projectile[proj].friendly = true; + Main.projectile[proj].Calamity().lineColor = 1; + } } } else if (projectile.velocity.Y == 0f) diff --git a/Projectiles/Magic/HolyLaser.cs b/Projectiles/Magic/HolyLaser.cs index 0c4fee34f3..f86eb715bb 100644 --- a/Projectiles/Magic/HolyLaser.cs +++ b/Projectiles/Magic/HolyLaser.cs @@ -53,8 +53,9 @@ namespace CalamityMod.Projectiles.Magic { if (projectile.owner == Main.myPlayer) { - int proj = 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[proj].Calamity().forceMagic = true; + int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMagic = true; } } } diff --git a/Projectiles/Magic/IceBarrageMain.cs b/Projectiles/Magic/IceBarrageMain.cs index 4e9b23e3c7..c63f4849b1 100644 --- a/Projectiles/Magic/IceBarrageMain.cs +++ b/Projectiles/Magic/IceBarrageMain.cs @@ -156,9 +156,12 @@ namespace CalamityMod.Projectiles.Magic { Vector2 projspeed = new Vector2(Main.rand.NextFloat(-5f, 5f), Main.rand.NextFloat(-5f, 5f)); int ice = Projectile.NewProjectile(projectile.Center, projspeed, ProjectileID.NorthPoleSnowflake, (int)(projectile.damage * 0.05f), 2f, projectile.owner, 0f, (float)Main.rand.Next(3)); - Main.projectile[ice].timeLeft = 600; - Main.projectile[ice].melee = false; - Main.projectile[ice].Calamity().forceMagic = true; + if (ice.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[ice].timeLeft = 600; + Main.projectile[ice].melee = false; + Main.projectile[ice].Calamity().forceMagic = true; + } projectile.ai[1] = 0f; } } diff --git a/Projectiles/Magic/InfernadoFriendly.cs b/Projectiles/Magic/InfernadoFriendly.cs index 28b5b6d6ad..07a70202d7 100644 --- a/Projectiles/Magic/InfernadoFriendly.cs +++ b/Projectiles/Magic/InfernadoFriendly.cs @@ -100,12 +100,15 @@ namespace CalamityMod.Projectiles.Magic center.Y += 2f; Projectile segment = Projectile.NewProjectileDirect(center, projectile.velocity, projectile.type, projectile.damage, projectile.knockBack, projectile.owner, 10f, projectile.ai[1] - 1f); //Defaults to magic - segment.Calamity().forceMelee = projectile.Calamity().forceMelee; - segment.Calamity().forceRanged = projectile.Calamity().forceRanged; - segment.Calamity().forceMinion = projectile.Calamity().forceMinion; - segment.Calamity().forceRogue = projectile.Calamity().forceRogue; - segment.Calamity().forceTypeless = projectile.Calamity().forceTypeless; - segment.Calamity().forceHostile = projectile.Calamity().forceHostile; + if (segment.whoAmI.WithinBounds(Main.maxProjectiles)) + { + segment.Calamity().forceMelee = projectile.Calamity().forceMelee; + segment.Calamity().forceRanged = projectile.Calamity().forceRanged; + segment.Calamity().forceMinion = projectile.Calamity().forceMinion; + segment.Calamity().forceRogue = projectile.Calamity().forceRogue; + segment.Calamity().forceTypeless = projectile.Calamity().forceTypeless; + segment.Calamity().forceHostile = projectile.Calamity().forceHostile; + } } if (projectile.ai[0] <= 0f) { diff --git a/Projectiles/Magic/SolarBeam2.cs b/Projectiles/Magic/SolarBeam2.cs index dbfacdc075..a20626f7e0 100644 --- a/Projectiles/Magic/SolarBeam2.cs +++ b/Projectiles/Magic/SolarBeam2.cs @@ -69,8 +69,9 @@ namespace CalamityMod.Projectiles.Magic target.immune[projectile.owner] = 4; if (projectile.owner == Main.myPlayer) { - int proj = 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[proj].Calamity().forceMagic = true; + int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMagic = true; } } } diff --git a/Projectiles/Magic/SparklingBeam.cs b/Projectiles/Magic/SparklingBeam.cs index cd46efefb5..4cc901c557 100644 --- a/Projectiles/Magic/SparklingBeam.cs +++ b/Projectiles/Magic/SparklingBeam.cs @@ -111,15 +111,16 @@ namespace CalamityMod.Projectiles.Magic if (target.life <= 0) { Player player = Main.player[projectile.owner]; - int shardDamage = (int)((SparklingEmpress.BaseDamage / 5) * player.MagicDamage()); + int shardDamage = projectile.damage / 5; int shardAmt = Main.rand.Next(2, 4); if (projectile.owner == Main.myPlayer) { for (int s = 0; s < shardAmt; s++) { 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; + int shard = Projectile.NewProjectile(target.Center, velocity, ModContent.ProjectileType(), shardDamage, 0f, projectile.owner); + if (shard.WithinBounds(Main.maxProjectiles)) + Main.projectile[shard].Calamity().forceMagic = true; } } } diff --git a/Projectiles/Magic/ThunderstormShot.cs b/Projectiles/Magic/ThunderstormShot.cs index 312706749e..2ba4ed5531 100644 --- a/Projectiles/Magic/ThunderstormShot.cs +++ b/Projectiles/Magic/ThunderstormShot.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Magic Main.PlaySound(SoundID.Item125, projectile.Center); for (int n = 0; n < 5; n++) { - CalamityUtils.ProjectileRain(projectile.Center, 200f, 100f, 1500f, 1500f, 29f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, projectile.owner); + CalamityUtils.ProjectileRain(projectile.Center, 200f, 100f, 1500f, 1500f, 29f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); } CalamityGlobalProjectile.ExpandHitboxBy(projectile, 36); int num226 = 36; diff --git a/Projectiles/Melee/CometQuasherMeteor.cs b/Projectiles/Melee/CometQuasherMeteor.cs index 51ed40cdf6..eeac7965b9 100644 --- a/Projectiles/Melee/CometQuasherMeteor.cs +++ b/Projectiles/Melee/CometQuasherMeteor.cs @@ -41,12 +41,7 @@ namespace CalamityMod.Projectiles.Melee public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item89, projectile.position); - projectile.position.X += (float)(projectile.width / 2); - projectile.position.Y += (float)(projectile.height / 2); - projectile.width = (int)(128f * projectile.scale); - projectile.height = (int)(128f * projectile.scale); - projectile.position.X -= (float)(projectile.width / 2); - projectile.position.Y -= (float)(projectile.height / 2); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(128f * projectile.scale)); for (int index = 0; index < 8; ++index) Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0.0f, 0.0f, 100, new Color(), 1.5f); for (int index1 = 0; index1 < 32; ++index1) diff --git a/Projectiles/Melee/DragonPowFlail.cs b/Projectiles/Melee/DragonPowFlail.cs index a335681163..aa1a91bf9b 100644 --- a/Projectiles/Melee/DragonPowFlail.cs +++ b/Projectiles/Melee/DragonPowFlail.cs @@ -182,10 +182,13 @@ namespace CalamityMod.Projectiles.Melee { 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; + if (petal.whoAmI.WithinBounds(Main.maxProjectiles)) + { + petal.Calamity().forceMelee = true; + petal.rotation = angle; + petal.usesLocalNPCImmunity = true; + petal.localNPCHitCooldown = -1; + } } } } diff --git a/Projectiles/Melee/FallenPaladinsHammerProj.cs b/Projectiles/Melee/FallenPaladinsHammerProj.cs index 49dc78e2f6..aef64d06ec 100644 --- a/Projectiles/Melee/FallenPaladinsHammerProj.cs +++ b/Projectiles/Melee/FallenPaladinsHammerProj.cs @@ -106,20 +106,22 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 300); - if (projectile.owner == Main.myPlayer) - { - int proj = 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[proj].Calamity().forceMelee = true; - } + OnHitEffect(); } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 300); + OnHitEffect(); + } + + private void OnHitEffect() + { if (projectile.owner == Main.myPlayer) { - int proj = 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[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } } diff --git a/Projectiles/Melee/Galaxia.cs b/Projectiles/Melee/Galaxia.cs index effeaf16c3..ef2a781f48 100644 --- a/Projectiles/Melee/Galaxia.cs +++ b/Projectiles/Melee/Galaxia.cs @@ -137,113 +137,141 @@ namespace CalamityMod.Projectiles.Melee { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(ModContent.BuffType(), 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } else if (jungle) { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.Thorns, 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.Leaf, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.Leaf, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } else if (snow) { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.Warmth, 600); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.IceBolt, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.IceBolt, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); } else if (beach) { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.Wet, 600); int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, ProjectileID.FlaironBubble, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } else if (corrupt) { player.AddBuff(BuffID.Wrath, 600); - int ball = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.CursedFlameFriendly, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[ball].Calamity().forceMelee = true; - Main.projectile[ball].penetrate = 1; + int ball = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.CursedFlameFriendly, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (ball.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[ball].Calamity().forceMelee = true; + Main.projectile[ball].penetrate = 1; + } } else if (crimson) { player.AddBuff(BuffID.Rage, 600); - int ball = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.GoldenShowerFriendly, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[ball].Calamity().forceMelee = true; - Main.projectile[ball].penetrate = 1; + int ball = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.GoldenShowerFriendly, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (ball.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[ball].Calamity().forceMelee = true; + Main.projectile[ball].penetrate = 1; + } } else if (dungeon) { target.AddBuff(BuffID.Frostburn, 1200); player.AddBuff(BuffID.Dangersense, 600); - int ball = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.WaterBolt, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[ball].Calamity().forceMelee = true; - Main.projectile[ball].penetrate = 1; + int ball = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.WaterBolt, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (ball.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[ball].Calamity().forceMelee = true; + Main.projectile[ball].penetrate = 1; + } } else if (desert) { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.Endurance, 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.BlackBolt, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.BlackBolt, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } else if (glow) { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.Spelunker, 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.Mushroom, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.Mushroom, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } else if (hell) { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.Inferno, 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.BallofFire, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.BallofFire, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } else if (holy) { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.Heartreach, 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.RainbowCrystalExplosion, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = -1; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.RainbowCrystalExplosion, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = -1; + } } else if (nebula) { player.AddBuff(BuffID.MagicPower, 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.NebulaBlaze1, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.NebulaBlaze1, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } else if (stardust) { player.AddBuff(BuffID.Summoning, 600); - int ball = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.StardustCellMinionShot, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[ball].Calamity().forceMelee = true; - Main.projectile[ball].penetrate = 1; + int ball = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.StardustCellMinionShot, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (ball.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[ball].Calamity().forceMelee = true; + Main.projectile[ball].penetrate = 1; + } } else if (solar) { player.AddBuff(BuffID.Titan, 600); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.SolarWhipSwordExplosion, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.SolarWhipSwordExplosion, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); } else if (vortex) { player.AddBuff(BuffID.AmmoReservation, 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.VortexBeaterRocket, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = -1; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.VortexBeaterRocket, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = -1; + } } else { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.DryadsWard, 600); - int ball = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.TerrarianBeam, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[ball].penetrate = 1; + int ball = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.TerrarianBeam, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + if (ball.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[ball].penetrate = 1; + } } } } diff --git a/Projectiles/Melee/Galaxia2.cs b/Projectiles/Melee/Galaxia2.cs index 860241cabc..549f18cfc4 100644 --- a/Projectiles/Melee/Galaxia2.cs +++ b/Projectiles/Melee/Galaxia2.cs @@ -138,113 +138,139 @@ namespace CalamityMod.Projectiles.Melee { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(ModContent.BuffType(), 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } else if (jungle) { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.Thorns, 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.Leaf, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.Leaf, projectile.damage, projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } else if (snow) { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.Warmth, 600); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.IceBolt, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.IceBolt, projectile.damage, projectile.knockBack, projectile.owner); } else if (beach) { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.Wet, 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, ProjectileID.FlaironBubble, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, ProjectileID.FlaironBubble, projectile.damage, projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } else if (corrupt) { player.AddBuff(BuffID.Wrath, 600); - int ball = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.CursedFlameFriendly, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[ball].Calamity().forceMelee = true; - Main.projectile[ball].penetrate = 1; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.CursedFlameFriendly, projectile.damage, projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].penetrate = 1; + } } else if (crimson) { player.AddBuff(BuffID.Rage, 600); - int ball = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.GoldenShowerFriendly, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[ball].Calamity().forceMelee = true; - Main.projectile[ball].penetrate = 1; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.GoldenShowerFriendly, projectile.damage, projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].penetrate = 1; + } } else if (dungeon) { target.AddBuff(BuffID.Frostburn, 1200); player.AddBuff(BuffID.Dangersense, 600); - int ball = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.WaterBolt, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[ball].Calamity().forceMelee = true; - Main.projectile[ball].penetrate = 1; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.WaterBolt, projectile.damage, projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].penetrate = 1; + } } else if (desert) { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.Endurance, 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.BlackBolt, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.BlackBolt, projectile.damage, projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } else if (glow) { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.Spelunker, 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.Mushroom, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.Mushroom, projectile.damage, projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } else if (hell) { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.Inferno, 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.BallofFire, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.BallofFire, projectile.damage, projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } else if (holy) { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.Heartreach, 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.RainbowCrystalExplosion, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = -1; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.RainbowCrystalExplosion, projectile.damage, projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = -1; + } } else if (nebula) { player.AddBuff(BuffID.MagicPower, 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.NebulaBlaze1, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.NebulaBlaze1, projectile.damage, projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } else if (stardust) { player.AddBuff(BuffID.Summoning, 600); - int ball = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.StardustCellMinionShot, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[ball].Calamity().forceMelee = true; - Main.projectile[ball].penetrate = 1; + int ball = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.StardustCellMinionShot, projectile.damage, projectile.knockBack, projectile.owner); + if (ball.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[ball].Calamity().forceMelee = true; + Main.projectile[ball].penetrate = 1; + } } else if (solar) { player.AddBuff(BuffID.Titan, 600); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.SolarWhipSwordExplosion, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.SolarWhipSwordExplosion, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); } else if (vortex) { player.AddBuff(BuffID.AmmoReservation, 600); - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.VortexBeaterRocket, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = -1; + int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.VortexBeaterRocket, projectile.damage, projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = -1; + } } else { target.AddBuff(ModContent.BuffType(), 1200); player.AddBuff(BuffID.DryadsWard, 600); - int ball = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X, projectile.velocity.Y, ProjectileID.TerrarianBeam, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[ball].penetrate = 1; + int ball = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.TerrarianBeam, projectile.damage, projectile.knockBack, projectile.owner); + if (ball.WithinBounds(Main.maxProjectiles)) + Main.projectile[ball].penetrate = 1; } } } diff --git a/Projectiles/Melee/GalaxySmasherHammer.cs b/Projectiles/Melee/GalaxySmasherHammer.cs index 1af2910ce5..96b93f1f3c 100644 --- a/Projectiles/Melee/GalaxySmasherHammer.cs +++ b/Projectiles/Melee/GalaxySmasherHammer.cs @@ -140,11 +140,25 @@ namespace CalamityMod.Projectiles.Melee } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + // Applies God Slayer Inferno on contact. + target.AddBuff(ModContent.BuffType(), 480); + OnHitEffect(target.Center); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + // Applies God Slayer Inferno on contact. + target.AddBuff(ModContent.BuffType(), 480); + OnHitEffect(target.Center); + } + + private void OnHitEffect(Vector2 targetPos) { // Some dust gets produced on impact. int dustSets = Main.rand.Next(5, 8); int dustRadius = 6; - Vector2 corner = new Vector2(target.Center.X - dustRadius, target.Center.Y - dustRadius); + Vector2 corner = new Vector2(targetPos.X - dustRadius, targetPos.Y - dustRadius); for (int i = 0; i < dustSets; ++i) { // Bigger, flying orb dust @@ -169,9 +183,6 @@ namespace CalamityMod.Projectiles.Melee // Makes an explosion sound. Main.PlaySound(SoundID.Item14, projectile.position); - // Applies God Slayer Inferno on contact. - target.AddBuff(ModContent.BuffType(), 480); - // Three death lasers (aka "Nebula Shots") swarm the target. int laserID = ModContent.ProjectileType(); int laserDamage = (int)(0.2f * projectile.damage); @@ -181,7 +192,7 @@ namespace CalamityMod.Projectiles.Melee { float startDist = Main.rand.NextFloat(260f, 270f); Vector2 startDir = Main.rand.NextVector2Unit(); - Vector2 startPoint = target.Center + startDir * startDist; + Vector2 startPoint = targetPos + startDir * startDist; float laserSpeed = Main.rand.NextFloat(15f, 18f); Vector2 velocity = startDir * -laserSpeed; @@ -189,67 +200,12 @@ namespace CalamityMod.Projectiles.Melee if (projectile.owner == Main.myPlayer) { int proj = Projectile.NewProjectile(startPoint, velocity, laserID, laserDamage, laserKB, projectile.owner); - Main.projectile[proj].Calamity().forceMelee = true; - Main.projectile[proj].tileCollide = false; - Main.projectile[proj].timeLeft = 30; - } - } - } - - public override void OnHitPvp(Player target, int damage, bool crit) - { - // Some dust gets produced on impact. - int dustSets = Main.rand.Next(5, 8); - int dustRadius = 6; - Vector2 corner = new Vector2(target.Center.X - dustRadius, target.Center.Y - dustRadius); - for (int i = 0; i < dustSets; ++i) - { - // Bigger, flying orb dust - float scaleOrb = 1.2f + Main.rand.NextFloat(1f); - int orb = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, 112); - Main.dust[orb].noGravity = true; - Main.dust[orb].velocity *= 4f; - Main.dust[orb].scale = scaleOrb; - - // Add six sparkles per flying orb - for (int j = 0; j < 6; ++j) - { - float scaleSparkle = 0.8f + Main.rand.NextFloat(1.1f); - int sparkle = Dust.NewDust(corner, 2 * dustRadius, 2 * dustRadius, 173); - Main.dust[sparkle].noGravity = true; - float dustSpeed = Main.rand.NextFloat(10f, 18f); - Main.dust[sparkle].velocity = Main.rand.NextVector2Unit() * dustSpeed; - Main.dust[sparkle].scale = scaleSparkle; - } - } - - // Makes an explosion sound. - Main.PlaySound(SoundID.Item14, projectile.position); - - // Applies God Slayer Inferno on contact. - target.AddBuff(ModContent.BuffType(), 480); - - // Three death lasers (aka "Nebula Shots") swarm the target. - int laserID = ModContent.ProjectileType(); - int laserDamage = (int)(0.2f * projectile.damage); - float laserKB = 2.5f; - int numLasers = 3; - for (int i = 0; i < numLasers; ++i) - { - float startDist = Main.rand.NextFloat(260f, 270f); - Vector2 startDir = Main.rand.NextVector2Unit(); - Vector2 startPoint = target.Center + startDir * startDist; - - float laserSpeed = Main.rand.NextFloat(15f, 18f); - Vector2 velocity = startDir * -laserSpeed; - - // NebulaShot projectile adjusts its own damage type based on ai[0]. So set it to 1f - if (projectile.owner == Main.myPlayer) - { - float damageType = 1f; - int proj = Projectile.NewProjectile(startPoint, velocity, laserID, laserDamage, laserKB, projectile.owner, damageType, 0f); - Main.projectile[proj].tileCollide = false; - Main.projectile[proj].timeLeft = 30; + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].tileCollide = false; + Main.projectile[proj].timeLeft = 30; + } } } } diff --git a/Projectiles/Melee/HellionSpike.cs b/Projectiles/Melee/HellionSpike.cs index 64c2de990b..dba9fe779f 100644 --- a/Projectiles/Melee/HellionSpike.cs +++ b/Projectiles/Melee/HellionSpike.cs @@ -73,8 +73,11 @@ namespace CalamityMod.Projectiles.Melee if (projectile.owner == Main.myPlayer) { 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; + if (petal.whoAmI.WithinBounds(Main.maxProjectiles)) + { + petal.Calamity().forceMelee = true; + petal.localNPCHitCooldown = -1; + } } } } diff --git a/Projectiles/Melee/IceBombFriendly.cs b/Projectiles/Melee/IceBombFriendly.cs index a6faae4750..64d6973bde 100644 --- a/Projectiles/Melee/IceBombFriendly.cs +++ b/Projectiles/Melee/IceBombFriendly.cs @@ -50,9 +50,11 @@ namespace CalamityMod.Projectiles.Melee { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; int projectile1 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ProjectileID.FrostShard, (int)(projectile.damage * 0.5), 0f, projectile.owner, 0f, 0f); - Main.projectile[projectile1].Calamity().forceMelee = true; + if (projectile1.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile1].Calamity().forceMelee = true; int projectile2 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ProjectileID.FrostShard, (int)(projectile.damage * 0.5), 0f, projectile.owner, 0f, 0f); - Main.projectile[projectile2].Calamity().forceMelee = true; + if (projectile2.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectile2].Calamity().forceMelee = true; } } for (int k = 0; k < 3; k++) diff --git a/Projectiles/Melee/LaserFountain.cs b/Projectiles/Melee/LaserFountain.cs index 07fd5e9533..e04bb71148 100644 --- a/Projectiles/Melee/LaserFountain.cs +++ b/Projectiles/Melee/LaserFountain.cs @@ -33,8 +33,11 @@ namespace CalamityMod.Projectiles.Melee if (projectile.owner == Main.myPlayer) { int projectile1 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(350f * Main.player[projectile.owner].MeleeDamage()), projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[projectile1].Calamity().forceMelee = true; - Main.projectile[projectile1].aiStyle = 1; + if (projectile1.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[projectile1].Calamity().forceMelee = true; + Main.projectile[projectile1].aiStyle = 1; + } } projectile.localAI[0] = 0f; } diff --git a/Projectiles/Melee/LightningThing.cs b/Projectiles/Melee/LightningThing.cs index 4aa8db290c..1a7c2b29b9 100644 --- a/Projectiles/Melee/LightningThing.cs +++ b/Projectiles/Melee/LightningThing.cs @@ -24,15 +24,18 @@ namespace CalamityMod.Projectiles.Melee } public override void Kill(int timeLeft) { - int damage = GaelsGreatsword.BaseDamage; + int damage = (int)(GaelsGreatsword.BaseDamage * Main.player[projectile.owner].MeleeDamage()); for (int i = 0; i < 3; i++) { int idx = Projectile.NewProjectile(projectile.Center + new Vector2(Main.rand.NextFloat(-35f, 35f), -1600f), Vector2.UnitY * 12f, - ProjectileID.CultistBossLightningOrbArc, GaelsGreatsword.BaseDamage, 0f, projectile.owner, + ProjectileID.CultistBossLightningOrbArc, damage, 0f, projectile.owner, MathHelper.PiOver2, Main.rand.Next(100)); - Main.projectile[idx].Calamity().forceMelee = true; - Main.projectile[idx].usesLocalNPCImmunity = true; - Main.projectile[idx].localNPCHitCooldown = GaelsGreatsword.ImmunityFrames; + if (idx.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[idx].Calamity().forceMelee = true; + Main.projectile[idx].usesLocalNPCImmunity = true; + Main.projectile[idx].localNPCHitCooldown = GaelsGreatsword.ImmunityFrames; + } } } } diff --git a/Projectiles/Melee/PlagueBeeDust.cs b/Projectiles/Melee/PlagueBeeDust.cs index 819da5084f..0f7e416f03 100644 --- a/Projectiles/Melee/PlagueBeeDust.cs +++ b/Projectiles/Melee/PlagueBeeDust.cs @@ -60,9 +60,12 @@ namespace CalamityMod.Projectiles.Melee { int spawnX = (int)(projectile.width / 2); int spawnY = (int)(projectile.width / 2); - int bee = Projectile.NewProjectile(projectile.Center.X + (float)Main.rand.Next(-spawnX, spawnX), projectile.Center.Y + (float)Main.rand.Next(-spawnY, spawnY), projectile.velocity.X, projectile.velocity.Y, player.beeType(), player.beeDamage(projectile.damage / 3), player.beeKB(0f), projectile.owner, 0f, 0f); - Main.projectile[bee].penetrate = 1; - Main.projectile[bee].Calamity().forceMelee = true; + int bee = Projectile.NewProjectile(projectile.Center.X + (float)Main.rand.Next(-spawnX, spawnX), projectile.Center.Y + (float)Main.rand.Next(-spawnY, spawnY), projectile.velocity.X, projectile.velocity.Y, player.beeType(), player.beeDamage(projectile.damage / 3), player.beeKB(0f), projectile.owner); + if (bee.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bee].Calamity().forceMelee = true; + Main.projectile[bee].penetrate = 1; + } } //Dust int dustType = 89; diff --git a/Projectiles/Melee/Spears/AstralPikeProj.cs b/Projectiles/Melee/Spears/AstralPikeProj.cs index a1c85d6fa0..4a9f04712d 100644 --- a/Projectiles/Melee/Spears/AstralPikeProj.cs +++ b/Projectiles/Melee/Spears/AstralPikeProj.cs @@ -49,21 +49,16 @@ namespace CalamityMod.Projectiles.Melee.Spears { for (int i = 0; i < 3; 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 * 150f; - speedY *= magnitude * 150f; - speedX = MathHelper.Clamp(speedX, -15f, 15f); - speedY = MathHelper.Clamp(speedY, -15f, 15f); if (projectile.owner == Main.myPlayer) { - int proj = Projectile.NewProjectile(spawnPosition.X, spawnPosition.Y, speedX, speedY, ModContent.ProjectileType(), (int)(projectile.damage * 0.4), 1f, projectile.owner, 3f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + Projectile star = CalamityUtils.ProjectileBarrage(projectile.Center, target.Center, Main.rand.NextBool(), 800f, 800f, 800f, 800f, 10f, ModContent.ProjectileType(), (int)(projectile.damage * 0.4), 1f, projectile.owner, true); + if (star.whoAmI.WithinBounds(Main.maxProjectiles)) + { + star.Calamity().forceMelee = true; + star.ai[0] = 3f; + } } + } } } diff --git a/Projectiles/Melee/Spears/EarthenPikeSpear.cs b/Projectiles/Melee/Spears/EarthenPikeSpear.cs index a5889059b3..6f70ba1bbd 100644 --- a/Projectiles/Melee/Spears/EarthenPikeSpear.cs +++ b/Projectiles/Melee/Spears/EarthenPikeSpear.cs @@ -48,7 +48,8 @@ namespace CalamityMod.Projectiles.Melee.Spears velocityY = 0.1f; int proj = Projectile.NewProjectile(projectile.Center.X + projectile.velocity.X, projectile.Center.Y + projectile.velocity.Y, projectile.velocity.X * 1.25f, velocityY, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), 0f, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } } } diff --git a/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs b/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs index 47f5399f4e..ad14606432 100644 --- a/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs +++ b/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs @@ -63,8 +63,9 @@ namespace CalamityMod.Projectiles.Melee.Spears { 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); - Main.projectile[boom].Calamity().forceMelee = true; + int boom = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (boom.WithinBounds(Main.maxProjectiles)) + Main.projectile[boom].Calamity().forceMelee = true; } if (crit) { diff --git a/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs b/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs index f4970d16a2..2405eb9ebe 100644 --- a/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs +++ b/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs @@ -58,8 +58,11 @@ namespace CalamityMod.Projectiles.Melee.Spears if (projectile.owner == Main.myPlayer) { 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; + if (petal.whoAmI.WithinBounds(Main.maxProjectiles)) + { + petal.Calamity().forceMelee = true; + petal.localNPCHitCooldown = -1; + } } } } diff --git a/Projectiles/Melee/StellarContemptHammer.cs b/Projectiles/Melee/StellarContemptHammer.cs index 3e4702ace9..7f288290e3 100644 --- a/Projectiles/Melee/StellarContemptHammer.cs +++ b/Projectiles/Melee/StellarContemptHammer.cs @@ -147,48 +147,7 @@ namespace CalamityMod.Projectiles.Melee // Do not drop lunar flares on dummies. if (target.type == NPCID.TargetDummy) return; - - // Play the Lunar Flare sound centered on the user, not the target (consistent with Lunar Flare and Stellar Striker) - Player user = Main.player[projectile.owner]; - Main.PlaySound(SoundID.Item88, projectile.position); - projectile.netUpdate = true; - - int numFlares = 2; - int flareDamage = (int)(0.3f * projectile.damage); - float flareKB = 4f; - for (int i = 0; i < numFlares; ++i) - { - float flareSpeed = Main.rand.NextFloat(8f, 11f); - - // Flares never come from straight up, there is always at least an 80 pixel horizontal offset - float xDist = Main.rand.NextFloat(80f, 320f) * (Main.rand.NextBool() ? -1f : 1f); - float yDist = Main.rand.NextFloat(1200f, 1440f); - Vector2 startPoint = target.Center + new Vector2(xDist, -yDist); - - // The flare is somewhat inaccurate based on the size of the target. - float xVariance = target.width / 4f; - if (xVariance < 8f) - xVariance = 8f; - float yVariance = target.height / 4f; - if (yVariance < 8f) - yVariance = 8f; - float xOffset = Main.rand.NextFloat(-xVariance, xVariance); - float yOffset = Main.rand.NextFloat(-yVariance, yVariance); - Vector2 offsetTarget = target.Center + new Vector2(xOffset, yOffset); - - // Finalize the velocity vector and make sure it's going at the right speed. - Vector2 velocity = offsetTarget - startPoint; - velocity.Normalize(); - velocity *= flareSpeed; - - float AI1 = Main.rand.Next(3); - if (projectile.owner == Main.myPlayer) - { - int proj = Projectile.NewProjectile(startPoint, velocity, ProjectileID.LunarFlare, flareDamage, flareKB, Main.myPlayer, 0f, AI1); - CalamityGlobalProjectile cgp = Main.projectile[proj].Calamity(); - cgp.forceMelee = true; - } - } + SpawnFlares(target.Center, target.width, target.height); } public override void OnHitPvp(Player target, int damage, bool crit) @@ -211,6 +170,13 @@ namespace CalamityMod.Projectiles.Melee if (!Main.dayTime) target.AddBuff(ModContent.BuffType(), 480); + SpawnFlares(target.Center, target.width, target.height); + } + + private void SpawnFlares(Vector2 targetPos, int width, int height) + { + // Play the Lunar Flare sound centered on the user, not the target (consistent with Lunar Flare and Stellar Striker) + Player user = Main.player[projectile.owner]; Main.PlaySound(SoundID.Item88, projectile.position); projectile.netUpdate = true; @@ -224,18 +190,18 @@ namespace CalamityMod.Projectiles.Melee // Flares never come from straight up, there is always at least an 80 pixel horizontal offset float xDist = Main.rand.NextFloat(80f, 320f) * (Main.rand.NextBool() ? -1f : 1f); float yDist = Main.rand.NextFloat(1200f, 1440f); - Vector2 startPoint = target.Center + new Vector2(xDist, -yDist); + Vector2 startPoint = targetPos + new Vector2(xDist, -yDist); // The flare is somewhat inaccurate based on the size of the target. - float xVariance = target.width / 4f; + float xVariance = width / 4f; if (xVariance < 8f) xVariance = 8f; - float yVariance = target.height / 4f; + float yVariance = height / 4f; if (yVariance < 8f) yVariance = 8f; float xOffset = Main.rand.NextFloat(-xVariance, xVariance); float yOffset = Main.rand.NextFloat(-yVariance, yVariance); - Vector2 offsetTarget = target.Center + new Vector2(xOffset, yOffset); + Vector2 offsetTarget = targetPos + new Vector2(xOffset, yOffset); // Finalize the velocity vector and make sure it's going at the right speed. Vector2 velocity = offsetTarget - startPoint; @@ -246,8 +212,11 @@ namespace CalamityMod.Projectiles.Melee if (projectile.owner == Main.myPlayer) { int proj = Projectile.NewProjectile(startPoint, velocity, ProjectileID.LunarFlare, flareDamage, flareKB, Main.myPlayer, 0f, AI1); - CalamityGlobalProjectile cgp = Main.projectile[proj].Calamity(); - cgp.forceMelee = true; + if (proj.WithinBounds(Main.maxProjectiles)) + { + CalamityGlobalProjectile cgp = Main.projectile[proj].Calamity(); + cgp.forceMelee = true; + } } } } diff --git a/Projectiles/Melee/Yoyos/ChaotrixYoyo.cs b/Projectiles/Melee/Yoyos/ChaotrixYoyo.cs index deebe87473..3e1cce6485 100644 --- a/Projectiles/Melee/Yoyos/ChaotrixYoyo.cs +++ b/Projectiles/Melee/Yoyos/ChaotrixYoyo.cs @@ -52,7 +52,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (projectile.owner == Main.myPlayer) { int boom = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - Main.projectile[boom].Calamity().forceMelee = true; + if (boom.WithinBounds(Main.maxProjectiles)) + Main.projectile[boom].Calamity().forceMelee = true; } } diff --git a/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs b/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs index 0529999874..5197b62cbd 100644 --- a/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs +++ b/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs @@ -105,7 +105,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (projectile.owner == Main.myPlayer) { int proj = Projectile.NewProjectile(laserSpawnPosition, velocity, ModContent.ProjectileType(), laserDamage, laserKB, projectile.owner); - Main.projectile[proj].Calamity().forceMelee = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } } } diff --git a/Projectiles/Melee/Yoyos/OracleYoyo.cs b/Projectiles/Melee/Yoyos/OracleYoyo.cs index 2affa509cd..c85f07211f 100644 --- a/Projectiles/Melee/Yoyos/OracleYoyo.cs +++ b/Projectiles/Melee/Yoyos/OracleYoyo.cs @@ -221,8 +221,11 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (projectile.owner == Main.myPlayer) { Projectile p = Projectile.NewProjectileDirect(target.Center, Vector2.Zero, ModContent.ProjectileType(), finalDamage, 0f, projectile.owner, i); - p.melee = true; - p.Calamity().forceMelee = true; + if (p.whoAmI.WithinBounds(Main.maxProjectiles)) + { + p.melee = true; + p.Calamity().forceMelee = true; + } } } } diff --git a/Projectiles/Melee/Yoyos/QuagmireYoyo.cs b/Projectiles/Melee/Yoyos/QuagmireYoyo.cs index 094eebef9e..0d53abad5f 100644 --- a/Projectiles/Melee/Yoyos/QuagmireYoyo.cs +++ b/Projectiles/Melee/Yoyos/QuagmireYoyo.cs @@ -38,24 +38,33 @@ namespace CalamityMod.Projectiles.Melee.Yoyos int proj; if (Main.rand.NextBool(10)) { - proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.35f, projectile.velocity.Y * 0.35f, ProjectileID.SporeGas, (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = 30; + proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.35f, projectile.velocity.Y * 0.35f, ProjectileID.SporeGas, (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 30; + } } if (Main.rand.NextBool(30)) { - proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, ProjectileID.SporeGas2, (int)(projectile.damage * 0.6), projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = 30; + proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, ProjectileID.SporeGas2, (int)(projectile.damage * 0.6), projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 30; + } } if (Main.rand.NextBool(50)) { - proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.15f, projectile.velocity.Y * 0.15f, ProjectileID.SporeGas3, (int)(projectile.damage * 0.7), projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = 30; + proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.15f, projectile.velocity.Y * 0.15f, ProjectileID.SporeGas3, (int)(projectile.damage * 0.7), projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceMelee = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 30; + } } } } diff --git a/Projectiles/Melee/Yoyos/SolarFlareYoyo.cs b/Projectiles/Melee/Yoyos/SolarFlareYoyo.cs index 84c2033be5..550ed61424 100644 --- a/Projectiles/Melee/Yoyos/SolarFlareYoyo.cs +++ b/Projectiles/Melee/Yoyos/SolarFlareYoyo.cs @@ -49,8 +49,9 @@ namespace CalamityMod.Projectiles.Melee.Yoyos target.AddBuff(ModContent.BuffType(), 300); if (projectile.owner == Main.myPlayer) { - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; + int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceMelee = true; } } diff --git a/Projectiles/Ranged/BeeRPG.cs b/Projectiles/Ranged/BeeRPG.cs index 715177685a..2db72bac8b 100644 --- a/Projectiles/Ranged/BeeRPG.cs +++ b/Projectiles/Ranged/BeeRPG.cs @@ -90,10 +90,7 @@ namespace CalamityMod.Projectiles.Ranged 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); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -115,9 +112,12 @@ namespace CalamityMod.Projectiles.Ranged value20 -= value21 * (float)num517; num518 += projectile.oldVelocity.X / 6f; num519 += projectile.oldVelocity.Y / 6f; - int num520 = Projectile.NewProjectile(value20.X, value20.Y, num518, num519, Main.player[projectile.owner].beeType(), Main.player[projectile.owner].beeDamage(projectile.damage / 4), Main.player[projectile.owner].beeKB(0f), Main.myPlayer, 0f, 0f); - Main.projectile[num520].penetrate = 2; - Main.projectile[num520].Calamity().forceRanged = true; + int bee = Projectile.NewProjectile(value20.X, value20.Y, num518, num519, Main.player[projectile.owner].beeType(), Main.player[projectile.owner].beeDamage(projectile.damage / 4), Main.player[projectile.owner].beeKB(0f), Main.myPlayer); + if (bee.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bee].penetrate = 2; + Main.projectile[bee].Calamity().forceRanged = true; + } } } } diff --git a/Projectiles/Ranged/CorrodedShell.cs b/Projectiles/Ranged/CorrodedShell.cs index b1609103d1..88dd5d207b 100644 --- a/Projectiles/Ranged/CorrodedShell.cs +++ b/Projectiles/Ranged/CorrodedShell.cs @@ -39,9 +39,12 @@ namespace CalamityMod.Projectiles.Ranged { if (projectile.owner == Main.myPlayer) { - int aura = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.15), projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[aura].Calamity().forceRanged = true; - Main.projectile[aura].timeLeft = 40; + int aura = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.15), projectile.knockBack, projectile.owner); + if (aura.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[aura].Calamity().forceRanged = true; + Main.projectile[aura].timeLeft = 40; + } } } } diff --git a/Projectiles/Ranged/DWArrow.cs b/Projectiles/Ranged/DWArrow.cs index fc8884b8f3..5d0914a36b 100644 --- a/Projectiles/Ranged/DWArrow.cs +++ b/Projectiles/Ranged/DWArrow.cs @@ -40,12 +40,6 @@ namespace CalamityMod.Projectiles.Ranged Main.PlaySound(SoundID.Item12, (int)projectile.position.X, (int)projectile.position.Y); } - // Force damage type based on AI variable (this is outdated code and the weapons themselves should set the force variables) - if (projectile.ai[0] == 1f) - projectile.Calamity().forceMelee = true; - else if (projectile.ai[0] == 2f) - projectile.Calamity().forceRogue = true; - Lighting.AddLight(projectile.Center, 0.4f, 0.2f, 0.4f); for (int num121 = 0; num121 < 2; num121++) { diff --git a/Projectiles/Ranged/DragonBurst.cs b/Projectiles/Ranged/DragonBurst.cs index af708a634a..477ca0e269 100644 --- a/Projectiles/Ranged/DragonBurst.cs +++ b/Projectiles/Ranged/DragonBurst.cs @@ -39,14 +39,13 @@ namespace CalamityMod.Projectiles.Ranged float num93 = projectile.velocity.X / 3f; float num94 = projectile.velocity.Y / 3f; int num95 = 4; - int num96 = Dust.NewDust(new Vector2(projectile.position.X + (float)num95, projectile.position.Y + (float)num95), projectile.width - num95 * 2, projectile.height - num95 * 2, 127, 0f, 0f, 100, default, 2f); - Main.dust[num96].noGravity = true; - Main.dust[num96].velocity *= 0.1f; - Main.dust[num96].velocity += projectile.velocity * 0.1f; - Dust expr_47FA_cp_0 = Main.dust[num96]; - expr_47FA_cp_0.position.X -= num93; - Dust expr_4815_cp_0 = Main.dust[num96]; - expr_4815_cp_0.position.Y -= num94; + int idx = Dust.NewDust(new Vector2(projectile.position.X + (float)num95, projectile.position.Y + (float)num95), projectile.width - num95 * 2, projectile.height - num95 * 2, 127, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[idx]; + dust.noGravity = true; + dust.velocity *= 0.1f; + dust.velocity += projectile.velocity * 0.1f; + dust.position.X -= num93; + dust.position.Y -= num94; if (Main.rand.NextBool(20)) { @@ -62,8 +61,9 @@ namespace CalamityMod.Projectiles.Ranged { if (projectile.owner == Main.myPlayer) { - int proj = 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[proj].Calamity().forceRanged = true; + int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceRanged = true; } } diff --git a/Projectiles/Ranged/ExplodingStake.cs b/Projectiles/Ranged/ExplodingStake.cs index 4e57b6f021..fc1f095f60 100644 --- a/Projectiles/Ranged/ExplodingStake.cs +++ b/Projectiles/Ranged/ExplodingStake.cs @@ -64,8 +64,9 @@ namespace CalamityMod.Projectiles.Ranged 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); - Main.projectile[boom].Calamity().forceRanged = true; - } + if (boom.WithinBounds(Main.maxProjectiles)) + Main.projectile[boom].Calamity().forceRanged = true; + } } public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) diff --git a/Projectiles/Ranged/FlurrystormCannonShooting.cs b/Projectiles/Ranged/FlurrystormCannonShooting.cs index aabf123833..d27a92f506 100644 --- a/Projectiles/Ranged/FlurrystormCannonShooting.cs +++ b/Projectiles/Ranged/FlurrystormCannonShooting.cs @@ -134,10 +134,13 @@ namespace CalamityMod.Projectiles.Ranged snowballVel.X += Main.rand.NextFloat(-2.25f, 2.25f); snowballVel.Y += Main.rand.NextFloat(-2.25f, 2.25f); int snowball = Projectile.NewProjectile(sourceS, snowballVel, projType, dmg, kBack, projectile.owner); - Main.projectile[snowball].noDropItem = true; - Main.projectile[snowball].Calamity().forceRanged = true; - Main.projectile[snowball].thrown = false; - Main.projectile[snowball].extraUpdates += Main.rand.Next(0,2); + if (snowball.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[snowball].noDropItem = true; + Main.projectile[snowball].Calamity().forceRanged = true; + Main.projectile[snowball].thrown = false; + Main.projectile[snowball].extraUpdates += Main.rand.Next(0,2); + } if (Main.rand.NextBool(5)) //ice chunk { diff --git a/Projectiles/Ranged/GoliathRocket.cs b/Projectiles/Ranged/GoliathRocket.cs index 1d7a314a2e..dfbcb6a23f 100644 --- a/Projectiles/Ranged/GoliathRocket.cs +++ b/Projectiles/Ranged/GoliathRocket.cs @@ -106,10 +106,7 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - projectile.position = projectile.Center; - projectile.width = projectile.height = 160; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 160); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -131,9 +128,12 @@ namespace CalamityMod.Projectiles.Ranged value20 -= value21 * (float)num517; num518 += projectile.oldVelocity.X / 6f; num519 += projectile.oldVelocity.Y / 6f; - int num520 = Projectile.NewProjectile(value20.X, value20.Y, num518, num519, Main.player[projectile.owner].beeType(), Main.player[projectile.owner].beeDamage(projectile.damage), Main.player[projectile.owner].beeKB(0f), Main.myPlayer, 0f, 0f); - Main.projectile[num520].penetrate = 2; - Main.projectile[num520].Calamity().forceRanged = true; + int bee = Projectile.NewProjectile(value20.X, value20.Y, num518, num519, Main.player[projectile.owner].beeType(), Main.player[projectile.owner].beeDamage(projectile.damage), Main.player[projectile.owner].beeKB(0f), Main.myPlayer); + if (bee.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bee].penetrate = 2; + Main.projectile[bee].Calamity().forceRanged = true; + } } } } diff --git a/Projectiles/Ranged/HiveBomb.cs b/Projectiles/Ranged/HiveBomb.cs index 40452af1b9..64c904726e 100644 --- a/Projectiles/Ranged/HiveBomb.cs +++ b/Projectiles/Ranged/HiveBomb.cs @@ -106,10 +106,7 @@ namespace CalamityMod.Projectiles.Ranged 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); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 64); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -131,9 +128,12 @@ namespace CalamityMod.Projectiles.Ranged value20 -= value21 * (float)num517; num518 += projectile.oldVelocity.X / 6f; num519 += projectile.oldVelocity.Y / 6f; - int num520 = Projectile.NewProjectile(value20.X, value20.Y, num518, num519, Main.player[projectile.owner].beeType(), Main.player[projectile.owner].beeDamage(projectile.damage / 3), Main.player[projectile.owner].beeKB(0f), Main.myPlayer, 0f, 0f); - Main.projectile[num520].penetrate = 2; - Main.projectile[num520].Calamity().forceRanged = true; + int bee = Projectile.NewProjectile(value20.X, value20.Y, num518, num519, Main.player[projectile.owner].beeType(), Main.player[projectile.owner].beeDamage(projectile.damage / 3), Main.player[projectile.owner].beeKB(0f), Main.myPlayer); + if (bee.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bee].penetrate = 2; + Main.projectile[bee].Calamity().forceRanged = true; + } } } } diff --git a/Projectiles/Ranged/HiveMissile.cs b/Projectiles/Ranged/HiveMissile.cs index f765cf2c87..8509bd1db0 100644 --- a/Projectiles/Ranged/HiveMissile.cs +++ b/Projectiles/Ranged/HiveMissile.cs @@ -106,10 +106,7 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - projectile.position = projectile.Center; - projectile.width = projectile.height = 80; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 80); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -131,9 +128,12 @@ namespace CalamityMod.Projectiles.Ranged value20 -= value21 * (float)num517; num518 += projectile.oldVelocity.X / 6f; num519 += projectile.oldVelocity.Y / 6f; - int num520 = Projectile.NewProjectile(value20.X, value20.Y, num518, num519, Main.player[projectile.owner].beeType(), Main.player[projectile.owner].beeDamage(projectile.damage / 2), Main.player[projectile.owner].beeKB(0f), Main.myPlayer, 0f, 0f); - Main.projectile[num520].penetrate = 2; - Main.projectile[num520].Calamity().forceRanged = true; + int bee = Projectile.NewProjectile(value20.X, value20.Y, num518, num519, Main.player[projectile.owner].beeType(), Main.player[projectile.owner].beeDamage(projectile.damage / 2), Main.player[projectile.owner].beeKB(0f), Main.myPlayer); + if (bee.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bee].penetrate = 2; + Main.projectile[bee].Calamity().forceRanged = true; + } } } } diff --git a/Projectiles/Ranged/HolyFireBulletProj.cs b/Projectiles/Ranged/HolyFireBulletProj.cs index 78e1617a34..d5d9374195 100644 --- a/Projectiles/Ranged/HolyFireBulletProj.cs +++ b/Projectiles/Ranged/HolyFireBulletProj.cs @@ -67,7 +67,8 @@ namespace CalamityMod.Projectiles.Ranged int blastDamage = (int)(projectile.damage * 0.85f); float scale = 0.85f + Main.rand.NextFloat() * 1.15f; int boom = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), blastDamage, projectile.knockBack, projectile.owner, 0f, scale); - Main.projectile[boom].Calamity().forceRanged = true; + if (boom.WithinBounds(Main.maxProjectiles)) + Main.projectile[boom].Calamity().forceRanged = true; } for (int k = 0; k < 4; k++) { diff --git a/Projectiles/Ranged/NapalmArrowProj.cs b/Projectiles/Ranged/NapalmArrowProj.cs index 01ab026311..3ece134f2f 100644 --- a/Projectiles/Ranged/NapalmArrowProj.cs +++ b/Projectiles/Ranged/NapalmArrowProj.cs @@ -38,10 +38,7 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - projectile.position = projectile.Center; - projectile.width = projectile.height = 32; - projectile.position.X -= (float)(projectile.width / 2); - projectile.position.Y -= (float)(projectile.height / 2); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); Main.PlaySound(SoundID.Item14, projectile.position); for (int j = 0; j < 5; j++) { @@ -66,19 +63,16 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i < 3; i++) { - Vector2 velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - while (velocity.X == 0f && velocity.Y == 0f) - { - velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - } - velocity.Normalize(); - velocity *= (float)Main.rand.Next(70, 101) * 0.1f; - int flames = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 0f, projectile.owner, 0f, 0f); - Main.projectile[flames].Calamity().forceRanged = true; - Main.projectile[flames].penetrate = 3; - Main.projectile[flames].usesLocalNPCImmunity = false; - Main.projectile[flames].usesIDStaticNPCImmunity = true; - Main.projectile[flames].idStaticNPCHitCooldown = 10; + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f, 0.1f); + int flames = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), 0f, projectile.owner); + if (flames.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[flames].Calamity().forceRanged = true; + Main.projectile[flames].penetrate = 3; + Main.projectile[flames].usesLocalNPCImmunity = false; + Main.projectile[flames].usesIDStaticNPCImmunity = true; + Main.projectile[flames].idStaticNPCHitCooldown = 10; + } } } } diff --git a/Projectiles/Ranged/PlagueArrow.cs b/Projectiles/Ranged/PlagueArrow.cs index 6490b0ae85..7f53a23154 100644 --- a/Projectiles/Ranged/PlagueArrow.cs +++ b/Projectiles/Ranged/PlagueArrow.cs @@ -48,9 +48,12 @@ namespace CalamityMod.Projectiles.Ranged value20 -= value21 * (float)num517; num518 += projectile.oldVelocity.X / 6f; num519 += projectile.oldVelocity.Y / 6f; - int num520 = Projectile.NewProjectile(value20.X, value20.Y, num518, num519, Main.player[projectile.owner].beeType(), Main.player[projectile.owner].beeDamage(projectile.damage / 2), Main.player[projectile.owner].beeKB(0f), Main.myPlayer, 0f, 0f); - Main.projectile[num520].Calamity().forceRanged = true; - Main.projectile[num520].penetrate = 2; + int bee = Projectile.NewProjectile(value20.X, value20.Y, num518, num519, Main.player[projectile.owner].beeType(), Main.player[projectile.owner].beeDamage(projectile.damage / 2), Main.player[projectile.owner].beeKB(0f), Main.myPlayer); + if (bee.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[bee].penetrate = 2; + Main.projectile[bee].Calamity().forceRanged = true; + } } } } diff --git a/Projectiles/Ranged/SeaDragonRocket.cs b/Projectiles/Ranged/SeaDragonRocket.cs index 757e5a6ad8..4de60b7477 100644 --- a/Projectiles/Ranged/SeaDragonRocket.cs +++ b/Projectiles/Ranged/SeaDragonRocket.cs @@ -82,10 +82,7 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - 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); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 192); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; @@ -122,9 +119,12 @@ namespace CalamityMod.Projectiles.Ranged } velocity.Normalize(); velocity *= (float)Main.rand.Next(70, 101) * 0.1f; - int flames = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.33), 0f, projectile.owner, 0f, 0f); - Main.projectile[flames].Calamity().forceRanged = true; - Main.projectile[flames].penetrate = 3; + int flames = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.33), 0f, projectile.owner); + if (flames.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[flames].penetrate = 3; + Main.projectile[flames].Calamity().forceRanged = true; + } } } } diff --git a/Projectiles/Ranged/SporeBomb.cs b/Projectiles/Ranged/SporeBomb.cs index c05d251d6a..9a903726e8 100644 --- a/Projectiles/Ranged/SporeBomb.cs +++ b/Projectiles/Ranged/SporeBomb.cs @@ -85,10 +85,13 @@ namespace CalamityMod.Projectiles.Ranged for (int s = 0; s < sporeAmt; s++) { 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; + int proj = Projectile.NewProjectile(projectile.Center, velocity, ProjectileID.SporeGas + Main.rand.Next(3), (int)(projectile.damage * 0.25), 0f, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceRanged = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 30; + } } } } diff --git a/Projectiles/Ranged/StarfleetMK2Gun.cs b/Projectiles/Ranged/StarfleetMK2Gun.cs index af13705b79..81183bda4e 100644 --- a/Projectiles/Ranged/StarfleetMK2Gun.cs +++ b/Projectiles/Ranged/StarfleetMK2Gun.cs @@ -108,10 +108,13 @@ namespace CalamityMod.Projectiles.Ranged ProjectileID.Starfury }); int star = Projectile.NewProjectile(position, speed, type, damage, knockBack, projectile.owner); - Main.projectile[star].penetrate = 1; - Main.projectile[star].timeLeft = 300; - Main.projectile[star].Calamity().forceRanged = true; - Main.projectile[star].netUpdate = true; + if (star.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[star].penetrate = 1; + Main.projectile[star].timeLeft = 300; + Main.projectile[star].Calamity().forceRanged = true; + Main.projectile[star].netUpdate = true; + } projectile.netUpdate = true; } } diff --git a/Projectiles/Rogue/AuroradicalStar.cs b/Projectiles/Rogue/AuroradicalStar.cs index 5af928b27e..12bc1fb418 100644 --- a/Projectiles/Rogue/AuroradicalStar.cs +++ b/Projectiles/Rogue/AuroradicalStar.cs @@ -126,29 +126,29 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 180); + OnHitEffect(target.Center, target.width); + } + + private void OnHitEffect(Vector2 targetPos, int width) + { if (projectile.Calamity().stealthStrike && Main.myPlayer == projectile.owner) { - 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 pos = new Vector2(targetPos.X + width * 0.5f + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + Vector2 velocity = (targetPos - pos) / 40f; 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); + int comet = Projectile.NewProjectile(pos, velocity, ModContent.ProjectileType(), dmg, projectile.knockBack, projectile.owner); + if (comet.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[comet].Calamity().forceRogue = true; + Main.projectile[comet].Calamity().lineColor = Main.rand.Next(3); + } } } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 180); - if (projectile.Calamity().stealthStrike && Main.myPlayer == projectile.owner) - { - 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; - 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); - } + OnHitEffect(target.Center, target.width); } public override void Kill(int timeLeft) diff --git a/Projectiles/Rogue/BloodsoakedCrashax.cs b/Projectiles/Rogue/BloodsoakedCrashax.cs index 3624824d2d..76ccadd083 100644 --- a/Projectiles/Rogue/BloodsoakedCrashax.cs +++ b/Projectiles/Rogue/BloodsoakedCrashax.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = projectile.height = 30; projectile.friendly = true; projectile.penetrate = 10; - projectile.timeLeft = 600; //10 seconds and counting + projectile.timeLeft = 600; //10 seconds and counting (but not actually because extra updates) projectile.aiStyle = 2; aiType = ProjectileID.ThrowingKnife; //Throwing Knife AI projectile.Calamity().rogue = true; @@ -106,7 +106,8 @@ namespace CalamityMod.Projectiles.Rogue 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; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().forceRogue = true; } Player player = Main.player[projectile.owner]; diff --git a/Projectiles/Rogue/ContaminatedBileFlask.cs b/Projectiles/Rogue/ContaminatedBileFlask.cs index b7fc3b4f10..3a6cb5381c 100644 --- a/Projectiles/Rogue/ContaminatedBileFlask.cs +++ b/Projectiles/Rogue/ContaminatedBileFlask.cs @@ -39,8 +39,11 @@ namespace CalamityMod.Projectiles.Rogue { Main.PlaySound(SoundID.Item107, projectile.Bottom); Projectile explosion = Projectile.NewProjectileDirect(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner); - explosion.Calamity().stealthStrike = projectile.Calamity().stealthStrike; - explosion.timeLeft = explosion.Calamity().stealthStrike ? 60 : 20; + if (explosion.whoAmI.WithinBounds(Main.maxProjectiles)) + { + explosion.Calamity().stealthStrike = projectile.Calamity().stealthStrike; + explosion.timeLeft = explosion.Calamity().stealthStrike ? 60 : 20; + } } } } diff --git a/Projectiles/Rogue/Crystalline2.cs b/Projectiles/Rogue/Crystalline2.cs index 8a1506f74e..2e826f872f 100644 --- a/Projectiles/Rogue/Crystalline2.cs +++ b/Projectiles/Rogue/Crystalline2.cs @@ -68,7 +68,8 @@ namespace CalamityMod.Projectiles.Rogue { Vector2 projspeed = new Vector2(Main.rand.NextFloat(-8f, 8f), Main.rand.NextFloat(-8f, 8f)); int shard = Projectile.NewProjectile(projectile.Center, projspeed, ProjectileID.CrystalShard, (int)(projectile.damage * 0.4f), 2f, projectile.owner); - Main.projectile[shard].Calamity().forceRogue = true; + if (shard.WithinBounds(Main.maxProjectiles)) + Main.projectile[shard].Calamity().forceRogue = true; } } } diff --git a/Projectiles/Rogue/CursedDaggerProj.cs b/Projectiles/Rogue/CursedDaggerProj.cs index 5027f41fe5..01c6d0244e 100644 --- a/Projectiles/Rogue/CursedDaggerProj.cs +++ b/Projectiles/Rogue/CursedDaggerProj.cs @@ -43,10 +43,13 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.owner == Main.myPlayer) { Vector2 velocity = new Vector2(Main.rand.NextFloat(-14f, 14f), Main.rand.NextFloat(-14f, 14f)); - int flame = Projectile.NewProjectile(projectile.Center, velocity, Main.rand.NextBool(2) ? ProjectileID.CursedFlameFriendly : ProjectileID.CursedDartFlame, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, 0f, 0f); - Main.projectile[flame].Calamity().forceRogue = true; - Main.projectile[flame].usesLocalNPCImmunity = true; - Main.projectile[flame].localNPCHitCooldown = 10; + int flame = Projectile.NewProjectile(projectile.Center, velocity, Main.rand.NextBool(2) ? ProjectileID.CursedFlameFriendly : ProjectileID.CursedDartFlame, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner); + if (flame.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[flame].Calamity().forceRogue = true; + Main.projectile[flame].usesLocalNPCImmunity = true; + Main.projectile[flame].localNPCHitCooldown = 10; + } } } } diff --git a/Projectiles/Rogue/DuneHopperProjectile.cs b/Projectiles/Rogue/DuneHopperProjectile.cs index bf94c17fc1..e94b9eacf2 100644 --- a/Projectiles/Rogue/DuneHopperProjectile.cs +++ b/Projectiles/Rogue/DuneHopperProjectile.cs @@ -1,6 +1,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue @@ -35,7 +36,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity.Y += 0.4f; } } - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.ToRadians(45f); + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(45f); } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Rogue/EpidemicShredderProjectile.cs b/Projectiles/Rogue/EpidemicShredderProjectile.cs index 1b779eacf1..ef94713d2b 100644 --- a/Projectiles/Rogue/EpidemicShredderProjectile.cs +++ b/Projectiles/Rogue/EpidemicShredderProjectile.cs @@ -47,7 +47,8 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.timeLeft % 5 == 0 && projectile.Calamity().stealthStrike) { int projIndex2 = Projectile.NewProjectile(projectile.Center, (projectile.velocity * -1f).RotatedByRandom(MathHelper.ToRadians(15f)), ModContent.ProjectileType(), (int)(projectile.damage * 0.25f), 2f, projectile.owner); - Main.projectile[projIndex2].Calamity().forceRogue = true; + if (projIndex2.WithinBounds(Main.maxProjectiles)) + Main.projectile[projIndex2].Calamity().forceRogue = true; } } @@ -66,7 +67,8 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.ai[0] == 0f) { int projIndex1 = Projectile.NewProjectile(projectile.Center, projectile.velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.25f), 2f, projectile.owner); - Main.projectile[projIndex1].Calamity().forceRogue = true; + if (projIndex1.WithinBounds(Main.maxProjectiles)) + Main.projectile[projIndex1].Calamity().forceRogue = true; projectile.ai[0] = 12f; //0.2th of a second cooldown } projectile.penetrate--; @@ -82,7 +84,8 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.ai[0] == 0f) { int projectileIndex = Projectile.NewProjectile(projectile.Center, projectile.velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.25f), 2f, projectile.owner); - Main.projectile[projectileIndex].Calamity().forceRogue = true; + if (projectileIndex.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectileIndex].Calamity().forceRogue = true; projectile.ai[0] = 12f; //0.2th of a second cooldown } target.AddBuff(ModContent.BuffType(), 300); @@ -93,7 +96,8 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.ai[0] == 0f) { int projectileIndex = Projectile.NewProjectile(projectile.Center, projectile.velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.25f), 2f, projectile.owner); - Main.projectile[projectileIndex].Calamity().forceRogue = true; + if (projectileIndex.WithinBounds(Main.maxProjectiles)) + Main.projectile[projectileIndex].Calamity().forceRogue = true; projectile.ai[0] = 12f; //0.2th of a second cooldown } target.AddBuff(ModContent.BuffType(), 300); diff --git a/Projectiles/Rogue/EradicatorProjectile.cs b/Projectiles/Rogue/EradicatorProjectile.cs index 1266233601..ed4fba6d6e 100644 --- a/Projectiles/Rogue/EradicatorProjectile.cs +++ b/Projectiles/Rogue/EradicatorProjectile.cs @@ -57,11 +57,14 @@ namespace CalamityMod.Projectiles.Rogue shootCounter = 0f; Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile laser = Projectile.NewProjectileDirect(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner); - laser.Calamity().forceRogue = true; - laser.aiStyle = Main.rand.NextBool() ? 1 : -1; - laser.penetrate = -1; - laser.usesLocalNPCImmunity = true; - laser.localNPCHitCooldown = 20; + if (laser.whoAmI.WithinBounds(Main.maxProjectiles)) + { + laser.Calamity().forceRogue = true; + laser.aiStyle = Main.rand.NextBool() ? 1 : -1; + laser.penetrate = -1; + laser.usesLocalNPCImmunity = true; + laser.localNPCHitCooldown = 20; + } } projectile.StickyProjAI(6, true); diff --git a/Projectiles/Rogue/FantasyTalismanProj.cs b/Projectiles/Rogue/FantasyTalismanProj.cs index 744533b7e7..d97a13a99f 100644 --- a/Projectiles/Rogue/FantasyTalismanProj.cs +++ b/Projectiles/Rogue/FantasyTalismanProj.cs @@ -48,8 +48,11 @@ namespace CalamityMod.Projectiles.Rogue { int spiritDamage = projectile.damage / 2; Projectile ghost = CalamityGlobalProjectile.SpawnOrb(projectile, spiritDamage, ProjectileID.SpectreWrath, 800f, 4f); - ghost.Calamity().forceRogue = true; - ghost.penetrate = 1; + if (ghost.whoAmI.WithinBounds(Main.maxProjectiles)) + { + ghost.Calamity().forceRogue = true; + ghost.penetrate = 1; + } } } } diff --git a/Projectiles/Rogue/FantasyTalismanStealth.cs b/Projectiles/Rogue/FantasyTalismanStealth.cs index 7dabe781c2..2822d57053 100644 --- a/Projectiles/Rogue/FantasyTalismanStealth.cs +++ b/Projectiles/Rogue/FantasyTalismanStealth.cs @@ -60,8 +60,11 @@ namespace CalamityMod.Projectiles.Rogue { int spiritDamage = projectile.damage / 2; Projectile ghost = CalamityGlobalProjectile.SpawnOrb(projectile, spiritDamage, ProjectileID.SpectreWrath, 800f, 4f); - ghost.Calamity().forceRogue = true; - ghost.penetrate = 1; + if (ghost.whoAmI.WithinBounds(Main.maxProjectiles)) + { + ghost.Calamity().forceRogue = true; + ghost.penetrate = 1; + } } } } diff --git a/Projectiles/Rogue/FeatherKnifeProjectile.cs b/Projectiles/Rogue/FeatherKnifeProjectile.cs index 2a27caa498..60d8dcf863 100644 --- a/Projectiles/Rogue/FeatherKnifeProjectile.cs +++ b/Projectiles/Rogue/FeatherKnifeProjectile.cs @@ -41,7 +41,8 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.owner == Main.myPlayer) { int proj = Projectile.NewProjectile(projectile.position, new Vector2(projectile.velocity.X / 20, 2), ModContent.ProjectileType(), (int)(projectile.damage * 0.4), projectile.knockBack, projectile.owner); - Main.projectile[proj].Calamity().forceRogue = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceRogue = true; } } } @@ -49,7 +50,8 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { int proj = Projectile.NewProjectile(projectile.position, new Vector2(projectile.velocity.X / 20, 2), ModContent.ProjectileType(), (int)(projectile.damage * 0.69), projectile.knockBack, projectile.owner); - Main.projectile[proj].Calamity().forceRogue = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceRogue = true; } public override void Kill(int timeLeft) diff --git a/Projectiles/Rogue/FlameScytheProjectile.cs b/Projectiles/Rogue/FlameScytheProjectile.cs index b5ed92a568..9d7e347dd6 100644 --- a/Projectiles/Rogue/FlameScytheProjectile.cs +++ b/Projectiles/Rogue/FlameScytheProjectile.cs @@ -71,7 +71,8 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.owner == Main.myPlayer) { int proj = Projectile.NewProjectile(position, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - Main.projectile[proj].Calamity().forceRogue = true; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceRogue = true; if (projectile.Calamity().stealthStrike && projectile.localAI[0] <= 0f) { Point result; diff --git a/Projectiles/Rogue/FrostyFlareStealth.cs b/Projectiles/Rogue/FrostyFlareStealth.cs index 967bfc816e..c0d7d932bf 100644 --- a/Projectiles/Rogue/FrostyFlareStealth.cs +++ b/Projectiles/Rogue/FrostyFlareStealth.cs @@ -57,8 +57,11 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.timeLeft % 10 == 0) { int snowflake = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0f, projectile.velocity.Y * 0f, ProjectileID.NorthPoleSnowflake, (int)(projectile.damage * 0.25), projectile.knockBack, projectile.owner, 0f, Main.rand.Next(3)); - Main.projectile[snowflake].Calamity().forceRogue = true; - Main.projectile[snowflake].timeLeft = 300; + if (snowflake.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[snowflake].Calamity().forceRogue = true; + Main.projectile[snowflake].timeLeft = 300; + } } int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 172); @@ -69,7 +72,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.ignoreWater = true; projectile.tileCollide = false; int id = (int)projectile.ai[1]; - if (id >= 0 && id < Main.maxNPCs && Main.npc[id].active && !Main.npc[id].dontTakeDamage) + if (id.WithinBounds(Main.maxNPCs) && Main.npc[id].active && !Main.npc[id].dontTakeDamage) { projectile.Center = Main.npc[id].Center - projectile.velocity * 2f; projectile.gfxOffY = Main.npc[id].gfxOffY; diff --git a/Projectiles/Rogue/GacruxianHome.cs b/Projectiles/Rogue/GacruxianHome.cs index 073b6c08dc..1e3019ac48 100644 --- a/Projectiles/Rogue/GacruxianHome.cs +++ b/Projectiles/Rogue/GacruxianHome.cs @@ -1,5 +1,6 @@ using CalamityMod.Dusts; using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,8 +11,6 @@ namespace CalamityMod.Projectiles.Rogue { public override string Texture => "CalamityMod/Items/Fishing/AstralCatches/GacruxianMollusk"; - private int stealthTrailTimer = 10; - public override void SetStaticDefaults() { DisplayName.SetDefault("Mollusk"); @@ -34,18 +33,19 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - stealthTrailTimer--; if (Main.rand.NextBool(4)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, ModContent.DustType(), projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - if (stealthTrailTimer == 0 && projectile.owner == Main.myPlayer) + if (projectile.timeLeft % 10 == 0 && projectile.owner == Main.myPlayer) { - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0f, projectile.velocity.Y * 0f, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceRogue = true; - Main.projectile[proj].localNPCHitCooldown = 10; - Main.projectile[proj].penetrate = 3; - stealthTrailTimer = 10; + int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceRogue = true; + Main.projectile[proj].localNPCHitCooldown = 10; + Main.projectile[proj].penetrate = 3; + } } CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 500f, 16f, 20f); } diff --git a/Projectiles/Rogue/GacruxianProj.cs b/Projectiles/Rogue/GacruxianProj.cs index ef9183f38e..9e159b9f21 100644 --- a/Projectiles/Rogue/GacruxianProj.cs +++ b/Projectiles/Rogue/GacruxianProj.cs @@ -1,5 +1,6 @@ using CalamityMod.Dusts; using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,8 +11,6 @@ namespace CalamityMod.Projectiles.Rogue { public override string Texture => "CalamityMod/Items/Fishing/AstralCatches/GacruxianMollusk"; - private int sparkTrailTimer = 10; - public override void SetStaticDefaults() { DisplayName.SetDefault("Mollusk"); @@ -31,25 +30,26 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - sparkTrailTimer--; if (Main.rand.NextBool(4)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, ModContent.DustType(), projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - if (sparkTrailTimer == 0) + if (projectile.timeLeft % 10 == 0) { if (projectile.Calamity().stealthStrike == true) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0f, projectile.velocity.Y * 0f, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.3), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), projectile.knockBack, projectile.owner); } else { - int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0f, projectile.velocity.Y * 0f, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceRogue = true; - Main.projectile[proj].localNPCHitCooldown = 10; - Main.projectile[proj].penetrate = 3; + int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceRogue = true; + Main.projectile[proj].localNPCHitCooldown = 10; + Main.projectile[proj].penetrate = 3; + } } - sparkTrailTimer = 10; } } diff --git a/Projectiles/Rogue/GelDartProjectile.cs b/Projectiles/Rogue/GelDartProjectile.cs index b51cee68fa..618f947cd2 100644 --- a/Projectiles/Rogue/GelDartProjectile.cs +++ b/Projectiles/Rogue/GelDartProjectile.cs @@ -36,10 +36,13 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.timeLeft % 8 == 0) { Vector2 velocity = new Vector2(Main.rand.NextFloat(-7f, 7f), Main.rand.NextFloat(-7f, 7f)); - int flame = Projectile.NewProjectile(projectile.Center, velocity, ProjectileID.SlimeGun, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, 0f, 0f); - Main.projectile[flame].Calamity().forceRogue = true; - Main.projectile[flame].usesLocalNPCImmunity = true; - Main.projectile[flame].localNPCHitCooldown = 10; + int slime = Projectile.NewProjectile(projectile.Center, velocity, ProjectileID.SlimeGun, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner); + if (slime.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[slime].Calamity().forceRogue = true; + Main.projectile[slime].usesLocalNPCImmunity = true; + Main.projectile[slime].localNPCHitCooldown = 10; + } } } } diff --git a/Projectiles/Rogue/GreenDonkeyKongReference.cs b/Projectiles/Rogue/GreenDonkeyKongReference.cs index 8a0abc7bf7..cec49f3447 100644 --- a/Projectiles/Rogue/GreenDonkeyKongReference.cs +++ b/Projectiles/Rogue/GreenDonkeyKongReference.cs @@ -83,10 +83,13 @@ namespace CalamityMod.Projectiles.Rogue int acidIndex = Projectile.NewProjectile(projectile.Center, projectile.velocity + acidVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.75f), 1f, projectile.owner); - Main.projectile[acidIndex].Calamity().forceRogue = true; - Main.projectile[acidIndex].timeLeft = 300; - Main.projectile[acidIndex].usesLocalNPCImmunity = true; - Main.projectile[acidIndex].localNPCHitCooldown = -1; + if (acidIndex.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[acidIndex].Calamity().forceRogue = true; + Main.projectile[acidIndex].timeLeft = 300; + Main.projectile[acidIndex].usesLocalNPCImmunity = true; + Main.projectile[acidIndex].localNPCHitCooldown = -1; + } } } @@ -98,8 +101,11 @@ namespace CalamityMod.Projectiles.Rogue int acidIndex = Projectile.NewProjectile(projectile.Center, projectile.velocity + acidVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.667f), 1f, projectile.owner); - Main.projectile[acidIndex].Calamity().forceRogue = true; - Main.projectile[acidIndex].timeLeft = 420; + if (acidIndex.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[acidIndex].Calamity().forceRogue = true; + Main.projectile[acidIndex].timeLeft = 420; + } } } diff --git a/Projectiles/Rogue/IcebreakerHammer.cs b/Projectiles/Rogue/IcebreakerHammer.cs index 72cf64ae6a..87806107f0 100644 --- a/Projectiles/Rogue/IcebreakerHammer.cs +++ b/Projectiles/Rogue/IcebreakerHammer.cs @@ -58,7 +58,8 @@ namespace CalamityMod.Projectiles.Rogue if (explosionCount < 3) //max amount of explosions to prevent worm memes { int ice = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 1.5), projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - Main.projectile[ice].Calamity().forceRogue = true; + if (ice.WithinBounds(Main.maxProjectiles)) + Main.projectile[ice].Calamity().forceRogue = true; explosionCount++; } @@ -88,7 +89,8 @@ namespace CalamityMod.Projectiles.Rogue { //no explosion count cap in pvp int ice = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 1.5), projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - Main.projectile[ice].Calamity().forceRogue = true; + if (ice.WithinBounds(Main.maxProjectiles)) + Main.projectile[ice].Calamity().forceRogue = true; int buffType = ModContent.BuffType(); float radius = 112f; // 7 blocks diff --git a/Projectiles/Rogue/IchorSpearProj.cs b/Projectiles/Rogue/IchorSpearProj.cs index 27cfa360ec..b9e463760a 100644 --- a/Projectiles/Rogue/IchorSpearProj.cs +++ b/Projectiles/Rogue/IchorSpearProj.cs @@ -48,11 +48,14 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.owner == Main.myPlayer) { Vector2 velocity = new Vector2(Main.rand.NextFloat(-14f, 14f), Main.rand.NextFloat(-14f, 14f)); - int ichor = Projectile.NewProjectile(projectile.Center, velocity, Main.rand.NextBool(2) ? ProjectileID.GoldenShowerFriendly : ProjectileID.IchorSplash, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, 0f, 0f); - Main.projectile[ichor].Calamity().forceRogue = true; - Main.projectile[ichor].usesLocalNPCImmunity = true; - Main.projectile[ichor].localNPCHitCooldown = 10; - Main.projectile[ichor].extraUpdates = 2; + int ichor = Projectile.NewProjectile(projectile.Center, velocity, Main.rand.NextBool(2) ? ProjectileID.GoldenShowerFriendly : ProjectileID.IchorSplash, (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner); + if (ichor.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[ichor].Calamity().forceRogue = true; + Main.projectile[ichor].usesLocalNPCImmunity = true; + Main.projectile[ichor].localNPCHitCooldown = 10; + Main.projectile[ichor].extraUpdates = 2; + } } } } diff --git a/Projectiles/Rogue/JewelSpike.cs b/Projectiles/Rogue/JewelSpike.cs index eef21832c8..166511b516 100644 --- a/Projectiles/Rogue/JewelSpike.cs +++ b/Projectiles/Rogue/JewelSpike.cs @@ -53,7 +53,8 @@ namespace CalamityMod.Projectiles.Rogue 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; int shard = Projectile.NewProjectile(projectile.Center.X + SpeedX, projectile.Center.Y + SpeedY, SpeedX, SpeedY, ProjectileID.CrystalShard, projectile.damage / 4, 0f, projectile.owner); - Main.projectile[shard].Calamity().forceRogue = true; + if (shard.WithinBounds(Main.maxProjectiles)) + Main.projectile[shard].Calamity().forceRogue = true; } } } diff --git a/Projectiles/Rogue/LeonidProgenitorBombshell.cs b/Projectiles/Rogue/LeonidProgenitorBombshell.cs index c0edfd58db..6249c0917f 100644 --- a/Projectiles/Rogue/LeonidProgenitorBombshell.cs +++ b/Projectiles/Rogue/LeonidProgenitorBombshell.cs @@ -77,41 +77,34 @@ namespace CalamityMod.Projectiles.Rogue if (Main.myPlayer == projectile.owner) { int flash = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 0f, 1f); - Main.projectile[flash].Calamity().forceRogue = true; - Main.projectile[flash].usesLocalNPCImmunity = true; - Main.projectile[flash].localNPCHitCooldown = 10; + if (flash.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[flash].Calamity().forceRogue = true; + Main.projectile[flash].usesLocalNPCImmunity = true; + Main.projectile[flash].localNPCHitCooldown = 10; + } Vector2 pos = new Vector2(projectile.Center.X + projectile.width * 0.5f + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); Vector2 velocity = (projectile.Center - pos) / 40f; int dmg = projectile.damage / 2; - int comet = Projectile.NewProjectile(pos, velocity, ModContent.ProjectileType(), dmg, projectile.knockBack, projectile.owner, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); + Projectile.NewProjectile(pos, velocity, ModContent.ProjectileType(), dmg, projectile.knockBack, projectile.owner, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 300); - if (!projectile.Calamity().stealthStrike || Main.myPlayer != projectile.owner) - return; - - Vector2 spinningpoint = new Vector2(0f, 6f); - float num1 = MathHelper.ToRadians(45f); - int cometAmt = 5; - float num3 = -(num1 * 2f) / (cometAmt - 1f); - for (int projIndex = 0; projIndex < cometAmt; ++projIndex) - { - int index2 = Projectile.NewProjectile(projectile.Center, spinningpoint.RotatedBy((double)num1 + (double)num3 * (double)projIndex, new Vector2()), ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, -1f); - Projectile proj = Main.projectile[index2]; - for (int index3 = 0; index3 < projectile.localNPCImmunity.Length; ++index3) - { - proj.localNPCImmunity[index3] = projectile.localNPCImmunity[index3]; - } - } - } + StealthStrikeEffect(); + } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 300); + StealthStrikeEffect(); + } + + private void StealthStrikeEffect() + { if (!projectile.Calamity().stealthStrike || Main.myPlayer != projectile.owner) return; diff --git a/Projectiles/Rogue/LionfishProj.cs b/Projectiles/Rogue/LionfishProj.cs index bd925033f7..3611455582 100644 --- a/Projectiles/Rogue/LionfishProj.cs +++ b/Projectiles/Rogue/LionfishProj.cs @@ -71,7 +71,8 @@ namespace CalamityMod.Projectiles.Rogue vector63 *= (float)Main.rand.Next(45, 65) * 0.1f; vector63 = vector63.RotatedBy((Main.rand.NextDouble() - 0.5) * 1.5707963705062866, default); int spike = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, vector63.X, vector63.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, -10f, 0f); - Main.projectile[spike].Calamity().forceRogue = true; + if (spike.WithinBounds(Main.maxProjectiles)) + Main.projectile[spike].Calamity().forceRogue = true; } } } diff --git a/Projectiles/Rogue/LostSoulFriendly.cs b/Projectiles/Rogue/LostSoulFriendly.cs index 8bfad305ef..23fe22da43 100644 --- a/Projectiles/Rogue/LostSoulFriendly.cs +++ b/Projectiles/Rogue/LostSoulFriendly.cs @@ -43,7 +43,8 @@ namespace CalamityMod.Projectiles.Rogue Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.25f / 255f, (255 - projectile.alpha) * 0.25f / 255f, (255 - projectile.alpha) * 0.25f / 255f); projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - //CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 400f, 6f, 20f); + if (projectile.ai[0] != 1f) + CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 400f, 6f, 20f); } public override void Kill(int timeLeft) diff --git a/Projectiles/Rogue/OrichalcumSpikedGemstoneProjectile.cs b/Projectiles/Rogue/OrichalcumSpikedGemstoneProjectile.cs index a6dc9b442b..f341125da8 100644 --- a/Projectiles/Rogue/OrichalcumSpikedGemstoneProjectile.cs +++ b/Projectiles/Rogue/OrichalcumSpikedGemstoneProjectile.cs @@ -56,30 +56,16 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (Main.myPlayer != projectile.owner) - return; - - for (int i = 0; i < 2; i++) - { - int direction = Main.player[projectile.owner].direction; - float xStart = Main.screenPosition.X; - if (direction < 0) - xStart += Main.screenWidth; - float yStart = Main.screenPosition.Y + Main.rand.Next(Main.screenHeight); - Vector2 startPos = new Vector2(xStart, yStart); - Vector2 pathToTravel = target.Center - startPos; - pathToTravel.X += Main.rand.NextFloat(-50f, 50f) * 0.1f; - pathToTravel.Y += Main.rand.NextFloat(-50f, 50f) * 0.1f; - float speedMult = 24f / pathToTravel.Length(); - pathToTravel.X *= speedMult; - pathToTravel.Y *= speedMult; - int petal = Projectile.NewProjectile(startPos, pathToTravel, ProjectileID.FlowerPetal, projectile.damage, 0f, projectile.owner, 0f, 0f); - Main.projectile[petal].Calamity().forceRogue = true; - } + OnHitEffect(target.Center); } public override void OnHitPvp(Player target, int damage, bool crit) { + OnHitEffect(target.Center); + } + + private void OnHitEffect(Vector2 targetPos) + { if (Main.myPlayer != projectile.owner) return; @@ -91,14 +77,15 @@ namespace CalamityMod.Projectiles.Rogue xStart += Main.screenWidth; float yStart = Main.screenPosition.Y + Main.rand.Next(Main.screenHeight); Vector2 startPos = new Vector2(xStart, yStart); - Vector2 pathToTravel = target.Center - startPos; + Vector2 pathToTravel = targetPos - startPos; pathToTravel.X += Main.rand.NextFloat(-50f, 50f) * 0.1f; pathToTravel.Y += Main.rand.NextFloat(-50f, 50f) * 0.1f; float speedMult = 24f / pathToTravel.Length(); pathToTravel.X *= speedMult; pathToTravel.Y *= speedMult; - int petal = Projectile.NewProjectile(startPos, pathToTravel, ProjectileID.FlowerPetal, projectile.damage, 0f, projectile.owner, 0f, 0f); - Main.projectile[petal].Calamity().forceRogue = true; + int petal = Projectile.NewProjectile(startPos, pathToTravel, ProjectileID.FlowerPetal, projectile.damage, 0f, projectile.owner); + if (petal.WithinBounds(Main.maxProjectiles)) + Main.projectile[petal].Calamity().forceRogue = true; } } diff --git a/Projectiles/Rogue/PalladiumJavelinProjectile.cs b/Projectiles/Rogue/PalladiumJavelinProjectile.cs index 9555efbb1c..765e9f7e23 100644 --- a/Projectiles/Rogue/PalladiumJavelinProjectile.cs +++ b/Projectiles/Rogue/PalladiumJavelinProjectile.cs @@ -52,12 +52,18 @@ namespace CalamityMod.Projectiles.Rogue Dust.NewDust(projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 144, 0f, 0f, 0, default, 1f); } - int javelin = Projectile.NewProjectile(projectile.Center, projectile.velocity.RotatedBy(MathHelper.ToRadians(5f)), projectile.type, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - int javelin2 = Projectile.NewProjectile(projectile.Center, projectile.velocity.RotatedBy(MathHelper.ToRadians(-5f)), projectile.type, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[javelin].Calamity().lineColor = projectile.Calamity().lineColor + 1; - Main.projectile[javelin2].Calamity().lineColor = projectile.Calamity().lineColor + 1; - Main.projectile[javelin].Calamity().stealthStrike = true; - Main.projectile[javelin2].Calamity().stealthStrike = true; + int javelin = Projectile.NewProjectile(projectile.Center, projectile.velocity.RotatedBy(MathHelper.ToRadians(5f)), projectile.type, projectile.damage, projectile.knockBack, projectile.owner); + int javelin2 = Projectile.NewProjectile(projectile.Center, projectile.velocity.RotatedBy(MathHelper.ToRadians(-5f)), projectile.type, projectile.damage, projectile.knockBack, projectile.owner); + if (javelin.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[javelin].Calamity().lineColor = projectile.Calamity().lineColor + 1; + Main.projectile[javelin].Calamity().stealthStrike = true; + } + if (javelin2.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[javelin2].Calamity().lineColor = projectile.Calamity().lineColor + 1; + Main.projectile[javelin2].Calamity().stealthStrike = true; + } projectile.Kill(); } } diff --git a/Projectiles/Rogue/PhantasmalRuinProj.cs b/Projectiles/Rogue/PhantasmalRuinProj.cs index 637d8a1797..683bb02ebf 100644 --- a/Projectiles/Rogue/PhantasmalRuinProj.cs +++ b/Projectiles/Rogue/PhantasmalRuinProj.cs @@ -38,7 +38,7 @@ 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; Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 175, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, 0, default(Color), 0.85f); if (projectile.timeLeft % 18 == 0) { @@ -46,11 +46,11 @@ namespace CalamityMod.Projectiles.Rogue { if (projectile.Calamity().stealthStrike) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner); } else { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X * 0f, Main.rand.NextFloat(-2,2), ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, Main.rand.NextFloat(-2,2), ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner, 1f); } } } @@ -58,54 +58,34 @@ 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() + { float spread = 45f * 0.0174f; 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) { if (Main.player[projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] < 4) { - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { float ai1 = Main.rand.NextFloat() + 0.5f; 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 num23 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f) + randomSpeed, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.05), 0f, projectile.owner, 1f, ai1); - int num24 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f) + randomSpeed2, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.05), 0f, projectile.owner, 1f, ai1); + int num23 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f) + randomSpeed, ModContent.ProjectileType(), (int)(projectile.damage * 0.05), 0f, projectile.owner, 1f, ai1); + int num24 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f) + randomSpeed2, ModContent.ProjectileType(), (int)(projectile.damage * 0.05), 0f, projectile.owner, 1f, ai1); } } - else - { - damage = (int)(damage * 0.9); - } - } - } - - public override void OnHitPvp(Player target, int damage, bool crit) - { - float spread = 45f * 0.0174f; - 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 && Main.player[projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()] < 4) - { - for (i = 0; i < 4; i++) - { - float ai1 = Main.rand.NextFloat() + 0.5f; - 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 num23 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f) + randomSpeed, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.05), 0f, projectile.owner, 1f, ai1); - int num24 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f) + randomSpeed2, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.05), 0f, projectile.owner, 1f, ai1); - } - } - else - { - damage = (int)(damage * 0.9); } } } diff --git a/Projectiles/Rogue/PhantomLanceProj.cs b/Projectiles/Rogue/PhantomLanceProj.cs index 459ed43d48..3b5e9cdd46 100644 --- a/Projectiles/Rogue/PhantomLanceProj.cs +++ b/Projectiles/Rogue/PhantomLanceProj.cs @@ -12,8 +12,6 @@ namespace CalamityMod.Projectiles.Rogue { public override string Texture => "CalamityMod/Items/Weapons/Rogue/PhantomLance"; - private int projCount = 22; - public override void SetStaticDefaults() { DisplayName.SetDefault("Phantom Lance"); @@ -41,7 +39,7 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - if (projectile.Calamity().stealthStrike != true) + if (!projectile.Calamity().stealthStrike) { if (projectile.timeLeft <= 255) projectile.alpha += 1; @@ -51,34 +49,25 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity.Y *= 0.995f; } } - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 175, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, 0, default, 0.85f); - projCount--; - if (projCount <= 0) + projectile.ai[0]++; + if (projectile.ai[0] % 18f == 0f) { if (projectile.owner == Main.myPlayer) { + float damageMult = projectile.timeLeft * 0.7f / 300f; if (projectile.Calamity().stealthStrike) + damageMult = 0.7f; + int soulDamage = (int)(projectile.damage * damageMult); + int soul = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), soulDamage, projectile.knockBack, projectile.owner); + if (soul.WithinBounds(Main.maxProjectiles)) { - int stealthSoulDamage = (int)(projectile.damage * 0.7f); - float stealthSoulKB = projectile.knockBack; - int stealthSoul = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), stealthSoulDamage, stealthSoulKB, projectile.owner, 0f, 0f); - Main.projectile[stealthSoul].Calamity().forceRogue = true; - Main.projectile[stealthSoul].usesLocalNPCImmunity = true; - Main.projectile[stealthSoul].localNPCHitCooldown = -2; - } - else - { - float damageMult = projectile.timeLeft * 0.7f / 300f; - int soulDamage = (int)(projectile.damage * damageMult); - float soulKB = projectile.knockBack; - int soul = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), soulDamage, soulKB, projectile.owner, 0f, 0f); Main.projectile[soul].Calamity().forceRogue = true; Main.projectile[soul].usesLocalNPCImmunity = true; Main.projectile[soul].localNPCHitCooldown = -2; } } - projCount = 18; } } diff --git a/Projectiles/Rogue/PoisonBol.cs b/Projectiles/Rogue/PoisonBol.cs index 4c145bdaa0..31bb6eb1f3 100644 --- a/Projectiles/Rogue/PoisonBol.cs +++ b/Projectiles/Rogue/PoisonBol.cs @@ -37,30 +37,29 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.timeLeft < 20) projectile.alpha += 13; - if (projectile.Calamity().stealthStrike == true) + if (projectile.Calamity().stealthStrike) { projectile.localAI[1]++; - if ((double) projectile.localAI[1] >= 35) + if (projectile.localAI[1] % 35f == 0f) { - Vector2 velocity = projectile.velocity; - Vector2 vector2_1 = new Vector2((float) Main.rand.Next(-100, 101), (float) Main.rand.Next(-100, 101)); - vector2_1.Normalize(); - Vector2 vector2_2 = vector2_1 * ((float) Main.rand.Next(10, 21) * 0.1f); - if (Main.rand.Next(3) == 0) - vector2_2 *= 2f; - Vector2 vector2_3 = velocity * 0.25f + vector2_2; - Vector2 vector2_5 = vector2_3 * 0.8f; - int proj = Projectile.NewProjectile(projectile.Center.X - vector2_5.X, projectile.Center.Y - vector2_5.Y, vector2_5.X, vector2_5.Y, Main.rand.Next(569,572), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceRogue = true; - Main.projectile[proj].usesLocalNPCImmunity = true; - Main.projectile[proj].localNPCHitCooldown = 45; - projectile.localAI[1] = 0.0f; + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 20f); + if (Main.rand.NextBool(3)) + velocity *= 2f; + velocity += projectile.velocity * 0.25f; + velocity *= 0.8f; + int proj = Projectile.NewProjectile(projectile.Center - velocity, velocity, Main.rand.Next(569,572), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().forceRogue = true; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 45; + } } } Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.killSpikyBalls == true) + if (modPlayer.killSpikyBalls) { projectile.active = false; projectile.netUpdate = true; diff --git a/Projectiles/Rogue/Prismalline3.cs b/Projectiles/Rogue/Prismalline3.cs index 8b3f972d89..373624c752 100644 --- a/Projectiles/Rogue/Prismalline3.cs +++ b/Projectiles/Rogue/Prismalline3.cs @@ -50,9 +50,12 @@ namespace CalamityMod.Projectiles.Rogue for (int s = 0; s < shardCount; s++) { 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; + int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner); + if (shard.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[shard].Calamity().forceRogue = true; + Main.projectile[shard].penetrate = 1; + } } } } diff --git a/Projectiles/Rogue/PrismallineProj.cs b/Projectiles/Rogue/PrismallineProj.cs index 526c2af0b0..2bfbcfe0cb 100644 --- a/Projectiles/Rogue/PrismallineProj.cs +++ b/Projectiles/Rogue/PrismallineProj.cs @@ -64,10 +64,13 @@ namespace CalamityMod.Projectiles.Rogue for (int num252 = 0; num252 < shardCount; num252++) { 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; + int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner); + if (shard.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[shard].Calamity().forceRogue = true; + Main.projectile[shard].usesLocalNPCImmunity = true; + Main.projectile[shard].localNPCHitCooldown = 10; + } } for (int i = 0; i < numProj + 1; i++) { @@ -99,9 +102,12 @@ namespace CalamityMod.Projectiles.Rogue for (int s = 0; s < shardCount; s++) { 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; + int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner); + if (shard.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[shard].Calamity().forceRogue = true; + Main.projectile[shard].penetrate = 1; + } } } } diff --git a/Projectiles/Rogue/Quasar2.cs b/Projectiles/Rogue/Quasar2.cs index 928ca121c3..937d730296 100644 --- a/Projectiles/Rogue/Quasar2.cs +++ b/Projectiles/Rogue/Quasar2.cs @@ -91,9 +91,12 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.Calamity().stealthStrike && projectile.owner == Main.myPlayer) { int boomer = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.5f), projectile.knockBack, projectile.owner, 0f, 1f); - Main.projectile[boomer].Calamity().stealthStrike = projectile.Calamity().stealthStrike; - Main.projectile[boomer].height = Main.projectile[boomer].width = 280; - Main.projectile[boomer].Center = projectile.Center; + if (boomer.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[boomer].Calamity().stealthStrike = true; + Main.projectile[boomer].height = Main.projectile[boomer].width = 280; + Main.projectile[boomer].Center = projectile.Center; + } } } } diff --git a/Projectiles/Rogue/RadiantExplosion.cs b/Projectiles/Rogue/RadiantExplosion.cs index 341b09e032..4fec6b4f2f 100644 --- a/Projectiles/Rogue/RadiantExplosion.cs +++ b/Projectiles/Rogue/RadiantExplosion.cs @@ -97,68 +97,31 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - 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); - int num15 = 25; - int projectileType = Main.rand.Next(3); - if (projectileType == 0) - { - projectileType = ModContent.ProjectileType(); - } - else if (projectileType == 1) - { - projectileType = ProjectileID.HallowStar; - } - else - { - projectileType = ModContent.ProjectileType(); - } - 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, projectileType, (int)(projectile.damage * 0.75), 5f, projectile.owner, 2f, 0f); - Main.projectile[num17].Calamity().forceRogue = true; - } - } + OnHitEffect(target.Center); + } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 120); + OnHitEffect(target.Center); + } + + private void OnHitEffect(Vector2 targetPos) + { 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); - int num15 = 25; - int projectileType = Main.rand.Next(3); - if (projectileType == 0) - { - projectileType = ModContent.ProjectileType(); - } - else if (projectileType == 1) - { - projectileType = ProjectileID.HallowStar; - } - else - { - projectileType = ModContent.ProjectileType(); - } - 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, projectileType, (int)(projectile.damage * 0.75), 5f, projectile.owner, 2f, 0f); - Main.projectile[num17].Calamity().forceRogue = true; + int projType = Utils.SelectRandom(Main.rand, new int[] + { + ModContent.ProjectileType(), + ProjectileID.HallowStar, + ModContent.ProjectileType() + }); + Projectile star = CalamityUtils.ProjectileRain(targetPos, 400f, 100f, 500f, 800f, 25f, projType, (int)(projectile.damage * 0.75), 5f, projectile.owner); + if (star.whoAmI.WithinBounds(Main.maxProjectiles)) + { + star.Calamity().forceRogue = true; + star.ai[0] = 2f; + } } } } diff --git a/Projectiles/Rogue/RadiantStarKnife.cs b/Projectiles/Rogue/RadiantStarKnife.cs index 1d526ddd4c..dee98ba9a6 100644 --- a/Projectiles/Rogue/RadiantStarKnife.cs +++ b/Projectiles/Rogue/RadiantStarKnife.cs @@ -90,10 +90,10 @@ namespace CalamityMod.Projectiles.Rogue Main.projectile[stabber2].Calamity().stealthStrike = projectile.Calamity().stealthStrike; } Main.PlaySound(SoundID.Item14, projectile.position); - int boomer = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.75f), projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[boomer].Calamity().stealthStrike = projectile.Calamity().stealthStrike; - if (projectile.Calamity().stealthStrike) + int boomer = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.75f), projectile.knockBack, projectile.owner); + if (projectile.Calamity().stealthStrike && boomer.WithinBounds(Main.maxProjectiles)) { + Main.projectile[boomer].Calamity().stealthStrike = true; Main.projectile[boomer].height = 300; Main.projectile[boomer].width = 300; } diff --git a/Projectiles/Rogue/SandDollarStealth.cs b/Projectiles/Rogue/SandDollarStealth.cs index db7cd062ea..98e134d66f 100644 --- a/Projectiles/Rogue/SandDollarStealth.cs +++ b/Projectiles/Rogue/SandDollarStealth.cs @@ -46,8 +46,9 @@ namespace CalamityMod.Projectiles.Rogue for (int coralCount = 0; coralCount < coralAmt; coralCount++) { 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; + int coral = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 3, 0f, projectile.owner); + if (coral.WithinBounds(Main.maxProjectiles)) + Main.projectile[coral].Calamity().forceRogue = true; } } } diff --git a/Projectiles/Rogue/SealedSingularityProj.cs b/Projectiles/Rogue/SealedSingularityProj.cs index 5d5e9b04ea..90d58c81ee 100644 --- a/Projectiles/Rogue/SealedSingularityProj.cs +++ b/Projectiles/Rogue/SealedSingularityProj.cs @@ -48,8 +48,11 @@ namespace CalamityMod.Projectiles.Rogue Main.PlaySound(SoundID.Shatter, (int)projectile.position.X, (int)projectile.position.Y, 1, 1f, 0f); int blackhole = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, projectile.Calamity().stealthStrike ? -180f : 0f, 0f); - Main.projectile[blackhole].Center = projectile.Center; - Main.projectile[blackhole].Calamity().stealthStrike = projectile.Calamity().stealthStrike; + if (blackhole.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[blackhole].Center = projectile.Center; + Main.projectile[blackhole].Calamity().stealthStrike = projectile.Calamity().stealthStrike; + } for (int index = 0; index < 3; ++index) { diff --git a/Projectiles/Rogue/SkyStabberProj.cs b/Projectiles/Rogue/SkyStabberProj.cs index 194406fc3e..eb911614ac 100644 --- a/Projectiles/Rogue/SkyStabberProj.cs +++ b/Projectiles/Rogue/SkyStabberProj.cs @@ -86,7 +86,9 @@ namespace CalamityMod.Projectiles.Rogue { for (int n = 0; n < 4; n++) { - CalamityUtils.ProjectileRain(targetPos, 400f, 100f, 500f, 800f, 20f, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack * 0.25f, projectile.owner, 5); + Projectile feather = CalamityUtils.ProjectileRain(targetPos, 400f, 100f, 500f, 800f, 20f, ModContent.ProjectileType(), (int)(projectile.damage * 0.25), projectile.knockBack * 0.25f, projectile.owner); + if (feather.whoAmI.WithinBounds(Main.maxProjectiles)) + feather.Calamity().forceRogue = true; } } } diff --git a/Projectiles/Rogue/SpentFuelContainerProjectile.cs b/Projectiles/Rogue/SpentFuelContainerProjectile.cs index fa7b73db3e..fc16d6867d 100644 --- a/Projectiles/Rogue/SpentFuelContainerProjectile.cs +++ b/Projectiles/Rogue/SpentFuelContainerProjectile.cs @@ -53,7 +53,8 @@ namespace CalamityMod.Projectiles.Rogue if (WorldUtils.Find(projectile.Top.ToTileCoordinates(), Searches.Chain((GenSearch)new Searches.Down(80), (GenCondition)new Conditions.IsSolid()), out result)) { int proj = Projectile.NewProjectile(result.ToVector2() * 16f, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 2f, projectile.owner); - Main.projectile[proj].Calamity().stealthStrike = projectile.Calamity().stealthStrike; + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = projectile.Calamity().stealthStrike; } } } diff --git a/Projectiles/Rogue/UrchinStingerProj.cs b/Projectiles/Rogue/UrchinStingerProj.cs index 25122b3558..a22d191664 100644 --- a/Projectiles/Rogue/UrchinStingerProj.cs +++ b/Projectiles/Rogue/UrchinStingerProj.cs @@ -52,8 +52,9 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.localAI[0] % 40 == 0 && projectile.ai[0] == 1f) { Vector2 projspeed = new Vector2(Main.rand.NextFloat(-4f, 4f), Main.rand.NextFloat(-4f, 4f)); - int proj = Projectile.NewProjectile(projectile.Center, projspeed, ModContent.ProjectileType(), (int)(projdmg * 0.5f), 1f, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceRogue = true; + int proj = Projectile.NewProjectile(projectile.Center, projspeed, ModContent.ProjectileType(), (int)(projdmg * 0.5f), 1f, projectile.owner); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().forceRogue = true; } return false; } diff --git a/Projectiles/Rogue/ValedictionBoomerang.cs b/Projectiles/Rogue/ValedictionBoomerang.cs index dea5b032d5..3419450543 100644 --- a/Projectiles/Rogue/ValedictionBoomerang.cs +++ b/Projectiles/Rogue/ValedictionBoomerang.cs @@ -146,9 +146,12 @@ namespace CalamityMod.Projectiles.Rogue 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; + if (typhoon.whoAmI.WithinBounds(Main.maxProjectiles)) + { + typhoon.Calamity().forceRogue = true; + typhoon.usesLocalNPCImmunity = true; + typhoon.localNPCHitCooldown = 10; + } } } } diff --git a/Projectiles/Summon/AstrageldonSummon.cs b/Projectiles/Summon/AstrageldonSummon.cs index eeb30a3c4f..c2ef7f42e2 100644 --- a/Projectiles/Summon/AstrageldonSummon.cs +++ b/Projectiles/Summon/AstrageldonSummon.cs @@ -212,7 +212,7 @@ namespace CalamityMod.Projectiles.Summon Vector2 laserVel = objectivepos - projectile.Center; laserVel.Normalize(); laserVel *= scaleFactor3; - int laser = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, laserVel.X, laserVel.Y, projType, projectile.damage, 0f, projectile.owner, 0f, 0f); + int laser = Projectile.NewProjectile(projectile.Center, laserVel, projType, projectile.damage, 0f, projectile.owner); projectile.netUpdate = true; } } diff --git a/Projectiles/Summon/BabyBloodCrawler.cs b/Projectiles/Summon/BabyBloodCrawler.cs index f0d3a1b2d4..7a46e4f780 100644 --- a/Projectiles/Summon/BabyBloodCrawler.cs +++ b/Projectiles/Summon/BabyBloodCrawler.cs @@ -117,44 +117,22 @@ namespace CalamityMod.Projectiles.Summon immuneTime = 5; //cap to prevent potential insanity target.immune[projectile.owner] = immuneTime; - if (Main.rand.NextBool(2)) - { - for (int n = 0; n < Main.rand.Next(1, 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); - 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)((float)projectile.damage * Main.rand.NextFloat(0.7f, 1f)), projectile.knockBack * Main.rand.NextFloat(0.7f, 1f), projectile.owner, 0f, 0f); - } - } - } + OnHitEffects(target.Center); + } public override void OnHitPvp(Player target, int damage, bool crit) { + OnHitEffects(target.Center); + } + + private void OnHitEffects(Vector2 targetPos) + { if (Main.rand.NextBool(2)) { - for (int n = 0; n < Main.rand.Next(1, 3); n++) + int projAmt = Main.rand.Next(1, 3); + for (int n = 0; n < projAmt; 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); - 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)((float)projectile.damage * Main.rand.NextFloat(0.7f, 1f)), projectile.knockBack * Main.rand.NextFloat(0.7f, 1f), projectile.owner, 0f, 0f); + CalamityUtils.ProjectileRain(targetPos, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), (int)(projectile.damage * Main.rand.NextFloat(0.7f, 1f)), projectile.knockBack * Main.rand.NextFloat(0.7f, 1f), projectile.owner); } } } diff --git a/Projectiles/Summon/GiantIbanRobotOfDoom.cs b/Projectiles/Summon/GiantIbanRobotOfDoom.cs index 1de6bb0f26..e07cd41eb6 100644 --- a/Projectiles/Summon/GiantIbanRobotOfDoom.cs +++ b/Projectiles/Summon/GiantIbanRobotOfDoom.cs @@ -387,7 +387,7 @@ namespace CalamityMod.Projectiles.Summon 8f, projectile.owner, projectile.whoAmI); - if (player.HeldItem != null) + if (player.HeldItem != null && deathLaser.whoAmI.WithinBounds(Main.maxProjectiles)) { if (player.HeldItem.magic) { diff --git a/Projectiles/Typeless/DemonshadeRedDevil.cs b/Projectiles/Typeless/DemonshadeRedDevil.cs index e9d1b1ceaf..b3c5540d7a 100644 --- a/Projectiles/Typeless/DemonshadeRedDevil.cs +++ b/Projectiles/Typeless/DemonshadeRedDevil.cs @@ -100,30 +100,6 @@ namespace CalamityMod.Projectiles.Typeless float num634 = 2000f; float num635 = 3000f; float num636 = 150f; - float num637 = 0.05f; - for (int num638 = 0; num638 < Main.maxProjectiles; num638++) - { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X = projectile.velocity.X - num637; - } - else - { - projectile.velocity.X = projectile.velocity.X + num637; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num637; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num637; - } - } - } bool flag24 = false; if (projectile.ai[0] == 2f) { @@ -269,21 +245,24 @@ namespace CalamityMod.Projectiles.Typeless } if (projectile.ai[0] == 0f) { - float scaleFactor3 = 24f; - int num658 = ProjectileID.UnholyTridentFriendly; + float speed = 24f; + int projType = ProjectileID.UnholyTridentFriendly; if (flag25 && projectile.ai[1] == 0f) { projectile.ai[1] += 1f; - if (Main.myPlayer == projectile.owner && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, vector46, 0, 0)) + if (Main.myPlayer == projectile.owner && Collision.CanHitLine(projectile.Center, projectile.width, projectile.height, vector46, 0, 0)) { - Vector2 value19 = vector46 - projectile.Center; - value19.Normalize(); - value19 *= scaleFactor3; - int num659 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value19.X, value19.Y, num658, projectile.damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[num659].timeLeft = 300; - Main.projectile[num659].usesLocalNPCImmunity = true; - Main.projectile[num659].localNPCHitCooldown = 10; - Main.projectile[num659].Calamity().forceTypeless = true; //typeless + Vector2 velocity = vector46 - projectile.Center; + velocity.Normalize(); + velocity *= speed; + int trident = Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, 0f, Main.myPlayer); + if (trident.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[trident].timeLeft = 300; + Main.projectile[trident].usesLocalNPCImmunity = true; + Main.projectile[trident].localNPCHitCooldown = 10; + Main.projectile[trident].Calamity().forceTypeless = true; //typeless + } projectile.netUpdate = true; } } diff --git a/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index 37b097c3a9..7867b8b307 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -56,7 +56,7 @@ namespace CalamityMod CalamityRarity.Developer, CalamityRarity.Rainbow }; - + #region Object Extensions public static CalamityPlayer Calamity(this Player player) => player.GetModPlayer(); public static CalamityGlobalNPC Calamity(this NPC npc) => npc.GetGlobalNPC(); @@ -418,7 +418,7 @@ namespace CalamityMod /// Whether to ignore tiles when finding a target or not public static NPC MinionHoming(this Vector2 origin, float maxDistanceToCheck, Player owner, bool ignoreTiles = true) { - if (owner is null || owner.whoAmI < 0 || owner.whoAmI > Main.maxPlayers || owner.MinionAttackTargetNPC < 0 || owner.MinionAttackTargetNPC > Main.maxNPCs) + if (owner is null || !owner.whoAmI.WithinBounds(Main.maxPlayers) || !owner.MinionAttackTargetNPC.WithinBounds(Main.maxNPCs)) return ClosestNPCAt(origin, maxDistanceToCheck, ignoreTiles); NPC npc = Main.npc[owner.MinionAttackTargetNPC]; bool canHit = true; @@ -933,7 +933,7 @@ namespace CalamityMod { killProj = true; } - else if (npcIndex < 0 || npcIndex >= Main.maxNPCs) + else if (!npcIndex.WithinBounds(Main.maxNPCs)) { killProj = true; } @@ -1114,7 +1114,7 @@ namespace CalamityMod } } - 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, int extraUpdates = 0) + public static Projectile ProjectileRain(Vector2 targetPos, float xLimit, float xVariance, float yLimitLower, float yLimitUpper, float projSpeed, int projType, int damage, float knockback, int owner) { float x = targetPos.X + Main.rand.NextFloat(-xLimit, xLimit); if (projType == ModContent.ProjectileType()) @@ -1128,50 +1128,7 @@ namespace CalamityMod targetDist = speed / targetDist; velocity.X *= targetDist; velocity.Y *= targetDist; - Projectile proj = Projectile.NewProjectileDirect(source, velocity, projType, damage, knockback, owner, 0f, 0f); - proj.extraUpdates += extraUpdates; - 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; + return Projectile.NewProjectileDirect(source, velocity, projType, damage, knockback, owner); } 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) @@ -1190,8 +1147,7 @@ namespace CalamityMod 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; + return Projectile.NewProjectileDirect(spawnPosition, velocity, projType, damage, knockback, owner); } public static int DamageSoftCap(double dmgInput, int cap) @@ -4107,6 +4063,8 @@ namespace CalamityMod } } + public static bool WithinBounds(this int index, int cap) => index >= 0 && index < cap; + // 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) { From effed3b773cac20000a72475c2935bec0d5e0d23 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Fri, 11 Dec 2020 16:23:44 -0500 Subject: [PATCH 50/66] added thingy to vile feeder --- Projectiles/Summon/VileFeederSummon.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Projectiles/Summon/VileFeederSummon.cs b/Projectiles/Summon/VileFeederSummon.cs index 8f1e606c5d..837d42df2b 100644 --- a/Projectiles/Summon/VileFeederSummon.cs +++ b/Projectiles/Summon/VileFeederSummon.cs @@ -4,6 +4,7 @@ using CalamityMod.Items.Weapons.Summon; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; +using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -37,6 +38,16 @@ namespace CalamityMod.Projectiles.Summon projectile.minion = true; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.Calamity().lineColor); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.Calamity().lineColor = reader.ReadInt32(); + } + public override void AI() { Player player = Main.player[projectile.owner]; From e604645e9adb8dd999f72c8966f92b03ba6332c8 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Fri, 11 Dec 2020 16:33:37 -0500 Subject: [PATCH 51/66] some code cleanup --- Projectiles/Rogue/MalachiteStealth.cs | 17 +++++++---------- Projectiles/Summon/VileFeederSummon.cs | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Projectiles/Rogue/MalachiteStealth.cs b/Projectiles/Rogue/MalachiteStealth.cs index 3e477d69b9..f1dea697dc 100644 --- a/Projectiles/Rogue/MalachiteStealth.cs +++ b/Projectiles/Rogue/MalachiteStealth.cs @@ -38,14 +38,14 @@ namespace CalamityMod.Projectiles.Rogue { if (projectile.ai[0] == 0f) { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 800f, 10f, 25f); projectile.localAI[1] += 1f; if (projectile.localAI[1] > 4f) { for (int num468 = 0; num468 < 3; num468++) { - int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 0.75f); + int num469 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 0.75f); Main.dust[num469].noGravity = true; Main.dust[num469].velocity *= 0f; } @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Rogue else { int id = (int)projectile.ai[1]; - if (id >= 0 && id < Main.maxNPCs && Main.npc[id].active && !Main.npc[id].dontTakeDamage) + if (id.WithinBounds(Main.maxNPCs) && Main.npc[id].active && !Main.npc[id].dontTakeDamage) { projectile.Center = Main.npc[id].Center - projectile.velocity * 2f; projectile.gfxOffY = Main.npc[id].gfxOffY; @@ -83,14 +83,11 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { projectile.ai[0] = 2f; - projectile.position = projectile.Center; - projectile.width = projectile.height = 112; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 112); Main.PlaySound(SoundID.Item14, projectile.position); for (int i = 0; i < 7; i++) { - int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); + int dusty = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.2f); Main.dust[dusty].velocity *= 3f; if (Main.rand.NextBool(2)) { @@ -100,10 +97,10 @@ namespace CalamityMod.Projectiles.Rogue } for (int j = 0; j < 15; j++) { - int green = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); + int green = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); Main.dust[green].noGravity = true; Main.dust[green].velocity *= 5f; - green = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + green = Dust.NewDust(projectile.position, projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); Main.dust[green].velocity *= 2f; } projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Summon/VileFeederSummon.cs b/Projectiles/Summon/VileFeederSummon.cs index 837d42df2b..b29d50f33c 100644 --- a/Projectiles/Summon/VileFeederSummon.cs +++ b/Projectiles/Summon/VileFeederSummon.cs @@ -128,7 +128,7 @@ namespace CalamityMod.Projectiles.Summon { breakAway = true; } - else if (npcIndex < 0 || npcIndex >= Main.maxNPCs) + else if (!npcIndex.WithinBounds(Main.maxNPCs)) { breakAway = true; } From 582213bdd811c974846471d0ef868fa479ec4417 Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 11 Dec 2020 19:45:42 -0600 Subject: [PATCH 52/66] Fixed Aquatic Emblem loading problems --- CalPlayer/CalamityPlayer.cs | 19 ++++++++++--------- CalPlayer/CalamityPlayerMiscEffects.cs | 2 +- CalamityNetcode.cs | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 564c4a6f4f..7280d47cde 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -1118,6 +1118,7 @@ namespace CalamityMod.CalPlayer { "boost", boost }, { "stress", rage }, { "adrenaline", adrenaline }, + { "aquaticBoostPower", (double)aquaticBoost }, { "sCalDeathCount", sCalDeathCount }, { "sCalKillCount", sCalKillCount }, { "meleeLevel", meleeLevel }, @@ -1135,7 +1136,6 @@ namespace CalamityMod.CalPlayer { "deathModeBlizzardTime", deathModeBlizzardTime }, { "itemTypeLastReforged", itemTypeLastReforged }, { "reforgeTierSafety", reforgeTierSafety }, - //{ "aquaticBoost", aquaticBoost }, { "moveSpeedStat", moveSpeedStat }, { "defenseDamage", defenseDamage } }; @@ -1189,7 +1189,8 @@ namespace CalamityMod.CalPlayer rage = tag.GetAsInt("stress"); adrenaline = tag.GetAsInt("adrenaline"); - //aquaticBoost = tag.GetAsInt("aquaticBoost"); + if (tag.ContainsKey("aquaticBoostPower")) + aquaticBoost = (float)tag.GetAsDouble("aquaticBoostPower"); sCalDeathCount = tag.GetInt("sCalDeathCount"); sCalKillCount = tag.GetInt("sCalKillCount"); deathCount = tag.GetInt("deathCount"); @@ -1227,7 +1228,7 @@ namespace CalamityMod.CalPlayer int loadVersion = reader.ReadInt32(); rage = reader.ReadInt32(); adrenaline = reader.ReadInt32(); - //aquaticBoost = reader.ReadInt32(); + aquaticBoost = reader.ReadSingle(); sCalDeathCount = reader.ReadInt32(); sCalKillCount = reader.ReadInt32(); deathCount = reader.ReadInt32(); @@ -10237,7 +10238,7 @@ namespace CalamityMod.CalPlayer packet.Send(-1, player.whoAmI); } - /*public void AquaticBoostPacket(bool server) + public void AquaticBoostPacket(bool server) { ModPacket packet = mod.GetPacket(256); packet.Write((byte)CalamityModMessageType.AquaticBoostSync); @@ -10248,7 +10249,7 @@ namespace CalamityMod.CalPlayer packet.Send(); else packet.Send(-1, player.whoAmI); - }*/ + } public void MoveSpeedStatPacket(bool server) { @@ -10375,12 +10376,12 @@ namespace CalamityMod.CalPlayer ReforgeTierSafetyPacket(true); } - /*internal void HandleAquaticBoost(BinaryReader reader) + internal void HandleAquaticBoost(BinaryReader reader) { - aquaticBoost = reader.ReadInt32(); + aquaticBoost = reader.ReadSingle(); if (Main.netMode == NetmodeID.Server) AquaticBoostPacket(true); - }*/ + } internal void HandleMoveSpeedStat(BinaryReader reader) { @@ -10417,7 +10418,7 @@ namespace CalamityMod.CalPlayer DeathModeBlizzardTimePacket(false); ItemTypeLastReforgedPacket(false); ReforgeTierSafetyPacket(false); - //AquaticBoostPacket(false); + AquaticBoostPacket(false); MoveSpeedStatPacket(false); DefenseDamagePacket(false); } diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index e37bd4e615..c3521810a8 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -347,7 +347,7 @@ namespace CalamityMod.CalPlayer modPlayer.AdrenalinePacket(false); modPlayer.DeathModeUnderworldTimePacket(false); modPlayer.DeathModeBlizzardTimePacket(false); - //modPlayer.AquaticBoostPacket(false); + modPlayer.AquaticBoostPacket(false); modPlayer.MoveSpeedStatPacket(false); modPlayer.DefenseDamagePacket(false); } diff --git a/CalamityNetcode.cs b/CalamityNetcode.cs index 572f32e540..8b2c0c28ee 100644 --- a/CalamityNetcode.cs +++ b/CalamityNetcode.cs @@ -267,7 +267,7 @@ namespace CalamityMod StressSync, AdrenalineSync, - //AquaticBoostSync, + AquaticBoostSync, TeleportPlayer, BossRushStage, From 4729e00b27cc59417ae7045a639e67314ebb4c92 Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 11 Dec 2020 19:51:48 -0600 Subject: [PATCH 53/66] Mothron charge fix --- NPCs/CalamityVanillaMinibossesAI.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NPCs/CalamityVanillaMinibossesAI.cs b/NPCs/CalamityVanillaMinibossesAI.cs index e17056354e..03a3e66cd6 100644 --- a/NPCs/CalamityVanillaMinibossesAI.cs +++ b/NPCs/CalamityVanillaMinibossesAI.cs @@ -136,7 +136,7 @@ namespace CalamityMod.NPCs if (selection == 0 && Collision.CanHit(npc.Center, 1, 1, target.Center, 1, 1)) aiState = (int)MothronAIState.AccelerateTowardsPlayer; else if (selection == 1) - aiState = (int)MothronAIState.ChargePreparation; + aiState = (int)MothronAIState.ChargeRedirect; else if (selection == 2 && NPC.CountNPCS(NPCID.MothronEgg) + NPC.CountNPCS(NPCID.MothronSpawn) < 2) aiState = (int)MothronAIState.PickSpotToLayEgg; } @@ -252,7 +252,7 @@ namespace CalamityMod.NPCs flySpeedAdditive += 0.0333333351f; flySpeed = 24f + flySpeedAdditive; flyInertia = 4f; - idealVelocity = npc.DirectionTo(destination); + idealVelocity = npc.DirectionTo(destination) * flySpeed; npc.velocity = (npc.velocity * (flyInertia - 1f) + idealVelocity) / flyInertia; break; case MothronAIState.ChargePreparation: From 831b674aa1727ee1375d3271ab705df9ca155f5a Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 11 Dec 2020 20:23:16 -0600 Subject: [PATCH 54/66] Further desync reduction --- NPCs/CalamityVanillaMinibossesAI.cs | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/NPCs/CalamityVanillaMinibossesAI.cs b/NPCs/CalamityVanillaMinibossesAI.cs index 03a3e66cd6..c3efcf9aee 100644 --- a/NPCs/CalamityVanillaMinibossesAI.cs +++ b/NPCs/CalamityVanillaMinibossesAI.cs @@ -141,6 +141,7 @@ namespace CalamityMod.NPCs aiState = (int)MothronAIState.PickSpotToLayEgg; } npc.netUpdate = true; + npc.netSpam = 0; } break; @@ -247,6 +248,7 @@ namespace CalamityMod.NPCs aiState = (int)MothronAIState.ChargePreparation; flySpeedAdditive = 0f; npc.netUpdate = true; + npc.netSpam = 0; } flySpeedAdditive += 0.0333333351f; @@ -269,21 +271,24 @@ namespace CalamityMod.NPCs npc.velocity = (npc.velocity * (chargePreperationInertia - 1f) + chargeVelocity) / chargePreperationInertia; npc.spriteDirection = npc.direction = (npc.velocity.X > 0).ToDirectionInt(); - aiTimer++; // Redirect for 10 frames. After that time has been spent, immediately charge as usual. - if (Main.netMode != NetmodeID.MultiplayerClient && - aiTimer > 10f) + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.velocity = chargeVelocity; + aiTimer++; + if (aiTimer > 10f) + { + npc.velocity = chargeVelocity; - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; + if (npc.velocity.X < 0f) + npc.direction = -1; + else + npc.direction = 1; - aiState = (int)MothronAIState.DoTheFuckingCharge; - chargeDirection = npc.direction; - npc.netUpdate = true; + aiState = (int)MothronAIState.DoTheFuckingCharge; + chargeDirection = npc.direction; + npc.netUpdate = true; + npc.netSpam = 0; + } } break; @@ -320,6 +325,7 @@ namespace CalamityMod.NPCs flySpeedAdditive = 0f; npc.netUpdate = true; } + npc.netSpam = 0; } npc.rotation = (npc.rotation * 4f + npc.velocity.X * 0.0175f) / 5f; break; @@ -365,6 +371,7 @@ namespace CalamityMod.NPCs } } npc.netUpdate = true; + npc.netSpam = 0; } break; From e2c0f9da5833d189cdcda37562ee37aeaf295835 Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 11 Dec 2020 20:24:37 -0600 Subject: [PATCH 55/66] Dungeon fix oversight patch --- ILEditing/ILChanges.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ILEditing/ILChanges.cs b/ILEditing/ILChanges.cs index 1f45e81914..a361f46e9d 100644 --- a/ILEditing/ILChanges.cs +++ b/ILEditing/ILChanges.cs @@ -101,7 +101,7 @@ namespace CalamityMod.ILEditing cursor.Emit(OpCodes.Ldloc, 6); cursor.EmitDelegate>(unclampedValue => { - unclampedValue.X = MathHelper.Clamp(unclampedValue.X, SulphurousSea.BiomeWidth + 25, Main.maxTilesX - SulphurousSea.BiomeWidth); + unclampedValue.X = MathHelper.Clamp(unclampedValue.X, SulphurousSea.BiomeWidth + 25, Main.maxTilesX - SulphurousSea.BiomeWidth - 25); return unclampedValue; }); cursor.Emit(OpCodes.Stloc, 6); From a51da399dcce995ad96412dd0027723c11b841fa Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Fri, 11 Dec 2020 22:55:04 -0500 Subject: [PATCH 56/66] grax and depth crusher now have a right click to attack but no destroy --- Items/Tools/Grax.cs | 26 +++++++++++++++++++++++--- Items/Tools/PurityAxe.cs | 5 +---- Items/Weapons/Melee/DepthBlade.cs | 21 +++++++++++++++++++-- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/Items/Tools/Grax.cs b/Items/Tools/Grax.cs index 360c8d3549..2ed04dc688 100644 --- a/Items/Tools/Grax.cs +++ b/Items/Tools/Grax.cs @@ -7,10 +7,13 @@ namespace CalamityMod.Items.Tools { public class Grax : ModItem { + private static int HammerPower = 200; + private static int AxePower = 50; public override void SetStaticDefaults() { DisplayName.SetDefault("Grax"); - Tooltip.SetDefault("Hitting an enemy will greatly boost your defense and melee stats for a short time"); + Tooltip.SetDefault("Hitting an enemy will greatly boost your defense and melee stats for a short time\n" + + "Right click to use without hammering down walls or chopping down trees"); } public override void SetDefaults() @@ -24,8 +27,8 @@ namespace CalamityMod.Items.Tools item.useStyle = ItemUseStyleID.SwingThrow; item.useTime = 4; item.useTurn = true; - item.axe = 50; - item.hammer = 200; + item.axe = AxePower; + item.hammer = HammerPower; item.knockBack = 8f; item.UseSound = SoundID.Item1; item.autoReuse = true; @@ -35,6 +38,23 @@ namespace CalamityMod.Items.Tools item.Calamity().customRarity = CalamityRarity.Turquoise; } + public override bool AltFunctionUse(Player player) => true; + + public override bool CanUseItem(Player player) + { + if (player.altFunctionUse == 2) + { + item.axe = 0; + item.hammer = 0; + } + else + { + item.axe = AxePower; + item.hammer = HammerPower; + } + return base.CanUseItem(player); + } + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); diff --git a/Items/Tools/PurityAxe.cs b/Items/Tools/PurityAxe.cs index c5b156e2cd..b19e2969f3 100644 --- a/Items/Tools/PurityAxe.cs +++ b/Items/Tools/PurityAxe.cs @@ -43,10 +43,7 @@ namespace CalamityMod.Items.Tools return false; } - public override bool AltFunctionUse(Player player) - { - return true; - } + public override bool AltFunctionUse(Player player) => true; public override bool CanUseItem(Player player) { diff --git a/Items/Weapons/Melee/DepthBlade.cs b/Items/Weapons/Melee/DepthBlade.cs index 956da57f64..3eedc6f7e8 100644 --- a/Items/Weapons/Melee/DepthBlade.cs +++ b/Items/Weapons/Melee/DepthBlade.cs @@ -8,11 +8,13 @@ namespace CalamityMod.Items.Weapons.Melee { public class DepthBlade : ModItem { + private static int HammerPower = 50; public override void SetStaticDefaults() { DisplayName.SetDefault("Depth Crusher"); Tooltip.SetDefault("Hitting enemies will inflict the crush depth debuff\n" + - "The lower the enemies' defense, the more damage they take from this debuff"); + "The lower the enemies' defense, the more damage they take from this debuff\n" + + "Right click to use without hammering down walls"); } public override void SetDefaults() @@ -30,7 +32,22 @@ namespace CalamityMod.Items.Weapons.Melee item.autoReuse = true; item.value = Item.buyPrice(0, 2, 0, 0); item.rare = 2; - item.hammer = 50; + item.hammer = HammerPower; + } + + public override bool AltFunctionUse(Player player) => true; + + public override bool CanUseItem(Player player) + { + if (player.altFunctionUse == 2) + { + item.hammer = 0; + } + else + { + item.hammer = HammerPower; + } + return base.CanUseItem(player); } public override void MeleeEffects(Player player, Rectangle hitbox) From 54ad62fb96edef4723217e17b082eb53b1e652d7 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Fri, 11 Dec 2020 23:03:15 -0500 Subject: [PATCH 57/66] draedon's arsenal doesn't exist. It can't hurt you --- Items/Fishing/AstralCatches/GacruxianMollusk.cs | 3 ++- .../Weapons/DraedonsArsenal/FrequencyManipulator.cs | 4 +++- Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs | 5 +++-- Items/Weapons/DraedonsArsenal/SystemBane.cs | 4 +++- Items/Weapons/DraedonsArsenal/TrackingDisk.cs | 4 +++- Items/Weapons/DraedonsArsenal/WavePounder.cs | 4 +++- .../DraedonsArsenal/WavePounderProjectile.cs | 13 ++++++++----- 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Items/Fishing/AstralCatches/GacruxianMollusk.cs b/Items/Fishing/AstralCatches/GacruxianMollusk.cs index f8d29162a1..fe953cf8bb 100644 --- a/Items/Fishing/AstralCatches/GacruxianMollusk.cs +++ b/Items/Fishing/AstralCatches/GacruxianMollusk.cs @@ -47,7 +47,8 @@ namespace CalamityMod.Items.Fishing.AstralCatches if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 1f); - Main.projectile[stealth].Calamity().stealthStrike = true; + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; return false; } return true; diff --git a/Items/Weapons/DraedonsArsenal/FrequencyManipulator.cs b/Items/Weapons/DraedonsArsenal/FrequencyManipulator.cs index 00c8889fbe..7c4d99b2c1 100644 --- a/Items/Weapons/DraedonsArsenal/FrequencyManipulator.cs +++ b/Items/Weapons/DraedonsArsenal/FrequencyManipulator.cs @@ -52,7 +52,9 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal 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.NewProjectileDirect(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f).Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs b/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs index 5b676a6029..35115c48ee 100644 --- a/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs +++ b/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs @@ -48,8 +48,9 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal 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 grenade = Projectile.NewProjectileDirect(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - grenade.Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/DraedonsArsenal/SystemBane.cs b/Items/Weapons/DraedonsArsenal/SystemBane.cs index 7245254edf..43cb0cfddf 100644 --- a/Items/Weapons/DraedonsArsenal/SystemBane.cs +++ b/Items/Weapons/DraedonsArsenal/SystemBane.cs @@ -52,7 +52,9 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal 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.NewProjectileDirect(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f).Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/DraedonsArsenal/TrackingDisk.cs b/Items/Weapons/DraedonsArsenal/TrackingDisk.cs index 804e77c63f..08db5e5ffc 100644 --- a/Items/Weapons/DraedonsArsenal/TrackingDisk.cs +++ b/Items/Weapons/DraedonsArsenal/TrackingDisk.cs @@ -52,7 +52,9 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal 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.NewProjectileDirect(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f).Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Items/Weapons/DraedonsArsenal/WavePounder.cs b/Items/Weapons/DraedonsArsenal/WavePounder.cs index 17a57f20e0..a56b4f7923 100644 --- a/Items/Weapons/DraedonsArsenal/WavePounder.cs +++ b/Items/Weapons/DraedonsArsenal/WavePounder.cs @@ -50,7 +50,9 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal 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.NewProjectileDirect(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f).Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } diff --git a/Projectiles/DraedonsArsenal/WavePounderProjectile.cs b/Projectiles/DraedonsArsenal/WavePounderProjectile.cs index 2ac7b1e5d5..0e6b376d8d 100644 --- a/Projectiles/DraedonsArsenal/WavePounderProjectile.cs +++ b/Projectiles/DraedonsArsenal/WavePounderProjectile.cs @@ -68,11 +68,14 @@ namespace CalamityMod.Projectiles.DraedonsArsenal for (int i = 0; i < 7; i++) { Projectile explosion = Projectile.NewProjectileDirect(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.3), projectile.knockBack, projectile.owner); - explosion.ai[1] = Main.rand.NextFloat(320f, 870f) + i * 45f; // Randomize the maximum radius. - explosion.localAI[1] = Main.rand.NextFloat(0.08f, 0.25f); // And the interpolation step. - explosion.Opacity = MathHelper.Lerp(0.18f, 0.6f, i / 7f) + Main.rand.NextFloat(-0.08f, 0.08f); - explosion.Calamity().stealthStrike = true; - explosion.netUpdate = true; + if (explosion.whoAmI.WithinBounds(Main.maxProjectiles)) + { + explosion.ai[1] = Main.rand.NextFloat(320f, 870f) + i * 45f; // Randomize the maximum radius. + explosion.localAI[1] = Main.rand.NextFloat(0.08f, 0.25f); // And the interpolation step. + explosion.Opacity = MathHelper.Lerp(0.18f, 0.6f, i / 7f) + Main.rand.NextFloat(-0.08f, 0.08f); + explosion.Calamity().stealthStrike = true; + explosion.netUpdate = true; + } } } } From 64e8fb02a6c3a4c5183c8a0580cc73d2ef9cc9ce Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+termigator1359@users.noreply.github.com> Date: Fri, 11 Dec 2020 23:18:59 -0500 Subject: [PATCH 58/66] fixed modded double jumps only working on the mounts they weren't supposed to work on --- CalPlayer/CalamityPlayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 7dfddac78c..906709f4c0 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -3157,7 +3157,7 @@ namespace CalamityMod.CalPlayer bool mountCheck = true; if (player.mount != null && player.mount.Active) - mountCheck = player.mount.BlockExtraJumps; + mountCheck = !player.mount.BlockExtraJumps; bool canJump = (!player.doubleJumpCloud || !player.jumpAgainCloud) && (!player.doubleJumpSandstorm || !player.jumpAgainSandstorm) && (!player.doubleJumpBlizzard || !player.jumpAgainBlizzard) && From 2b51feb17146feff05c2fb36149d8699321f43ee Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sat, 12 Dec 2020 02:04:57 -0500 Subject: [PATCH 59/66] rogue damage formula 2.0 stealth no longer gives move speed --- CalPlayer/CalamityPlayer.cs | 50 ++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 669f039f8c..981ddf22fd 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -282,6 +282,9 @@ namespace CalamityMod.CalPlayer #endregion #region Rogue + // If stealth is too weak, increase this number. If stealth is too strong, decrease this number. + private static readonly double StealthDamageConstant = 0.5; + public float rogueStealth = 0f; public float rogueStealthMax = 0f; public float stealthGenStandstill = 1f; @@ -9824,27 +9827,44 @@ namespace CalamityMod.CalPlayer private void ProvideStealthStatBonuses() { if (!wearingRogueArmor || rogueStealthMax <= 0) - return; + return; - // Checking the item you hover over should allow for more accurate readings. - // While this is potentially abusable with accessories that work off of rogue boosts like Ink Bomb line, shouldn't you be using a weapon instead? + // Hovering over an item will adjust the stealth bonus dynamically so that you see the correct damage for an item you put your cursor on. Item it = !Main.HoverItem.IsAir ? Main.HoverItem : player.ActiveItem(); - // Stealth provides a damage bonus based on the item's damage and use time as well as the player's moving stealth regen - // Lower stealth regen will increase the stealth damage bonus to allow for more freedom in rogue builds while still giving stealth value (e.g. Menacing vs Silent) - // This variable is the amount of time it takes for the player to regenerate to full stealth from 0 while moving. It takes 9 seconds without any boosts. - float stealthRegenTime = 9f / (stealthGenMoving * stealthAcceleration); - float stealthBonus = rogueStealth * 0.1f * it.damage * ((float)Math.Log(it.useTime + 2, 4) / it.useTime) * (float)Math.Log((double)stealthRegenTime, 2.5); - throwingDamage += stealthBonus; - // Crit increases based on your stealth value. With certain gear, it's locked at 100% for stealth strikes. + // The potential damage bonus from stealth is a complex equation based on the item's use time, + // the player's averaged-together stealth generation stats, and max stealth. + // Lower stealth generation rate (especially while moving) enables higher maximum stealth damage. + // This enables stealth to be conditionally useful -- even powerful -- even without a dedicated stealth build. + double averagedStealthGen = 0.8 * stealthGenMoving + 0.2 * stealthGenStandstill; + double fakeStealthTime = 9D / averagedStealthGen; + + // Use time 3 = 162% damage ratio + // Use time 8 = 200% damage ratio + // Use time 13 = 221% damage ratio + // Use time 17 = 234% damage ratio + // Use time 20 = 242% damage ratio + // Use time 30 = 263% damage ratio + // Use time 59 = 297% damage ratio + double useTimeFactor = 0.75 + 0.75 * Math.Log(it.useTime + 2D, 4D); + + // 9.00 second stealth charge = 433% damage ratio + // 6.00 second stealth charge = 330% damage ratio + // 4.00 second stealth charge = 252% damage ratio + // 2.50 second stealth charge = 184% damage ratio + double stealthGenFactor = Math.Max(Math.Pow(fakeStealthTime, 2D / 3D), 1.5); + + double stealthAddedDamage = it.damage * rogueStealth * StealthDamageConstant * useTimeFactor * stealthGenFactor; + // TODO -- Store stealth damage elsewhere so that it can't affect rogue on-hits while you stand around with this damage boost. + throwingDamage += (float)stealthAddedDamage; + + // Show 100% crit chance if your stealth strikes always crit. + // In practice, this is only for visuals because Terraria determines crit status on hit. if (stealthStrikeAlwaysCrits && StealthStrikeAvailable()) throwingCrit = 100; - else - throwingCrit += (int)(rogueStealth * 20f); - // Stealth slightly increases movement speed and decreases aggro. - player.moveSpeed += rogueStealth * 0.05f; - player.aggro -= (int)(rogueStealth * 400f); + // Stealth slightly decreases aggro. + player.aggro -= (int)(rogueStealth * 300f); } private float UpdateStealthGenStats() From eed8656dc2aefd09da020d0fcf7d7b120e748c31 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sat, 12 Dec 2020 02:08:31 -0500 Subject: [PATCH 60/66] removed unnecessary if statement --- CalPlayer/CalamityPlayer.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 981ddf22fd..36d3b81d46 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -9790,14 +9790,11 @@ namespace CalamityMod.CalPlayer playRogueStealthSound = true; // Calculate stealth generation and gain stealth accordingly - if (wearingRogueArmor) - { - // 1f is normal speed, anything higher is faster. Default stealth generation is 3 seconds while standing still. - float currentStealthGen = UpdateStealthGenStats(); - rogueStealth += rogueStealthMax * (currentStealthGen / 180f); // 180 frames = 3 seconds - if (rogueStealth > rogueStealthMax) - rogueStealth = rogueStealthMax; - } + // 1f is normal speed, anything higher is faster. Default stealth generation is 3 seconds while standing still. + float currentStealthGen = UpdateStealthGenStats(); + rogueStealth += rogueStealthMax * (currentStealthGen / 180f); // 180 frames = 3 seconds + if (rogueStealth > rogueStealthMax) + rogueStealth = rogueStealthMax; ProvideStealthStatBonuses(); From ce92919714307baff62c986998c1ddc3edd6eff2 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 22 Aug 2020 18:38:37 -0400 Subject: [PATCH 61/66] UI scales but mousing over is fuck --- UI/RipperUI.cs | 17 +++++++++++------ UI/StealthUI.cs | 7 ++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/UI/RipperUI.cs b/UI/RipperUI.cs index 5e260a66c7..9c801e2c25 100644 --- a/UI/RipperUI.cs +++ b/UI/RipperUI.cs @@ -98,15 +98,17 @@ namespace CalamityMod.UI } } + float uiScale = Main.UIScale; + // Draw the border of the Rage Bar first - spriteBatch.Draw(borderTex, rageDrawPos + shakeOffset, Color.White); + spriteBatch.Draw(borderTex, rageDrawPos + shakeOffset, null, Color.White, 0f, borderTex.Size() * 0.5f, uiScale, SpriteEffects.None, 0); // The amount of the bar to draw depends on the player's current Rage level // 7 pixels of dead space, 90 pixels of bar, 7 pixels of dead space. Bar is 24 pixels tall int deadSpace = 7; int barWidth = barTex.Width - 2 * deadSpace; Rectangle cropRect = new Rectangle(0, 0, deadSpace + (int)(barWidth * rageRatio), barTex.Height); - spriteBatch.Draw(barTex, rageDrawPos + shakeOffset, cropRect, Color.White); + spriteBatch.Draw(barTex, rageDrawPos + shakeOffset, cropRect, Color.White, 0f, borderTex.Size() * 0.5f, uiScale, SpriteEffects.None, 0); // If the animation is active, draw the animation on top of both the border and the bar. if (animationActive) @@ -116,7 +118,7 @@ namespace CalamityMod.UI float yOffset = (borderTex.Height - frameHeight) / 2f; Vector2 sizeDiffOffset = new Vector2(xOffset, yOffset); Rectangle animCropRect = new Rectangle(0, (frameHeight + 1) * rageAnimFrame, animTex.Width, frameHeight); - spriteBatch.Draw(animTex, rageDrawPos + shakeOffset + sizeDiffOffset, animCropRect, Color.White); + spriteBatch.Draw(animTex, rageDrawPos + shakeOffset + sizeDiffOffset, animCropRect, Color.White, 0f, borderTex.Size() * 0.5f, uiScale, SpriteEffects.None, 0); } } @@ -145,15 +147,17 @@ namespace CalamityMod.UI } } + float uiScale = Main.UIScale; + // Draw the border of the Adrenaline Bar first - spriteBatch.Draw(borderTex, adrenDrawPos + shakeOffset, Color.White); + spriteBatch.Draw(borderTex, adrenDrawPos + shakeOffset, null, Color.White, 0f, borderTex.Size() * 0.5f, uiScale, SpriteEffects.None, 0); // The amount of the bar to draw depends on the player's current Adrenaline level // 7 pixels of dead space, 90 pixels of bar, 7 pixels of dead space. int deadSpace = 7; int barWidth = barTex.Width - 2 * deadSpace; Rectangle cropRect = new Rectangle(0, 0, deadSpace + (int)(barWidth * adrenRatio), barTex.Height); - spriteBatch.Draw(barTex, adrenDrawPos + shakeOffset, cropRect, Color.White); + spriteBatch.Draw(barTex, adrenDrawPos + shakeOffset, cropRect, Color.White, 0f, borderTex.Size() * 0.5f, uiScale, SpriteEffects.None, 0); // If the animation is active, draw the animation on top of both the border and the bar. if (animationActive) @@ -163,12 +167,13 @@ namespace CalamityMod.UI float yOffset = (borderTex.Height - frameHeight) / 2f; Vector2 sizeDiffOffset = new Vector2(xOffset, yOffset); Rectangle animCropRect = new Rectangle(0, (frameHeight + 1) * adrenAnimFrame, animTex.Width, frameHeight); - spriteBatch.Draw(animTex, adrenDrawPos + shakeOffset + sizeDiffOffset, animCropRect, Color.White); + spriteBatch.Draw(animTex, adrenDrawPos + shakeOffset + sizeDiffOffset, animCropRect, Color.White, 0f, borderTex.Size() * 0.5f, uiScale, SpriteEffects.None, 0); } } private static void HandleMouseInteraction(CalamityPlayer modPlayer, Vector2 rageBarSize, Vector2 adrenBarSize) { + float uiScale = Main.UIScale; Rectangle mouse = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 8, 8); Rectangle rageBar = new Rectangle((int)rageDrawPos.X, (int)rageDrawPos.Y, (int)rageBarSize.X, (int)rageBarSize.Y); Rectangle adrenBar = new Rectangle((int)adrenDrawPos.X, (int)adrenDrawPos.Y, (int)adrenBarSize.X, (int)adrenBarSize.Y); diff --git a/UI/StealthUI.cs b/UI/StealthUI.cs index c6a5b04f96..878a0c488f 100644 --- a/UI/StealthUI.cs +++ b/UI/StealthUI.cs @@ -38,16 +38,17 @@ namespace CalamityMod.UI Texture2D indicatorTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeterStrikeIndicator"); Texture2D barTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeterBar"); Texture2D fullBarTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/StealthMeterBarFull"); - spriteBatch.Draw(edgeTexture, DrawPosition, null, Color.White * modPlayer.stealthUIAlpha, 0f, edgeTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0); + float uiScale = Main.UIScale; + spriteBatch.Draw(edgeTexture, DrawPosition, null, Color.White * modPlayer.stealthUIAlpha, 0f, edgeTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); if (modPlayer.StealthStrikeAvailable()) { - spriteBatch.Draw(indicatorTexture, DrawPosition, null, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0); + spriteBatch.Draw(indicatorTexture, DrawPosition, null, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); } float completionRatio = modPlayer.rogueStealth / modPlayer.rogueStealthMax; Rectangle barRectangle = new Rectangle(0, 0, (int)(barTexture.Width * completionRatio), barTexture.Width); bool full = modPlayer.rogueStealth >= modPlayer.rogueStealthMax; - spriteBatch.Draw(full ? fullBarTexture : barTexture, DrawPosition, barRectangle, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0); + spriteBatch.Draw(full ? fullBarTexture : barTexture, DrawPosition, barRectangle, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); if (new Rectangle((int)(DrawPosition.X + Main.screenPosition.X - player.width / 2), (int)(DrawPosition.Y + Main.screenPosition.Y), barTexture.Width, barTexture.Height).Intersects( new Rectangle((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 8, 8))) { From 0b7807c6307cb6dfd4ceb4e2b2d87ce397ed7ba9 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Fri, 11 Dec 2020 21:44:13 -0500 Subject: [PATCH 62/66] Ripper Bars and Stealth Bar scale with UI and can now be properly moused over --- UI/RipperUI.cs | 4 ++-- UI/StealthUI.cs | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/UI/RipperUI.cs b/UI/RipperUI.cs index 9c801e2c25..42d1622f0b 100644 --- a/UI/RipperUI.cs +++ b/UI/RipperUI.cs @@ -175,8 +175,8 @@ namespace CalamityMod.UI { float uiScale = Main.UIScale; Rectangle mouse = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 8, 8); - Rectangle rageBar = new Rectangle((int)rageDrawPos.X, (int)rageDrawPos.Y, (int)rageBarSize.X, (int)rageBarSize.Y); - Rectangle adrenBar = new Rectangle((int)adrenDrawPos.X, (int)adrenDrawPos.Y, (int)adrenBarSize.X, (int)adrenBarSize.Y); + Rectangle rageBar = Utils.CenteredRectangle(rageDrawPos, rageBarSize * uiScale); + Rectangle adrenBar = Utils.CenteredRectangle(adrenDrawPos, adrenBarSize * uiScale); bool rageHover = mouse.Intersects(rageBar); bool adrenHover = mouse.Intersects(adrenBar); diff --git a/UI/StealthUI.cs b/UI/StealthUI.cs index 878a0c488f..79fedac613 100644 --- a/UI/StealthUI.cs +++ b/UI/StealthUI.cs @@ -49,8 +49,11 @@ namespace CalamityMod.UI Rectangle barRectangle = new Rectangle(0, 0, (int)(barTexture.Width * completionRatio), barTexture.Width); bool full = modPlayer.rogueStealth >= modPlayer.rogueStealthMax; spriteBatch.Draw(full ? fullBarTexture : barTexture, DrawPosition, barRectangle, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); - if (new Rectangle((int)(DrawPosition.X + Main.screenPosition.X - player.width / 2), (int)(DrawPosition.Y + Main.screenPosition.Y), barTexture.Width, barTexture.Height).Intersects( - new Rectangle((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 8, 8))) + + Rectangle mouse = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 8, 8); + Rectangle stealthBar = Utils.CenteredRectangle(DrawPosition, barTexture.Size() * uiScale); + + if (stealthBar.Intersects(mouse)) { if (modPlayer.rogueStealthMax > 0f && modPlayer.stealthUIAlpha >= 0.5f) { @@ -64,8 +67,7 @@ namespace CalamityMod.UI } if (!CalamityConfig.Instance.MeterPosLock) { - if (new Rectangle((int)(DrawPosition.X + Main.screenPosition.X - 26), (int)(DrawPosition.Y + Main.screenPosition.Y - 9), 52, 18).Intersects( - new Rectangle((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 8, 8))) + if (stealthBar.Intersects(mouse)) { if (Mouse.GetState().LeftButton == ButtonState.Pressed) { From 61fa035a73bbbb62e5b9c9f2327336b5322a8d6d Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sat, 12 Dec 2020 02:18:40 -0500 Subject: [PATCH 63/66] killed unnecessary doubles --- CalPlayer/CalamityPlayer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 412e8faeb1..01ec03f1a4 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -1122,7 +1122,7 @@ namespace CalamityMod.CalPlayer { "boost", boost }, { "stress", rage }, { "adrenaline", adrenaline }, - { "aquaticBoostPower", (double)aquaticBoost }, + { "aquaticBoostPower", aquaticBoost }, { "sCalDeathCount", sCalDeathCount }, { "sCalKillCount", sCalKillCount }, { "meleeLevel", meleeLevel }, @@ -1194,7 +1194,7 @@ namespace CalamityMod.CalPlayer rage = tag.GetFloat("stress"); adrenaline = tag.GetFloat("adrenaline"); if (tag.ContainsKey("aquaticBoostPower")) - aquaticBoost = (float)tag.GetAsDouble("aquaticBoostPower"); + aquaticBoost = tag.GetFloat("aquaticBoostPower"); sCalDeathCount = tag.GetInt("sCalDeathCount"); sCalKillCount = tag.GetInt("sCalKillCount"); deathCount = tag.GetInt("deathCount"); From 48a53d5fbc05a167a0df04e9ab7eaed89e83743f Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sat, 12 Dec 2020 02:24:06 -0500 Subject: [PATCH 64/66] caught int/float mixup in legacy --- CalPlayer/CalamityPlayer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 01ec03f1a4..e97360e2cc 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -1230,8 +1230,8 @@ namespace CalamityMod.CalPlayer public override void LoadLegacy(BinaryReader reader) { int loadVersion = reader.ReadInt32(); - rage = reader.ReadInt32(); - adrenaline = reader.ReadInt32(); + rage = reader.ReadSingle(); + adrenaline = reader.ReadSingle(); aquaticBoost = reader.ReadSingle(); sCalDeathCount = reader.ReadInt32(); sCalKillCount = reader.ReadInt32(); From a67496edb21aaa4ac6a67a3535f844be0f366540 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sat, 12 Dec 2020 02:48:57 -0500 Subject: [PATCH 65/66] ugly but extensible mod tile avoidance --- CalamityMod.cs | 4 +-- World/DraedonStructures.cs | 57 +++++++++++++++++++++++++------------- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/CalamityMod.cs b/CalamityMod.cs index 4cb0495871..4b6a186b5e 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -138,9 +138,8 @@ namespace CalamityMod ILChanges.Load(); BossRushEvent.Load(); - BossHealthBarManager.Load(this); - + DraedonStructures.Load(); CalamityLists.LoadLists(); SetupVanillaDR(); SetupBossKillTimes(); @@ -267,6 +266,7 @@ namespace CalamityMod BossRushEvent.Unload(); SchematicManager.Unload(); BossHealthBarManager.Unload(); + DraedonStructures.Unload(); TileFraming.Unload(); diff --git a/World/DraedonStructures.cs b/World/DraedonStructures.cs index 2afdc92e5b..3402eab80b 100644 --- a/World/DraedonStructures.cs +++ b/World/DraedonStructures.cs @@ -16,6 +16,34 @@ namespace CalamityMod.World { public static class DraedonStructures { + private static int[] otherModTilesToAvoid; + + internal static void Load() + { + IList avoid = new List(16); + + // Mod of Redemption's labs use modded blocks, but must still be avoided. + Mod mor = ModLoader.GetMod("Redemption"); + if (mor != null) + { + // Thanks to Hallam to providing these tile names. + string[] redemptionAvoidTiles = new string[] + { + "LabTileUnsafe", + "OvergrownLabTile" + }; + foreach (string tileName in redemptionAvoidTiles) + avoid.Add(mor.TileType(tileName)); + } + + otherModTilesToAvoid = avoid.ToArray(); + } + + internal static void Unload() + { + otherModTilesToAvoid = null; + } + public static bool ShouldAvoidLocation(Point placementPoint, bool careAboutLava = true) { Tile tile = CalamityUtils.ParanoidTileRetrieval(placementPoint.X, placementPoint.Y); @@ -39,27 +67,16 @@ namespace CalamityMod.World { return true; } - // Avoid Thorium's Blood Chamber (where you summon Viscount) - if (tile.type == TileID.StoneSlab || - tile.wall == WallID.StoneSlab) - { - return true; - } - // As well as MoD's special labs. - Mod modOfRedemption = ModLoader.GetMod("Redemption"); - if (modOfRedemption != null) - { - // Thanks to Hallam to providing these tile names. - string[] tilesToAvoid = new string[] - { - "LabTileUnsafe", - "OvergrownLabTile" - }; - if (tilesToAvoid.Any(tileTypeName => tile.type == modOfRedemption.TileType(tileTypeName))) - return true; - } - return false; + // + // Below this line: Avoiding other mod worldgen. + // + + // Avoid Thorium's Blood Chamber (where you summon Viscount). This is done separately because it uses vanilla tiles. + if (tile.type == TileID.StoneSlab || tile.wall == WallID.StoneSlab) + return true; + // Avoid all other registered modded tiles to avoid. + return otherModTilesToAvoid.Any(id => tile.type == id); } #region Workshop From d02c3423bd153db076447cc1878a90c218f9813a Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sat, 12 Dec 2020 04:41:45 -0500 Subject: [PATCH 66/66] fixed microwave compile error --- Projectiles/Melee/Yoyos/MicrowaveYoyo.cs | 51 ++++++++++-------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs b/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs index 3eef5ddb9c..26495a4869 100644 --- a/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs +++ b/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs @@ -3,8 +3,8 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Graphics; +using System.IO; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -14,8 +14,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos { private const float Radius = 100f; private SoundEffectInstance mmmmmm = null; - private bool spawnedAura = false; - public int soundCooldown = 0; + private bool spawnedAura = false; + public int soundCooldown = 0; public override void SetStaticDefaults() { @@ -43,15 +43,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.localNPCHitCooldown = 10; } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(soundCooldown); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - soundCooldown = reader.ReadInt32(); - } + public override void SendExtraAI(BinaryWriter writer) => writer.Write(soundCooldown); + public override void ReceiveExtraAI(BinaryReader reader) => soundCooldown = reader.ReadInt32(); public override void AI() { @@ -70,12 +63,12 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (projectile.owner == Main.myPlayer && !spawnedAura) { Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.35), projectile.knockBack, projectile.owner, projectile.identity, 0f); - spawnedAura = true; + spawnedAura = true; } - // Decrement sound cooldown - if (soundCooldown > 0 && projectile.FinalExtraUpdate()) - soundCooldown--; + // Decrement sound cooldown + if (soundCooldown > 0 && projectile.FinalExtraUpdate()) + soundCooldown--; // Dust circle appears for all players, even though the aura projectile is only spawned by the owner int numDust = (int)(0.2f * MathHelper.TwoPi * Radius); @@ -97,9 +90,9 @@ namespace CalamityMod.Projectiles.Melee.Yoyos Main.dust[dust].scale = 0.1599999999f; } - // Delete the projectile if it is farther than 200 blocks away from the player - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) - projectile.Kill(); + // Delete the projectile if it is farther than 200 blocks away from the player + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) + projectile.Kill(); } public override void Kill(int timeLeft) @@ -123,21 +116,21 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 300); - if (target.life <= 0 && soundCooldown <= 0) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/MicrowaveBeep"), (int)projectile.Center.X, (int)projectile.Center.Y); - soundCooldown = 45; - } + if (target.life <= 0 && soundCooldown <= 0) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/MicrowaveBeep"), (int)projectile.Center.X, (int)projectile.Center.Y); + soundCooldown = 45; + } } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 300); - if (target.statLife <= 0 && soundCooldown <= 0) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/MicrowaveBeep"), (int)projectile.Center.X, (int)projectile.Center.Y); - soundCooldown = 45; - } + if (target.statLife <= 0 && soundCooldown <= 0) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/MicrowaveBeep"), (int)projectile.Center.X, (int)projectile.Center.Y); + soundCooldown = 45; + } } } }