diff --git a/Buffs/Pets/ArcherofLunamoon.png b/Buffs/Pets/ArcherofLunamoon.png index 726d2ab0d5..a3a5614f8a 100644 Binary files a/Buffs/Pets/ArcherofLunamoon.png and b/Buffs/Pets/ArcherofLunamoon.png differ diff --git a/Buffs/StatBuffs/AbsorberRegen.cs b/Buffs/StatBuffs/AbsorberRegen.cs new file mode 100644 index 0000000000..21e8bbfd57 --- /dev/null +++ b/Buffs/StatBuffs/AbsorberRegen.cs @@ -0,0 +1,20 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.StatBuffs +{ + public class AbsorberRegen : ModBuff + { + public override void SetStaticDefaults() + { + Main.debuff[Type] = false; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().AbsorberRegen = true; + } + } +} diff --git a/Buffs/StatBuffs/AbsorberRegen.png b/Buffs/StatBuffs/AbsorberRegen.png new file mode 100644 index 0000000000..e0432a84a8 Binary files /dev/null and b/Buffs/StatBuffs/AbsorberRegen.png differ diff --git a/Buffs/StatBuffs/GreenJellyRegen.cs b/Buffs/StatBuffs/GreenJellyRegen.cs new file mode 100644 index 0000000000..79347cf7ef --- /dev/null +++ b/Buffs/StatBuffs/GreenJellyRegen.cs @@ -0,0 +1,20 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.StatBuffs +{ + public class GreenJellyRegen : ModBuff + { + public override void SetStaticDefaults() + { + Main.debuff[Type] = false; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().GreenJellyRegen = true; + } + } +} diff --git a/Buffs/StatBuffs/GreenJellyRegen.png b/Buffs/StatBuffs/GreenJellyRegen.png new file mode 100644 index 0000000000..b5cd1f4743 Binary files /dev/null and b/Buffs/StatBuffs/GreenJellyRegen.png differ diff --git a/Buffs/StatBuffs/PinkJellyRegen.cs b/Buffs/StatBuffs/PinkJellyRegen.cs new file mode 100644 index 0000000000..37cb15cc06 --- /dev/null +++ b/Buffs/StatBuffs/PinkJellyRegen.cs @@ -0,0 +1,20 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.StatBuffs +{ + public class PinkJellyRegen : ModBuff + { + public override void SetStaticDefaults() + { + Main.debuff[Type] = false; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().PinkJellyRegen = true; + } + } +} diff --git a/Buffs/StatBuffs/PinkJellyRegen.png b/Buffs/StatBuffs/PinkJellyRegen.png new file mode 100644 index 0000000000..6dd75f8c34 Binary files /dev/null and b/Buffs/StatBuffs/PinkJellyRegen.png differ diff --git a/Buffs/StatDebuffs/AbsorberAffliction.cs b/Buffs/StatDebuffs/AbsorberAffliction.cs new file mode 100644 index 0000000000..82d3f8f1ac --- /dev/null +++ b/Buffs/StatDebuffs/AbsorberAffliction.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.StatDebuffs +{ + public class AbsorberAffliction : ModBuff + { + public override void SetStaticDefaults() + { + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(NPC npc, ref int buffIndex) + { + if (npc.Calamity().absorberAffliction < npc.buffTime[buffIndex]) + npc.Calamity().absorberAffliction = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; + } + } +} diff --git a/Buffs/StatDebuffs/AbsorberAffliction.png b/Buffs/StatDebuffs/AbsorberAffliction.png new file mode 100644 index 0000000000..6453bad23c Binary files /dev/null and b/Buffs/StatDebuffs/AbsorberAffliction.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index fdf9f68151..1b595e2d93 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -58,6 +58,7 @@ using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; +using CalamityMod.Projectiles.Typless; using CalamityMod.UI; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -73,6 +74,7 @@ using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; using Terraria.ModLoader.IO; +using static Terraria.ModLoader.PlayerDrawLayer; namespace CalamityMod.CalPlayer { @@ -83,6 +85,8 @@ namespace CalamityMod.CalPlayer #region No Category public static bool areThereAnyDamnBosses = false; public static bool areThereAnyDamnEvents = false; + public bool potionSick = false; + public int timePotionSick; public bool drawBossHPBar = true; public float stealthUIAlpha = 1f; public float SulphWaterUIOpacity = 1f; @@ -230,6 +234,8 @@ namespace CalamityMod.CalPlayer public int auralisAurora = 0; public int necroReviveCounter = -1; public int hideOfDeusTimer = 0; + public int giantShellPostHit = 0; + public int tortShellPostHit = 0; public int spiritOriginBullseyeShootCountdown = 0; public int spiritOriginConvertedCrit = 0; public int RustyMedallionCooldown = 0; @@ -270,6 +276,8 @@ namespace CalamityMod.CalPlayer public static readonly SoundStyle IjiDeathSound = new("CalamityMod/Sounds/Custom/IjiDies"); public static readonly SoundStyle DrownSound = new("CalamityMod/Sounds/Custom/AbyssDrown"); public static readonly SoundStyle LeonDeathNoiseRE4_ForGFB = new("CalamityMod/Sounds/Custom/GFB/LeonDeathNoiseRE4"); + public static readonly SoundStyle BaroclawHit = new("CalamityMod/Sounds/NPCKilled/DevourerSegmentBreak2") { Volume = 0.7f }; + public static readonly SoundStyle AbsorberHit = new("CalamityMod/Sounds/Custom/AbilitySounds/SilvaActivation") { Volume = 0.7f }; #endregion #region Rogue @@ -458,8 +466,8 @@ namespace CalamityMod.CalPlayer public bool transformer = false; public bool hideOfDeus = false; public bool dAmulet = false; - public bool fCarapace = false; public bool gShell = false; + public bool tortShell = false; public bool absorber = false; public bool aAmpoule = false; public bool sponge = false; @@ -495,6 +503,10 @@ namespace CalamityMod.CalPlayer public bool toxicHeart = false; public bool abaddon = false; public bool aeroStone = false; + public bool lifejelly = false; + public bool cleansingjelly = false; + public bool GrandGelatin = false; + public int CleansingEffect = 0; public bool community = false; public bool shatteredCommunity = false; public bool fleshTotem = false; @@ -523,6 +535,9 @@ namespace CalamityMod.CalPlayer public bool spiritOrigin = false; public bool spiritOriginVanity = false; public bool darkSunRing = false; + public bool crawCarapace = false; + public bool baroclaw = false; + public bool HasReducedDashFirstFrame = false; public bool voidOfCalamity = false; public bool voidOfExtinction = false; public bool eArtifact = false; @@ -827,6 +842,9 @@ namespace CalamityMod.CalPlayer public bool flaskBrimstone = false; public bool fabsolVodka = false; public bool mushy = false; + public bool PinkJellyRegen = false; + public bool GreenJellyRegen = false; + public bool AbsorberRegen = false; public bool shellBoost = false; public bool cFreeze = false; public bool shine = false; @@ -1056,6 +1074,7 @@ namespace CalamityMod.CalPlayer public bool witheringWeaponEnchant = false; public bool witheredDebuff = false; + public bool absorberAffliction = false; public int witheredWeaponHoldTime = 0; public int witheringDamageDone = 0; @@ -1371,9 +1390,6 @@ namespace CalamityMod.CalPlayer #region ResetEffects public override void ResetEffects() { - // Max health bonuses - if (absorber) - Player.statLifeMax2 += sponge ? 30 : 20; if (fleshKnuckles) Player.statLifeMax2 += 45; @@ -1537,8 +1553,8 @@ namespace CalamityMod.CalPlayer transformer = false; hideOfDeus = false; dAmulet = false; - fCarapace = false; gShell = false; + tortShell = false; absorber = false; aAmpoule = false; sponge = false; @@ -1565,6 +1581,9 @@ namespace CalamityMod.CalPlayer toxicHeart = false; abaddon = false; aeroStone = false; + lifejelly = false; + GrandGelatin = false; + cleansingjelly = false; community = false; shatteredCommunity = false; stressPills = false; @@ -1582,6 +1601,10 @@ namespace CalamityMod.CalPlayer harpyWingBoost = false; //harpy wings + harpy ring fleshKnuckles = false; darkSunRing = false; + crawCarapace = false; + baroclaw = false; + gShell = false; + tortShell = false; voidOfCalamity = false; voidOfExtinction = false; eArtifact = false; @@ -1767,6 +1790,7 @@ namespace CalamityMod.CalPlayer irradiated = false; bFlames = false; witheredDebuff = false; + absorberAffliction = false; weakBrimstoneFlames = false; gsInferno = false; astralInfection = false; @@ -1831,6 +1855,9 @@ namespace CalamityMod.CalPlayer shine = false; anechoicCoating = false; mushy = false; + PinkJellyRegen = false; + GreenJellyRegen = false; + AbsorberRegen = false; shellBoost = false; cFreeze = false; tRegen = false; @@ -2170,6 +2197,7 @@ namespace CalamityMod.CalPlayer irradiated = false; bFlames = false; witheredDebuff = false; + absorberAffliction = false; weakBrimstoneFlames = false; gsInferno = false; astralInfection = false; @@ -2268,6 +2296,9 @@ namespace CalamityMod.CalPlayer shine = false; anechoicCoating = false; mushy = false; + PinkJellyRegen = false; + GreenJellyRegen = false; + AbsorberRegen = false; enraged = false; shellBoost = false; cFreeze = false; @@ -3215,6 +3246,26 @@ namespace CalamityMod.CalPlayer if (Player.accRunSpeed < accRunSpeedMin) Player.accRunSpeed = accRunSpeedMin; + //Life Jelly regen aura spawn when using a healing potion + if (timePotionSick == 1 && Player.whoAmI == Main.myPlayer && lifejelly && !GrandGelatin) + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0, Player.whoAmI); + + //Cleansing Jelly cleansing aura spawn when using a healing potion + if (timePotionSick == 1 && Player.whoAmI == Main.myPlayer && cleansingjelly && !GrandGelatin) + { + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0, Player.whoAmI); + } + //Grand Gellatin regen and cleansing aura spawn when using a healing potion + if (timePotionSick == 1 && Player.whoAmI == Main.myPlayer && GrandGelatin && !absorber) + { + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0, Player.whoAmI); + } + //Absorber's regen, cleansing, and buffing aura spawn when using a healing potion + if (timePotionSick == 1 && Player.whoAmI == Main.myPlayer && absorber) + { + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0, Player.whoAmI); + } + if (snowman) { if (Player.whoAmI == Main.myPlayer && !snowmanNoseless) @@ -3428,8 +3479,18 @@ namespace CalamityMod.CalPlayer { if (Player.whoAmI == Main.myPlayer && CalamityConfig.Instance.VanillaCooldownDisplay) { + if (Player.whoAmI == Main.myPlayer && Player.potionDelay != 0) + potionSick = true; + else + potionSick = false; + + if (!potionSick) + timePotionSick = 0; + else + timePotionSick++; + // Add a cooldown display for potion sickness if the player has the vanilla counter ticking - if (Player.potionDelay > 0 && !Player.HasCooldown(PotionSickness.ID)) + if (potionSick && !Player.HasCooldown(PotionSickness.ID)) Player.AddCooldown(PotionSickness.ID, Player.potionDelay, false); if (cooldowns.TryGetValue(PotionSickness.ID, out CooldownInstance cd)) @@ -3586,37 +3647,6 @@ namespace CalamityMod.CalPlayer #endregion #region Dodges - private bool HandleDodges() - { - if (Player.whoAmI != Main.myPlayer || disableAllDodges) - return false; - - if (spectralVeil && spectralVeilImmunity > 0) - { - SpectralVeilDodge(); - return true; - } - - if (HandleDashDodges()) - return true; - - // Mirror evades do not work if the global dodge cooldown is active. This cooldown can be triggered by either mirror. - if (!Player.HasCooldown(GlobalDodge.ID)) - { - if (eclipseMirror) - { - EclipseMirrorEvade(); - return true; - } - else if (abyssalMirror) - { - AbyssMirrorEvade(); - return true; - } - } - return false; - } - private void SpectralVeilDodge() { Player.GiveIFrames(spectralVeilImmunity, true); //Set immunity before setting this variable to 0 @@ -3700,7 +3730,7 @@ namespace CalamityMod.CalPlayer NetMessage.SendData(MessageID.Dodge, -1, -1, null, Player.whoAmI, 1f, 0f, 0f, 0, 0, 0); } - public void AbyssMirrorEvade() + public void AbyssMirrorDodge() { if (Player.whoAmI == Main.myPlayer && abyssalMirror && !eclipseMirror) { @@ -3732,7 +3762,7 @@ namespace CalamityMod.CalPlayer } } - public void EclipseMirrorEvade() + public void EclipseMirrorDodge() { if (Player.whoAmI == Main.myPlayer && eclipseMirror) { @@ -4918,7 +4948,51 @@ namespace CalamityMod.CalPlayer if (NPC.AnyNPCs(ModContent.NPCType())) { Player.AddBuff(ModContent.BuffType(), 15, true); - } + } + + if (crawCarapace) + { + npc.AddBuff(ModContent.BuffType(), 720); + SoundEngine.PlaySound(SoundID.NPCHit33 with { Volume = 0.5f }, Player.Center); + } + + if (baroclaw) + { + npc.AddBuff(ModContent.BuffType(), 1800); + SoundEngine.PlaySound(BaroclawHit, Player.Center); + Vector2 bloodSpawnPosition = Player.Center + Main.rand.NextVector2Circular(Player.width, Player.height) * 0.04f; + Vector2 splatterDirection = (Player.Center - bloodSpawnPosition).SafeNormalize(Vector2.UnitY); + for (int i = 0; i < 9; i++) + { + int sparkLifetime = Main.rand.Next(12, 18); + float sparkScale = Main.rand.NextFloat(0.8f, 1f) * 0.955f; + Color sparkColor = Color.Lerp(Color.RoyalBlue, Color.DarkBlue, Main.rand.NextFloat(0.7f)); + sparkColor = Color.Lerp(sparkColor, Color.RoyalBlue, Main.rand.NextFloat()); + Vector2 sparkVelocity = splatterDirection.RotatedByRandom(0.6f) * Main.rand.NextFloat(12f, 25f); + sparkVelocity.Y -= 5.5f; + SparkParticle spark = new SparkParticle(Player.Center, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + } + + if (absorber) + { + npc.AddBuff(ModContent.BuffType(), 1800); + SoundEngine.PlaySound(AbsorberHit, Player.Center); + Vector2 bloodSpawnPosition = Player.Center + Main.rand.NextVector2Circular(Player.width, Player.height) * 0.04f; + Vector2 splatterDirection = (Player.Center - bloodSpawnPosition).SafeNormalize(Vector2.UnitY); + for (int i = 0; i < 12; i++) + { + int sparkLifetime = Main.rand.Next(11, 16); + float sparkScale = Main.rand.NextFloat(1.8f, 2.8f) * 0.955f; + Color sparkColor = Color.Lerp(Color.DarkSeaGreen, Color.MediumSeaGreen, Main.rand.NextFloat(0.7f)); + sparkColor = Color.Lerp(sparkColor, Color.DarkSeaGreen, Main.rand.NextFloat()); + Vector2 sparkVelocity = splatterDirection.RotatedByRandom(0.6f) * Main.rand.NextFloat(12f, 25f); + sparkVelocity.Y -= 4.7f; + SparkParticle spark = new SparkParticle(Player.Center, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + } } public override void OnHitByProjectile(Projectile proj, Player.HurtInfo hurtInfo) @@ -5421,9 +5495,9 @@ namespace CalamityMod.CalPlayer Vector2 drawPosition = Main.LocalPlayer.Center - Main.screenPosition; Vector2 auroraOffset = drawPosition - Vector2.UnitY * 15f; int origin = size / 2; + float auroraPower = MathHelper.Clamp(unclampedAuroraPower, 0f, 1f); for (int i = 0; i < auroraCount; i++) { - float auroraPower = MathHelper.Clamp(unclampedAuroraPower, 0f, 1f); float offsetAngle = MathHelper.TwoPi * i / auroraCount + timeScalar1; Color auroraColor = GetCurrentMoonlightDyeColor(offsetAngle) * 0.8f; auroraColor.A = 0; @@ -5636,8 +5710,58 @@ namespace CalamityMod.CalPlayer public override bool ConsumableDodge(Player.HurtInfo info) { - if (HandleDodges()) + // Vanilla dodges are gated behind the global dodge cooldown + if (!Player.HasCooldown(GlobalDodge.ID)) + { + // Re-implementation of vanilla item Black Belt as a consumable dodge + if (Player.whoAmI == Main.myPlayer && Player.blackBelt) + { + Player.NinjaDodge(); + Player.AddCooldown(GlobalDodge.ID, BalancingConstants.BeltDodgeCooldown); + return true; + } + + // Re-implementation of vanilla item Brain of Confusion as a consumable dodge + if (Player.whoAmI == Main.myPlayer && Player.brainOfConfusionItem != null && !Player.brainOfConfusionItem.IsAir) + { + Player.BrainOfConfusionDodge(); + int cooldownTime = amalgam ? BalancingConstants.AmalgamDodgeCooldown : BalancingConstants.BrainDodgeCooldown; + Player.AddCooldown(GlobalDodge.ID, cooldownTime); + return true; + } + } + + // + // CALAMITY DODGES + // + + if (Player.whoAmI != Main.myPlayer || disableAllDodges) + return false; + + if (spectralVeil && spectralVeilImmunity > 0) + { + SpectralVeilDodge(); return true; + } + + // TODO -- drag all dodge code into a CalamityPlayer sub-file dedicated to dodging and nothing else + if (HandleDashDodges()) + return true; + + // Mirror evades do not work if the global dodge cooldown is active. This cooldown can be triggered by either mirror. + if (!Player.HasCooldown(GlobalDodge.ID)) + { + if (eclipseMirror) + { + EclipseMirrorDodge(); + return true; + } + else if (abyssalMirror) + { + AbyssMirrorDodge(); + return true; + } + } return base.ConsumableDodge(info); } @@ -5817,7 +5941,7 @@ namespace CalamityMod.CalPlayer if (absorber) { - int healAmt = (int)(hurtInfo.Damage / (sponge ? 16D : 20D)); + int healAmt = (int)(hurtInfo.Damage / 20D); Player.statLife += healAmt; Player.HealEffect(healAmt); } @@ -5867,9 +5991,15 @@ namespace CalamityMod.CalPlayer SoundEngine.PlaySound(SoundID.Item96, Player.Center); } - if ((gShell || flameLickedShell) && !Player.panic) + if ((flameLickedShell) && !Player.panic) Player.AddBuff(ModContent.BuffType(), 180); + if (gShell) //5 seconds of no dash reduction and reduced defense + giantShellPostHit = 300; + + if (tortShell) //5 seconds of no dash reduction and reduced defense + tortShellPostHit = 300; + if (abyssalDivingSuitPlates && hurtInfo.Damage > 50) { if (abyssalDivingSuitPlateHits < 3) @@ -6193,32 +6323,6 @@ namespace CalamityMod.CalPlayer } } } - if (fCarapace) - { - var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); - if (hurtInfo.Damage > 0) - { - SoundEngine.PlaySound(SoundID.NPCHit45, Player.Center); - float spread = 45f * 0.0174f; - double startAngle = Math.Atan2(Player.velocity.X, Player.velocity.Y) - spread / 2; - double deltaAngle = spread / 8f; - double offsetAngle; - int fDamage = (int)Player.GetBestClassDamage().ApplyTo(70); - if (Player.whoAmI == Main.myPlayer) - { - for (int i = 0; i < 4; i++) - { - float xPos = Main.rand.NextBool(2) ? Player.Center.X + 100 : Player.Center.X - 100; - Vector2 spawnPos = new Vector2(xPos, Player.Center.Y + Main.rand.Next(-100, 101)); - offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - int spore1 = Projectile.NewProjectile(source, spawnPos.X, spawnPos.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ProjectileID.TruffleSpore, fDamage, 1.25f, Player.whoAmI, 0f, 0f); - int spore2 = Projectile.NewProjectile(source, spawnPos.X, spawnPos.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ProjectileID.TruffleSpore, fDamage, 1.25f, Player.whoAmI, 0f, 0f); - Main.projectile[spore1].timeLeft = 300; - Main.projectile[spore2].timeLeft = 300; - } - } - } - } if (aSpark) { var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index c187ea3dce..8e54c36a74 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using CalamityMod.CalPlayer.DrawLayers; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -59,6 +60,7 @@ namespace CalamityMod.CalPlayer Rectangle screenArea = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 50, Main.screenWidth + 1000, Main.screenHeight + 100); int dustDrawn = 0; float maxShroomDust = Main.maxDustToDraw / 2; + Color shroomColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); for (int i = 0; i < Main.maxDustToDraw; i++) { Dust dust = Main.dust[i]; @@ -67,7 +69,7 @@ namespace CalamityMod.CalPlayer // Only draw dust near the screen, for performance reasons. if (new Rectangle((int)dust.position.X, (int)dust.position.Y, 4, 4).Intersects(screenArea)) { - dust.color = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); + dust.color = shroomColor; for (int j = 0; j < 4; j++) { Vector2 dustDrawPosition = dust.position; @@ -84,8 +86,8 @@ namespace CalamityMod.CalPlayer if (j == 0 || j == 1) dustDrawPosition.Y = Player.Center.Y + distanceY; - - else dustDrawPosition.Y = Player.Center.Y - distanceY; + else + dustDrawPosition.Y = Player.Center.Y - distanceY; dustDrawPosition.Y -= 4f; Main.spriteBatch.Draw(TextureAssets.Dust.Value, dustDrawPosition - Main.screenPosition, dust.frame, dust.color, dust.rotation, new Vector2(4f), dust.scale, SpriteEffects.None, 0f); @@ -378,6 +380,24 @@ namespace CalamityMod.CalPlayer fullBright = true; } } + if (calamityPlayer.absorberAffliction) + { + if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) + { + int dust = Dust.NewDust(drawInfo.Position - new Vector2(2f), Player.width + 4, Player.height + 4, 63, Player.velocity.X * 0.4f, Player.velocity.Y * 0.4f, 100, Color.DarkSeaGreen, 1.5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.8f; + Main.dust[dust].velocity.Y -= 0.5f; + drawInfo.DustCache.Add(dust); + } + if (noRogueStealth) + { + r *= 0.25f; + g *= 0.25f; + b *= 0.1f; + fullBright = true; + } + } else if (calamityPlayer.icarusFolly || calamityPlayer.dragonFire) { if (Main.rand.NextBool(calamityPlayer.dragonFire ? 6 : 12) && drawInfo.shadow == 0f) @@ -516,6 +536,30 @@ namespace CalamityMod.CalPlayer fullBright = true; } } + if (calamityPlayer.PinkJellyRegen) + { + if (Main.rand.NextBool(24) && drawInfo.shadow == 0f) + { + Particle Plus = new HealingPlus(Player.Center, Main.rand.NextFloat(0.5f, 1.2f), Color.HotPink, Color.LightPink, Main.rand.Next(10, 15)); + GeneralParticleHandler.SpawnParticle(Plus); + } + } + if (calamityPlayer.GreenJellyRegen) + { + if (Main.rand.NextBool(16) && drawInfo.shadow == 0f) + { + Particle Plus = new HealingPlus(Player.Center, Main.rand.NextFloat(0.6f, 1.3f), Color.Lime, Color.LimeGreen, Main.rand.Next(10, 15)); + GeneralParticleHandler.SpawnParticle(Plus); + } + } + if (calamityPlayer.AbsorberRegen) + { + if (Main.rand.NextBool(11) && drawInfo.shadow == 0f) + { + Particle Plus = new HealingPlus(Player.Center, Main.rand.NextFloat(0.7f, 1.4f), Color.DarkSeaGreen, Color.DarkSeaGreen, Main.rand.Next(10, 15)); + GeneralParticleHandler.SpawnParticle(Plus); + } + } if (calamityPlayer.bloodfinBoost) { if (Main.rand.NextBool(6) && drawInfo.shadow == 0f) diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index b281824a10..386bc6fb4e 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -660,6 +660,15 @@ namespace CalamityMod.CalPlayer if (sRegen) Player.lifeRegen += 2; + if (PinkJellyRegen) + Player.lifeRegen += 4; + + if (GreenJellyRegen) + Player.lifeRegen += 6; + + if (AbsorberRegen) + Player.lifeRegen += 7; + if (hallowedRegen) Player.lifeRegen += 3; @@ -669,12 +678,6 @@ namespace CalamityMod.CalPlayer if (trinketOfChi || chiRegen) Player.lifeRegen += 2; - if (absorber) - { - if (Player.StandingStill() && Player.itemAnimation == 0) - Player.lifeRegen += 4; - } - if (aAmpoule) { Player.lifeRegen += 4; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index fc4ee0501c..6c590f216f 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -238,6 +238,36 @@ namespace CalamityMod.CalPlayer //Todo - Move this back to the wulfrum set class whenever statmodifiers are implemented for stats other than damage if (WulfrumHat.PowerModeEngaged(Player, out _)) Player.moveSpeed *= 0.8f; + + if (gShell) + { + //reduce player dash velocity as long as you didn't just get hit + if (Player.dashDelay == -1 && giantShellPostHit == 0) + { + if (!HasReducedDashFirstFrame) + { + Player.velocity.X *= 0.9f; + HasReducedDashFirstFrame = true; + } + } + else + HasReducedDashFirstFrame = false; + } + + if (tortShell) + { + //reduce player dash velocity as long as you didn't just get hit + if (Player.dashDelay == -1 && tortShellPostHit == 0) + { + if (!HasReducedDashFirstFrame) + { + Player.velocity.X *= 0.85f; + HasReducedDashFirstFrame = true; + } + } + else + HasReducedDashFirstFrame = false; + } } #endregion @@ -1556,13 +1586,9 @@ namespace CalamityMod.CalPlayer // Absorber bonus if (absorber) { - Player.moveSpeed += 0.05f; - Player.jumpSpeedBoost += 0.25f; - Player.thorns += 0.5f; - Player.endurance += sponge ? 0.1f : 0.07f; - - if (Player.StandingStill() && Player.itemAnimation == 0) - Player.manaRegenBonus += 4; + Player.moveSpeed += 0.1f; + Player.jumpSpeedBoost += 0.5f; + Player.thorns += 3.5f; } // Affliction bonus @@ -2458,6 +2484,54 @@ namespace CalamityMod.CalPlayer Player.statDefense += Main.eclipse ? 10 : 20; } + if (AbsorberRegen) + { + Player.GetDamage() += 0.1f; + Player.endurance += 0.07f; + } + + if (crawCarapace) + Player.GetDamage() += 0.05f; + + if (baroclaw) + Player.GetDamage() += 0.08f; + + if (gShell) + { + if (giantShellPostHit == 1) + SoundEngine.PlaySound(SoundID.Zombie58, Player.Center); + + if (giantShellPostHit > 0) + { + Player.statDefense -= 5; + giantShellPostHit--; + } + if (giantShellPostHit < 0) + { + giantShellPostHit = 0; + } + } + + if (tortShell) + { + if (tortShellPostHit == 1) + SoundEngine.PlaySound(SoundID.NPCHit24 with {Volume = 0.5f}, Player.Center); + + if (tortShellPostHit > 0) + { + Player.statDefense -= 10; + tortShellPostHit--; + } + else + Player.endurance += 0.05f; + + if (tortShellPostHit < 0) + { + tortShellPostHit = 0; + } + } + + // Ancient Chisel nerf if (Player.chiselSpeed) Player.pickSpeed += 0.1f; @@ -3225,7 +3299,7 @@ namespace CalamityMod.CalPlayer { if (Player.whoAmI == Main.myPlayer) { - //Reduce the buffTime of Electrified + // Reduce the buffTime of Electrified. for (int l = 0; l < Player.MaxBuffs; l++) { bool electrified = Player.buffType[l] == BuffID.Electrified; @@ -3233,15 +3307,15 @@ namespace CalamityMod.CalPlayer Player.buffTime[l]--; } - //Summon the aura + // Summon the aura. // https://github.com/tModLoader/tModLoader/wiki/IEntitySource#detailed-list var source = Player.GetSource_Buff(Player.FindBuffIndex(ModContent.BuffType())); int damage = (int)Player.GetBestClassDamage().ApplyTo(10); if (Player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - Projectile.NewProjectile(source, Player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Player.whoAmI, 0f, 0f); + Projectile.NewProjectile(source, Player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Player.whoAmI); } } - else if (Player.ownedProjectileCounts[ModContent.ProjectileType()] != 0) + else if (Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) { if (Player.whoAmI == Main.myPlayer) { @@ -3543,6 +3617,16 @@ namespace CalamityMod.CalPlayer // (in addition to the player taking more defense damage, of course). if (totalDefenseDamage > 0) { + //Used to cleanse all defense damage by accessories + if (CleansingEffect == 1) + { + totalDefenseDamage = 0; + defenseDamageRecoveryFrames = 0; + totalDefenseDamageRecoveryFrames = DefenseDamageBaseRecoveryTime; + defenseDamageDelayFrames = 0; + CleansingEffect = 0; + } + // Defense damage is capped at your maximum defense, no matter what. if (totalDefenseDamage > Player.statDefense) totalDefenseDamage = Player.statDefense; diff --git a/CalPlayer/DrawLayers/AuricSetTrailLayer.cs b/CalPlayer/DrawLayers/AuricSetTrailLayer.cs index 24c742e3de..05ec02fc47 100644 --- a/CalPlayer/DrawLayers/AuricSetTrailLayer.cs +++ b/CalPlayer/DrawLayers/AuricSetTrailLayer.cs @@ -24,11 +24,12 @@ namespace CalamityMod.CalPlayer.DrawLayers { Player drawPlayer = drawInfo.drawPlayer; List existingDrawData = drawInfo.DrawDataCache; - for (float i = 0f; i < drawPlayer.Calamity().OldPositions.Length; i+=0.8f) + float movementSpeedInterpolant = CobaltArmorSetChange.CalculateMovementSpeedInterpolant(drawPlayer); + for (float i = 0f; i < drawPlayer.Calamity().OldPositions.Length; i += 0.8f) { float completionRatio = i / (float)drawPlayer.Calamity().OldPositions.Length; float scale = MathHelper.Lerp(1f, 0.7f, completionRatio); - float opacity = MathHelper.Lerp(0.18f, 0.06f, completionRatio) * CobaltArmorSetChange.CalculateMovementSpeedInterpolant(drawPlayer); + float opacity = MathHelper.Lerp(0.18f, 0.06f, completionRatio) * movementSpeedInterpolant; List afterimages = new List(); for (int j = 0; j < existingDrawData.Count; j++) { diff --git a/CalPlayer/DrawLayers/CobaltSetTrailLayer.cs b/CalPlayer/DrawLayers/CobaltSetTrailLayer.cs index 0a8c3bfca5..7c44e6a59b 100644 --- a/CalPlayer/DrawLayers/CobaltSetTrailLayer.cs +++ b/CalPlayer/DrawLayers/CobaltSetTrailLayer.cs @@ -24,11 +24,12 @@ namespace CalamityMod.CalPlayer.DrawLayers { Player drawPlayer = drawInfo.drawPlayer; List existingDrawData = drawInfo.DrawDataCache; + float movementSpeedInterpolant = CobaltArmorSetChange.CalculateMovementSpeedInterpolant(drawPlayer); for (int i = 0; i < drawPlayer.Calamity().OldPositions.Length; i++) { float completionRatio = i / (float)drawPlayer.Calamity().OldPositions.Length; float scale = MathHelper.Lerp(1f, 0.5f, completionRatio); - float opacity = MathHelper.Lerp(0.23f, 0.07f, completionRatio) * CobaltArmorSetChange.CalculateMovementSpeedInterpolant(drawPlayer); + float opacity = MathHelper.Lerp(0.23f, 0.07f, completionRatio) * movementSpeedInterpolant; List afterimages = new List(); for (int j = 0; j < existingDrawData.Count; j++) { diff --git a/CalPlayer/DrawLayers/ForbiddenSignLayer.cs b/CalPlayer/DrawLayers/ForbiddenSignLayer.cs index 0e283ad12c..288ee55479 100644 --- a/CalPlayer/DrawLayers/ForbiddenSignLayer.cs +++ b/CalPlayer/DrawLayers/ForbiddenSignLayer.cs @@ -56,10 +56,12 @@ namespace CalamityMod.CalPlayer.DrawLayers drawInfo.DrawDataCache.Add(drawData); // Draw 4 semi-transparent copies. + float timeX4 = sinusoidalTime * 4f; + Vector2 origin = texture.Size() * 0.5f; for (float i = 0f; i < 4f; i++) { - float angle = MathHelper.TwoPi / 4f * i; - drawData = new(glowmask, position + angle.ToRotationVector2() * sinusoidalTime * 4f, null, afterimageColor, drawPlayer.bodyRotation, texture.Size() * 0.5f, 1f, spriteEffects, 0); + float angle = MathHelper.PiOver2 * i; + drawData = new(glowmask, position + angle.ToRotationVector2() * timeX4, null, afterimageColor, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0); drawInfo.DrawDataCache.Add(drawData); } } diff --git a/CalPlayer/DrawLayers/GemTechGemLayer.cs b/CalPlayer/DrawLayers/GemTechGemLayer.cs index 71dae348e0..4c49822018 100644 --- a/CalPlayer/DrawLayers/GemTechGemLayer.cs +++ b/CalPlayer/DrawLayers/GemTechGemLayer.cs @@ -22,6 +22,9 @@ namespace CalamityMod.CalPlayer.DrawLayers { Player drawPlayer = drawInfo.drawPlayer; CalamityPlayer modPlayer = drawPlayer.Calamity(); + float opacity = MathHelper.Lerp(0.85f, 1.05f, (float)Math.Cos(Main.GlobalTimeWrappedHourly * 2.3f) * 0.5f + 0.5f); + float time = Main.GlobalTimeWrappedHourly * 0.61f; + float gemTime = Main.GlobalTimeWrappedHourly * 3.41f; for (int i = 5; i >= 0; i--) { Texture2D gemTexture; @@ -61,11 +64,11 @@ namespace CalamityMod.CalPlayer.DrawLayers if (!modPlayer.GemTechState.GemIsActive(gemType)) continue; - float drawOffsetAngle = modPlayer.GemTechState.CalculateGemOffsetAngle(gemType); - float gemOpacity = MathHelper.Lerp(0.85f, 1.05f, (float)Math.Cos(Main.GlobalTimeWrappedHourly * 2.3f) * 0.5f + 0.5f); + float drawOffsetAngle = modPlayer.GemTechState.CalculateGemOffsetAngle(gemType, gemTime); + float gemOpacity = opacity; // Incorporate a sinusoidal pulse into the pulse factor. - pulseFactor *= (float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.61f + drawOffsetAngle); + pulseFactor *= (float)Math.Cos(time + drawOffsetAngle); // Somewhat unorthodox way of creating an illusion of gems being drawn behind the player via orbiting. // Instead of actually messing with a Z position it simply fades away when the sine of the draw @@ -75,12 +78,15 @@ namespace CalamityMod.CalPlayer.DrawLayers Vector2 baseDrawPosition = modPlayer.GemTechState.CalculateGemPosition(gemType) - Main.screenPosition; // Draw back afterimages. + float afterimageTime = Main.GlobalTimeWrappedHourly * 0.47f; + float backAfterImageOpacity = gemOpacity * 0.24f; + Vector2 origin = gemTexture.Size() * 0.5f; for (int j = 0; j < 5; j++) { - Color backAfterimageColor = Main.hslToRgb((Main.GlobalTimeWrappedHourly * 0.47f + j / 5f) % 1f, 1f, 0.67f); - backAfterimageColor = Color.Lerp(backAfterimageColor, Color.White, 0.64f) * gemOpacity * 0.24f; + Color backAfterimageColor = Main.hslToRgb((afterimageTime + j / 5f) % 1f, 1f, 0.67f); + backAfterimageColor = Color.Lerp(backAfterimageColor, Color.White, 0.64f) * backAfterImageOpacity; Vector2 drawPosition = baseDrawPosition + (MathHelper.TwoPi * j / 5f).ToRotationVector2() * pulseFactor; - DrawData gemBackDrawData = new DrawData(gemTexture, drawPosition, null, backAfterimageColor, 0f, gemTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0); + DrawData gemBackDrawData = new DrawData(gemTexture, drawPosition, null, backAfterimageColor, 0f, origin, 1f, SpriteEffects.None, 0); drawInfo.DrawDataCache.Add(gemBackDrawData); } diff --git a/CalamityLists.cs b/CalamityLists.cs index 5811c55105..a797497b7d 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -1145,6 +1145,7 @@ namespace CalamityMod BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), diff --git a/Cooldowns/SandsmokeBomb.cs b/Cooldowns/SandsmokeBomb.cs index 730ca12fa7..971383af77 100644 --- a/Cooldowns/SandsmokeBomb.cs +++ b/Cooldowns/SandsmokeBomb.cs @@ -31,13 +31,15 @@ namespace CalamityMod.Cooldowns public override void OnCompleted() { + Vector2 playerVelocity = instance.player.velocity / 8f; + Vector2 particleGravity = Vector2.UnitY * 0.03f; for (int i = 0; i < 16; i++) { Vector2 dustDisplace = Main.rand.NextVector2Circular(80f, 50f); Vector2 dustPosition = instance.player.MountedCenter + dustDisplace; - Vector2 dustSpeed = Main.rand.NextVector2Circular(0.5f, 0.5f) + instance.player.velocity / 8f - Vector2.UnitY.RotatedByRandom(MathHelper.PiOver4) * 0.06f; + Vector2 dustSpeed = Main.rand.NextVector2Circular(0.5f, 0.5f) + playerVelocity - Vector2.UnitY.RotatedByRandom(MathHelper.PiOver4) * 0.06f; dustSpeed.X += 1.4f * (float)Math.Sin(((dustDisplace.X + 80f) / 160f) * MathHelper.Pi) * (Main.rand.NextBool() ? -1 : 1); - Particle dust = new SandyDustParticle(dustPosition, dustSpeed, Color.White, Main.rand.NextFloat(0.7f, 1.2f), Main.rand.Next(20, 50), 0.03f, Vector2.UnitY * 0.03f); + Particle dust = new SandyDustParticle(dustPosition, dustSpeed, Color.White, Main.rand.NextFloat(0.7f, 1.2f), Main.rand.Next(20, 50), 0.03f, particleGravity); GeneralParticleHandler.SpawnParticle(dust); } } diff --git a/DataStructures/GemTechArmorState.cs b/DataStructures/GemTechArmorState.cs index adb167e9e2..7626e78b26 100644 --- a/DataStructures/GemTechArmorState.cs +++ b/DataStructures/GemTechArmorState.cs @@ -342,14 +342,15 @@ namespace CalamityMod.DataStructures Owner.manaRegen += GemTechHeadgear.NonMagicItemManaRegenBoost; } - public float CalculateGemOffsetAngle(GemTechArmorGemType gemType) + public float CalculateGemOffsetAngle(GemTechArmorGemType gemType, float time) { - return MathHelper.TwoPi * (int)gemType / 6f + Main.GlobalTimeWrappedHourly * 3.41f; + return MathHelper.TwoPi * (int)gemType / 6f + time; } public Vector2 CalculateGemPosition(GemTechArmorGemType gemType) { - Vector2 baseDrawOffsetDirection = CalculateGemOffsetAngle(gemType).ToRotationVector2() * new Vector2(1f, 0.2f); + float gemTime = Main.GlobalTimeWrappedHourly * 3.41f; + Vector2 baseDrawOffsetDirection = CalculateGemOffsetAngle(gemType, gemTime).ToRotationVector2() * new Vector2(1f, 0.2f); Vector2 gemPosition = Owner.Center + baseDrawOffsetDirection * Owner.width * 1.25f; gemPosition.Y += Owner.gfxOffY; if (Owner.mount?.Active ?? false) diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index e68b0200a7..bcbe7a05a4 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -58,7 +58,7 @@ namespace CalamityMod.ILEditing // Mechanics / features On_NPC.ApplyTileCollision += AllowTriggeredFallthrough; IL_Player.ApplyEquipFunctional += ScopesRequireVisibilityToZoom; - On_Player.Hurt_PlayerDeathReason_int_int_bool_bool_int_bool_float_float_float += RemoveRNGFromDodges; + IL_Player.Hurt_PlayerDeathReason_int_int_refHurtInfo_bool_bool_int_bool_float_float_float += DodgeMechanicAdjustments; IL_Player.DashMovement += FixAllDashMechanics; On_Player.DoCommonDashHandle += ApplyDashKeybind; IL_Player.GiveImmuneTimeForCollisionAttack += MakeShieldSlamIFramesConsistent; diff --git a/ILEditing/ILHelperMethods.cs b/ILEditing/ILHelperMethods.cs index 86408ea30e..167e4bd24a 100644 --- a/ILEditing/ILHelperMethods.cs +++ b/ILEditing/ILHelperMethods.cs @@ -137,18 +137,32 @@ namespace CalamityMod.ILEditing new Vector2(x + 0.5f, y + 0.5f), }; + float lerpAmt = (1f - SulphuricWaterSafeZoneSystem.NearbySafeTiles[closestSafeZone]) * 21f; for (int i = 0; i < 4; i++) { float distanceToClosest = points[i].Distance(closestSafeZone.ToVector2()); - float acidicWaterInterpolant = Utils.GetLerpValue(12f, 20.5f, distanceToClosest + (1f - SulphuricWaterSafeZoneSystem.NearbySafeTiles[closestSafeZone]) * 21f, true); - if (i == 0) - initialColor.TopLeftColor = Color.Lerp(initialColor.TopLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); - if (i == 1) - initialColor.TopRightColor = Color.Lerp(initialColor.TopRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); - if (i == 2) - initialColor.BottomLeftColor = Color.Lerp(initialColor.BottomLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); - if (i == 3) - initialColor.BottomRightColor = Color.Lerp(initialColor.BottomRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); + float acidicWaterInterpolant = Utils.GetLerpValue(12f, 20.5f, distanceToClosest + lerpAmt, true); + switch (i) + { + case 0: + initialColor.TopLeftColor = Color.Lerp(initialColor.TopLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); + break; + + case 1: + initialColor.TopRightColor = Color.Lerp(initialColor.TopRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); + break; + + case 2: + initialColor.BottomLeftColor = Color.Lerp(initialColor.BottomLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); + break; + + case 3: + initialColor.BottomRightColor = Color.Lerp(initialColor.BottomRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); + break; + + default: + break; + } } } diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index 78ff25d23e..e75606368f 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -1,10 +1,14 @@ -using CalamityMod.Balancing; +using System; +using System.Linq; +using System.Reflection; +using CalamityMod.Balancing; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; -using CalamityMod.Cooldowns; -using CalamityMod.ForegroundDrawing; +using CalamityMod.DataStructures; using CalamityMod.Events; using CalamityMod.FluidSimulation; +using CalamityMod.ForegroundDrawing; +using CalamityMod.Items.Accessories; using CalamityMod.Items.Dyes; using CalamityMod.NPCs; using CalamityMod.NPCs.Astral; @@ -12,39 +16,30 @@ using CalamityMod.NPCs.AstrumAureus; using CalamityMod.NPCs.Crabulon; using CalamityMod.NPCs.Ravager; using CalamityMod.Particles; +using CalamityMod.Particles.Metaballs; using CalamityMod.Projectiles; -using CalamityMod.Systems; -using CalamityMod.Waters; -using CalamityMod.World; using CalamityMod.Projectiles.Typeless; -using CalamityMod.Items.Accessories; +using CalamityMod.Systems; +using CalamityMod.Tiles.Abyss; +using CalamityMod.Waters; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Mono.Cecil.Cil; using MonoMod.Cil; using ReLogic.Content; -using System; -using System.Linq; -using System.Reflection; using Terraria; using Terraria.DataStructures; using Terraria.GameContent; +using Terraria.GameContent.Drawing; +using Terraria.GameContent.Events; using Terraria.GameContent.Liquid; using Terraria.GameInput; using Terraria.Graphics; +using Terraria.Graphics.Light; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; using Terraria.UI.Gamepad; -using Terraria.Utilities; -using Terraria.Graphics.Light; -using Terraria.GameContent.Events; -using CalamityMod.DataStructures; -using CalamityMod.Particles.Metaballs; -using Terraria.GameContent.Drawing; -using CalamityMod.Tiles.Abyss; -using System.Collections.Generic; -using CalamityMod.BiomeManagers; namespace CalamityMod.ILEditing { @@ -282,7 +277,7 @@ namespace CalamityMod.ILEditing dashing = false; } } - #endregion Dash Fixes and Improvements + #endregion #region Allow Empress to Enrage in Boss Rush private static bool AllowEmpressToEnrageInBossRush(Terraria.On_NPC.orig_ShouldEmpressBeEnraged orig) @@ -292,7 +287,7 @@ namespace CalamityMod.ILEditing return orig(); } - #endregion Allow Empress to Enrage in Boss Rush + #endregion #region Enabling of Triggered NPC Platform Fallthrough // Why this isn't a mechanism provided by TML itself or vanilla itself is beyond me. @@ -309,7 +304,7 @@ namespace CalamityMod.ILEditing orig(self, fall, cPosition, cWidth, cHeight); } - #endregion Enabling of Triggered NPC Platform Fallthrough + #endregion #region Town NPC Spawning Improvements private static void PermitNighttimeTownNPCSpawning(ILContext il) @@ -341,41 +336,76 @@ namespace CalamityMod.ILEditing orig(); Main.desiredWorldTilesUpdateRate = oldWorldRate; } - #endregion Town NPC Spawning Improvements + #endregion - #region Removal of Dodge RNG - private static double RemoveRNGFromDodges(Terraria.On_Player.orig_Hurt_PlayerDeathReason_int_int_bool_bool_int_bool_float_float_float orig, Player self, PlayerDeathReason damageSource, int Damage, int hitDirection, bool pvp, bool quiet, int cooldownCounter, bool dodgeable, float armorPenetration, float scalingArmorPenetration, float knockback) + #region Dodge Mechanic Adjustments + private static void DodgeMechanicAdjustments(ILContext il) { - if (self.whoAmI == Main.myPlayer) - { - // Disable dodges - if (self.Calamity().disableAllDodges) - dodgeable = false; - - // Provided you have no other dodges, disable dodging while under the cooldown - bool hasOtherDodges = self.shadowDodge; - if (self.HasCooldown(GlobalDodge.ID)) - dodgeable = hasOtherDodges; + var cursor = new ILCursor(il); - // Remove Black Belt RNG and add the cooldown - else if (self.blackBelt) - { - self.NinjaDodge(); - self.AddCooldown(GlobalDodge.ID, BalancingConstants.BeltDodgeCooldown); - return 0.0; - } - // Remove Brain of Confusion RNG and add the cooldown - else if (self.brainOfConfusionItem != null && !self.brainOfConfusionItem.IsAir) - { - self.BrainOfConfusionDodge(); - self.AddCooldown(GlobalDodge.ID, self.Calamity().amalgam ? BalancingConstants.AmalgamDodgeCooldown : BalancingConstants.BrainDodgeCooldown); - return 0.0; - } + // Skip past the first half of the function. We do not care about the following opening steps of Player.Hurt: + // 1. AllowShimmerDodge + // 2. Journey's god mode + // 3. TML PlayerLoader.ImmuneTo + // 4. vanilla iframe check + // 5. ModifyHurt + // 6. ogre knockback + // + // To skip to the part we care about, go after the one and only call to HurtModifiers.ToHurtInfo. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCall(typeof(Player.HurtModifiers), nameof(Player.HurtModifiers.ToHurtInfo)))) + { + LogFailure("Dodge Mechanic Adjustments", "Could not locate the call to HurtModifiers.ToHurtInfo."); + return; } - return orig(self, damageSource, Damage, hitDirection, pvp, quiet, cooldownCounter, dodgeable, armorPenetration, scalingArmorPenetration, knockback); + // The load for the dodgeable boolean is impossible to decipher due to being an ldarg_s (optional parameter). + // This is used to make Day Empress' attacks undodgeable. + // Instead, find the immediately following brfalse. + // If Calamity's old Armageddon bool which "Disables all dodges" is enabled, EVERY attack is considered undodgeable. + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchBrfalse(out ILLabel branchEnd))) + { + LogFailure("Dodge Mechanic Adjustments", "Could not locate the dodgeable boolean branch."); + return; + } + + // AND with an emitted delegate which takes the player and gets whether Calamity is allowing dodges for them right now + cursor.Emit(OpCodes.Ldarg_0); + cursor.EmitDelegate((Player p) => !p.Calamity().disableAllDodges); + cursor.Emit(OpCodes.And); + + // Skip ahead to Black Belt + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("blackBelt"))) + { + LogFailure("Dodge Mechanic Adjustments", "Could not locate the Black Belt equipped boolean."); + return; + } + + // Destroy the value, utterly, and in its place put zero. + // The player is never considered to have Black Belt equipped from the perspective of vanilla code. + // Calamity re-implements Black Belt in CalamityPlayer.ConsumableDodge + cursor.Emit(OpCodes.Pop); + cursor.Emit(OpCodes.Ldc_I4_0); + + // Skip ahead to Brain of Confusion + // Here the part we skip to is actually + // brainOfConfusionItem != null + // This is implemented as a brfalse, so just do the same thing as above. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("brainOfConfusionItem"))) + { + LogFailure("Dodge Mechanic Adjustments", "Could not locate the Brain of Confusion tracked equipped item."); + return; + } + + // The player is never considered to have Brain of Confusion equipped from the perspective of vanilla code. + // Calamity re-implements Brain of Confusion in CalamityPlayer.ConsumableDodge + // Instead of being limited by its buff, it is limited by the Global Dodge Cooldown. + cursor.Emit(OpCodes.Pop); + cursor.Emit(OpCodes.Ldc_I4_0); + + // No interference with ShadowDodge (previously Titanium armor, now Hallowed armor) + CalamityMod.Instance.Logger.Info(il.ToString()); } - #endregion Removal of Dodge RNG + #endregion #region Custom Gate Door Logic private static bool OpenDoor_LabDoorOverride(Terraria.On_WorldGen.orig_OpenDoor orig, int i, int j, int direction) @@ -409,7 +439,7 @@ namespace CalamityMod.ILEditing // If it's anything else, let vanilla and/or TML handle it. return orig(i, j, forced); } - #endregion Custom Gate Door Logic + #endregion #region Platform Collision Checks for Grounded Bosses private static bool EnableCalamityBossPlatformCollision(Terraria.On_NPC.orig_Collision_DecideFallThroughPlatforms orig, NPC self) @@ -421,7 +451,7 @@ namespace CalamityMod.ILEditing return orig(self); } - #endregion Platform Collision Checks for Grounded Bosses + #endregion #region Incorporate Enchantments in Item Names private static string IncorporateEnchantmentInAffix(Terraria.On_Item.orig_AffixName orig, Item self) @@ -431,7 +461,7 @@ namespace CalamityMod.ILEditing result = $"{self.Calamity().AppliedEnchantment.Value.Name} {result}"; return result; } - #endregion Incorporate Enchantments in Item Names + #endregion #region Hellbound Enchantment Projectile Creation Effects private static int IncorporateMinionExplodingCountdown(Terraria.On_Projectile.orig_NewProjectile_IEntitySource_float_float_float_float_int_int_float_int_float_float_float orig, IEntitySource spawnSource, float x, float y, float xSpeed, float ySpeed, int type, int damage, float knockback, int owner, float ai0, float ai1, float ai2) @@ -452,7 +482,7 @@ namespace CalamityMod.ILEditing } return proj; } - #endregion Hellbound Enchantment Projectile Creation Effects + #endregion #region Mana Sickness Replacement for Chaos Stone private static void ConditionallyReplaceManaSickness(ILContext il) @@ -480,7 +510,7 @@ namespace CalamityMod.ILEditing return ModContent.BuffType(); }); } - #endregion Mana Sickness Replacement for Chaos Stone + #endregion #region Fire Cursor Effect for the Calamity Accessory private static void UseCoolFireCursorEffect(Terraria.On_Main.orig_DrawCursor orig, Vector2 bonus, bool smart) @@ -552,13 +582,12 @@ namespace CalamityMod.ILEditing color = Color.Lerp(color, Color.White, 0.75f); float offsetAngleValue = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 6.7f) * 0.99f; - float horizontalAreaValue = (float)horizontalArea * 0.34f; int origin = size / 2; for (int i = -horizontalArea; i <= horizontalArea; i++) { float offsetAngle = offsetAngleValue; - offsetAngle += i / horizontalAreaValue; + offsetAngle += i / (float)horizontalArea * 0.34f; Vector2 velocity = Main.MouseWorld - UIManagementSystem.PreviousMouseWorld; if (velocity.Length() < 64f) { @@ -626,7 +655,7 @@ namespace CalamityMod.ILEditing Texture2D crosshairTexture = TextureAssets.Cursors[15].Value; Main.spriteBatch.Draw(crosshairTexture, baseDrawPosition, null, cursorColor, 0f, crosshairTexture.Size() * 0.5f, Main.cursorScale, SpriteEffects.None, 0f); } - #endregion Fire Cursor Effect for the Calamity Accessory + #endregion #region Custom Draw Layers private static void AdditiveDrawing(ILContext il) @@ -662,7 +691,7 @@ namespace CalamityMod.ILEditing Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); }); } - #endregion Custom Draw Layers + #endregion #region General Particle Rendering private static void DrawFusableParticles(Terraria.On_Main.orig_SortDrawCacheWorms orig, Main self) @@ -688,7 +717,7 @@ namespace CalamityMod.ILEditing FusableParticleManager.LoadParticleRenderSets(true, width, height); orig(width, height, fullscreen); } - #endregion General Particle Rendering + #endregion #region Custom Lava Visuals private static void DrawCustomLava(Terraria.GameContent.Drawing.On_TileDrawing.orig_DrawPartialLiquid orig, TileDrawing self, bool behindBlocks, Tile tileCache, ref Vector2 position, ref Rectangle liquidSize, int liquidType, ref VertexColors colors) @@ -876,7 +905,7 @@ namespace CalamityMod.ILEditing orig(self, waterfallType, x, y, opacity, position, sourceRect, color, effects); } - #endregion Custom Lava Visuals + #endregion #region Water Visuals private static void MakeSulphSeaWaterBetter(Terraria.Graphics.Light.On_TileLightScanner.orig_GetTileLight orig, TileLightScanner self, int x, int y, out Vector3 outputColor) @@ -985,7 +1014,7 @@ namespace CalamityMod.ILEditing } } } - #endregion Water Visuals + #endregion #region Statue Additions /// @@ -1071,7 +1100,7 @@ namespace CalamityMod.ILEditing // couldn't find the right place to insert throw new Exception("Hook location not found, switch(*) { case 54: ..."); } - #endregion Statue Additions + #endregion #region Make Tax Collector Worth it private static void MakeTaxCollectorUseful(ILContext il) @@ -1093,7 +1122,7 @@ namespace CalamityMod.ILEditing cursor.Emit(OpCodes.Pop); cursor.Emit(OpCodes.Call, "get_TaxesToCollectLimit"); } - #endregion Make Tax Collector Worth it + #endregion #region Foreground tiles drawing private static void DrawForegroundStuff(Terraria.On_Main.orig_DrawGore orig, Main self) @@ -1222,7 +1251,7 @@ namespace CalamityMod.ILEditing if (armorItem.type == ModContent.ItemType()) self.Calamity().CalamityFireDyeShader = GameShaders.Armor.GetShaderFromItemId(dyeItem.type); } - #endregion Find Calamity Item Dye Shader + #endregion #region Scopes Require Visibility to Zoom private static void ScopesRequireVisibilityToZoom(ILContext il) diff --git a/Items/Accessories/AmidiasPendant.cs b/Items/Accessories/AmidiasPendant.cs index b77b2b3309..deec0c23ce 100644 --- a/Items/Accessories/AmidiasPendant.cs +++ b/Items/Accessories/AmidiasPendant.cs @@ -43,11 +43,13 @@ namespace CalamityMod.Items.Accessories Vector2 baseVelocity = player.Center - baseSpawn; baseVelocity.Normalize(); baseVelocity *= speed2; + int spawnOffset = ShardProjectiles * 15; + float spread = -ShardAngleSpread / 2f; for (int i = 0; i < ShardProjectiles; i++) { Vector2 spawn = baseSpawn; - spawn.X = spawn.X + i * 30 - (ShardProjectiles * 15); - Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-ShardAngleSpread / 2 + (ShardAngleSpread * i / (float)ShardProjectiles))); + spawn.X = spawn.X + i * 30 - spawnOffset; + Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(spread + (ShardAngleSpread * i / (float)ShardProjectiles))); velocity.X = velocity.X + 3 * Main.rand.NextFloat() - 1.5f; int type = 0; int damage = 0; @@ -67,7 +69,7 @@ namespace CalamityMod.Items.Accessories break; } int finalDamage = (int)player.GetBestClassDamage().ApplyTo(damage); - Projectile.NewProjectile(source, spawn.X, spawn.Y, velocity.X / 3, velocity.Y / 2, type, finalDamage, 5f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(source, spawn.X, spawn.Y, velocity.X / 3, velocity.Y / 2, type, finalDamage, 5f, Main.myPlayer); } } } diff --git a/Items/Accessories/Baroclaw.cs b/Items/Accessories/Baroclaw.cs new file mode 100644 index 0000000000..365da37aa4 --- /dev/null +++ b/Items/Accessories/Baroclaw.cs @@ -0,0 +1,36 @@ +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; + +namespace CalamityMod.Items.Accessories +{ + public class Baroclaw : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + public override void SetDefaults() + { + Item.width = 30; + Item.height = 44; + Item.value = CalamityGlobalItem.Rarity7BuyPrice; + Item.rare = ItemRarityID.Lime; + Item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.baroclaw = true; + player.thorns += 1.1f; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(12). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Accessories/Baroclaw.png b/Items/Accessories/Baroclaw.png new file mode 100644 index 0000000000..79f8c3c76d Binary files /dev/null and b/Items/Accessories/Baroclaw.png differ diff --git a/Items/Accessories/ManaJelly.cs b/Items/Accessories/CleansingJelly.cs similarity index 65% rename from Items/Accessories/ManaJelly.cs rename to Items/Accessories/CleansingJelly.cs index 3f978e6527..3a1611de7a 100644 --- a/Items/Accessories/ManaJelly.cs +++ b/Items/Accessories/CleansingJelly.cs @@ -2,10 +2,12 @@ using Terraria; using Terraria.ModLoader; using Terraria.ID; +using CalamityMod.CalPlayer; namespace CalamityMod.Items.Accessories { - public class ManaJelly : ModItem, ILocalizedModType + [LegacyName("ManaJelly")] + public class CleansingJelly : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; public override void SetDefaults() @@ -19,11 +21,8 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.statManaMax2 += 20; - if ((double)Math.Abs(player.velocity.X) < 0.05 && (double)Math.Abs(player.velocity.Y) < 0.05 && player.itemAnimation == 0) - { - player.manaRegenBonus += 4; - } + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.cleansingjelly = true; } } } diff --git a/Items/Accessories/ManaJelly.png b/Items/Accessories/CleansingJelly.png similarity index 100% rename from Items/Accessories/ManaJelly.png rename to Items/Accessories/CleansingJelly.png diff --git a/Items/Accessories/CrawCarapace.cs b/Items/Accessories/CrawCarapace.cs index 4e01739f08..b66e9f9f1d 100644 --- a/Items/Accessories/CrawCarapace.cs +++ b/Items/Accessories/CrawCarapace.cs @@ -1,6 +1,7 @@ using Terraria; using Terraria.ModLoader; using Terraria.ID; +using CalamityMod.CalPlayer; namespace CalamityMod.Items.Accessories { @@ -9,7 +10,6 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public override void SetDefaults() { - Item.defense = 5; Item.width = 28; Item.height = 28; Item.value = CalamityGlobalItem.Rarity1BuyPrice; @@ -19,7 +19,9 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.thorns += 0.5f; + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.crawCarapace = true; + player.thorns += 0.25f; } } } diff --git a/Items/Accessories/FungalCarapace.cs b/Items/Accessories/FungalCarapace.cs deleted file mode 100644 index 0094caaf5a..0000000000 --- a/Items/Accessories/FungalCarapace.cs +++ /dev/null @@ -1,27 +0,0 @@ -using CalamityMod.CalPlayer; -using Terraria; -using Terraria.ModLoader; -using Terraria.ID; - -namespace CalamityMod.Items.Accessories -{ - public class FungalCarapace : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Accessories"; - public override void SetDefaults() - { - Item.defense = 6; - Item.width = 20; - Item.height = 24; - Item.value = CalamityGlobalItem.Rarity4BuyPrice; - Item.rare = ItemRarityID.LightRed; - Item.accessory = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.fCarapace = true; - } - } -} diff --git a/Items/Accessories/FungalCarapace.png b/Items/Accessories/FungalCarapace.png deleted file mode 100644 index 6d4633b776..0000000000 Binary files a/Items/Accessories/FungalCarapace.png and /dev/null differ diff --git a/Items/Accessories/GiantShell.cs b/Items/Accessories/GiantShell.cs index 7b56586c36..3d6c009bac 100644 --- a/Items/Accessories/GiantShell.cs +++ b/Items/Accessories/GiantShell.cs @@ -21,7 +21,6 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.moveSpeed -= 0.15f; CalamityPlayer modPlayer = player.Calamity(); modPlayer.gShell = true; } diff --git a/Items/Accessories/GiantTortoiseShell.cs b/Items/Accessories/GiantTortoiseShell.cs index a962d5a46d..b058933739 100644 --- a/Items/Accessories/GiantTortoiseShell.cs +++ b/Items/Accessories/GiantTortoiseShell.cs @@ -2,6 +2,8 @@ using Terraria; using Terraria.ModLoader; using Terraria.ID; +using CalamityMod.Items.Materials; +using CalamityMod.CalPlayer; namespace CalamityMod.Items.Accessories { @@ -10,7 +12,7 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public override void SetDefaults() { - Item.defense = 14; + Item.defense = 15; Item.width = 20; Item.height = 24; Item.value = CalamityGlobalItem.Rarity4BuyPrice; @@ -20,9 +22,16 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.moveSpeed -= 0.1f; - player.thorns += 0.25f; - player.buffImmune[ModContent.BuffType()] = true; + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.tortShell = true; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(ItemID.TurtleShell). + AddTile(TileID.Anvils). + Register(); } } } diff --git a/Items/Accessories/GrandGelatin.cs b/Items/Accessories/GrandGelatin.cs index 5c9271d321..2668c59e0d 100644 --- a/Items/Accessories/GrandGelatin.cs +++ b/Items/Accessories/GrandGelatin.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -19,21 +20,16 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.GrandGelatin = true; player.moveSpeed += 0.1f; player.jumpSpeedBoost += 0.5f; - player.statLifeMax2 += 20; - player.statManaMax2 += 20; - if (Math.Abs(player.velocity.X) < 0.05f && Math.Abs(player.velocity.Y) < 0.05f && player.itemAnimation == 0) - { - player.lifeRegen += 4; - player.manaRegenBonus += 4; - } } public override void AddRecipes() { CreateRecipe(). - AddIngredient(). + AddIngredient(). AddIngredient(). AddIngredient(). AddIngredient(ItemID.SoulofLight, 2). diff --git a/Items/Accessories/LifeJelly.cs b/Items/Accessories/LifeJelly.cs index dea425b790..0c4d0719e6 100644 --- a/Items/Accessories/LifeJelly.cs +++ b/Items/Accessories/LifeJelly.cs @@ -2,6 +2,7 @@ using Terraria; using Terraria.ModLoader; using Terraria.ID; +using CalamityMod.CalPlayer; namespace CalamityMod.Items.Accessories { @@ -19,11 +20,8 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.statLifeMax2 += 20; - if ((double)Math.Abs(player.velocity.X) < 0.05 && (double)Math.Abs(player.velocity.Y) < 0.05 && player.itemAnimation == 0) - { - player.lifeRegen += 4; - } + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.lifejelly = true; } } } diff --git a/Items/Accessories/MarniteRepulsionShield.cs b/Items/Accessories/MarniteRepulsionShield.cs index b269debdfe..d03afe5221 100644 --- a/Items/Accessories/MarniteRepulsionShield.cs +++ b/Items/Accessories/MarniteRepulsionShield.cs @@ -109,12 +109,14 @@ namespace CalamityMod.Items.Accessories Vector2 dustDirection = (Vector2.UnitX * -1 * Owner.direction).RotatedByRandom(MathHelper.PiOver2 * 0.93f); dustOrigin += dustDirection * 14f; float spikeSpeed = Main.rand.NextFloat(1f, 3f); + Vector2 dustVelocity = dustDirection * spikeSpeed + Owner.velocity; + Vector2 dustOriginOffset = dustDirection * 4f; for (int i = 0; i < 5; i++) { - Dust dust = Dust.NewDustPerfect(dustOrigin, 229, dustDirection * spikeSpeed + Owner.velocity, 120, Scale: Main.rand.NextFloat(0.6f, 1f)); + Dust dust = Dust.NewDustPerfect(dustOrigin, 229, dustVelocity, 120, Scale: Main.rand.NextFloat(0.6f, 1f)); dust.noGravity = true; - dustOrigin += dustDirection * 4f; + dustOrigin += dustOriginOffset; } } } diff --git a/Items/Accessories/RoverDrive.cs b/Items/Accessories/RoverDrive.cs index 8dfa6e76d4..bcb757cc18 100644 --- a/Items/Accessories/RoverDrive.cs +++ b/Items/Accessories/RoverDrive.cs @@ -49,7 +49,7 @@ namespace CalamityMod.Items.Accessories float scale = 0.15f + 0.03f * (0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.5f + i * 0.2f)); - if (playerFound == false) + if (!playerFound) { float shieldStrentgh = forcedVisibility ? 1f : (float)Math.Pow(Main.LocalPlayer.GetModPlayer().ProtectionMatrixDurability / (float)ProtectionMatrixDurabilityMax, 0.5f); float noiseScale = MathHelper.Lerp(0.4f, 0.8f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.3f) * 0.5f + 0.5f); diff --git a/Items/Accessories/TheAbsorber.cs b/Items/Accessories/TheAbsorber.cs index 6fdd27deab..dc8af18d29 100644 --- a/Items/Accessories/TheAbsorber.cs +++ b/Items/Accessories/TheAbsorber.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public override void SetDefaults() { - Item.defense = 15; + Item.defense = 16; Item.width = 20; Item.height = 24; Item.value = CalamityGlobalItem.Rarity9BuyPrice; @@ -24,29 +24,14 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - // Removed Giant Shell speed boost from The Absorber - // modPlayer.gShell = true; - modPlayer.fCarapace = true; modPlayer.absorber = true; - player.statManaMax2 += 20; - player.buffImmune[ModContent.BuffType()] = true; } public override void AddRecipes() { CreateRecipe(). AddIngredient(). - AddIngredient(). - AddIngredient(). - AddIngredient(). - AddIngredient(5). - AddTile(TileID.LunarCraftingStation). - Register(); - - CreateRecipe(). - AddIngredient(). - AddIngredient(). - AddIngredient(). + AddIngredient(). AddIngredient(). AddIngredient(5). AddTile(TileID.LunarCraftingStation). diff --git a/Items/Accessories/TheSponge.cs b/Items/Accessories/TheSponge.cs index 3fc5761971..f496f18b5e 100644 --- a/Items/Accessories/TheSponge.cs +++ b/Items/Accessories/TheSponge.cs @@ -41,8 +41,6 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); // Removed Giant Shell speed boost from Sponge // modPlayer.gShell = true; - modPlayer.fCarapace = true; - modPlayer.absorber = true; modPlayer.sponge = true; player.statManaMax2 += 30; player.buffImmune[ModContent.BuffType()] = true; @@ -100,7 +98,7 @@ namespace CalamityMod.Items.Accessories public override void AddRecipes() { CreateRecipe(). - AddIngredient(). + AddIngredient(). AddIngredient(10). AddIngredient(20). AddIngredient(5). diff --git a/Items/Armor/LunicCorps/LunicCorpsHelmet.cs b/Items/Armor/LunicCorps/LunicCorpsHelmet.cs index f110b562b1..a48f245e2f 100644 --- a/Items/Armor/LunicCorps/LunicCorpsHelmet.cs +++ b/Items/Armor/LunicCorps/LunicCorpsHelmet.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Items.Armor.LunicCorps float scale = 0.11f + 0.022f * (0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.5f + i * 0.2f)); - if (playerFound == false) + if (!playerFound) { float shieldStrentgh = (float)Math.Pow(Main.LocalPlayer.GetModPlayer().masterChefShieldDurability / (float)MasterChefShieldDurabilityMax, 0.5f); float noiseScale = MathHelper.Lerp(0.4f, 0.8f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.3f) * 0.5f + 0.5f); diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 8b86e9e46a..a7e0fd96bc 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -36,6 +36,7 @@ using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.IO; using Terraria.Utilities; +using CalamityMod.Projectiles.Typless; namespace CalamityMod.Items { diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index a736cbca9a..4137134be1 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using CalamityMod.Balancing; +using CalamityMod.Items.Accessories; using CalamityMod.Items.Placeables.Ores; using Microsoft.Xna.Framework; using Terraria; @@ -1371,6 +1372,15 @@ namespace CalamityMod.Items shimmerTransmute[ItemID.LunarOre] = ModContent.ItemType(); shimmerTransmute[ItemID.ChlorophyteOre] = ModContent.ItemType(); shimmerTransmute[ItemID.CobaltOre] = ModContent.ItemType(); + + //Fuck vanilla's stupid Giant Shelly, Crawdad, and Salamander exclusivity + shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); + shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); + + //Jelly swap'n + shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); + shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); + shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); } #endregion } diff --git a/Items/Materials/AshesofAnnihilation.cs b/Items/Materials/AshesofAnnihilation.cs index 9ef182d567..7f78bed34a 100644 --- a/Items/Materials/AshesofAnnihilation.cs +++ b/Items/Materials/AshesofAnnihilation.cs @@ -36,11 +36,14 @@ namespace CalamityMod.Items.Materials float outwardness = pulse * baseScale * 8f; Color drawColor = Color.BlueViolet * (float)Math.Sqrt(1f - pulse) * 0.7f; drawColor.A = 0; + float scale = baseScale * MathHelper.Lerp(1f, 1.45f, pulse); + Vector2 drawPositionOffset = Vector2.UnitY * 2f; + float velocity = Item.velocity.X * 0.2f; + Vector2 origin = frame.Size() * 0.5f; for (int i = 0; i < 4; i++) { - float scale = baseScale * MathHelper.Lerp(1f, 1.45f, pulse); - Vector2 drawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 4f).ToRotationVector2() * outwardness - Vector2.UnitY * 2f; - spriteBatch.Draw(TextureAssets.Item[Item.type].Value, drawPosition, frame, drawColor, Item.velocity.X * 0.2f, frame.Size() * 0.5f, scale, SpriteEffects.None, 0f); + Vector2 drawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 4f).ToRotationVector2() * outwardness - drawPositionOffset; + spriteBatch.Draw(TextureAssets.Item[Item.type].Value, drawPosition, frame, drawColor, velocity, origin, scale, SpriteEffects.None, 0f); } } diff --git a/Items/Materials/ExoPrism.cs b/Items/Materials/ExoPrism.cs index 016b682b82..d3dc3348ef 100644 --- a/Items/Materials/ExoPrism.cs +++ b/Items/Materials/ExoPrism.cs @@ -31,11 +31,13 @@ namespace CalamityMod.Items.Materials float outwardnessFactor = MathHelper.Lerp(0.9f, 1.3f, pulse); Color drawColor = Color.MintCream * (1f - pulse) * 0.27f; drawColor.A = 0; + float scale = baseScale * outwardnessFactor; + float velocity = Item.velocity.X * 0.2f; + Vector2 origin = frame.Size() * 0.5f; for (int i = 0; i < 4; i++) { - float scale = baseScale * outwardnessFactor; Vector2 drawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 4f; - spriteBatch.Draw(TextureAssets.Item[Item.type].Value, drawPosition, frame, drawColor, Item.velocity.X * 0.2f, frame.Size() * 0.5f, scale, SpriteEffects.None, 0f); + spriteBatch.Draw(TextureAssets.Item[Item.type].Value, drawPosition, frame, drawColor, velocity, origin, scale, SpriteEffects.None, 0f); } } diff --git a/Items/Materials/MiracleMatter.cs b/Items/Materials/MiracleMatter.cs index 55c58e03b7..0e77633698 100644 --- a/Items/Materials/MiracleMatter.cs +++ b/Items/Materials/MiracleMatter.cs @@ -43,9 +43,10 @@ namespace CalamityMod.Items.Materials Color drawColor = Color.Lerp(new Color(255, 218, 99), new Color(249, 134, 44), pulse); drawColor *= MathHelper.Lerp(0.35f, 0.67f, CalamityUtils.Convert01To010(pulse)); drawColor.A = 25; + float drawPositionOffset = outwardnessFactor * baseScale * 8f; for (int i = 0; i < 8; i++) { - Vector2 drawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 8f).ToRotationVector2() * outwardnessFactor * baseScale * 8f; + Vector2 drawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 8f).ToRotationVector2() * drawPositionOffset; spriteBatch.Draw(TextureAssets.Item[Item.type].Value, drawPosition, frame, drawColor, 0f, Vector2.Zero, baseScale, SpriteEffects.None, 0f); } } diff --git a/Items/Materials/PlasmaDriveCore.cs b/Items/Materials/PlasmaDriveCore.cs index ba255eecfa..aded54296f 100644 --- a/Items/Materials/PlasmaDriveCore.cs +++ b/Items/Materials/PlasmaDriveCore.cs @@ -37,10 +37,11 @@ namespace CalamityMod.Items.Materials GameShaders.Misc["CalamityMod:BasicTint"].Apply(); float outlineWidth = MathHelper.Lerp(2, 3, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2f) * 0.5f + 0.5f); + float positionOffset = outlineWidth * scale; for (float i = 0; i < 1; i += 0.25f) { - spriteBatch.Draw(tex, position + (i * MathHelper.TwoPi).ToRotationVector2() * outlineWidth * scale, frame, outlineColor, 0f, origin, scale, 0f, 0f); + spriteBatch.Draw(tex, position + (i * MathHelper.TwoPi).ToRotationVector2() * positionOffset, frame, outlineColor, 0f, origin, scale, 0f, 0f); } spriteBatch.End(); diff --git a/Items/Potions/TeslaPotion.cs b/Items/Potions/TeslaPotion.cs index 3f7c274dab..045783c6e9 100644 --- a/Items/Potions/TeslaPotion.cs +++ b/Items/Potions/TeslaPotion.cs @@ -11,10 +11,7 @@ namespace CalamityMod.Items.Potions public class TeslaPotion : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Potions"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 20; - } + public override void SetStaticDefaults() => Item.ResearchUnlockCount = 20; public override void SetDefaults() { diff --git a/Items/Weapons/Melee/Hellkite.cs b/Items/Weapons/Melee/Hellkite.cs index 7f03619fdf..51accfa0b6 100644 --- a/Items/Weapons/Melee/Hellkite.cs +++ b/Items/Weapons/Melee/Hellkite.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Melee } // NOTE: Modded item variants don't seem to be supported as of now, so this is probably temporary (also there is no way around modifiers screwing rarity/value in some way) - public override void ModifyWeaponDamage(Player player, ref StatModifier damage) => damage += (Main.zenithWorld ? (1369f / 180f - 1f) : 0f); + public override void ModifyWeaponDamage(Player player, ref StatModifier damage) => damage += (Main.zenithWorld ? (1669f / 180f - 1f) : 0f); public override void ModifyWeaponKnockback(Player player, ref StatModifier knockback) => knockback += (Main.zenithWorld ? 1.5f : 0f); public override float UseSpeedMultiplier(Player player) => Main.zenithWorld ? 2.5f : 1f; public override void ModifyItemScale(Player player, ref float scale) => scale *= (Main.zenithWorld ? 2.5f : 1f); diff --git a/Localization/en-US/Mods.CalamityMod.Buffs.hjson b/Localization/en-US/Mods.CalamityMod.Buffs.hjson index 765c1974c6..cdb65f784d 100644 --- a/Localization/en-US/Mods.CalamityMod.Buffs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Buffs.hjson @@ -1470,4 +1470,28 @@ WitherBlossomsBuff: { WulfrumDroidBuff: { DisplayName: Wulfrum Droid Description: The wulfrum droid will protect you +} + +PinkJellyRegen: { + DisplayName: Pink Jelly Regen + Description: The power of goo refreshes you, life regen increased by 4 +} + +GreenJellyRegen: { + DisplayName: Green Jelly Regen + Description: The regenerative goo empowers you, life regen increased by 6 +} + +AbsorberRegen: { + DisplayName: Regeneraga + Description: + ''' + You are blessed by the culmimation of nature's powers + Life regen increased by 7, damage increased by 10%, damage reduction increased by 7% + ''' +} + +AbsorberAffliction: { + DisplayName: Absorber Affliction + Description: Damn nature, you scary! } \ No newline at end of file diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 9d3d33084e..0e25763bb4 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -418,7 +418,20 @@ CounterScarf: { CrawCarapace: { DisplayName: Craw Carapace - Tooltip: Enemies take damage when they touch you + Tooltip: + ''' + 5% increased damage + Enemies that hit you take damage and are inflicted with Armor Crunch + ''' +} + +Baroclaw: { + DisplayName: Baroclaw + Tooltip: + ''' + 8% increased damage + Enemies that hit you take high damage and are inflicted with Armor Crunch for a long time + ''' } CrimsonFlask: { @@ -755,11 +768,6 @@ FrostFlare: { ''' } -FungalCarapace: { - DisplayName: Fungal Carapace - Tooltip: You emit a cloud of mushroom spores when you are hit -} - FungalClump: { DisplayName: Fungal Clump Tooltip: @@ -799,8 +807,8 @@ GiantShell: { DisplayName: Giant Shell Tooltip: ''' - 15% reduced movement speed - Taking a hit will make you move very fast for a short time + 10% reduced dash velocity + Taking a hit will remove the dash penalty and reduce defense for 5 seconds ''' } @@ -808,9 +816,9 @@ GiantTortoiseShell: { DisplayName: Giant Tortoise Shell Tooltip: ''' - 10% decreased movement speed - Enemies take damage when they hit you - Grants immunity to Armor Crunch + 5% increased damage reduction + 15% reduced dash velocity + Taking a hit will remove the dash penalty and reduce defense and damage reduction for 5 seconds ''' } @@ -851,9 +859,10 @@ GrandGelatin: { DisplayName: Grand Gelatin Tooltip: ''' - 10% increased movement and jump speed - +20 max life and mana - Standing still boosts life and mana regen + 10% increased movement speed and jump speed + Using a healing potion will spawn a cleansing aura + Walking into the aura removes all debuffs and defense damage one time + The aura provides increased life regen for all players inside for 8 seconds ''' } @@ -992,8 +1001,8 @@ LifeJelly: { DisplayName: Life Jelly Tooltip: ''' - +20 max life - Standing still boosts life regen + Using a healing potion will spawn a lingering aura + The aura provides increased life regen for all players inside for 5 seconds ''' } @@ -1026,12 +1035,12 @@ LuxorsGift: { ''' } -ManaJelly: { - DisplayName: Mana Jelly +CleansingJelly: { + DisplayName: Cleansing Jelly Tooltip: ''' - +20 max mana - Standing still boosts mana regen + Using a healing potion will spawn a cleansing aura + Walking into the aura removes all debuffs and defense damage one time ''' } @@ -1691,14 +1700,12 @@ TheAbsorber: { DisplayName: The Absorber Tooltip: ''' - 5% increased movement and jump speed - +20 max life and mana - Standing still boosts life and mana regen - Enemies take damage when they touch you - You emit a cloud of mushroom spores when you are hit - 7% increased damage reduction + 10% increased movement and jump speed + Enemies take immense damage when they touch you and are afflicted with a debuff that reduces damage reduction significantly + Using a healing potion will spawn a cleansing aura + Walking into the aura removes all debuffs and defense damage one time + The aura provides greatly increased life regen, damage, and damage reduction for all players inside for 15 seconds 5% of the damage from enemy attacks is absorbed and converted into healing - Grants immunity to Armor Crunch ''' } @@ -1780,17 +1787,7 @@ TheFirstShadowflame: { TheSponge: { DisplayName: The Sponge - Tooltip: - ''' - 10% increased damage reduction - +30 max life and mana - 5% increased movement and jump speed - Standing still boosts life and mana regen - Enemies take damage when they touch you - You emit a cloud of mushroom spores when you are hit - 6.25% of the damage from enemy attacks is absorbed and converted into healing - Grants immunity to Armor Crunch - ''' + Tooltip: OUT OF ORDER } TheTransformer: { diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Healing.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Healing.hjson index d563644df8..ff6d6004fa 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Healing.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Healing.hjson @@ -16,4 +16,8 @@ ReaverHealOrb.DisplayName: Reaver Heal Orb RoyalHeal.DisplayName: Heal ShinobiHealOrb.DisplayName: Blue Healing Orb SilvaOrb.DisplayName: Silva Orb -TransfusionTrail.DisplayName: Heal \ No newline at end of file +TransfusionTrail.DisplayName: Heal +AbsorberAura.DisplayName: Absorber Aura +BlueJellyAura.DisplayName: Blue Jelly Aura +GreenJellyAura.DisplayName: Green Jelly Aura +PinkJellyAura.DisplayName: Pink Jelly Aura \ No newline at end of file diff --git a/NPCs/Abyss/MirageJelly.cs b/NPCs/Abyss/MirageJelly.cs index dd2b8e65d5..81425f34d7 100644 --- a/NPCs/Abyss/MirageJelly.cs +++ b/NPCs/Abyss/MirageJelly.cs @@ -223,7 +223,7 @@ namespace CalamityMod.NPCs.Abyss postClone.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 2, 5, 7, 10, 14)); npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 7, 5)); - npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 7, 5)); + npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 7, 5)); npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 7, 5)); npcLoot.Add(ItemID.JellyfishNecklace, 10); } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index e6bd96f69f..ac25f39b93 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -217,6 +217,7 @@ namespace CalamityMod.NPCs public int pearlAura = 0; public int bBlood = 0; public int marked = 0; + public int absorberAffliction = 0; public int irradiated = 0; public int bFlames = 0; public int hFlames = 0; @@ -424,6 +425,7 @@ namespace CalamityMod.NPCs myClone.pearlAura = pearlAura; myClone.bBlood = bBlood; myClone.marked = marked; + myClone.absorberAffliction = absorberAffliction; myClone.irradiated = irradiated; myClone.bFlames = bFlames; myClone.hFlames = hFlames; @@ -2670,6 +2672,8 @@ namespace CalamityMod.NPCs float calcDR = DR; if (marked > 0) calcDR *= 0.5f; + if (absorberAffliction > 0) + calcDR *= 0.7f; if (npc.betsysCurse) calcDR *= 0.66f; if (npc.Calamity().kamiFlu > 0) @@ -4196,6 +4200,8 @@ namespace CalamityMod.NPCs vulnerabilityHex--; if (marked > 0) marked--; + if (absorberAffliction > 0) + absorberAffliction--; if (irradiated > 0) irradiated--; if (bFlames > 0) @@ -4936,6 +4942,7 @@ namespace CalamityMod.NPCs #region Edit Spawn Pool internal static readonly FieldInfo MaxSpawnsField = typeof(NPC).GetField("maxSpawns", BindingFlags.NonPublic | BindingFlags.Static); + public static void AttemptToSpawnLabCritters(Player player) { if (Main.netMode == NetmodeID.MultiplayerClient) @@ -4949,19 +4956,26 @@ namespace CalamityMod.NPCs if (player.nearbyActiveNPCs >= maxSpawnCount) return; + float playerCenterX = player.Center.X / 16f; + float playerCenterY = player.Center.Y / 16f; + Vector2 sunkenSeaLabCenter = CalamityWorld.SunkenSeaLabCenter / 16f; + Vector2 planetoidLabCenter = CalamityWorld.PlanetoidLabCenter / 16f; + Vector2 jungleLabCenter = CalamityWorld.JungleLabCenter / 16f; + Vector2 hellLabCenter = CalamityWorld.HellLabCenter / 16f; + Vector2 iceLabCenter = CalamityWorld.IceLabCenter / 16f; for (int i = 0; i < 8; i++) { - int checkPositionX = (int)(player.Center.X / 16 + Main.rand.Next(30, 54) * Main.rand.NextBool(2).ToDirectionInt()); - int checkPositionY = (int)(player.Center.Y / 16 + Main.rand.Next(24, 45) * Main.rand.NextBool(2).ToDirectionInt()); + int checkPositionX = (int)(playerCenterX + Main.rand.Next(30, 54) * Main.rand.NextBool(2).ToDirectionInt()); + int checkPositionY = (int)(playerCenterY + Main.rand.Next(24, 45) * Main.rand.NextBool(2).ToDirectionInt()); Vector2 checkPosition = new Vector2(checkPositionX, checkPositionY); Tile aboveSpawnTile = CalamityUtils.ParanoidTileRetrieval(checkPositionX, checkPositionY - 1); - bool nearLab = CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.SunkenSeaLabCenter / 16f) < 180f; - nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.PlanetoidLabCenter / 16f) < 180f; - nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.JungleLabCenter / 16f) < 180f; - nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.HellLabCenter / 16f) < 180f; - nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.IceLabCenter / 16f) < 180f; - bool nearPlagueLab = CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.JungleLabCenter / 16f) < 180f; + bool nearLab = CalamityUtils.ManhattanDistance(checkPosition, sunkenSeaLabCenter) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, planetoidLabCenter) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, jungleLabCenter) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, hellLabCenter) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, iceLabCenter) < 180f; + bool nearPlagueLab = CalamityUtils.ManhattanDistance(checkPosition, jungleLabCenter) < 180f; bool isLabWall = aboveSpawnTile.WallType == WallType() || aboveSpawnTile.WallType == WallType() || aboveSpawnTile.WallType == WallType(); isLabWall |= aboveSpawnTile.WallType == WallType() || aboveSpawnTile.WallType == WallType() || aboveSpawnTile.WallType == WallType(); @@ -5520,6 +5534,9 @@ namespace CalamityMod.NPCs if (marked > 0 || sulphurPoison > 0 || vaporfied > 0) drawColor = Color.Fuchsia; + if (absorberAffliction > 0) + drawColor = Color.DarkSeaGreen; + if (pearlAura > 0) drawColor = Color.White; @@ -5620,6 +5637,8 @@ namespace CalamityMod.NPCs buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/KamiFlu").Value); if (marked > 0) buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/MarkedforDeath").Value); + if (absorberAffliction > 0) + buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/AbsorberAffliction").Value); if (pearlAura > 0) buffTextureList.Add(Request("CalamityMod/Buffs/StatDebuffs/PearlAura").Value); if (relicOfResilienceWeakness > 0) @@ -5784,6 +5803,8 @@ namespace CalamityMod.NPCs alpha15.G = (byte)(alpha15.G * num212); alpha15.B = (byte)(alpha15.B * num212); alpha15.A = (byte)(alpha15.A * num212); + float xOffset = screenPos.X + npc.width / 2 - TextureAssets.Npc[npc.type].Value.Width * npc.scale / 2f + vector11.X * npc.scale; + float yOffset = screenPos.Y + npc.height - TextureAssets.Npc[npc.type].Value.Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + vector11.Y * npc.scale + num66 + npc.gfxOffY; for (int num213 = 0; num213 < 4; num213++) { Vector2 position9 = npc.position; @@ -5791,28 +5812,20 @@ namespace CalamityMod.NPCs float num215 = Math.Abs(npc.Center.Y - Main.LocalPlayer.Center.Y); if (num213 == 0 || num213 == 2) - { position9.X = Main.LocalPlayer.Center.X + num214; - } else - { position9.X = Main.LocalPlayer.Center.X - num214; - } position9.X -= npc.width / 2; if (num213 == 0 || num213 == 1) - { position9.Y = Main.LocalPlayer.Center.Y + num215; - } else - { position9.Y = Main.LocalPlayer.Center.Y - num215; - } position9.Y -= npc.height / 2; - Main.spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position9.X - screenPos.X + npc.width / 2 - TextureAssets.Npc[npc.type].Value.Width * npc.scale / 2f + vector11.X * npc.scale, position9.Y - screenPos.Y + npc.height - TextureAssets.Npc[npc.type].Value.Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + vector11.Y * npc.scale + num66 + npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(npc.frame), alpha15, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Main.spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position9.X - xOffset, position9.Y - yOffset), new Microsoft.Xna.Framework.Rectangle?(npc.frame), alpha15, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } else @@ -6070,16 +6083,18 @@ namespace CalamityMod.NPCs if ((newAI[3] >= 900f && destroyerLifeRatio < 0.5f) || (newAI[1] < 600f && newAI[1] > 60f)) { + Color drawColor2 = new Color(50, 50, 255, 0) * (1f - npc.alpha / 255f); for (int i = 0; i < 3; i++) { spriteBatch.Draw(TextureAssets.Dest[npc.type - NPCID.TheDestroyer].Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, - new Color(50, 50, 255, 0) * (1f - npc.alpha / 255f), npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); } } else { + Color drawColor2 = new Color(255, 255, 255, 0) * (1f - npc.alpha / 255f); spriteBatch.Draw(TextureAssets.Dest[npc.type - NPCID.TheDestroyer].Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, - new Color(255, 255, 255, 0) * (1f - npc.alpha / 255f), npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); } } } diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 5b07cc7353..649c3dea6f 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -137,12 +137,6 @@ namespace CalamityMod.NPCs npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 7, 4)); break; - // Anomura Fungus - // Fungal Carapace @ 14.29% Normal, 25% Expert+ - case NPCID.AnomuraFungus: - npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 7, 4)); - break; - // Tim // Plasma Rod @ 33.33% Normal, 50% Expert+ case NPCID.Tim: @@ -255,9 +249,9 @@ namespace CalamityMod.NPCs break; // Blue Jellyfish - // Mana Jelly @ 14.29% Normal, 25% Expert+ + // Cleansing Jelly @ 14.29% Normal, 25% Expert+ case NPCID.BlueJellyfish: - npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 7, 4)); + npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 7, 4)); break; // Green Jellyfish @@ -359,12 +353,6 @@ namespace CalamityMod.NPCs npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 3, 2)); break; - // Giant Tortoise - // Giant Tortoise Shell @ 14.29% Normal, 25% Expert+ - case NPCID.GiantTortoise: - npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 7, 4)); - break; - // Angry Trapper // Trapper Bulb @ 50% Normal, 100% Expert+ case NPCID.AngryTrapper: @@ -1786,6 +1774,7 @@ namespace CalamityMod.NPCs // First kill: Notify of Abyss chests being unlocked. if (!NPC.downedBoss3) { + World.Abyss.AbleToUnlockChests = true; World.Abyss.UnlockAllAbyssChests(); string keysk = "Mods.CalamityMod.Status.Progression.SkeletronAbyssChestNotification"; diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index 5d61ee310f..1682b7eb5a 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -1425,7 +1425,9 @@ namespace CalamityMod.NPCs { shop.AddWithCustomValue(ItemType(), Item.buyPrice(silver: 25), potionSells) .Add(ItemID.MilkCarton) - .AddWithCustomValue(ItemID.Marrow, Item.buyPrice(gold: 25), Condition.Hardmode); + .AddWithCustomValue(ItemID.Marrow, Item.buyPrice(gold: 25), Condition.Hardmode) + .AddWithCustomValue(ItemType(), Item.buyPrice(gold: 12)) + .AddWithCustomValue(ItemType(), Item.buyPrice(gold: 12)); } if (type == NPCID.Golfer) diff --git a/Particles/ConstellationRing.cs b/Particles/ConstellationRing.cs index b5277b1239..49798eef21 100644 --- a/Particles/ConstellationRing.cs +++ b/Particles/ConstellationRing.cs @@ -48,19 +48,27 @@ namespace CalamityMod.Particles spriteBatch.Draw(ringTexture, Position - Main.screenPosition, null, Color * Opacity, Rotation, ringTexture.Size() / 2f, Squish * Scale, SpriteEffects.None, 0); + float time = Main.GlobalTimeWrappedHourly * SpinSpeed; + float starPosOffsetX = Squish.X * Scale * ringTexture.Width * 0.45f; + float starPosOffsetY = Squish.Y * Scale * ringTexture.Height * 0.45f; + float properBloomSize = (float)starTexture.Height / (float)bloomTexture.Height; + Color starColor = Color * Opacity * 0.5f; + Color starColor2 = Color.White * Opacity; + Vector2 bloomOrigin = bloomTexture.Size() / 2f; + float bloomScale = Scale * properBloomSize; + Vector2 starOrigin = starTexture.Size() / 2f; + float starScale = Scale * 0.75f; for (int i = 0; i < StarAmount; i++) { + float starHeight = (float)Math.Sin(Offset + time + i * MathHelper.TwoPi / (float)StarAmount); + float starWidth = (float)Math.Cos(Offset + time + i * MathHelper.TwoPi / (float)StarAmount); - float starHeight = (float)Math.Sin(Offset + Main.GlobalTimeWrappedHourly * SpinSpeed + i * MathHelper.TwoPi / (float)StarAmount); - float starWidth = (float)Math.Cos(Offset + Main.GlobalTimeWrappedHourly * SpinSpeed + i * MathHelper.TwoPi / (float)StarAmount); + Vector2 starPos = Position + Rotation.ToRotationVector2() * starWidth * starPosOffsetX + (Rotation + MathHelper.PiOver2).ToRotationVector2() * starHeight * starPosOffsetY; - Vector2 starPos = Position + Rotation.ToRotationVector2() * starWidth * (Squish.X * Scale * ringTexture.Width * 0.45f) + (Rotation + MathHelper.PiOver2).ToRotationVector2() * starHeight * (Squish.Y * Scale * ringTexture.Height * 0.45f); - - //Ajust the bloom's texture to be the same size as the star's - float properBloomSize = (float)starTexture.Height / (float)bloomTexture.Height; - spriteBatch.Draw(bloomTexture, starPos - Main.screenPosition, null, Color * Opacity * 0.5f, 0, bloomTexture.Size() / 2f, Scale * properBloomSize, SpriteEffects.None, 0); - spriteBatch.Draw(starTexture, starPos - Main.screenPosition, null, Color * Opacity * 0.5f, Rotation + MathHelper.PiOver4 + MathHelper.PiOver4 * i, starTexture.Size() / 2f, Scale * 0.75f, SpriteEffects.None, 0); - spriteBatch.Draw(starTexture, starPos - Main.screenPosition, null, Color.White * Opacity, Rotation + MathHelper.PiOver4 * i, starTexture.Size() / 2f, Scale, SpriteEffects.None, 0); + // Ajust the bloom's texture to be the same size as the star's. + spriteBatch.Draw(bloomTexture, starPos - Main.screenPosition, null, starColor, 0, bloomOrigin, bloomScale, SpriteEffects.None, 0); + spriteBatch.Draw(starTexture, starPos - Main.screenPosition, null, starColor, Rotation + MathHelper.PiOver4 + MathHelper.PiOver4 * i, starOrigin, starScale, SpriteEffects.None, 0); + spriteBatch.Draw(starTexture, starPos - Main.screenPosition, null, starColor2, Rotation + MathHelper.PiOver4 * i, starOrigin, Scale, SpriteEffects.None, 0); } } diff --git a/Particles/HealingPlus.cs b/Particles/HealingPlus.cs new file mode 100644 index 0000000000..3d812d2f54 --- /dev/null +++ b/Particles/HealingPlus.cs @@ -0,0 +1,57 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using System; +using static Terraria.ModLoader.PlayerDrawLayer; + +namespace CalamityMod.Particles +{ + public class HealingPlus : Particle + { + public override string Texture => "CalamityMod/Particles/HealingPlus"; + public override bool UseAdditiveBlend => true; + public override bool UseCustomDraw => true; + public override bool SetLifetime => true; + + public Player Owner; + public Color StartColor; + public Color EndColor; + public Vector2 OverridePosition; + public float Opacity; + + public HealingPlus(Vector2 position, float scale, Color colorStart, Color colorEnd, int lifetime) + { + Position = position; + Scale = scale; + Velocity.X = 0; + Velocity.Y = Main.rand.NextFloat(-2f, -5f); + Rotation = 0; + StartColor = colorStart; + EndColor = colorEnd; + Color = colorStart; + Lifetime = lifetime; + } + + public override void Update() + { + Color = Color.Lerp(StartColor, EndColor, LifetimeCompletion); + Lighting.AddLight(Position, Color.ToVector3() * 0.2f); + Opacity -= 0.05f; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D tex = ModContent.Request(Texture).Value; + + Vector2 Size = new Vector2 (Scale); + + Vector2 origin = new Vector2(tex.Width, tex.Height); + + Vector2 PositionAdjust = new Vector2(-16, -40); + + spriteBatch.Draw(tex, Position - Main.screenPosition - PositionAdjust, null, Color, Rotation, origin, Size, SpriteEffects.None, 0); + + } + } +} diff --git a/Particles/HealingPlus.png b/Particles/HealingPlus.png new file mode 100644 index 0000000000..f864d8d77c Binary files /dev/null and b/Particles/HealingPlus.png differ diff --git a/Particles/HighResHollowCircleHardEdge.png b/Particles/HighResHollowCircleHardEdge.png new file mode 100644 index 0000000000..709ae95924 Binary files /dev/null and b/Particles/HighResHollowCircleHardEdge.png differ diff --git a/Particles/SnowflakeSparkle.cs b/Particles/SnowflakeSparkle.cs index 951490b546..3a5b130d6c 100644 --- a/Particles/SnowflakeSparkle.cs +++ b/Particles/SnowflakeSparkle.cs @@ -9,13 +9,17 @@ namespace CalamityMod.Particles public class SnowflakeSparkle : Particle { public override string Texture => "CalamityMod/Particles/HalfIceStar"; + public override bool UseAdditiveBlend => true; + public override bool UseCustomDraw => true; + public override bool SetLifetime => true; private float Spin; private float opacity; private Color Bloom; + private Color LightColor => Bloom * opacity; private float BloomScale; private int Spokes; @@ -46,15 +50,18 @@ namespace CalamityMod.Particles { Texture2D spokesTexture = ModContent.Request(Texture).Value; Texture2D bloomTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; - //Ajust the bloom's texture to be the same size as the star's + // Ajust the bloom's texture to be the same size as the star's. float properBloomSize = (float)spokesTexture.Height / (float)bloomTexture.Height; + float halvedOpacity = opacity * 0.5f; - spriteBatch.Draw(bloomTexture, Position - Main.screenPosition, null, Bloom * opacity * 0.5f, 0, bloomTexture.Size()/2f, Scale * BloomScale * properBloomSize, SpriteEffects.None, 0); + spriteBatch.Draw(bloomTexture, Position - Main.screenPosition, null, Bloom * halvedOpacity, 0, bloomTexture.Size() / 2f, Scale * BloomScale * properBloomSize, SpriteEffects.None, 0); + Color spokeColor = Color * halvedOpacity; + Vector2 origin = spokesTexture.Size() / 2f; for (int i = 0; i < Spokes; i++) { - float rotation = Rotation + MathHelper.Lerp(0f, MathHelper.Pi, i/(float)Spokes); - spriteBatch.Draw(spokesTexture, Position - Main.screenPosition, null, Color * opacity * 0.5f, Rotation + rotation, spokesTexture.Size() / 2f, Scale, SpriteEffects.None, 0); + float rotation = Rotation + MathHelper.Lerp(0f, MathHelper.Pi, i / (float)Spokes); + spriteBatch.Draw(spokesTexture, Position - Main.screenPosition, null, spokeColor, Rotation + rotation, origin, Scale, SpriteEffects.None, 0); } } } diff --git a/Particles/StaticPulseRing.cs b/Particles/StaticPulseRing.cs new file mode 100644 index 0000000000..27649de303 --- /dev/null +++ b/Particles/StaticPulseRing.cs @@ -0,0 +1,53 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using static CalamityMod.CalamityUtils; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class StaticPulseRing : Particle + { + public override string Texture => "CalamityMod/Particles/HighResHollowCircleHardEdge"; + public override bool UseAdditiveBlend => true; + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + + private float OriginalScale; + private float FinalScale; + private Vector2 Squish; + private Color BaseColor; + + //Basically DirectionalPulseRing, but doesn't move or change opacity + public StaticPulseRing(Vector2 position, Vector2 velocity, Color color, Vector2 squish, float rotation, float originalScale, float finalScale, int lifeTime) + { + Position = position; + Velocity = velocity; + BaseColor = color; + OriginalScale = originalScale; + FinalScale = finalScale; + Scale = originalScale; + Lifetime = lifeTime; + Squish = squish; + Rotation = rotation; + } + + public override void Update() + { + float pulseProgress = PiecewiseAnimation(LifetimeCompletion, new CurveSegment[] { new CurveSegment(EasingType.PolyOut, 0f, 0f, 1f, 4) }); + Scale = MathHelper.Lerp(OriginalScale, FinalScale, pulseProgress); + + Color = BaseColor; + Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f); + Velocity *= 0; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D tex = ModContent.Request(Texture).Value; + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color, Rotation, tex.Size() / 2f, Scale * Squish, SpriteEffects.None, 0); + } + + } +} diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 310e53046e..c0505245b5 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -208,7 +208,7 @@ namespace CalamityMod.Projectiles // Reduce secondary yoyo damage if the player has Yoyo Glove // Brief behavior documentation of yoyo AI: ai[0, 1] are the x, y co-ords and localAI[0] is the airtime in frames // All secondary yoyos are spawned with ai[0] of 1 which tells then tell its AI to do secondary yoyo AI - if (Main.player[projectile.owner].yoyoGlove && projectile.aiStyle == 99) + if (Main.player[projectile.owner].yoyoGlove && projectile.aiStyle == ProjAIStyleID.Yoyo) { // Store damage on first frame if (projectile.ai[2] == 0f) @@ -2772,6 +2772,8 @@ namespace CalamityMod.Projectiles Color color9 = new(Main.DiscoR, Main.DiscoG, Main.DiscoB, projectile.alpha); Color alpha15 = projectile.GetAlpha(color9); + float offsetX = Main.screenPosition.X + (projectile.width / 2) - texture.Width * projectile.scale / 2f + vector11.X * projectile.scale; + float offsetY = Main.screenPosition.Y + projectile.height - texture.Height * projectile.scale / Main.projFrames[projectile.type] + 4f + vector11.Y * projectile.scale + projectile.gfxOffY; for (int num213 = 0; num213 < 4; num213++) { Vector2 position9 = projectile.position; @@ -2795,7 +2797,7 @@ namespace CalamityMod.Projectiles position9.Y -= projectile.height / 2; Main.spriteBatch.Draw(texture, - new Vector2(position9.X - Main.screenPosition.X + (projectile.width / 2) - texture.Width * projectile.scale / 2f + vector11.X * projectile.scale, position9.Y - Main.screenPosition.Y + projectile.height - texture.Height * projectile.scale / Main.projFrames[projectile.type] + 4f + vector11.Y * projectile.scale + projectile.gfxOffY), + new Vector2(position9.X - offsetX, position9.Y - offsetY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y, texture.Width, frames)), alpha15, projectile.rotation, vector11, projectile.scale, spriteEffects, 0); } } diff --git a/Projectiles/Healing/AbsorberAura.cs b/Projectiles/Healing/AbsorberAura.cs new file mode 100644 index 0000000000..960679fef4 --- /dev/null +++ b/Projectiles/Healing/AbsorberAura.cs @@ -0,0 +1,151 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatBuffs; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using System.Collections.Generic; + +namespace CalamityMod.Projectiles.Typless +{ + public class AbsorberAura : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Healing"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + private static float Radius = 160f; + public int ShinkGrow = 0; + public int Framecounter = 0; + public int CleanseOnce = 1; + public int PulseOnce = 1; + public int PulseOnce2 = 1; + public int PulseOnce3 = 1; + public static readonly SoundStyle Spawnsound = new("CalamityMod/Sounds/Custom/OrbHeal3") { Volume = 0.5f }; + public List cleanseList = new List(new bool[Main.maxPlayers]); + public ref int CleansingEffect => ref Main.player[Projectile.owner].Calamity().CleansingEffect; + + public override void SetDefaults() + { + //These shouldn't matter because its circular + Projectile.width = 336; + Projectile.height = 336; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Default; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 2710; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + + public override void AI() + { + Framecounter++; + + for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + { + Player player = Main.player[playerIndex]; + float targetDist = Vector2.Distance(player.Center, Projectile.Center); + + //Remove the players debuffs and defense damage, but only once per aura + if (targetDist < 232f) + { + player.AddBuff(ModContent.BuffType(), 900); + if (cleanseList[playerIndex] == false) + { + cleanseList[playerIndex] = true; + CleansingEffect = 1; + for (int l = 0; l < Player.MaxBuffs; l++) + { + int hasBuff = player.buffType[l]; + if (player.buffTime[l] > 2 && CalamityLists.debuffList.Contains(hasBuff)) + { + player.buffTime[l] *= 0; + } + } + for (int i = 0; i < 55; i++) + { + int dust = Dust.NewDust(player.Center, player.width + 4, player.height + 4, 63, player.velocity.X * 0.2f, player.velocity.Y * 0.2f, 100, Color.DarkSeaGreen, 5.5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.5f; + Main.dust[dust].velocity.Y -= 0.5f; + } + SoundEngine.PlaySound(Spawnsound with { Pitch = -0.9f }, Projectile.Center); + } + } + } + + if (ShinkGrow == 0) + { + if (PulseOnce == 1) + { + Particle pulse = new StaticPulseRing(Projectile.Center, Vector2.Zero, Color.DarkSeaGreen, new Vector2(1f, 1f), 0f, 0f, 0.2925f, 10); + GeneralParticleHandler.SpawnParticle(pulse); + PulseOnce = 0; + } + + if (Framecounter == 10) + { + ShinkGrow = 1; + } + } + if (ShinkGrow == 1) + { + if (PulseOnce2 == 1) + { + Particle pulse2 = new StaticPulseRing(Projectile.Center, Vector2.Zero, Color.DarkSeaGreen, new Vector2(1f, 1f), 0f, 0.2925f, 0.2925f, 2700); + GeneralParticleHandler.SpawnParticle(pulse2); + PulseOnce2 = 0; + } + + for (int i = 0; i < 3; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2CircularEdge(301.6f, 301.6f), 63, null, 0, Color.DarkSeaGreen); + dust.scale = Main.rand.NextFloat(1.2f, 2.3f); + dust.noGravity = true; + } + + for (int i = 0; i < 1; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(292.5f, 292.5f), 63, null, 0, Color.DarkSeaGreen); + dust.scale = Main.rand.NextFloat(0.3f, 0.9f); + dust.noGravity = true; + } + + if (Framecounter == 2710) + { + ShinkGrow = 2; + } + } + if (ShinkGrow == 2) + { + if (PulseOnce3 == 1) + { + Particle pulse3 = new StaticPulseRing(Projectile.Center, Vector2.Zero, Color.DarkSeaGreen, new Vector2(1f, 1f), 0f, 0.2925f, 0f, 10); + GeneralParticleHandler.SpawnParticle(pulse3); + PulseOnce3 = 0; + } + } + } + + public override bool? CanCutTiles() + { + return false; + } + public override bool? CanHitNPC(NPC target) + { + return false; + } + + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Radius, targetHitbox); + + } +} diff --git a/Projectiles/Healing/BlueJellyAura.cs b/Projectiles/Healing/BlueJellyAura.cs new file mode 100644 index 0000000000..c681b6d31b --- /dev/null +++ b/Projectiles/Healing/BlueJellyAura.cs @@ -0,0 +1,149 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatBuffs; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using System.Collections.Generic; + +namespace CalamityMod.Projectiles.Typless +{ + public class BlueJellyAura : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Healing"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + private static float Radius = 160f; + public int ShinkGrow = 0; + public int Framecounter = 0; + public int CleanseOnce = 1; + public int PulseOnce = 1; + public int PulseOnce2 = 1; + public int PulseOnce3 = 1; + public static readonly SoundStyle Spawnsound = new("CalamityMod/Sounds/Custom/OrbHeal1") { Volume = 0.5f }; + public ref int CleansingEffect => ref Main.player[Projectile.owner].Calamity().CleansingEffect; + public List cleanseList = new List(new bool[Main.maxPlayers]); + + + public override void SetDefaults() + { + //These shouldn't matter because its circular + Projectile.width = 336; + Projectile.height = 336; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Default; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 2710; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + + public override void AI() + { + Framecounter++; + + for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + { + Player player = Main.player[playerIndex]; + float targetDist = Vector2.Distance(player.Center, Projectile.Center); + + //Remove the players debuffs and defense damage, but only once per aura + if (targetDist < 155f && cleanseList[playerIndex] == false) + { + cleanseList[playerIndex] = true; + CleansingEffect = 1; + for (int l = 0; l < Player.MaxBuffs; l++) + { + int hasBuff = player.buffType[l]; + if (player.buffTime[l] > 2 && CalamityLists.debuffList.Contains(hasBuff)) + { + player.buffTime[l] *= 0; + } + } + for (int i = 0; i < 55; i++) + { + int dust = Dust.NewDust(player.Center, player.width + 4, player.height + 4, 187, player.velocity.X * 0.2f, player.velocity.Y * 0.2f, 100, default, 5.5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.2f; + Main.dust[dust].velocity.Y -= 0.5f; + } + + SoundEngine.PlaySound(Spawnsound with { Pitch = -0.9f }, Projectile.Center); + } + } + + if (ShinkGrow == 0) + { + if (PulseOnce == 1) + { + Particle pulse = new StaticPulseRing(Projectile.Center, Vector2.Zero, Color.RoyalBlue, new Vector2(1f, 1f), 0f, 0f, 0.152f, 10); + GeneralParticleHandler.SpawnParticle(pulse); + PulseOnce = 0; + } + + if (Framecounter == 10) + { + ShinkGrow = 1; + } + } + if (ShinkGrow == 1) + { + if (PulseOnce2 == 1) + { + Particle pulse2 = new StaticPulseRing(Projectile.Center, Vector2.Zero, Color.RoyalBlue, new Vector2(1f, 1f), 0f, 0.152f, 0.152f, 2700); + GeneralParticleHandler.SpawnParticle(pulse2); + PulseOnce2 = 0; + } + + for (int i = 0; i < 1; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2CircularEdge(155f, 155f), 187); + dust.scale = Main.rand.NextFloat(2.2f, 3.3f); + dust.noGravity = true; + } + + for (int i = 0; i < 1; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(150f, 150f), 187); + dust.scale = Main.rand.NextFloat(0.8f, 1.3f); + dust.noGravity = true; + } + + if (Framecounter == 2710) + { + ShinkGrow = 2; + } + } + if (ShinkGrow == 2) + { + if (PulseOnce3 == 1) + { + Particle pulse3 = new StaticPulseRing(Projectile.Center, Vector2.Zero, Color.RoyalBlue, new Vector2(1f, 1f), 0f, 0.152f, 0f, 10); + GeneralParticleHandler.SpawnParticle(pulse3); + PulseOnce3 = 0; + } + } + } + + public override bool? CanCutTiles() + { + return false; + } + public override bool? CanHitNPC(NPC target) + { + return false; + } + + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Radius, targetHitbox); + + } +} diff --git a/Projectiles/Healing/GreenJellyAura.cs b/Projectiles/Healing/GreenJellyAura.cs new file mode 100644 index 0000000000..2e8e87b847 --- /dev/null +++ b/Projectiles/Healing/GreenJellyAura.cs @@ -0,0 +1,151 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatBuffs; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using System.Collections.Generic; + +namespace CalamityMod.Projectiles.Typless +{ + public class GreenJellyAura : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Healing"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + private static float Radius = 160f; + public int ShinkGrow = 0; + public int Framecounter = 0; + public int CleanseOnce = 1; + public int PulseOnce = 1; + public int PulseOnce2 = 1; + public int PulseOnce3 = 1; + public static readonly SoundStyle Spawnsound = new("CalamityMod/Sounds/Custom/OrbHeal3") { Volume = 0.5f }; + public List cleanseList = new List(new bool[Main.maxPlayers]); + public ref int CleansingEffect => ref Main.player[Projectile.owner].Calamity().CleansingEffect; + + public override void SetDefaults() + { + //These shouldn't matter because its circular + Projectile.width = 336; + Projectile.height = 336; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Default; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 2710; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + + public override void AI() + { + Framecounter++; + + for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + { + Player player = Main.player[playerIndex]; + float targetDist = Vector2.Distance(player.Center, Projectile.Center); + + //Remove the players debuffs and defense damage, but only once per aura + if (targetDist < 232f) + { + player.AddBuff(ModContent.BuffType(), 480); + if (cleanseList[playerIndex] == false) + { + cleanseList[playerIndex] = true; + CleansingEffect = 1; + for (int l = 0; l < Player.MaxBuffs; l++) + { + int hasBuff = player.buffType[l]; + if (player.buffTime[l] > 2 && CalamityLists.debuffList.Contains(hasBuff)) + { + player.buffTime[l] *= 0; + } + } + for (int i = 0; i < 55; i++) + { + int dust = Dust.NewDust(player.Center, player.width + 4, player.height + 4, 298, player.velocity.X * 0.2f, player.velocity.Y * 0.2f, 100, default, 5.5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 1.5f; + Main.dust[dust].velocity.Y -= 0.5f; + } + SoundEngine.PlaySound(Spawnsound with { Pitch = -0.9f }, Projectile.Center); + } + } + } + + if (ShinkGrow == 0) + { + if (PulseOnce == 1) + { + Particle pulse = new StaticPulseRing(Projectile.Center, Vector2.Zero, Color.Lime, new Vector2(1f, 1f), 0f, 0f, 0.225f, 10); + GeneralParticleHandler.SpawnParticle(pulse); + PulseOnce = 0; + } + + if (Framecounter == 10) + { + ShinkGrow = 1; + } + } + if (ShinkGrow == 1) + { + if (PulseOnce2 == 1) + { + Particle pulse2 = new StaticPulseRing(Projectile.Center, Vector2.Zero, Color.Lime, new Vector2(1f, 1f), 0f, 0.225f, 0.225f, 2700); + GeneralParticleHandler.SpawnParticle(pulse2); + PulseOnce2 = 0; + } + + for (int i = 0; i < 2; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2CircularEdge(232f, 232f), 298); + dust.scale = Main.rand.NextFloat(2.2f, 3.3f); + dust.noGravity = true; + } + + for (int i = 0; i < 1; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(225f, 225f), 298); + dust.scale = Main.rand.NextFloat(0.8f, 1.3f); + dust.noGravity = true; + } + + if (Framecounter == 2710) + { + ShinkGrow = 2; + } + } + if (ShinkGrow == 2) + { + if (PulseOnce3 == 1) + { + Particle pulse3 = new StaticPulseRing(Projectile.Center, Vector2.Zero, Color.Lime, new Vector2(1f, 1f), 0f, 0.225f, 0f, 10); + GeneralParticleHandler.SpawnParticle(pulse3); + PulseOnce3 = 0; + } + } + } + + public override bool? CanCutTiles() + { + return false; + } + public override bool? CanHitNPC(NPC target) + { + return false; + } + + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Radius, targetHitbox); + + } +} diff --git a/Projectiles/Healing/PinkJellyAura.cs b/Projectiles/Healing/PinkJellyAura.cs new file mode 100644 index 0000000000..75f5ce63f7 --- /dev/null +++ b/Projectiles/Healing/PinkJellyAura.cs @@ -0,0 +1,124 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatBuffs; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typless +{ + public class PinkJellyAura : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Healing"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + private static float Radius = 160f; + public int ShinkGrow = 0; + public int Framecounter = 0; + public int PulseOnce = 1; + public int PulseOnce2 = 1; + public int PulseOnce3 = 1; + public static readonly SoundStyle Spawnsound = new("CalamityMod/Sounds/Custom/OrbHeal1") { Volume = 0.5f }; + + public override void SetDefaults() + { + //These shouldn't matter because its circular + Projectile.width = 336; + Projectile.height = 336; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Default; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 2710; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + + public override void AI() + { + Framecounter++; + + for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + { + Player player = Main.player[playerIndex]; + float targetDist = Vector2.Distance(player.Center, Projectile.Center); + if (targetDist < 155f) + { + player.AddBuff(ModContent.BuffType(), 300); + } + } + + if (ShinkGrow == 0) + { + if (PulseOnce == 1) + { + Particle pulse = new StaticPulseRing(Projectile.Center, Vector2.Zero, Color.HotPink, new Vector2(1f, 1f), 0f, 0f, 0.152f, 10); + GeneralParticleHandler.SpawnParticle(pulse); + SoundEngine.PlaySound(Spawnsound with { Pitch = -0.9f }, Projectile.Center); + PulseOnce = 0; + } + + if (Framecounter == 10) + { + ShinkGrow = 1; + } + } + if (ShinkGrow == 1) + { + if (PulseOnce2 == 1) + { + Particle pulse2 = new StaticPulseRing(Projectile.Center, Vector2.Zero, Color.HotPink, new Vector2(1f, 1f), 0f, 0.152f, 0.152f, 2700); + GeneralParticleHandler.SpawnParticle(pulse2); + PulseOnce2 = 0; + } + + for (int i = 0; i < 1; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2CircularEdge(155f, 155f), 242); + dust.scale = Main.rand.NextFloat(2.2f, 3.3f); + dust.noGravity = true; + } + + for (int i = 0; i < 1; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(150f, 150f), 242); + dust.scale = Main.rand.NextFloat(0.8f, 1.3f); + dust.noGravity = true; + } + + if (Framecounter == 2710) + { + ShinkGrow = 2; + } + } + if (ShinkGrow == 2) + { + if (PulseOnce3 == 1) + { + Particle pulse3 = new StaticPulseRing(Projectile.Center, Vector2.Zero, Color.HotPink, new Vector2(1f, 1f), 0f, 0.152f, 0f, 10); + GeneralParticleHandler.SpawnParticle(pulse3); + PulseOnce3 = 0; + } + } + } + + public override bool? CanCutTiles() + { + return false; + } + public override bool? CanHitNPC(NPC target) + { + return false; + } + + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Radius, targetHitbox); + + } +} diff --git a/Projectiles/Melee/FallenPaladinsHammerEcho.cs b/Projectiles/Melee/FallenPaladinsHammerEcho.cs index 9c880575fc..9ecacb7c6c 100644 --- a/Projectiles/Melee/FallenPaladinsHammerEcho.cs +++ b/Projectiles/Melee/FallenPaladinsHammerEcho.cs @@ -20,7 +20,6 @@ namespace CalamityMod.Projectiles.Melee ProjectileID.Sets.TrailCacheLength[Projectile.type] = 15; ProjectileID.Sets.TrailingMode[Projectile.type] = 0; } - //This is all copied straight from PwnagehammerEcho with some minor edits. public override void SetDefaults() { Projectile.width = 40; @@ -41,23 +40,20 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - speed = Projectile.velocity.Length(); Projectile.ai[0] += 1f; - if (Projectile.ai[0] > 55f) - { - CalamityUtils.HomeInOnNPC(Projectile, Projectile.tileCollide, 2000f, speed, 12f); - } if (Projectile.ai[0] < 42f) { - Projectile.velocity *= 0.9575f; + Projectile.velocity *= 0.95f; Projectile.rotation += MathHelper.ToRadians(Projectile.ai[0] * 0.5f) * Projectile.localAI[0]; } - else if (Projectile.ai[0] < 44f) + else if (Projectile.ai[0] > 42f) { Projectile.extraUpdates = 1; if (Projectile.ai[1] < 0f) { - Projectile.Kill(); + CalamityUtils.HomeInOnNPC(Projectile, Projectile.tileCollide, 2000f, speed, 12f); + if (Projectile.ai[0] > 80f) + Projectile.Kill(); return; } @@ -66,7 +62,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.Kill(); else { - float velConst = 12f; + float velConst = 7f; + velConst--; Projectile.velocity = new Vector2((target.Center.X - Projectile.Center.X) / velConst, (target.Center.Y - Projectile.Center.Y) / velConst); Projectile.rotation += MathHelper.ToRadians(48f) * Projectile.localAI[0]; } diff --git a/Projectiles/Melee/GalaxySmasherEcho.cs b/Projectiles/Melee/GalaxySmasherEcho.cs index ac4bfe603d..7699be7196 100644 --- a/Projectiles/Melee/GalaxySmasherEcho.cs +++ b/Projectiles/Melee/GalaxySmasherEcho.cs @@ -45,23 +45,19 @@ namespace CalamityMod.Projectiles.Melee rotatehammer *= 1.2f; Projectile.rotation += MathHelper.ToRadians(rotatehammer) * Projectile.direction; Projectile.ai[0] += 1f; - speed = Projectile.velocity.Length(); - if (Projectile.ai[0] > 55f) - { - CalamityUtils.HomeInOnNPC(Projectile, Projectile.tileCollide, 2000f, speed, 12f); - } if (Projectile.ai[0] < 42f) { - Projectile.velocity *= 0.9575f; + Projectile.velocity *= 0.95f; Projectile.rotation += MathHelper.ToRadians(Projectile.ai[0] * 0.5f) * Projectile.localAI[0]; } - else if (Projectile.ai[0] < 44f) + else if (Projectile.ai[0] > 42f) { Projectile.extraUpdates = 1; if (Projectile.ai[1] < 0f) { - Projectile.Kill(); - return; + CalamityUtils.HomeInOnNPC(Projectile, Projectile.tileCollide, 2000f, speed, 12f); + if (Projectile.ai[0] > 80f) + Projectile.Kill(); } NPC target = Main.npc[(int)Projectile.ai[1]]; @@ -69,7 +65,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.Kill(); else { - float velConst = 24f; + float velConst = 5f; + velConst--; Projectile.velocity = new Vector2((target.Center.X - Projectile.Center.X) / velConst, (target.Center.Y - Projectile.Center.Y) / velConst); Projectile.rotation += MathHelper.ToRadians(48f) * Projectile.localAI[0]; } diff --git a/Projectiles/Melee/GalaxySmasherHammer.cs b/Projectiles/Melee/GalaxySmasherHammer.cs index ff1d2805d4..8cd049249f 100644 --- a/Projectiles/Melee/GalaxySmasherHammer.cs +++ b/Projectiles/Melee/GalaxySmasherHammer.cs @@ -163,7 +163,7 @@ namespace CalamityMod.Projectiles.Melee { if (InPulse == 1) { - Particle pulse2 = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Color.Orchid, new Vector2(1f, 1f), Main.rand.NextFloat(12f, 25f), 50f, 0.1f, 30); + Particle pulse2 = new StaticPulseRing(Projectile.Center, Vector2.Zero, Color.Orchid, new Vector2(1f, 1f), 0f, 4.9f, 0f, 25); GeneralParticleHandler.SpawnParticle(pulse2); InPulse = 2; } diff --git a/Projectiles/Melee/StellarContemptEcho.cs b/Projectiles/Melee/StellarContemptEcho.cs index 5088826751..f8202cee55 100644 --- a/Projectiles/Melee/StellarContemptEcho.cs +++ b/Projectiles/Melee/StellarContemptEcho.cs @@ -56,12 +56,14 @@ namespace CalamityMod.Projectiles.Melee Projectile.velocity *= 0.95f; Projectile.rotation += MathHelper.ToRadians(Projectile.ai[0] * 0.5f) * Projectile.localAI[0]; } - else if (Projectile.ai[0] < 44f) + else if (Projectile.ai[0] > 42f) { Projectile.extraUpdates = 1; if (Projectile.ai[1] < 0f) { - Projectile.Kill(); + CalamityUtils.HomeInOnNPC(Projectile, Projectile.tileCollide, 2000f, speed, 12f); + if (Projectile.ai[0] > 80f) + Projectile.Kill(); return; } @@ -72,11 +74,13 @@ namespace CalamityMod.Projectiles.Melee } else { - float velConst = 24f; + float velConst = 7f; + velConst--; Projectile.velocity = new Vector2((target.Center.X - Projectile.Center.X) / velConst, (target.Center.Y - Projectile.Center.Y) / velConst); Projectile.rotation += MathHelper.ToRadians(48f) * Projectile.localAI[0]; } } + if (Main.rand.NextBool(2)) { diff --git a/Projectiles/Rogue/ShockGrenadeProjectile.cs b/Projectiles/Rogue/ShockGrenadeProjectile.cs index 265b05cd35..e35e913101 100644 --- a/Projectiles/Rogue/ShockGrenadeProjectile.cs +++ b/Projectiles/Rogue/ShockGrenadeProjectile.cs @@ -123,6 +123,7 @@ namespace CalamityMod.Projectiles.Rogue SoundEngine.PlaySound(SoundID.Item93 with { Volume = SoundID.Item93.Volume * 0.5f }, Projectile.position); } + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, 3, Projectile.owner, 0, 0); } } diff --git a/Projectiles/Typeless/TeslaAura.cs b/Projectiles/Typeless/TeslaAura.cs index adaa05d9fe..9797462532 100644 --- a/Projectiles/Typeless/TeslaAura.cs +++ b/Projectiles/Typeless/TeslaAura.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { - //Protect against other mod projectile reflection like emode Granite Golems + // Protect against other mod projectile reflection like emode Granite Golems. Projectile.friendly = true; Projectile.hostile = false; @@ -55,11 +55,11 @@ namespace CalamityMod.Projectiles.Typeless Projectile.localAI[1]++; } if (Projectile.localAI[1] >= framesX) - { Projectile.localAI[1] = 0; - } - Player player = Main.player[Projectile.owner]; + Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.15f / 255f, (255 - Projectile.alpha) * 0.15f / 255f, (255 - Projectile.alpha) * 0.01f / 255f); + + Player player = Main.player[Projectile.owner]; Projectile.Center = player.Center; if (player is null || player.dead) { @@ -77,13 +77,10 @@ namespace CalamityMod.Projectiles.Typeless if (target.knockBackResist <= 0f) return; + // 07AUG2023: Ozzatron: TML was giving NaN knockback, probably due to 0 base knockback. Do not use hit.Knockback if (CalamityGlobalNPC.ShouldAffectNPC(target)) { - float knockbackMultiplier = hit.Knockback - (1f - target.knockBackResist); - if (knockbackMultiplier < 0) - { - knockbackMultiplier = 0; - } + float knockbackMultiplier = MathHelper.Clamp(1f - target.knockBackResist, 0f, 1f); Vector2 trueKnockback = target.Center - Projectile.Center; trueKnockback.Normalize(); target.velocity = trueKnockback * knockbackMultiplier; @@ -139,10 +136,9 @@ namespace CalamityMod.Projectiles.Typeless public override bool? CanHitNPC(NPC target) { - if (NPCID.Sets.ProjectileNPC[target.type] || target.catchItem != 0 && target.type != ModContent.NPCType()) - { + if (NPCID.Sets.ProjectileNPC[target.type] || (target.catchItem != 0 && target.type != ModContent.NPCType())) return false; - } + return null; } } diff --git a/Scenes/MusicScenes/BaseMusicSceneEffect.cs b/Scenes/MusicScenes/BaseMusicSceneEffect.cs index 6f157d50a5..03b7271f85 100644 --- a/Scenes/MusicScenes/BaseMusicSceneEffect.cs +++ b/Scenes/MusicScenes/BaseMusicSceneEffect.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; //using System.Reflection; using Terraria; using Terraria.ModLoader; @@ -54,7 +54,7 @@ namespace CalamityMod.Systems if (MusicModMusic is null && VanillaMusic == -1) return false; - /* + /* // You can't even edit music if the game has Otherworld toggle on lol. // Theoretically, reflection would only occur if the music mod is disabled if (MusicModMusic is null) @@ -69,31 +69,35 @@ namespace CalamityMod.Systems } */ - for (int j = 0; j < Main.maxNPCs; j++) + Rectangle screenRect = new Rectangle((int)Main.screenPosition.X, (int)Main.screenPosition.Y, Main.screenWidth, Main.screenHeight); + int musicDistance = MusicDistance * 2; + for (int j = 0; j < Main.maxNPCs; j++) { NPC npc = Main.npc[j]; if (!npc.active) continue; bool inList = false; - if (npc.type == NPCType) - inList = true; - else - { - for (int i = 0; i < AdditionalNPCs.Length; i++) - { - if (npc.type == AdditionalNPCs[i]) - { - inList = true; - break; - } - } - } + if (npc.type == NPCType) + { + inList = true; + } + else + { + for (int i = 0; i < AdditionalNPCs.Length; i++) + { + if (npc.type == AdditionalNPCs[i]) + { + inList = true; + break; + } + } + } + if (!inList) continue; - Rectangle screenRect = new Rectangle((int)Main.screenPosition.X, (int)Main.screenPosition.Y, Main.screenWidth, Main.screenHeight); - Rectangle npcBox = new Rectangle((int)npc.Center.X - MusicDistance, (int)npc.Center.Y - MusicDistance, MusicDistance * 2, MusicDistance * 2); + Rectangle npcBox = new Rectangle((int)npc.Center.X - MusicDistance, (int)npc.Center.Y - MusicDistance, musicDistance, musicDistance); if (screenRect.Intersects(npcBox)) return true; } diff --git a/Skies/AstralSky.cs b/Skies/AstralSky.cs index 8cbbae6aa5..accc6752b0 100644 --- a/Skies/AstralSky.cs +++ b/Skies/AstralSky.cs @@ -41,14 +41,14 @@ namespace CalamityMod.Skies public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) { - // Small worlds, default draw height + // Small worlds, default draw height. int AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 2; - // Medium worlds + // Medium worlds. if (Main.maxTilesX >= 6400 && Main.maxTilesX < 8400) AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 4; - // Large worlds (and anything bigger) + // Large worlds (and anything bigger). if (Main.maxTilesX >= 8400) AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 140; @@ -58,9 +58,21 @@ namespace CalamityMod.Skies spriteBatch.Draw(CalamityMod.AstralSky, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White * opacity); // Terraria's conditions. - int bgTop = (int)((-Main.screenPosition.Y) / (Main.worldSurface * 16.0 - 600.0) * 200.0); if (Main.netMode != NetmodeID.Server) { + int bgTop = (int)((-Main.screenPosition.Y) / (Main.worldSurface * 16.0 - 600.0) * 200.0); + float colorMult = 0.952f * opacity; + Color astralcyan = new Color(100, 183, 255); + Color purple = new Color(201, 148, 255); + Color yellow = new Color(255, 146, 73); + float width1 = Main.screenWidth / 500f; + float height1 = Main.screenHeight / 600f; + float width2 = Main.screenWidth / 600f; + float height2 = Main.screenHeight / 800f; + float width3 = Main.screenWidth / 200f; + float height3 = Main.screenHeight / 900f; + float width4 = Main.screenWidth / 1000f; + float height4 = Main.screenHeight / 200f; for (int i = 0; i < Main.star.Length; i++) { Star star = Main.star[i]; @@ -69,67 +81,28 @@ namespace CalamityMod.Skies Texture2D t2D = TextureAssets.Star[star.type].Value; Vector2 origin = new Vector2(t2D.Width * 0.5f, t2D.Height * 0.5f); - - float posX = star.position.X * (Main.screenWidth / 500f); - float posY = star.position.Y * (Main.screenHeight / 600f); - Color astralcyan = new Color(100, 183, 255); - + float posX = star.position.X * width1; + float posY = star.position.Y * height1; Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), astralcyan * star.twinkle * colorMult, star.rotation, origin, (star.scale * star.twinkle) - 0.2f, SpriteEffects.None, 0f); - spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), astralcyan * star.twinkle * 0.952f * opacity, star.rotation, origin, (star.scale * star.twinkle) - 0.2f, SpriteEffects.None, 0f); - } + origin = new Vector2(t2D.Width * 0.2f, t2D.Height * 0.2f); + posX = star.position.X * width2; + posY = star.position.Y * height2; + position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), purple * star.twinkle * colorMult, star.rotation, origin, (star.scale * star.twinkle) + 0.2f, SpriteEffects.None, 0f); - for (int i = 0; i < Main.star.Length; i++) - { - Star star = Main.star[i]; - if (star == null) - continue; + origin = new Vector2(t2D.Width * 0.8f, t2D.Height * 0.8f); + posX = star.position.X * width3; + posY = star.position.Y * height3; + position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), yellow * star.twinkle * colorMult, star.rotation, origin, star.scale * star.twinkle, SpriteEffects.None, 0f); - Texture2D t2D = TextureAssets.Star[star.type].Value; - Vector2 origin = new Vector2(t2D.Width * 0.2f, t2D.Height * 0.2f); - - float posX = star.position.X * (Main.screenWidth / 600f); - float posY = star.position.Y * (Main.screenHeight / 800f); - Color purple = new Color(201, 148, 255); - - Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); - - spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), purple * star.twinkle * 0.952f * opacity, star.rotation, origin, (star.scale * star.twinkle) + 0.2f, SpriteEffects.None, 0f); - } - - for (int i = 0; i < Main.star.Length; i++) - { - Star star = Main.star[i]; - if (star == null) - continue; - - Texture2D t2D = TextureAssets.Star[star.type].Value; - Vector2 origin = new Vector2(t2D.Width * 0.8f, t2D.Height * 0.8f); - - float posX = star.position.X * (Main.screenWidth / 200f); - float posY = star.position.Y * (Main.screenHeight / 900f); - Color yellow = new Color(255, 146, 73); - - Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); - - spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), yellow * star.twinkle * 0.952f * opacity, star.rotation, origin, star.scale * star.twinkle, SpriteEffects.None, 0f); - } - - for (int i = 0; i < Main.star.Length; i++) - { - Star star = Main.star[i]; - if (star == null) - continue; - - Texture2D t2D = TextureAssets.Star[star.type].Value; - Vector2 origin = new Vector2(t2D.Width * 0.5f, t2D.Height * 0.5f); - - float posX = star.position.X * (Main.screenWidth / 1000f); - float posY = star.position.Y * (Main.screenHeight / 200f); - - Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); - - spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), Color.White * star.twinkle * 0.952f * opacity, star.rotation, origin, star.scale * star.twinkle, SpriteEffects.None, 0f); + origin = new Vector2(t2D.Width * 0.5f, t2D.Height * 0.5f); + posX = star.position.X * width4; + posY = star.position.Y * height4; + position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), Color.White * star.twinkle * colorMult, star.rotation, origin, star.scale * star.twinkle, SpriteEffects.None, 0f); } } } diff --git a/Skies/AstralSkyDesert.cs b/Skies/AstralSkyDesert.cs index e267226be0..ccad1cda73 100644 --- a/Skies/AstralSkyDesert.cs +++ b/Skies/AstralSkyDesert.cs @@ -14,6 +14,8 @@ namespace CalamityMod.Skies private bool skyActive; private float opacity; + private const float Scale = 2f; + public override void Deactivate(params object[] args) { skyActive = Main.LocalPlayer.Calamity().ZoneAstral && !Main.LocalPlayer.ZoneDungeon && BiomeTileCounterSystem.AstralTiles > 950 && Main.LocalPlayer.ZoneDesert && !Main.LocalPlayer.ZoneSnow; @@ -40,31 +42,33 @@ namespace CalamityMod.Skies public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) { - // Small worlds, default draw height + // Small worlds, default draw height. int AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 2; - // Medium worlds + // Medium worlds. if (Main.maxTilesX >= 6400 && Main.maxTilesX < 8400) AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 4; - // Large worlds (and anything bigger) + // Large worlds (and anything bigger). if (Main.maxTilesX >= 8400) AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 140; - // Background from here starting from the back layer to the front layer + // Background from here starting from the back layer to the front layer. + float width = Main.screenWidth / 2f; + float height = Main.screenHeight / 2f; + Color color = new Color(63, 51, 90, 255) * opacity; if (maxDepth >= 9f && minDepth < 9f) { float screenParralaxMultiplier = 0.16f; Texture2D texture = CalamityMod.AstralSurfaceHorizon; - float scale = 2.0f; int x = (int)(Main.screenPosition.X * screenParralaxMultiplier); - x %= (int)(texture.Width * scale); + x %= (int)(texture.Width * Scale); int y = (int)(Main.screenPosition.Y * screenParralaxMultiplier); y -= 1380; // 1000 for (int k = -1; k <= 1; k++) { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, (float)AstralBiomeHeight), scale, SpriteEffects.None, 0f); + var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); + spriteBatch.Draw(texture, pos - texture.Size() / 2f * Scale, null, color, 0f, new Vector2(0f, (float)AstralBiomeHeight), Scale, SpriteEffects.None, 0f); } } @@ -72,15 +76,14 @@ namespace CalamityMod.Skies { float screenParralaxMultiplier = 0.4f; Texture2D texture = CalamityMod.AstralDesertSurfaceFar; - float scale = 2.0f; int x = (int)(Main.screenPosition.X * 0.5f * screenParralaxMultiplier); - x %= (int)(texture.Width * scale); + x %= (int)(texture.Width * Scale); int y = (int)(Main.screenPosition.Y * 0.45f * screenParralaxMultiplier); y -= 1520; // 1000 for (int k = -1; k <= 1; k++) { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, (float)AstralBiomeHeight), scale, SpriteEffects.None, 0f); + var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); + spriteBatch.Draw(texture, pos - texture.Size() / 2f * Scale, null, color, 0f, new Vector2(0f, (float)AstralBiomeHeight), Scale, SpriteEffects.None, 0f); } } @@ -88,15 +91,14 @@ namespace CalamityMod.Skies { float screenParralaxMultiplier = 0.4f; Texture2D texture = CalamityMod.AstralDesertSurfaceMiddle; - float scale = 2.0f; int x = (int)(Main.screenPosition.X * 0.8f * screenParralaxMultiplier); - x %= (int)(texture.Width * scale); + x %= (int)(texture.Width * Scale); int y = (int)(Main.screenPosition.Y * 0.5f * screenParralaxMultiplier); y -= 1900; // 1000 for (int k = -1; k <= 1; k++) { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, (float)AstralBiomeHeight), scale, SpriteEffects.None, 0f); + var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); + spriteBatch.Draw(texture, pos - texture.Size() / 2f * Scale, null, color, 0f, new Vector2(0f, (float)AstralBiomeHeight), Scale, SpriteEffects.None, 0f); } } @@ -104,15 +106,14 @@ namespace CalamityMod.Skies { float screenParralaxMultiplier = 0.4f; Texture2D texture = CalamityMod.AstralDesertSurfaceClose; - float scale = 2.0f; - int x = (int)(Main.screenPosition.X * 1.0f * screenParralaxMultiplier); - x %= (int)(texture.Width * scale); + int x = (int)(Main.screenPosition.X * 1f * screenParralaxMultiplier); + x %= (int)(texture.Width * Scale); int y = (int)(Main.screenPosition.Y * 0.55f * screenParralaxMultiplier); y -= 2050; // 1000 for (int k = -1; k <= 1; k++) { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, (float)AstralBiomeHeight), scale, SpriteEffects.None, 0f); + var pos = new Vector2(width - x + texture.Width * k * Scale, height - y); + spriteBatch.Draw(texture, pos - texture.Size() / 2f * Scale, null, color, 0f, new Vector2(0f, (float)AstralBiomeHeight), Scale, SpriteEffects.None, 0f); } } } diff --git a/Skies/AstralSkySurface.cs b/Skies/AstralSkySurface.cs index 1c95e64e8a..0a5b5adeb8 100644 --- a/Skies/AstralSkySurface.cs +++ b/Skies/AstralSkySurface.cs @@ -41,18 +41,21 @@ namespace CalamityMod.Skies public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) { - // Small worlds, default draw height + // Small worlds, default draw height. int AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 2; - // Medium worlds + // Medium worlds. if (Main.maxTilesX >= 6400 && Main.maxTilesX < 8400) AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 4; - // Large worlds (and anything bigger) + // Large worlds (and anything bigger). if (Main.maxTilesX >= 8400) AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 140; - // Background from here starting from the back layer to the front layer + // Background from here starting from the back layer to the front layer. + float width = Main.screenWidth / 2f; + float height = Main.screenHeight / 2f; + Color textureColor = new Color(63, 51, 90, 255) * opacity; if (maxDepth >= 9f && minDepth < 9f) { float screenParralaxMultiplier = 0.16f; @@ -62,10 +65,11 @@ namespace CalamityMod.Skies x %= (int)(texture.Width * scale); int y = (int)(Main.screenPosition.Y * screenParralaxMultiplier); y -= 1380; // 1000 + Vector2 position = texture.Size() / 2f * scale; for (int k = -1; k <= 1; k++) { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); + var pos = new Vector2(width - x + texture.Width * k * scale, height - y); + spriteBatch.Draw(texture, pos - position, null, textureColor, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); } } @@ -78,10 +82,11 @@ namespace CalamityMod.Skies x %= (int)(texture.Width * scale); int y = (int)(Main.screenPosition.Y * 0.45f * screenParralaxMultiplier); y -= 1520; // 1000 + Vector2 position = texture.Size() / 2f * scale; for (int k = -1; k <= 1; k++) { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); + var pos = new Vector2(width - x + texture.Width * k * scale, height - y); + spriteBatch.Draw(texture, pos - position, null, textureColor, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); } } @@ -94,17 +99,19 @@ namespace CalamityMod.Skies x %= (int)(texture.Width * scale); int y = (int)(Main.screenPosition.Y * 0.5f * screenParralaxMultiplier); y -= 1900; // 1000 + Vector2 position = texture.Size() / 2f * scale; for (int k = -1; k <= 1; k++) { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); + var pos = new Vector2(width - x + texture.Width * k * scale, height - y); + spriteBatch.Draw(texture, pos - position, null, textureColor, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); } Texture2D textureglow = CalamityMod.AstralSurfaceMiddleGlow; + Color textureGlowColor = Color.White * 0.5f * opacity; for (int k = -1; k <= 1; k++) { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(textureglow, pos - texture.Size() / 2f * scale, null, Color.White * 0.5f * opacity, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); + var pos = new Vector2(width - x + texture.Width * k * scale, height - y); + spriteBatch.Draw(textureglow, pos - position, null, textureGlowColor, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); } } @@ -117,17 +124,19 @@ namespace CalamityMod.Skies x %= (int)(texture.Width * scale); int y = (int)(Main.screenPosition.Y * 0.55f * screenParralaxMultiplier); y -= 1880; // 1000 + Vector2 position = texture.Size() / 2f * scale; for (int k = -1; k <= 1; k++) { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); + var pos = new Vector2(width - x + texture.Width * k * scale, height - y); + spriteBatch.Draw(texture, pos - position, null, textureColor, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); } Texture2D textureglow = CalamityMod.AstralSurfaceCloseGlow; + Color textureGlowColor = Color.White * 0.7f * opacity; for (int k = -1; k <= 1; k++) { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(textureglow, pos - texture.Size() / 2f * scale, null, Color.White * 0.7f * opacity, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); + var pos = new Vector2(width - x + texture.Width * k * scale, height - y); + spriteBatch.Draw(textureglow, pos - position, null, textureGlowColor, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); } } @@ -140,20 +149,21 @@ namespace CalamityMod.Skies x %= (int)(texture.Width * scale); int y = (int)(Main.screenPosition.Y * 0.6f * screenParralaxMultiplier); y -= 2100; // 1000 + Vector2 position = texture.Size() / 2f * scale; for (int k = -1; k <= 1; k++) { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); + var pos = new Vector2(width - x + texture.Width * k * scale, height - y); + spriteBatch.Draw(texture, pos - position, null, textureColor, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); } Texture2D textureglow = CalamityMod.AstralSurfaceFrontGlow; + Color textureGlowColor = Color.White * 0.9f * opacity; for (int k = -1; k <= 1; k++) { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(textureglow, pos - texture.Size() / 2f * scale, null, Color.White * 0.9f * opacity, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); + var pos = new Vector2(width - x + texture.Width * k * scale, height - y); + spriteBatch.Draw(textureglow, pos - position, null, textureGlowColor, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); } } - } public override void Update(GameTime gameTime) diff --git a/Skies/BossRushSky.cs b/Skies/BossRushSky.cs index 3663cd663c..ec6463980b 100644 --- a/Skies/BossRushSky.cs +++ b/Skies/BossRushSky.cs @@ -113,17 +113,20 @@ namespace CalamityMod.Skies Texture2D eyeTexture = ModContent.Request("CalamityMod/Skies/XerocEye").Value; Color baseColorDraw = Color.Lerp(Color.White, Color.Red, IncrementalInterest); + Vector2 origin = eyeTexture.Size() * 0.5f; - spriteBatch.Draw(eyeTexture, drawPosition, null, baseColorDraw, 0f, eyeTexture.Size() * 0.5f, scale, SpriteEffects.None, 0f); + spriteBatch.Draw(eyeTexture, drawPosition, null, baseColorDraw, 0f, origin, scale, SpriteEffects.None, 0f); Color fadedColor = Color.Lerp(baseColorDraw, Color.Coral, 0.3f) * MathHelper.Lerp(0.18f, 0.3f, IncrementalInterest); fadedColor.A = 0; float backEyeOutwardness = MathHelper.Lerp(8f, 4f, IncrementalInterest); int backInstances = (int)MathHelper.Lerp(6f, 24f, IncrementalInterest); + float fourPi = MathHelper.TwoPi * 2f; + float time = Main.GlobalTimeWrappedHourly * 2.1f; for (int i = 0; i < backInstances; i++) { - Vector2 drawOffset = (MathHelper.TwoPi * 2f * i / backInstances + Main.GlobalTimeWrappedHourly * 2.1f).ToRotationVector2() * backEyeOutwardness; - spriteBatch.Draw(eyeTexture, drawPosition + drawOffset, null, fadedColor, 0f, eyeTexture.Size() * 0.5f, scale, SpriteEffects.None, 0f); + Vector2 drawOffset = (fourPi * i / backInstances + time).ToRotationVector2() * backEyeOutwardness; + spriteBatch.Draw(eyeTexture, drawPosition + drawOffset, null, fadedColor, 0f, origin, scale, SpriteEffects.None, 0f); } } diff --git a/Skies/BrimstoneCragSky.cs b/Skies/BrimstoneCragSky.cs index 3c033becf8..b0ab303404 100644 --- a/Skies/BrimstoneCragSky.cs +++ b/Skies/BrimstoneCragSky.cs @@ -116,18 +116,20 @@ namespace CalamityMod.Skies // Draw cinders. Texture2D cinderTexture = ModContent.Request("CalamityMod/Skies/CalamitasCinder").Value; float scaleFade = skyActiveLeeway / 60f; + Color offsetDrawColor = Color.Red * 0.56f; + offsetDrawColor.A = 0; + Vector2 origin = cinderTexture.Size() * 0.5f; + float cinderScale = 1.5f * scaleFade; for (int i = 0; i < Cinders.Count; i++) { Vector2 drawPosition = Cinders[i].Center - Main.screenPosition; for (int j = 0; j < 3; j++) { Vector2 offsetDrawPosition = drawPosition + (MathHelper.TwoPi * j / 3f).ToRotationVector2() * 1.4f; - Color offsetDrawColor = Color.Red * 0.56f; - offsetDrawColor.A = 0; - spriteBatch.Draw(cinderTexture, offsetDrawPosition, null, offsetDrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale * 1.5f * scaleFade, SpriteEffects.None, 0f); + spriteBatch.Draw(cinderTexture, offsetDrawPosition, null, offsetDrawColor, 0f, origin, Cinders[i].Scale * cinderScale, SpriteEffects.None, 0f); } - spriteBatch.Draw(cinderTexture, drawPosition, null, Cinders[i].DrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale * scaleFade, SpriteEffects.None, 0f); + spriteBatch.Draw(cinderTexture, drawPosition, null, Cinders[i].DrawColor, 0f, origin, Cinders[i].Scale * scaleFade, SpriteEffects.None, 0f); } } } diff --git a/Skies/CryogenSky.cs b/Skies/CryogenSky.cs index 28a56df119..1bbd055d07 100644 --- a/Skies/CryogenSky.cs +++ b/Skies/CryogenSky.cs @@ -60,12 +60,17 @@ namespace CalamityMod.Skies } float auroraStrength = CalculateAuroraStrength(); + float width = Main.screenWidth * 0.5f; + float height = Main.screenHeight * 0.1f; + Vector2 centerOffset = Vector2.UnitX * Main.screenWidth * 0.5f; + float time = Main.GlobalTimeWrappedHourly * 1.2f; + float centerOffsetRatioIncrement = 1f / 1800f * MathHelper.Lerp(0.2f, 1f, auroraStrength) * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.9f); for (int i = 0; i < Auroras.Length; i++) { - Vector2 centerRange = new Vector2(Main.screenWidth * 0.5f, Main.screenHeight * 0.1f / Auroras[i].Depth); - Auroras[i].Center = centerRange * (Auroras[i].CenterOffsetRatio * MathHelper.TwoPi).ToRotationVector2() + Vector2.UnitX * Main.screenWidth * 0.5f; - Auroras[i].Center.Y -= 180f + (float)Math.Cos(Main.GlobalTimeWrappedHourly * 1.2f + Auroras[i].CenterOffsetRatio * MathHelper.Pi) * 50f; - Auroras[i].CenterOffsetRatio += 1f / 1800f * MathHelper.Lerp(0.2f, 1f, auroraStrength) * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.9f); + Vector2 centerRange = new Vector2(width, height / Auroras[i].Depth); + Auroras[i].Center = centerRange * (Auroras[i].CenterOffsetRatio * MathHelper.TwoPi).ToRotationVector2() + centerOffset; + Auroras[i].Center.Y -= 180f + (float)Math.Cos(time + Auroras[i].CenterOffsetRatio * MathHelper.Pi) * 50f; + Auroras[i].CenterOffsetRatio += centerOffsetRatioIncrement; } } @@ -115,39 +120,39 @@ namespace CalamityMod.Skies { var auroraTexture = CalamityUtils.AuroraTexture; float auroraStrength = CalculateAuroraStrength(); + float hueOffset = 0.5f * MathHelper.Lerp(0.15f, 0.95f, auroraStrength); + float time = (float)Math.Cos(Main.GlobalTimeWrappedHourly * 1.2f) * 0.25f; + float time2 = Main.GlobalTimeWrappedHourly * 0.7f; + float auroraColorLerp = MathHelper.Lerp(0.3f, 1f, auroraStrength); + float fadeInLerp = Utils.GetLerpValue(45f, 0f, FadeInCountdown); + float fadeOutLerp = Utils.GetLerpValue(0f, 45f, FadeoutTimer); + float brightnessLerp = MathHelper.Lerp(0.6f, 1.1f, (float)Math.Sin(Main.GlobalTimeWrappedHourly / 1.8f) * 0.5f + 0.5f); + Vector2 origin = auroraTexture.Size() * 0.5f; for (int i = 0; i < Auroras.Length; i++) { - float hue = 0.5f + Auroras[i].ColorHueOffset * 0.5f * MathHelper.Lerp(0.15f, 0.95f, auroraStrength); - hue += (float)Math.Cos(Main.GlobalTimeWrappedHourly * 1.2f) * 0.25f; + float hue = 0.5f + Auroras[i].ColorHueOffset * hueOffset; + hue += time; hue %= 1f; float scale = 1.4f / Auroras[i].Depth; - scale += (float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.7f + Auroras[i].CenterOffsetRatio * MathHelper.TwoPi) * 0.2f; + scale += (float)Math.Cos(time2 + Auroras[i].CenterOffsetRatio * MathHelper.TwoPi) * 0.2f; Color auroraColor = Main.hslToRgb(hue, 1f, 0.825f) * 0.85f; - auroraColor *= MathHelper.Lerp(0.3f, 1f, auroraStrength); + auroraColor *= auroraColorLerp; if (FadeInCountdown > 0f) - auroraColor *= Utils.GetLerpValue(45f, 0f, FadeInCountdown); + auroraColor *= fadeInLerp; if (FadeoutTimer > 0f) - auroraColor *= Utils.GetLerpValue(0f, 45f, FadeoutTimer); + auroraColor *= fadeOutLerp; if (Main.dayTime) auroraColor *= 0.4f; float yBrightness = MathHelper.Lerp(1.5f, 0.5f, 1f - MathHelper.Clamp((Auroras[i].Center.Y + 300f) / 200f, 0f, 1f)) * 1.3f; - yBrightness *= MathHelper.Lerp(0.6f, 1.1f, (float)Math.Sin(Main.GlobalTimeWrappedHourly / 1.8f) * 0.5f + 0.5f); + yBrightness *= brightnessLerp; if (yBrightness > 1.3f) yBrightness = 1.3f; auroraColor *= yBrightness; - spriteBatch.Draw(auroraTexture, - Auroras[i].Center, - null, - auroraColor * 1.1f, - MathHelper.PiOver2, - auroraTexture.Size() * 0.5f, - scale, - Auroras[i].DirectionEffect, - 0f); + spriteBatch.Draw(auroraTexture, Auroras[i].Center, null, auroraColor * 1.1f, MathHelper.PiOver2, origin, scale, Auroras[i].DirectionEffect, 0f); } } } @@ -156,12 +161,13 @@ namespace CalamityMod.Skies { FadeInCountdown = 45f; Auroras = new CryogenAurora[150]; + float randomOffsetMax = 3f / Auroras.Length; for (int i = 0; i < Auroras.Length; i++) { Auroras[i].Depth = Main.rand.NextFloat(1f, 2.2f); Auroras[i].ColorHueOffset = Main.rand.NextFloat(-1f, 1f); Auroras[i].DirectionEffect = Utils.SelectRandom(Main.rand, SpriteEffects.None, SpriteEffects.FlipHorizontally); - Auroras[i].CenterOffsetRatio = i / (float)Auroras.Length + Main.rand.NextFloat(3f / Auroras.Length); + Auroras[i].CenterOffsetRatio = i / (float)Auroras.Length + Main.rand.NextFloat(randomOffsetMax); } } diff --git a/Skies/ExoMechsSky.cs b/Skies/ExoMechsSky.cs index 49376eb50c..31cdddfc44 100644 --- a/Skies/ExoMechsSky.cs +++ b/Skies/ExoMechsSky.cs @@ -141,12 +141,13 @@ namespace CalamityMod.Skies Vector2 scale = new Vector2(Main.screenWidth * 1.1f / TextureAssets.MagicPixel.Value.Width, Main.screenHeight * 1.1f / TextureAssets.MagicPixel.Value.Height); Vector2 screenArea = new Vector2(Main.screenWidth, Main.screenHeight) * 0.5f; Color drawColor = Color.White * MathHelper.Lerp(0f, 0.24f, LightningIntensity) * BackgroundIntensity; + Vector2 origin = TextureAssets.MagicPixel.Value.Size() * 0.5f; // Draw a grey background as base. - spriteBatch.Draw(TextureAssets.MagicPixel.Value, screenArea, null, OnTileColor(Color.Transparent), 0f, TextureAssets.MagicPixel.Value.Size() * 0.5f, scale, SpriteEffects.None, 0f); + spriteBatch.Draw(TextureAssets.MagicPixel.Value, screenArea, null, OnTileColor(Color.Transparent), 0f, origin, scale, SpriteEffects.None, 0f); for (int i = 0; i < 2; i++) - spriteBatch.Draw(TextureAssets.MagicPixel.Value, screenArea, null, drawColor, 0f, TextureAssets.MagicPixel.Value.Size() * 0.5f, scale, SpriteEffects.None, 0f); + spriteBatch.Draw(TextureAssets.MagicPixel.Value, screenArea, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); } Texture2D flashTexture = ModContent.Request("Terraria/Images/Misc/VortexSky/Flash").Value; diff --git a/Skies/MonolithSky.cs b/Skies/MonolithSky.cs index ff23c053d4..28bf868c5b 100644 --- a/Skies/MonolithSky.cs +++ b/Skies/MonolithSky.cs @@ -111,18 +111,19 @@ namespace CalamityMod.Skies // Draw cinders. Texture2D cinderTexture = ModContent.Request("CalamityMod/Skies/CalamitasCinder").Value; + Color offsetDrawColor = Color.Red * 0.56f; + offsetDrawColor.A = 0; + Vector2 origin = cinderTexture.Size() * 0.5f; for (int i = 0; i < Cinders.Count; i++) { Vector2 drawPosition = Cinders[i].Center - Main.screenPosition; for (int j = 0; j < 3; j++) { Vector2 offsetDrawPosition = drawPosition + (MathHelper.TwoPi * j / 3f).ToRotationVector2() * 1.4f; - Color offsetDrawColor = Color.Red * 0.56f; - offsetDrawColor.A = 0; - spriteBatch.Draw(cinderTexture, offsetDrawPosition, null, offsetDrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale * 1.5f, SpriteEffects.None, 0f); + spriteBatch.Draw(cinderTexture, offsetDrawPosition, null, offsetDrawColor, 0f, origin, Cinders[i].Scale * 1.5f, SpriteEffects.None, 0f); } - spriteBatch.Draw(cinderTexture, drawPosition, null, Cinders[i].DrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale, SpriteEffects.None, 0f); + spriteBatch.Draw(cinderTexture, drawPosition, null, Cinders[i].DrawColor, 0f, origin, Cinders[i].Scale, SpriteEffects.None, 0f); } } diff --git a/Skies/SCalSky.cs b/Skies/SCalSky.cs index 0e816ec2dd..dd3e8ed6ae 100644 --- a/Skies/SCalSky.cs +++ b/Skies/SCalSky.cs @@ -228,15 +228,16 @@ namespace CalamityMod.Skies for (int i = 0; i < Cinders.Count; i++) { Vector2 drawPosition = Cinders[i].Center - Main.screenPosition; + Color offsetDrawColor = cinderColor * 0.56f; + offsetDrawColor.A = 0; + Vector2 cinderOrigin = cinderTexture.Size() * 0.5f; for (int j = 0; j < 3; j++) { Vector2 offsetDrawPosition = drawPosition + (MathHelper.TwoPi * j / 3f).ToRotationVector2() * 1.4f; - Color offsetDrawColor = cinderColor * 0.56f; - offsetDrawColor.A = 0; - spriteBatch.Draw(cinderTexture, offsetDrawPosition, null, offsetDrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale * 1.5f, SpriteEffects.None, 0f); + spriteBatch.Draw(cinderTexture, offsetDrawPosition, null, offsetDrawColor, 0f, cinderOrigin, Cinders[i].Scale * 1.5f, SpriteEffects.None, 0f); } - spriteBatch.Draw(cinderTexture, drawPosition, null, Cinders[i].DrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale, SpriteEffects.None, 0f); + spriteBatch.Draw(cinderTexture, drawPosition, null, Cinders[i].DrawColor, 0f, cinderOrigin, Cinders[i].Scale, SpriteEffects.None, 0f); } } diff --git a/Skies/StormWeaverFlashSky.cs b/Skies/StormWeaverFlashSky.cs index ddb4329bf1..42471c402e 100644 --- a/Skies/StormWeaverFlashSky.cs +++ b/Skies/StormWeaverFlashSky.cs @@ -42,9 +42,10 @@ namespace CalamityMod.Skies Vector2 scale = new Vector2(Main.screenWidth * 1.1f / white.Width, Main.screenHeight * 1.1f / white.Height); Vector2 screenCenter = new Vector2(Main.screenWidth, Main.screenHeight) * 0.5f; Color drawColor = Color.White * MathHelper.Lerp(0f, 0.88f, lightningFlashPower); + Vector2 origin = white.Size() * 0.5f; for (int i = 0; i < 2; i++) - spriteBatch.Draw(white, screenCenter, null, drawColor, 0f, white.Size() * 0.5f, scale, SpriteEffects.None, 0f); + spriteBatch.Draw(white, screenCenter, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); } public override void Reset() { } diff --git a/Skies/SulphurSeaSky.cs b/Skies/SulphurSeaSky.cs index 37fd99fd16..7c5ed3383f 100644 --- a/Skies/SulphurSeaSky.cs +++ b/Skies/SulphurSeaSky.cs @@ -13,6 +13,11 @@ namespace CalamityMod.Skies private bool skyActive; private float opacity; + private const float ScreenParralaxMultiplier = 0.4f; + + // Vanila scales backgrounds to 250% size. Depending on what you might want to do you can change this if you wanted to make a non scaled bg. + private const float Scale = 2.5f; + public override void Deactivate(params object[] args) { skyActive = Main.LocalPlayer.Calamity().ZoneSulphur; @@ -49,46 +54,52 @@ namespace CalamityMod.Skies if (Main.maxTilesX >= 8400) sulphurSeaHeight = (World.SulphurousSea.YStart + (int)Main.worldSurface) / 140; + // Explantion on how to use this BG code for skies. + // This changes the speed of the parralax, the closer the layer to the player the faster it should be. if (maxDepth >= 1f && minDepth < 1f) { - // Explantion on how to use this BG code for skies. - // This changes the speed of the parralax, the closer the layer to the player the faster it should be. - float screenParralaxMultiplier = 0.4f; Texture2D texture = CalamityMod.SulphurSeaSkyFront; - // Vanila scales backgrounds to 250% size. Depending on what you might want to do you can change this if you wanted to make a non scaled bg. - float scale = 2.5f; - - //Keep in mind that y paralex should always be half of x's or it will feel odd compared to how terraria does it. - //keep in mind when you change screen parralax it affects the y offset for the bg in the world. - int x = (int)(Main.screenPosition.X * 1f * screenParralaxMultiplier); - x %= (int)(texture.Width * scale); - int y = (int)(Main.screenPosition.Y * 0.5f * screenParralaxMultiplier); + // Keep in mind that y paralex should always be half of x's or it will feel odd compared to how terraria does it. + // Keep in mind when you change screen parralax it affects the y offset for the bg in the world. + int x = (int)(Main.screenPosition.X * ScreenParralaxMultiplier); + x %= (int)(texture.Width * Scale); + int y = (int)(Main.screenPosition.Y * 0.5f * ScreenParralaxMultiplier); // Y offset to align with whatever position you want it in the world (is affected by screenParralaxMultiplier as stated before). y -= 1800; - //this loops the BG horizontally. + float screenWidth = Main.screenWidth / 2f; + float screenHeight = Main.screenHeight / 2f; + Vector2 position = texture.Size() / 2f * Scale; + Color color = Color.LightSeaGreen * 0.5f * opacity; + + // This loops the BG horizontally. for (int k = -1; k <= 1; k++) { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, Color.LightSeaGreen * 0.5f * opacity, 0f, new Vector2(0f, (float)sulphurSeaHeight), scale, SpriteEffects.None, 0f); + var pos = new Vector2(screenWidth - x + texture.Width * k * Scale, screenHeight - y); + spriteBatch.Draw(texture, pos - position, null, color, 0f, new Vector2(0f, (float)sulphurSeaHeight), Scale, SpriteEffects.None, 0f); } } if (maxDepth >= 3f && minDepth < 3f) { - float screenParralaxMultiplier = 0.4f; Texture2D texture = CalamityMod.SulphurSeaSurface; - float scale = 2.5f; - int x = (int)(Main.screenPosition.X * 1f * screenParralaxMultiplier); - x %= (int)(texture.Width * scale); - int y = (int)(Main.screenPosition.Y * 0.5f * screenParralaxMultiplier); + + int x = (int)(Main.screenPosition.X * ScreenParralaxMultiplier); + x %= (int)(texture.Width * Scale); + int y = (int)(Main.screenPosition.Y * 0.5f * ScreenParralaxMultiplier); y -= 1800; // 1000 + + float screenWidth = Main.screenWidth / 2f; + float screenHeight = Main.screenHeight / 2f; + Vector2 position = texture.Size() / 2f * Scale; + Color color = Main.ColorOfTheSkies * opacity; + for (int k = -1; k <= 1; k++) { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, Main.ColorOfTheSkies * opacity, 0f, new Vector2(0f, (float)sulphurSeaHeight), scale, SpriteEffects.None, 0f); + var pos = new Vector2(screenWidth - x + texture.Width * k * Scale, screenHeight - y); + spriteBatch.Draw(texture, pos - position, null, color, 0f, new Vector2(0f, (float)sulphurSeaHeight), Scale, SpriteEffects.None, 0f); } } } diff --git a/Tiles/Abyss/AbyssTreasureChest.cs b/Tiles/Abyss/AbyssTreasureChest.cs index 8605571cf4..fc1d013cdd 100644 --- a/Tiles/Abyss/AbyssTreasureChest.cs +++ b/Tiles/Abyss/AbyssTreasureChest.cs @@ -26,7 +26,15 @@ namespace CalamityMod.Tiles.Abyss // Locked Chest stuff public override bool IsLockedChest(int i, int j) => Main.tile[i, j].TileFrameX / 36 == 1; - public override bool UnlockChest(int i, int j, ref short frameXAdjustment, ref int dustType, ref bool manual) => true; + public override bool UnlockChest(int i, int j, ref short frameXAdjustment, ref int dustType, ref bool manual) + { + //Skeletron must be dead, NPC.downedBoss3 is added as a safety measure for worlds generated before this was placed or in case the first bool gets cleared + // since tmod has not fixed the modded data disappearing bug + if (World.Abyss.AbleToUnlockChests || NPC.downedBoss3) + return true; + else + return false; + } public override bool RightClick(int i, int j) { diff --git a/Tiles/BaseTiles/BaseBossRelic.cs b/Tiles/BaseTiles/BaseBossRelic.cs index 4805328ac3..3e2575ff6e 100644 --- a/Tiles/BaseTiles/BaseBossRelic.cs +++ b/Tiles/BaseTiles/BaseBossRelic.cs @@ -95,25 +95,21 @@ namespace CalamityMod.Tiles.BaseTiles public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch) { - // This is lighting-mode specific, always include this if you draw tiles manually + // This is lighting-mode specific, always include this if you draw tiles manually. Vector2 offScreen = new Vector2(Main.offScreenRange); if (Main.drawToScreen) - { offScreen = Vector2.Zero; - } - // Take the tile, check if it actually exists + // Take the tile, check if it actually exists. Point p = new Point(i, j); Tile tile = Main.tile[p.X, p.Y]; if (tile == null || !tile.HasTile) - { return; - } - // Get the initial draw parameters + // Get the initial draw parameters. Texture2D texture = RelicTexture.Value; - int frameY = tile.TileFrameX / FrameWidth; // Picks the frame on the sheet based on the placeStyle of the item + int frameY = tile.TileFrameX / FrameWidth; // Picks the frame on the sheet based on the placeStyle of the item. Rectangle frame = texture.Frame(HorizontalFrames, VerticalFrames, 0, frameY); Vector2 origin = frame.Size() / 2f; @@ -121,26 +117,26 @@ namespace CalamityMod.Tiles.BaseTiles Color color = Lighting.GetColor(p.X, p.Y); - bool direction = tile.TileFrameY / FrameHeight != 0; // This is related to the alternate tile data we registered before + bool direction = tile.TileFrameY / FrameHeight != 0; // This is related to the alternate tile data we registered before. SpriteEffects effects = direction ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - // Some math magic to make it smoothly move up and down over time + // Some math magic to make it smoothly move up and down over time. const float TwoPi = (float)Math.PI * 2f; float offset = (float)Math.Sin(Main.GlobalTimeWrappedHourly * TwoPi / 5f); Vector2 drawPos = worldPos + offScreen - Main.screenPosition + new Vector2(0f, -40f) + new Vector2(0f, offset * 4f); - // Draw the main texture + // Draw the main texture. spriteBatch.Draw(texture, drawPos, frame, color, 0f, origin, 1f, effects, 0f); - // Draw the periodic glow effect + // Draw the periodic glow effect. float scale = (float)Math.Sin(Main.GlobalTimeWrappedHourly * TwoPi / 2f) * 0.3f + 0.7f; Color effectColor = color; effectColor.A = 0; effectColor = effectColor * 0.1f * scale; - for (float num5 = 0f; num5 < 1f; num5 += 1f / 6f) - { - spriteBatch.Draw(texture, drawPos + (TwoPi * num5).ToRotationVector2() * (6f + offset * 2f), frame, effectColor, 0f, origin, 1f, effects, 0f); - } + float offset2 = 6f + offset * 2f; + float oneSixth = 1f / 6f; + for (float k = 0f; k < 1f; k += oneSixth) + spriteBatch.Draw(texture, drawPos + (TwoPi * k).ToRotationVector2() * offset2, frame, effectColor, 0f, origin, 1f, effects, 0f); } } } diff --git a/Tiles/BaseTiles/BasePylonTile.cs b/Tiles/BaseTiles/BasePylonTile.cs index 78555f954a..c5f751bdc4 100644 --- a/Tiles/BaseTiles/BasePylonTile.cs +++ b/Tiles/BaseTiles/BasePylonTile.cs @@ -102,18 +102,18 @@ namespace CalamityMod.Tiles.BaseTiles Rectangle frame = crystalTexture.Frame(CrystalHorizontalFrameCount, CrystalVerticalFrameCount, 0, frameY); Vector2 origin = frame.Size() / 2f; - //Used to make the crystal bob, and the 6-way glow pulse a bit + // Used to make the crystal bob, and the 6-way glow pulse a bit. float sineOffset = (float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi / 5f); Vector2 tilePosition = p.ToWorldCoordinates(24f, 64f); Vector2 drawCenter = tilePosition + offScreen + Vector2.UnitY * (-40f + sineOffset * 4f); - drawCenter -= Vector2.One; //This isn't vanilla, but since our sheets lack the extra side 2 pixels, it makes our pylons offset by one pixel in each direction (imperceptible). This makes our pylons 100% aligned with vanilla + drawCenter -= Vector2.One; // This isn't vanilla, but since our sheets lack the extra side 2 pixels, it makes our pylons offset by one pixel in each direction (imperceptible). This makes our pylons 100% aligned with vanilla. - //Vanilla just has a nextbool(4) but thats because vanilla doesnt care about the update rate. We do this because in the updateEveryFrame lightning mode, the game runs the draw calls 4x as often + // Vanilla just has a nextbool(4) but thats because vanilla doesnt care about the update rate. We do this because in the updateEveryFrame lightning mode, the game runs the draw calls 4x as often. bool frameToSpawnDust = !Lighting.UpdateEveryFrame || Main.rand.NextBool(4); if (!Main.gamePaused && Main.instance.IsActive && frameToSpawnDust && Main.rand.NextBool(10)) { - //Important to remember to remove the offscreen vector. Vanilla drawing doesn't have this vector, but we do. If we don't remove it, the dust just gets spawned offscreen + //Important to remember to remove the offscreen vector. Vanilla drawing doesn't have this vector, but we do. If we don't remove it, the dust just gets spawned offscreen. Rectangle dustBox = Utils.CenteredRectangle(drawCenter - offScreen, frame.Size()); int dust = Dust.NewDust(dustBox.TopLeft(), dustBox.Width, dustBox.Height, DustID, 0f, 0f, 254, DustColor, 0.5f); @@ -121,35 +121,33 @@ namespace CalamityMod.Tiles.BaseTiles Main.dust[dust].velocity.Y -= 0.2f; } - //Crystal is 80% fullbright + // Crystal is 80% fullbright. Color crystalColor = Color.Lerp(Lighting.GetColor(p.X, p.Y), Color.White, 0.8f); spriteBatch.Draw(crystalTex, drawCenter - Main.screenPosition, frame, crystalColor * 0.7f, 0f, origin, 1f, 0f, 0f); - //Draw a 6-way glowing effect + // Draw a 6-way glowing effect. float glowOpacity = (float)Math.Sin((double)Main.GlobalTimeWrappedHourly * MathHelper.TwoPi) * 0.2f + 0.8f; Color glowColor = new Color(255, 255, 255, 0) * 0.1f * glowOpacity; - for (float k = 0f; k < 1f; k += 1 / 6f) - { - spriteBatch.Draw(crystalTex, drawCenter - Main.screenPosition + (MathHelper.TwoPi * k).ToRotationVector2() * (6f + sineOffset * 2f), frame, glowColor, 0f, origin, 1f, 0f, 0f); - } + float oneSixth = 1f / 6f; + float offset = 6f + sineOffset * 2f; + for (float k = 0f; k < 1f; k += oneSixth) + spriteBatch.Draw(crystalTex, drawCenter - Main.screenPosition + (MathHelper.TwoPi * k).ToRotationVector2() * offset, frame, glowColor, 0f, origin, 1f, 0f, 0f); int tileSelectionTier = 0; if (Main.InSmartCursorHighlightArea(p.X, p.Y, out var actuallySelected)) { tileSelectionTier = 1; if (actuallySelected) - { tileSelectionTier = 2; - } } - //Draw the selection glow + // Draw the selection glow. if (tileSelectionTier != 0) { int averageBrightness = (crystalColor.R + crystalColor.G + crystalColor.B) / 3; if (averageBrightness > 10) { - //Use the vanilla crystal sheet to get the autoselect outline + // Use the vanilla crystal sheet to get the autoselect outline. Texture2D vanillaCrystalSheet = TextureAssets.Extra[181].Value; Rectangle smartCursorGlowFrame = vanillaCrystalSheet.Frame(12, 8, 2, frameY); diff --git a/UI/AstralArcanumUI.cs b/UI/AstralArcanumUI.cs index cabd3d2c78..ef5cc8cbfb 100644 --- a/UI/AstralArcanumUI.cs +++ b/UI/AstralArcanumUI.cs @@ -55,40 +55,43 @@ namespace CalamityMod.UI } else { - //Closed, do stuff in here if need be + // Closed, do stuff in here if need be. } } public static void UpdateAndDraw(SpriteBatch sb) { - //Don't do anything if not open + // Don't do anything if not open. if (!Open) return; - //Draw center circle + // Draw center circle DrawCircle(sb, CenterPoint, 0, CircleStyle.Normal); Vector2 centerToMouse = Main.MouseScreen - CenterPoint; float rotation = centerToMouse.ToRotation(); - //Draw the arrow that points towards the mouse + // Draw the arrow that points towards the mouse. sb.Draw(CircleTextures, CenterPoint, new Rectangle(0, CircleTextureSize, 24, 10), Color.White, rotation, new Vector2(12, 5f), 1f, SpriteEffects.None, 0f); int current = 0; int selectedCircle = -1; + int offset = CircleOffset * 2; + int radius = CircleTextureSize / 2; + for (int x = 0; x < 2; x++) { for (int y = 0; y < 2; y++) { Vector2 center = new Vector2( - CenterPoint.X - CircleOffset + x * CircleOffset * 2, - CenterPoint.Y - CircleOffset + y * CircleOffset * 2); + CenterPoint.X - CircleOffset + x * offset, + CenterPoint.Y - CircleOffset + y * offset); - Circle c = new Circle(center, CircleTextureSize / 2); + Circle c = new Circle(center, radius); CircleStyle style = CircleStyle.Normal; - //If the mouse is in the circle + // If the mouse is in the circle. if (c.Contains(Main.MouseScreen)) { style = CircleStyle.Selected; @@ -97,7 +100,7 @@ namespace CalamityMod.UI selectedCircle = current; - //If left clicked + // If left clicked. if ((Main.mouseLeft && Main.mouseLeftRelease)) { Main.mouseLeftRelease = false; @@ -113,7 +116,7 @@ namespace CalamityMod.UI } } - //Literally so the sound plays + // Literally so the sound plays. if (LastHovered != selectedCircle) { LastHovered = selectedCircle; diff --git a/UI/BossHealthBarManager.cs b/UI/BossHealthBarManager.cs index 94f6ae7b6a..82f4d3e09b 100644 --- a/UI/BossHealthBarManager.cs +++ b/UI/BossHealthBarManager.cs @@ -695,10 +695,12 @@ namespace CalamityMod.UI { float pulse = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 4.5f) * 0.5f + 0.5f; float outwardness = EnrageTimer / (float)EnrageAnimationTime * 1.5f + pulse * 2f; + Color color1 = Color.Red * 0.6f; + Color color2 = Color.Black * 0.2f; for (int i = 0; i < 4; i++) { Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * outwardness; - CalamityUtils.DrawBorderStringEightWay(sb, FontAssets.MouseText.Value, name, new Vector2(x + BarMaxWidth - nameSize.X, y + 23 - nameSize.Y) + drawOffset, Color.Red * 0.6f, Color.Black * 0.2f); + CalamityUtils.DrawBorderStringEightWay(sb, FontAssets.MouseText.Value, name, new Vector2(x + BarMaxWidth - nameSize.X, y + 23 - nameSize.Y) + drawOffset, color1, color2); } } } @@ -708,10 +710,12 @@ namespace CalamityMod.UI { float pulse = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 4.5f) * 0.5f + 0.5f; float outwardness = IncreasingDefenseOrDRTimer / (float)IncreasedDefenseOrDRAnimationTime * 1.5f + pulse * 2f; + Color color1 = Color.LightGray * 0.6f; + Color color2 = Color.Black * 0.2f; for (int i = 0; i < 4; i++) { Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * outwardness; - CalamityUtils.DrawBorderStringEightWay(sb, FontAssets.MouseText.Value, name, new Vector2(x + BarMaxWidth - nameSize.X, y + 23 - nameSize.Y) + drawOffset, Color.LightGray * 0.6f, Color.Black * 0.2f); + CalamityUtils.DrawBorderStringEightWay(sb, FontAssets.MouseText.Value, name, new Vector2(x + BarMaxWidth - nameSize.X, y + 23 - nameSize.Y) + drawOffset, color1, color2); } } } diff --git a/UI/CalamitasEnchantments/CalamitasEnchantUI.cs b/UI/CalamitasEnchantments/CalamitasEnchantUI.cs index e3a00ad00d..9eaeb4654f 100644 --- a/UI/CalamitasEnchantments/CalamitasEnchantUI.cs +++ b/UI/CalamitasEnchantments/CalamitasEnchantUI.cs @@ -188,9 +188,10 @@ namespace CalamityMod.UI.CalamitasEnchants costDrawPositionTopLeft.X += (int)((FontAssets.MouseText.Value.MeasureString(costText).X * 0.5f + 12f) * Main.UIScale); int[] coinsArray = Utils.CoinsSplit(cost); + float y = costDrawPositionTopLeft.Y + 54f * Main.UIScale; for (int i = 0; i < 4; i++) { - Vector2 drawPosition = new Vector2(costDrawPositionTopLeft.X + (ChatManager.GetStringSize(FontAssets.MouseText.Value, costText, Vector2.One, -1f).X + ((24 * i) - 24f)) * Main.UIScale, costDrawPositionTopLeft.Y + 54f * Main.UIScale); + Vector2 drawPosition = new Vector2(costDrawPositionTopLeft.X + (ChatManager.GetStringSize(FontAssets.MouseText.Value, costText, Vector2.One, -1f).X + ((24 * i) - 24f)) * Main.UIScale, y); spriteBatch.Draw(TextureAssets.Item[ItemID.PlatinumCoin - i].Value, drawPosition, null, Color.White, 0f, TextureAssets.Item[ItemID.PlatinumCoin - i].Size() * 0.5f, Main.UIScale, SpriteEffects.None, 0f); Utils.DrawBorderStringFourWay(spriteBatch, FontAssets.ItemStack.Value, coinsArray[3 - i].ToString(), drawPosition.X - 11f, drawPosition.Y, Color.White, Color.Black, new Vector2(0.3f), 0.75f * Main.UIScale); } diff --git a/UI/DraedonLogs/DraedonsLogGUI.cs b/UI/DraedonLogs/DraedonsLogGUI.cs index 89bfd6a208..e14730ab4f 100644 --- a/UI/DraedonLogs/DraedonsLogGUI.cs +++ b/UI/DraedonLogs/DraedonsLogGUI.cs @@ -61,23 +61,15 @@ namespace CalamityMod.UI.DraedonLogs float yPageTop = MathHelper.Lerp(Main.screenHeight * 2, Main.screenHeight * 0.25f, FadeTime / (float)FadeTimeMax); Rectangle mouseRectangle = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 2, 2); + float drawPositionX = Main.screenWidth * 0.5f; + Vector2 drawPosition = new Vector2(drawPositionX, yPageTop); + Rectangle pageRectangle = new Rectangle((int)drawPosition.X - (int)(pageTexture.Width * scale.X), (int)yPageTop, (int)(pageTexture.Width * scale.X) * 2, (int)(pageTexture.Height * scale.Y)); for (int i = 0; i < 2; i++) { - Vector2 drawPosition = new Vector2(Main.screenWidth * 0.5f, yPageTop); - spriteBatch.Draw(pageTexture, - drawPosition, - null, - Color.White, - 0f, - new Vector2(i == 0f ? pageTexture.Width : 0f, 0f), - scale, - i == 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, - 0f); + spriteBatch.Draw(pageTexture, drawPosition, null, Color.White, 0f, new Vector2(i == 0f ? pageTexture.Width : 0f, 0f), scale, i == 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); + if (!HoveringOverBook) - { - Rectangle pageRectangle = new Rectangle((int)drawPosition.X - (int)(pageTexture.Width * scale.X), (int)yPageTop, (int)(pageTexture.Width * scale.X) * 2, (int)(pageTexture.Height * scale.Y)); HoveringOverBook = mouseRectangle.Intersects(pageRectangle); - } } // Create text and arrows. @@ -100,24 +92,19 @@ namespace CalamityMod.UI.DraedonLogs Page = TotalPages; DrawArrows(spriteBatch, xResolutionScale, yResolutionScale, yPageTop + 506f * yResolutionScale, mouseRectangle); + + int textDrawPositionX = (int)(pageTexture.Width * xResolutionScale + 350 * xResolutionScale); + int yScale = (int)(42 * yResolutionScale); + int yScale2 = (int)(yOffsetPerLine * yResolutionScale); for (int i = 0; i < dialogLines.Count; i++) { if (dialogLines[i] != null) { - int textDrawPositionX = (int)(pageTexture.Width * xResolutionScale + 350 * xResolutionScale); - int textDrawPositionY = (int)(42 * yResolutionScale) + i * (int)(yOffsetPerLine * yResolutionScale) + (int)yPageTop; - - Utils.DrawBorderStringFourWay(spriteBatch, - FontAssets.MouseText.Value, - dialogLines[i], - textDrawPositionX, - textDrawPositionY, - Color.DarkCyan, - Color.Black, - Vector2.Zero, - xResolutionScale); + int textDrawPositionY = yScale + i * yScale2 + (int)yPageTop; + Utils.DrawBorderStringFourWay(spriteBatch, FontAssets.MouseText.Value, dialogLines[i], textDrawPositionX, textDrawPositionY, Color.DarkCyan, Color.Black, Vector2.Zero, xResolutionScale); } } + DrawSpecialImage(spriteBatch, xResolutionScale, yResolutionScale, yPageTop - 70f * yResolutionScale); } } diff --git a/UI/DraedonsArsenal/LabHologramProjectorUI.cs b/UI/DraedonsArsenal/LabHologramProjectorUI.cs index 967fcd109c..a1e3263a62 100644 --- a/UI/DraedonsArsenal/LabHologramProjectorUI.cs +++ b/UI/DraedonsArsenal/LabHologramProjectorUI.cs @@ -83,14 +83,14 @@ namespace CalamityMod.UI.DraedonsArsenal Vector2.Zero, 1f, SpriteEffects.None, 0f); // Draw the dialogue itself. + float x = (int)TextPadding + (int)(Main.screenWidth - TextAreaWidth) / 2; for (int i = 0; i < lineCount + 1; i++) { string text = dialogLines[i]; if (text is null) continue; - Utils.DrawBorderStringFourWay(spriteBatch, FontAssets.MouseText.Value, dialogLines[i], - (int)TextPadding + (int)(Main.screenWidth - TextAreaWidth) / 2, 120 + i * YOffsetPerLine, Color.Cyan, Color.Black, - Vector2.Zero); + + Utils.DrawBorderStringFourWay(spriteBatch, FontAssets.MouseText.Value, dialogLines[i], x, 120 + i * YOffsetPerLine, Color.Cyan, Color.Black, Vector2.Zero); } } } diff --git a/UI/ModeIndicator/ModeIndicatorUI.cs b/UI/ModeIndicator/ModeIndicatorUI.cs index 7bb61f7a36..90c6b4b05d 100644 --- a/UI/ModeIndicator/ModeIndicatorUI.cs +++ b/UI/ModeIndicator/ModeIndicatorUI.cs @@ -18,6 +18,7 @@ using Terraria.GameInput; using Terraria.UI.Chat; using System.Text.RegularExpressions; using static Terraria.GameContent.FontAssets; +using System.Runtime.InteropServices; namespace CalamityMod.UI.ModeIndicator { @@ -310,35 +311,39 @@ namespace CalamityMod.UI.ModeIndicator text = string.Empty; bool modeHovered = false; + Vector2 positionOffset = (barLength / (float)(tiers + 1f)) * Vector2.UnitY; + float progressMult = 0.8f * progress; + Color progressColor = Color.White * progress; for (int i = 0; i < tiers; i++) { int modesAtTier = DifficultyTiers[i].Length; + float width = WidthForTier(modesAtTier) * 0.5f; for (int j = 0; j < modesAtTier; j++) { DifficultyMode mode = DifficultyTiers[i][j]; Texture2D hexIcon = mode.Texture.Value; + Vector2 hexIconSize = hexIcon.Size(); - //Get position - Vector2 iconPosition = basePosition + (barLength / (float)(tiers + 1f)) * Vector2.UnitY * i; + // Get position. + Vector2 iconPosition = basePosition + positionOffset * i; if (modesAtTier > 1) - iconPosition += Vector2.UnitX * MathHelper.Lerp(WidthForTier(modesAtTier) * -0.5f, WidthForTier(modesAtTier) * 0.5f, j / (float)(modesAtTier - 1)) * BarWidthExpansionProgress; + iconPosition += Vector2.UnitX * MathHelper.Lerp(width * -1f, width, j / (float)(modesAtTier - 1)) * BarWidthExpansionProgress; - bool hovered = MouseScreenArea.Intersects(Utils.CenteredRectangle(iconPosition, hexIcon.Size())); + bool hovered = MouseScreenArea.Intersects(Utils.CenteredRectangle(iconPosition, hexIconSize)); float usedOpacity = mode.Enabled ? 0.85f : 0.55f; - if (hovered) usedOpacity = MathHelper.Lerp(usedOpacity, 1f, 0.7f); - //outline the currently selected difficulty. + // Outline the currently selected difficulty. if (mode == GetCurrentDifficulty) { usedOpacity = 1f; - spriteBatch.Draw(outlineTexture, iconPosition, null, mode.ChatTextColor * 0.8f * progress, 0f, outlineTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f); + spriteBatch.Draw(outlineTexture, iconPosition, null, mode.ChatTextColor * progressMult, 0f, outlineTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f); } - spriteBatch.Draw(hexIcon, iconPosition, null, Color.White * usedOpacity * progress, 0f, hexIcon.Size() * 0.5f, 1f, SpriteEffects.None, 0f); + spriteBatch.Draw(hexIcon, iconPosition, null, progressColor * usedOpacity, 0f, hexIconSize * 0.5f, 1f, SpriteEffects.None, 0f); if (menuOpenTransitionTime == 0 && hovered) { @@ -376,10 +381,10 @@ namespace CalamityMod.UI.ModeIndicator string text = "\n" + mode.ShortDescription.ToString(); - //Not scuffed anymore + // Not scuffed anymore. if (mode.ExpandedDescription != LocalizedText.Empty) { - //Show the description either if the player is holding shift. + // Show the description either if the player is holding shift. if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift)) text += "\n" + mode.ExpandedDescription.ToString(); @@ -393,47 +398,45 @@ namespace CalamityMod.UI.ModeIndicator public static void SwitchToDifficulty(DifficultyMode mode) { //No swap on server (although this doesn't matter anymore since it's not an item but dnc. - //No swap if the requested difficulty is the same as the current one + //No swap if the requested difficulty is the same as the current one. if (mode == GetCurrentDifficulty) return; - //Todo, maybe in the future having a way to have multiple difficulty options on the same tier that can coexist, and it works in branching pathes? Not very necessary for cal & addons - //But would be super useful so other mods can let their own difficulties go there. + // Todo, maybe in the future having a way to have multiple difficulty options on the same tier that can coexist, and it works in branching pathes? Not very necessary for cal & addons. + // But would be super useful so other mods can let their own difficulties go there. - //Disable difficulties + // Disable difficulties. for (int i = 0; i < Difficulties.Length; i++) { - //Disable all difficulties at the same tier / at a tier above itself + // Disable all difficulties at the same tier / at a tier above itself. if (Difficulties[i]._difficultyTier >= mode._difficultyTier && Difficulties[i] != mode) { if (Difficulties[i].Enabled) { if (Difficulties[i].DeactivationTextKey != string.Empty) DisplayLocalizedText(Difficulties[i].DeactivationTextKey, Difficulties[i].ChatTextColor); + Difficulties[i].Enabled = false; } } } - //Look at all the lower tiers. + // Look at all the lower tiers. for (int i = 0; i < mode._difficultyTier; i++) { - //If there are no alternate difficulties at that tier, no need to ask, just choose that one. + // If there are no alternate difficulties at that tier, no need to ask, just choose that one. if (DifficultyTiers[i].Length == 1) { DifficultyTiers[i][0].Enabled = true; - } - - //if there are alternate difficulties, we ask nicely to know which one is the preffered one. + } + // If there are alternate difficulties, we ask nicely to know which one is the preffered one. else { - //First off, disable them all to avoid conflicts if one was already selected before. + // First off, disable them all to avoid conflicts if one was already selected before. for (int j = 0; j < DifficultyTiers[i].Length; j++) - { DifficultyTiers[i][j].Enabled = false; - } - //Enable the one favored by the mode. + // Enable the one favored by the mode. DifficultyTiers[i][mode.FavoredDifficultyAtTier(i)].Enabled = true; } } diff --git a/Utilities/CalamityRecipes.cs b/Utilities/CalamityRecipes.cs index 42091111ee..84df43188b 100644 --- a/Utilities/CalamityRecipes.cs +++ b/Utilities/CalamityRecipes.cs @@ -1798,11 +1798,6 @@ namespace CalamityMod r.AddTile(TileID.CrystalBall); r.Register(); - // Turtle Shell with Giant Tortoise Shell - r = Recipe.Create(ItemID.TurtleShell); - r.AddIngredient(ModContent.ItemType()); - r.Register(); - // Pulse Bow r = Recipe.Create(ItemID.PulseBow); r.AddIngredient(ItemID.ShroomiteBar, 16); diff --git a/Utilities/CollisionUtils.cs b/Utilities/CollisionUtils.cs index f8b02121b2..bdfb95b8ea 100644 --- a/Utilities/CollisionUtils.cs +++ b/Utilities/CollisionUtils.cs @@ -75,6 +75,7 @@ namespace CalamityMod if (WorldGen.SolidTile(tile) || (checkDirection.Y >= 0f && tile.HasTile && Main.tileSolidTop[tile.TileType])) return i; } + return null; } } diff --git a/Utilities/DrawingUtils.cs b/Utilities/DrawingUtils.cs index 690ebe06ac..8e7d8da452 100644 --- a/Utilities/DrawingUtils.cs +++ b/Utilities/DrawingUtils.cs @@ -73,6 +73,7 @@ namespace CalamityMod if (CalamityConfig.Instance.Afterimages) { Vector2 centerOffset = drawCentered ? proj.Size / 2f : Vector2.Zero; + Color alphaColor = proj.GetAlpha(lightColor); switch (mode) { // Standard afterimages. No customizable features other than total afterimage count. @@ -82,7 +83,7 @@ namespace CalamityMod { Vector2 drawPos = proj.oldPos[i] + centerOffset - Main.screenPosition + new Vector2(0f, proj.gfxOffY); // DO NOT REMOVE THESE "UNNECESSARY" FLOAT CASTS. THIS WILL BREAK THE AFTERIMAGES. - Color color = proj.GetAlpha(lightColor) * ((float)(proj.oldPos.Length - i) / (float)proj.oldPos.Length); + Color color = alphaColor * ((float)(proj.oldPos.Length - i) / (float)proj.oldPos.Length); Main.spriteBatch.Draw(texture, drawPos, new Rectangle?(rectangle), color, rotation, origin, scale, spriteEffects, 0f); } break; @@ -92,7 +93,7 @@ namespace CalamityMod case 1: // Safety check: the loop must increment int increment = Math.Max(1, typeOneIncrement); - Color drawColor = proj.GetAlpha(lightColor); + Color drawColor = alphaColor; int afterimageCount = ProjectileID.Sets.TrailCacheLength[proj.type]; float afterimageColorCount = (float)afterimageCount * 1.5f; int k = 0; @@ -120,7 +121,7 @@ namespace CalamityMod Vector2 drawPos = proj.oldPos[i] + centerOffset - Main.screenPosition + new Vector2(0f, proj.gfxOffY); // DO NOT REMOVE THESE "UNNECESSARY" FLOAT CASTS. THIS WILL BREAK THE AFTERIMAGES. - Color color = proj.GetAlpha(lightColor) * ((float)(proj.oldPos.Length - i) / (float)proj.oldPos.Length); + Color color = alphaColor * ((float)(proj.oldPos.Length - i) / (float)proj.oldPos.Length); Main.spriteBatch.Draw(texture, drawPos, new Rectangle?(rectangle), color, afterimageRot, origin, scale, sfxForThisAfterimage, 0f); } break; diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index 5197f0a9b8..452c1edf1d 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -226,10 +226,9 @@ namespace CalamityMod { if (player.inventory[item].pick <= 0) continue; + if (player.inventory[item].pick > highestPickPower) - { highestPickPower = player.inventory[item].pick; - } } return highestPickPower; @@ -256,23 +255,25 @@ namespace CalamityMod /// How many tiles above every checked tile are checked for non-solid ground public static bool CheckSolidGround(this Player player, int solidGroundAhead = 0, int airExposureNeeded = 0) { - if (player.velocity.Y != 0) //Player gotta be standing still in any case + if (player.velocity.Y != 0) // Player gotta be standing still in any case. return false; Tile checkedTile; bool ConditionMet = true; - for (int i = 0; i <= solidGroundAhead; i++) //Check i tiles in front of the player + int playerCenterX = (int)player.Center.X / 16; + int playerCenterY = (int)(player.position.Y + (float)player.height - 1f) / 16 + 1; + for (int i = 0; i <= solidGroundAhead; i++) // Check i tiles in front of the player. { - ConditionMet = Main.tile[(int)player.Center.X / 16 + player.direction * i, (int)(player.position.Y + (float)player.height - 1f) / 16 + 1].IsTileSolidGround(); + ConditionMet = Main.tile[playerCenterX + player.direction * i, playerCenterY].IsTileSolidGround(); if (!ConditionMet) return ConditionMet; - for (int j = 1; j <= airExposureNeeded; j++) //Check j tiles ontop of each checked tiles for non-solid ground + for (int j = 1; j <= airExposureNeeded; j++) // Check j tiles ontop of each checked tiles for non-solid ground. { - checkedTile = Main.tile[(int)player.Center.X / 16 + player.direction * i, (int)(player.position.Y + (float)player.height - 1f) / 16 + 1 - j]; + checkedTile = Main.tile[playerCenterX + player.direction * i, playerCenterY - j]; - ConditionMet = !(checkedTile != null && checkedTile.HasUnactuatedTile && Main.tileSolid[checkedTile.TileType]); //IsTileSolidGround minus the ground part, to avoid platforms and other half solid tiles messing it up + ConditionMet = !(checkedTile != null && checkedTile.HasUnactuatedTile && Main.tileSolid[checkedTile.TileType]); // IsTileSolidGround minus the ground part, to avoid platforms and other half solid tiles messing it up. if (!ConditionMet) return ConditionMet; } @@ -283,6 +284,7 @@ namespace CalamityMod #region Location and Biomes public static bool IsUnderwater(this Player player) => Collision.DrownCollision(player.position, player.width, player.height, player.gravDir); + public static bool InSpace(this Player player) { float x = Main.maxTilesX / 4200f; @@ -290,10 +292,15 @@ namespace CalamityMod float spaceGravityMult = (float)((player.position.Y / 16f - (60f + 10f * x)) / (Main.worldSurface / 6.0)); return spaceGravityMult < 1f; } + public static bool PillarZone(this Player player) => player.ZoneTowerStardust || player.ZoneTowerSolar || player.ZoneTowerVortex || player.ZoneTowerNebula; + public static bool InCalamity(this Player player) => player.Calamity().ZoneCalamity; + public static bool InSunkenSea(this Player player) => player.Calamity().ZoneSunkenSea; + public static bool InSulphur(this Player player) => player.Calamity().ZoneSulphur; + public static bool InAstral(this Player player, int biome = 0) //1 is above ground, 2 is underground, 3 is desert { switch (biome) @@ -311,6 +318,7 @@ namespace CalamityMod return player.Calamity().ZoneAstral; } } + public static bool InAbyss(this Player player, int layer = 0) { switch (layer) @@ -390,6 +398,7 @@ namespace CalamityMod for (int i = 0; i < player.hurtCooldowns.Length; ++i) if (player.hurtCooldowns[i] < frames) player.hurtCooldowns[i] = frames; + return true; } diff --git a/Utilities/ProjectileUtils.cs b/Utilities/ProjectileUtils.cs index f2126c15f8..926bee0dd5 100644 --- a/Utilities/ProjectileUtils.cs +++ b/Utilities/ProjectileUtils.cs @@ -479,6 +479,8 @@ namespace CalamityMod maxTrailPoints = (int)projectile.localAI[0]; Vector2 cumulativeOffset = Vector2.Zero; + Color alpha = projectile.GetAlpha(lightColor); + float fixedRotation = projectile.rotation + MathHelper.PiOver2; for (int i = 1; i <= (int)projectile.localAI[0]; i++) { Vector2 velToUseThisIter = projectile.velocity; @@ -493,10 +495,9 @@ namespace CalamityMod } } cumulativeOffset += Vector2.Normalize(velToUseThisIter) * spacer; - Color color = projectile.GetAlpha(lightColor); + Color color = alpha; color *= (maxTrailPoints - (float)i) / maxTrailPoints; color.A = 0; - float fixedRotation = projectile.rotation + MathHelper.PiOver2; Main.spriteBatch.Draw(texture, drawPos - cumulativeOffset, null, color, fixedRotation, origin, projectile.scale, spriteEffects, 0f); } } @@ -548,9 +549,10 @@ namespace CalamityMod float time = Main.player[projectile.owner].miscCounter % 216000f / 60f; Color outerColor = outer * 0.2f; outerColor.A = 0; + float rotation = MathHelper.TwoPi * time; for (int o = 0; o < 6; o += 2) { - Vector2 spinStart = drawStartOuter + spinPoint.RotatedBy(MathHelper.TwoPi * time - MathHelper.Pi * o / 3f); + Vector2 spinStart = drawStartOuter + spinPoint.RotatedBy(rotation - MathHelper.Pi * o / 3f); float scaleMultOuter = 1.5f - o * 0.1f; Main.EntitySpriteDraw(aura, spinStart, auraRec, outerColor, auraRotation, auraOrigin, scaleMultOuter, SpriteEffects.None, 0); } @@ -565,9 +567,8 @@ namespace CalamityMod scaleMult = (scaleMult + i) % 1f; float colorMult = scaleMult * 2f; if (colorMult > 1f) - { colorMult = 2f - colorMult; - } + Main.EntitySpriteDraw(aura, drawStartInner, auraRec, innerColor * colorMult, auraRotation, auraOrigin, 0.3f + scaleMult * 0.5f, SpriteEffects.None, 0); } } @@ -596,11 +597,13 @@ namespace CalamityMod } bool canKillWalls = false; + float projectilePositionX = projectile.position.X / 16f; + float projectilePositionY = projectile.position.Y / 16f; for (int x = minTileX; x <= maxTileX; x++) { for (int y = minTileY; y <= maxTileY; y++) { - Vector2 explodeArea = new Vector2(Math.Abs(x - projectile.position.X / 16f), Math.Abs(y - projectile.position.Y / 16f)); + Vector2 explodeArea = new Vector2(Math.Abs(x - projectilePositionX), Math.Abs(y - projectilePositionY)); float distance = explodeArea.Length(); if (distance < explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].WallType == WallID.None) { @@ -644,7 +647,7 @@ namespace CalamityMod Tile tile = Main.tile[i, j]; bool t = 1 == 1; bool f = 1 == 2; - Vector2 explodeArea = new Vector2(Math.Abs(i - projectile.position.X / 16f), Math.Abs(j - projectile.position.Y / 16f)); + Vector2 explodeArea = new Vector2(Math.Abs(i - projectilePositionX), Math.Abs(j - projectilePositionY)); float distance = explodeArea.Length(); if (distance < explosionRadius) { @@ -654,14 +657,11 @@ namespace CalamityMod if (checkExplosions) { if (Main.tileDungeon[tile.TileType] || explosionCheckList.Contains(tile.TileType)) - { canKillTile = false; - } if (!TileLoader.CanExplode(i, j)) - { canKillTile = false; - } } + if (Main.tileContainer[tile.TileType]) canKillTile = false; if (!TileLoader.CanKillTile(i, j, tile.TileType, ref t) || !TileLoader.CanKillTile(i, j, tile.TileType, ref f)) @@ -673,11 +673,10 @@ namespace CalamityMod { WorldGen.KillTile(i, j, false, false, false); if (!tile.HasTile && Main.netMode != NetmodeID.SinglePlayer) - { NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, i, j, 0f, 0, 0, 0); - } } } + if (canKillTile) { for (int x = i - 1; x <= i + 1; x++) @@ -689,13 +688,12 @@ namespace CalamityMod canExplode = WallLoader.CanExplode(x, y, Main.tile[x, y].WallType); if (wallExcludeList.Any() && wallExcludeList.Contains(Main.tile[x, y].WallType)) canKillWalls = false; + if (Main.tile[x, y] != null && Main.tile[x, y].WallType > WallID.None && canKillWalls && canExplode) { WorldGen.KillWall(x, y, false); if (Main.tile[x, y].WallType == WallID.None && Main.netMode != NetmodeID.SinglePlayer) - { NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 2, x, y, 0f, 0, 0, 0); - } } } } diff --git a/Utilities/TileFraming.cs b/Utilities/TileFraming.cs index b621f6a70c..81c30b5627 100644 --- a/Utilities/TileFraming.cs +++ b/Utilities/TileFraming.cs @@ -206,8 +206,10 @@ namespace CalamityMod return false; for (int i = 0; i < PlantCheckAgainst[plant].Length; ++i) + { if (PlantCheckAgainst[plant][i] == check) return false; + } return true; } diff --git a/Utilities/TileUtils.cs b/Utilities/TileUtils.cs index 24df06d0a1..543f728b5b 100644 --- a/Utilities/TileUtils.cs +++ b/Utilities/TileUtils.cs @@ -62,18 +62,16 @@ namespace CalamityMod { if (xIter < 0 || xIter >= Main.maxTilesX) continue; + for (int yIter = y - 1; yIter <= y + 1; yIter++) { if (yIter < 0 || yIter >= Main.maxTilesY) continue; + if (xIter == x && yIter == y) - { WorldGen.TileFrame(x, y, resetFrame, false); - } else - { WorldGen.TileFrame(xIter, yIter, false, false); - } } } } @@ -82,31 +80,27 @@ namespace CalamityMod { int x = i - Main.tile[i, j].TileFrameX / 18 % tileX; int y = j - Main.tile[i, j].TileFrameY / 18 % tileY; + int tileXX18 = 18 * tileX; for (int l = x; l < x + tileX; l++) { for (int m = y; m < y + tileY; m++) { if (Main.tile[l, m].HasTile && Main.tile[l, m].TileType == type) { - if (Main.tile[l, m].TileFrameX < (18 * tileX)) - { - Main.tile[l, m].TileFrameX += (short)(18 * tileX); - } + if (Main.tile[l, m].TileFrameX < tileXX18) + Main.tile[l, m].TileFrameX += (short)(tileXX18); else - { - Main.tile[l, m].TileFrameX -= (short)(18 * tileX); - } + Main.tile[l, m].TileFrameX -= (short)(tileXX18); } } } + if (Wiring.running) { for (int k = 0; k < tileX; k++) { for (int l = 0; l < tileY; l++) - { Wiring.SkipWire(x + k, y + l); - } } } } @@ -121,12 +115,13 @@ namespace CalamityMod int yOffset = TileObjectData.GetTileData(tile).DrawYOffset; ulong num190 = Main.TileFrameSeed ^ (ulong)((long)j << 32 | (long)(uint)i); - + float drawPositionX = i * 16 - (int)Main.screenPosition.X - (width - 16f) / 2f; + float drawPositionY = j * 16 - (int)Main.screenPosition.Y; for (int c = 0; c < 7; c++) { float shakeX = Utils.RandomInt(ref num190, -10, 11) * 0.15f; float shakeY = Utils.RandomInt(ref num190, -10, 1) * 0.35f; - Main.spriteBatch.Draw(flameTexture, new Vector2(i * 16 - (int)Main.screenPosition.X - (width - 16f) / 2f + shakeX, j * 16 - (int)Main.screenPosition.Y + shakeY + yOffset) + zero, new Rectangle(tile.TileFrameX + offsetX, tile.TileFrameY + offsetY, width, height), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(flameTexture, new Vector2(drawPositionX + shakeX, drawPositionY + shakeY + yOffset) + zero, new Rectangle(tile.TileFrameX + offsetX, tile.TileFrameY + offsetY, width, height), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } } @@ -171,11 +166,13 @@ namespace CalamityMod { int width = flameTexture.Width; int height = flameTexture.Height; + float drawPositionX = item.position.X - Main.screenPosition.X + item.width * 0.5f; + float drawPositionY = item.position.Y - Main.screenPosition.Y + item.height - flameTexture.Height * 0.5f + 2f; for (int c = 0; c < 7; c++) { float shakeX = Main.rand.Next(-10, 11) * 0.15f; float shakeY = Main.rand.Next(-10, 1) * 0.35f; - Main.spriteBatch.Draw(flameTexture, new Vector2(item.position.X - Main.screenPosition.X + item.width * 0.5f + shakeX, item.position.Y - Main.screenPosition.Y + item.height - flameTexture.Height * 0.5f + 2f + shakeY), new Rectangle(0, 0, width, height), new Color(100, 100, 100, 0), 0f, default, 1f, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(flameTexture, new Vector2(drawPositionX + shakeX, drawPositionY + shakeY), new Rectangle(0, 0, width, height), new Color(100, 100, 100, 0), 0f, default, 1f, SpriteEffects.None, 0f); } } @@ -239,6 +236,7 @@ namespace CalamityMod { if (WorldGen.InWorld(i, j)) continue; + if (WorldGen.SolidTile(Framing.GetTileSafely(i, j))) return true; } @@ -254,6 +252,7 @@ namespace CalamityMod { if (!WorldGen.InWorld(i, j)) return false; + if (!WorldGen.SolidTile(Framing.GetTileSafely(i, j))) return false; } @@ -269,6 +268,7 @@ namespace CalamityMod { if (!WorldGen.InWorld(i, j)) return false; + if (!WorldGen.SolidTile(Framing.GetTileSafely(i, j))) return false; } diff --git a/Walls/VoidstoneWall.cs b/Walls/VoidstoneWall.cs index 937ec1998b..21170ca508 100644 --- a/Walls/VoidstoneWall.cs +++ b/Walls/VoidstoneWall.cs @@ -54,10 +54,11 @@ namespace CalamityMod.Walls Vector2 pos = new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero; Main.spriteBatch.Draw(TextureAssets.Wall[wallType].Value, pos + new Vector2(-8 + xOff, -8), frame, Lighting.GetColor(i, j, Color.White), 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + Color glowColor = drawcolor * 0.4f; for (int k = 0; k < 3; k++) { Vector2 offset = new Vector2(Main.rand.NextFloat(-1, 1f), Main.rand.NextFloat(-1, 1f)) * 0.2f * k; - Main.spriteBatch.Draw(GlowTexture, pos + offset + new Vector2(-8 + xOff, -8), frame, drawcolor * 0.4f, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(GlowTexture, pos + offset + new Vector2(-8 + xOff, -8), frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } } diff --git a/Walls/VoidstoneWallUnsafe.cs b/Walls/VoidstoneWallUnsafe.cs index 4f88ec3d09..a633899346 100644 --- a/Walls/VoidstoneWallUnsafe.cs +++ b/Walls/VoidstoneWallUnsafe.cs @@ -60,10 +60,11 @@ namespace CalamityMod.Walls Vector2 pos = new Vector2((i * 16 - (int)Main.screenPosition.X), (j * 16 - (int)Main.screenPosition.Y)) + zero; Main.spriteBatch.Draw(TextureAssets.Wall[wallType].Value, pos + new Vector2(-8 + xOff, -8), frame, Lighting.GetColor(i, j, Color.White), 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + Color glowColor = drawcolor * 0.4f; for (int k = 0; k < 3; k++) { - Vector2 offset = new Vector2(Main.rand.NextFloat(-1, 1f), Main.rand.NextFloat(-1, 1f)) * 0.2f * k; - Main.spriteBatch.Draw(GlowTexture, pos + offset + new Vector2(-8 + xOff, -8), frame, drawcolor * 0.4f, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + Vector2 offset = new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f)) * 0.2f * k; + Main.spriteBatch.Draw(GlowTexture, pos + offset + new Vector2(-8 + xOff, -8), frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } } diff --git a/World/Abyss.cs b/World/Abyss.cs index 58c8efe080..36921246e3 100644 --- a/World/Abyss.cs +++ b/World/Abyss.cs @@ -36,6 +36,7 @@ namespace CalamityMod.World public static bool AtLeftSideOfWorld = false; public static int AbyssChasmBottom = 0; + public static bool AbleToUnlockChests = false; //used for unlocking chests during skeletron's death and so that they cannot be opened beforehand public static void PlaceAbyss() { int x = Main.maxTilesX; diff --git a/World/UndergroundShrines.cs b/World/UndergroundShrines.cs index a508bee98e..88e7c8e8c6 100644 --- a/World/UndergroundShrines.cs +++ b/World/UndergroundShrines.cs @@ -15,6 +15,8 @@ using Terraria.ModLoader; using Terraria.WorldBuilding; using static CalamityMod.Schematics.SchematicManager; +using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.Potions; namespace CalamityMod.World { @@ -62,6 +64,22 @@ namespace CalamityMod.World new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), }; + if (Main.zenithWorld) + { + int evil = Utils.SelectRandom(WorldGen.genRand, ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType()); + contents = new List() + { + new ChestItem(ModContent.ItemType(), 1), + new ChestItem(ItemID.RottenChunk, WorldGen.genRand.Next(24, 28 + 1)), + new ChestItem(ItemID.CorruptionKey, 1), + new ChestItem(ItemID.CorruptTorch, WorldGen.genRand.Next(100, 110 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(evil, 1), + new ChestItem(ItemID.RedPotion, WorldGen.genRand.Next(1, 2 + 1)), + new ChestItem(ItemID.GasTrap,1), + }; + } + for (int i = 0; i < contents.Count; i++) { chest.item[i].SetDefaults(contents[i].Type); @@ -136,6 +154,23 @@ namespace CalamityMod.World new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), }; + //Gfb loot change + if (Main.zenithWorld) + { + //Cannot modify the return value of List.this[int] because its not a variable so gotta do this instead + contents = new List() + { + new ChestItem(ModContent.ItemType(), 1), + new ChestItem(ItemID.Vertebrae, WorldGen.genRand.Next(24, 28 + 1)), + new ChestItem(ItemID.CrimsonKey, 1), + new ChestItem(ItemID.CrimsonTorch, WorldGen.genRand.Next(100, 110 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ModContent.ItemType(), WorldGen.genRand.Next(2, 2 + 1)), + new ChestItem(ItemID.RedPotion, WorldGen.genRand.Next(1, 2 + 1)), + new ChestItem(ItemID.GasTrap, 1), + }; + } + for (int i = 0; i < contents.Count; i++) { chest.item[i].SetDefaults(contents[i].Type); @@ -211,6 +246,21 @@ namespace CalamityMod.World new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), }; + if (Main.zenithWorld) + { + int golfClub = Utils.SelectRandom(WorldGen.genRand, ItemID.GolfClubBronzeWedge, ItemID.GolfClubWedge, ItemID.GasTrap); + contents = new List() + { + new ChestItem(ModContent.ItemType(), 1), + new ChestItem(ModContent.ItemType(), WorldGen.genRand.Next(6, 8 + 1)), + new ChestItem(ItemID.DungeonDesertKey, 1), + new ChestItem(ItemID.DesertTorch, WorldGen.genRand.Next(100, 110 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ModContent.ItemType(), 1), + new ChestItem(ItemID.RedPotion, WorldGen.genRand.Next(1, 2 + 1)), + new ChestItem(golfClub, 1), //Implying that the golfer messed with the loot but forgot this, OR its trapped + }; + } for (int i = 0; i < contents.Count; i++) { @@ -267,6 +317,9 @@ namespace CalamityMod.World public static void FillGraniteShrineChest(Chest chest) { int potionType = Utils.SelectRandom(WorldGen.genRand, ItemID.EndurancePotion, ItemID.HeartreachPotion, ItemID.LifeforcePotion); + if (Main.zenithWorld) + potionType = ItemID.RedPotion; + List contents = new List() { new ChestItem(ModContent.ItemType(), 1), @@ -274,7 +327,8 @@ namespace CalamityMod.World new ChestItem(ItemID.BlueTorch, WorldGen.genRand.Next(100, 110 + 1)), new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(10, 12 + 1)), - new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), + new ChestItem(potionType, WorldGen.genRand.Next(Main.zenithWorld ? 1 : 10, (Main.zenithWorld ? 2 : 12) + 1)), + new ChestItem((Main.rand.NextBool(2) && Main.zenithWorld) ? ItemID.GasTrap : ItemID.Granite, Main.zenithWorld ? 1 : WorldGen.genRand.Next(7,15+1)), }; for (int i = 0; i < contents.Count; i++) @@ -291,7 +345,7 @@ namespace CalamityMod.World do { int placementPositionX = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.1f), (int)(Main.maxTilesX * 0.9f)); - int placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.3f), (int)(Main.maxTilesY * 0.85f)); + int placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.2f), (int)(Main.maxTilesY * 0.85f)); Point placementPoint = new Point(placementPositionX, placementPositionY); Vector2 schematicSize = new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)); @@ -308,8 +362,10 @@ namespace CalamityMod.World canGenerateInLocation = false; //The granite geode is supposed to fully float in free air. No tile replacements - if (tile.WallType == WallID.GraniteUnsafe && !tile.HasTile) - graniteWallsInArea++; + if (tile.WallType == WallID.GraniteUnsafe && !tile.HasTile && !Main.remixWorld) + graniteWallsInArea++; + else if ((tile.WallType == WallID.MarbleUnsafe || tile.TileType == TileID.Marble) && Main.remixWorld) //Get fixed boi makes it generate in marble biomes + graniteWallsInArea++; } } if (!canGenerateInLocation || graniteWallsInArea < totalTiles * 0.95f || !structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y))) @@ -324,7 +380,7 @@ namespace CalamityMod.World break; } - } while (tries <= 20000); + } while (tries <= 30000); } #endregion @@ -343,6 +399,21 @@ namespace CalamityMod.World new ChestItem(foodType, WorldGen.genRand.Next(10, 12 + 1)), }; + if (Main.zenithWorld) + { + contents = new List() + { + new ChestItem(ModContent.ItemType(), 1), + new ChestItem(ItemID.FlinxFur, WorldGen.genRand.Next(6, 8 + 1)), + new ChestItem(ItemID.FrozenKey, 1), + new ChestItem(ItemID.IceTorch, WorldGen.genRand.Next(100, 110 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ItemID.Eggnog, WorldGen.genRand.Next(10, 12 + 1)), + new ChestItem(ModContent.ItemType(), WorldGen.genRand.Next(200, 349 + 1)), + new ChestItem(Main.rand.NextBool(2) ? ItemID.GasTrap : ItemID.Marshmallow, 1) + }; + } + for (int i = 0; i < contents.Count; i++) { chest.item[i].SetDefaults(contents[i].Type); @@ -400,6 +471,8 @@ namespace CalamityMod.World public static void FillMarbleShrineChest(Chest chest) { int potionType = Utils.SelectRandom(WorldGen.genRand, ItemID.EndurancePotion, ItemID.HeartreachPotion, ItemID.LifeforcePotion); + if (Main.zenithWorld) + potionType = ItemID.RedPotion; List contents = new List() { new ChestItem(ModContent.ItemType(), 1), @@ -407,7 +480,8 @@ namespace CalamityMod.World new ChestItem(ItemID.WhiteTorch, WorldGen.genRand.Next(100, 110 + 1)), new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(10, 12 + 1)), - new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), + new ChestItem(potionType, WorldGen.genRand.Next(Main.zenithWorld ? 1 : 10, (Main.zenithWorld ? 2 : 12) + 1)), + new ChestItem((Main.rand.NextBool(2) && Main.zenithWorld) ? ItemID.GasTrap : ItemID.Marble, Main.zenithWorld ? 1 : WorldGen.genRand.Next(7,15+1)), }; for (int i = 0; i < contents.Count; i++) @@ -424,7 +498,7 @@ namespace CalamityMod.World do { int placementPositionX = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.1f), (int)(Main.maxTilesX * 0.9f)); - int placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.3f), (int)(Main.maxTilesY * 0.85f)); + int placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.2f), (int)(Main.maxTilesY * 0.85f)); Point placementPoint = new Point(placementPositionX, placementPositionY); Vector2 schematicSize = new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)); @@ -443,7 +517,9 @@ namespace CalamityMod.World //Marble biomes either have blocks or walls, occasionally both //This should be near maximum to prevent the structure from overextending - if (tile.TileType == TileID.Marble || tile.WallType == WallID.MarbleUnsafe) + if ((tile.TileType == TileID.Marble || tile.WallType == WallID.MarbleUnsafe) && !Main.zenithWorld) + marbleStuffInArea++; + else if ((tile.WallType == WallID.GraniteUnsafe || tile.TileType == TileID.Granite) && Main.zenithWorld) //Generates in granite in gfb marbleStuffInArea++; //There should be some space between the pillars so it doesn't make pillars in the middle of nowhere zone @@ -466,7 +542,7 @@ namespace CalamityMod.World break; } - } while (tries <= 20000); + } while (tries <= 30000); } #endregion @@ -475,14 +551,31 @@ namespace CalamityMod.World { int potionType = Utils.SelectRandom(WorldGen.genRand, ItemID.ShinePotion, ItemID.MiningPotion, ItemID.BuilderPotion); List contents = new List() - { + { new ChestItem(ModContent.ItemType(), 1), new ChestItem(ItemID.TruffleWorm, 3), new ChestItem(ItemID.MushroomTorch, WorldGen.genRand.Next(100, 110 + 1)), new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), - }; + }; + + // Gfb loot change + if (Main.zenithWorld) + { + //"Cannot modify the return value of List.this[int] because its not a variable" so gotta do this instead, I could add a bunch of bools but I feel this is better for how much is changed + contents = new List() + { + new ChestItem(ModContent.ItemType(), 1), + new ChestItem(ItemID.TruffleWorm, 3), + new ChestItem(ItemID.MushroomTorch, WorldGen.genRand.Next(50, 60 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(4, 6 + 1)), + new ChestItem(ModContent.ItemType(), WorldGen.genRand.Next(2, 3 + 1)), + new ChestItem(ItemID.RedPotion, WorldGen.genRand.Next(1, 2 + 1)), + new ChestItem(ItemID.GasTrap, 1) + }; + } + for (int i = 0; i < contents.Count; i++) { @@ -500,7 +593,7 @@ namespace CalamityMod.World int placementPositionX = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.2f), (int)(Main.maxTilesX * 0.8f)); int placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.2f), (int)(Main.maxTilesY * 0.85f)); - // Gfb and Dont Dig up + // Gfb and remix if (Main.remixWorld) { // Ensure that the shrine doesn't generate too close to the center of the world @@ -509,7 +602,7 @@ namespace CalamityMod.World placementPositionX = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.2f), (int)(Main.maxTilesX * 0.8f)); } while (placementPositionX > (int)(Main.maxTilesX * 0.4f) && placementPositionX < (int)(Main.maxTilesX * 0.6f)); - placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.8f), (int)(Main.maxTilesY * 0.85f)); //Mushroom layer + placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.85f), (int)(Main.maxTilesY * 0.9f)); //Mushroom layer } Point placementPoint = new Point(placementPositionX, placementPositionY); @@ -543,7 +636,7 @@ namespace CalamityMod.World { tries++; } - else if (!canGenerateInLocation && Main.remixWorld) //GFB nor dont dig up will not give a shit about mushrooms or the rectangle + else if (!canGenerateInLocation && Main.remixWorld) //GFB and remix will not give a shit about mushrooms or the rectangle { tries++; } @@ -562,14 +655,17 @@ namespace CalamityMod.World public static void FillSurfaceShrineChest(Chest chest) { int potionType = Utils.SelectRandom(WorldGen.genRand, ItemID.RecallPotion, ItemID.CalmingPotion, ItemID.SwiftnessPotion); + if (Main.zenithWorld) + potionType = ItemID.Sake; List contents = new List() { new ChestItem(ModContent.ItemType(), 1), new ChestItem(ItemID.PinkGel, WorldGen.genRand.Next(12, 15 + 1)), new ChestItem(ItemID.Torch, WorldGen.genRand.Next(50, 60 + 1)), new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(4, 6 + 1)), - new ChestItem(ItemID.LesserHealingPotion, WorldGen.genRand.Next(10, 12 + 1)), + new ChestItem(Main.zenithWorld ? ItemID.RestorationPotion : ItemID.LesserHealingPotion, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), + new ChestItem(Main.zenithWorld ? ItemID.GasTrap : ItemID.Mushroom, Main.zenithWorld ? 1 : WorldGen.genRand.Next(5,9+1)), }; for (int i = 0; i < contents.Count; i++) @@ -598,6 +694,9 @@ namespace CalamityMod.World //use Main.worldSurface and not WorldGen.WorldSurface, i believe that is why it was genning on the surface so much int placementPositionY = (int)Main.worldSurface + numTilesBelowSurface; + + if (Main.remixWorld) + placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.65f), (int)(Main.maxTilesY * 0.7f)); //above mushroom layer Point placementPoint = new Point(placementPositionX, placementPositionY); Vector2 schematicSize = new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)); @@ -632,49 +731,59 @@ namespace CalamityMod.World } else { - Point result; - Point shrineTunnelPlacementPoint = new Point(placementPoint.X + (int)(schematicSize.X * 0.5f), placementPoint.Y); - bool flag = WorldUtils.Find(shrineTunnelPlacementPoint, Searches.Chain(new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()), out result); - if (WorldUtils.Find(shrineTunnelPlacementPoint, Searches.Chain(new Searches.Up(shrineTunnelPlacementPoint.Y - result.Y), new Conditions.IsTile(TileID.Sand)), out Point _)) + if (!Main.remixWorld) // Make tunnel if its not remix or Gfb { - tries++; - } - else if (!flag) - { - tries++; - } - else - { - result.Y += numTilesBelowSurface; - - bool[] array = new bool[TileID.Sets.GeneralPlacementTiles.Length]; - for (int i = 0; i < array.Length; i++) - array[i] = TileID.Sets.GeneralPlacementTiles[i]; - - array[TileID.Containers] = false; - array[TileID.Containers2] = false; - - if (!structures.CanPlace(new Rectangle(shrineTunnelPlacementPoint.X, result.Y + 10, 1, shrineTunnelPlacementPoint.Y - result.Y - 9), array, 2)) + Point result; + Point shrineTunnelPlacementPoint = new Point(placementPoint.X + (int)(schematicSize.X * 0.5f), placementPoint.Y); + bool flag = WorldUtils.Find(shrineTunnelPlacementPoint, Searches.Chain(new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()), out result); + if (WorldUtils.Find(shrineTunnelPlacementPoint, Searches.Chain(new Searches.Up(shrineTunnelPlacementPoint.Y - result.Y), new Conditions.IsTile(TileID.Sand)), out Point _)) + { + tries++; + } + else if (!flag) { tries++; } else { - bool _ = true; - PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref _, new Action(FillSurfaceShrineChest)); - structures.AddProtectedStructure(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y), 4); + result.Y += numTilesBelowSurface; - // Generate entrance tunnel - ShapeData data = new ShapeData(); - WorldUtils.Gen(new Point(shrineTunnelPlacementPoint.X, result.Y + 10), new Shapes.Rectangle(1, shrineTunnelPlacementPoint.Y - result.Y - 9), Actions.Chain(new Modifiers.Blotches(2, 0.2), new Modifiers.SkipTiles(TileID.LivingWood, TileID.LeafBlock), new Actions.ClearTile().Output(data), new Modifiers.Expand(1), new Modifiers.OnlyTiles(TileID.Sand), new Actions.SetTile(TileID.HardenedSand).Output(data))); - WorldUtils.Gen(new Point(shrineTunnelPlacementPoint.X, result.Y + 10), new ModShapes.All(data), new Actions.SetFrames(frameNeighbors: true)); + bool[] array = new bool[TileID.Sets.GeneralPlacementTiles.Length]; + for (int i = 0; i < array.Length; i++) + array[i] = TileID.Sets.GeneralPlacementTiles[i]; - break; + array[TileID.Containers] = false; + array[TileID.Containers2] = false; + + if (!structures.CanPlace(new Rectangle(shrineTunnelPlacementPoint.X, result.Y + 10, 1, shrineTunnelPlacementPoint.Y - result.Y - 9), array, 2)) + { + tries++; + } + else + { + bool _ = true; + PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref _, new Action(FillSurfaceShrineChest)); + structures.AddProtectedStructure(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y), 4); + + // Generate entrance tunnel + ShapeData data = new ShapeData(); + WorldUtils.Gen(new Point(shrineTunnelPlacementPoint.X, result.Y + 10), new Shapes.Rectangle(1, shrineTunnelPlacementPoint.Y - result.Y - 9), Actions.Chain(new Modifiers.Blotches(2, 0.2), new Modifiers.SkipTiles(TileID.LivingWood, TileID.LeafBlock), new Actions.ClearTile().Output(data), new Modifiers.Expand(1), new Modifiers.OnlyTiles(TileID.Sand), new Actions.SetTile(TileID.HardenedSand).Output(data))); + WorldUtils.Gen(new Point(shrineTunnelPlacementPoint.X, result.Y + 10), new ModShapes.All(data), new Actions.SetFrames(frameNeighbors: true)); + + break; + } } + } else + { + bool _ = true; + PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref _, new Action(FillSurfaceShrineChest)); + structures.AddProtectedStructure(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y), 4); + break; } + } - } while (tries <= 20000); + } while (tries <= 30000); } #endregion