diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 856bf77770..2aca24c0fd 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -5326,16 +5326,18 @@ namespace CalamityMod.CalPlayer } #endregion - if (Player.Calamity().baconOil && !Player.mount.Active) + if ((Player.Calamity().baconOil || Player.GetModPlayer().HasAlcohol(AlcoholType.BaconOil)) && !Player.mount.Active) { Player.noFallDmg = true; - + + float stackScale = (Player.Calamity().baconOil && Player.GetModPlayer().HasAlcohol(AlcoholType.BaconOil)) ? 1.33f : 1; + float velX = Math.Abs(Player.velocity.X); float velY = Math.Abs(Player.velocity.Y); float speedMult = Player.GetBestClassDamage().ApplyTo(1); - float maxMoveSpeed = 10.5f * speedMult; - float minMoveSpeed = 3; // Minimum move speed to be at if the player can bounce + float maxMoveSpeed = 10.5f * speedMult * stackScale; + float minMoveSpeed = 3 * stackScale; // Minimum move speed to be at if the player can bounce float hitboxSizeMult = 0.45f; bool onPlatform = false; @@ -5354,9 +5356,9 @@ namespace CalamityMod.CalPlayer bool hitDown = velY > minMoveSpeed && (Collision.SolidCollision(Player.Bottom + Vector2.UnitY * Player.velocity.Y, (int)(Player.width * hitboxSizeMult), 1) || onPlatform); bool hitUp = velY > minMoveSpeed && Collision.SolidCollision(Player.Top + Vector2.UnitY * Player.velocity.Y, (int)(Player.width * hitboxSizeMult), 1); bool hitSide = velX > minMoveSpeed && Collision.SolidCollision(Vector2.Lerp(Player.TopLeft, Player.Left, 0.15f) + Vector2.UnitX * Player.velocity.X, 1, (int)(Player.height * hitboxSizeMult)) || Collision.SolidCollision(Vector2.Lerp(Player.TopRight, Player.Right, 0.15f) + Vector2.UnitX * Player.velocity.X, 1, (int)(Player.height * hitboxSizeMult)); - float acceleration = 0.05f; + float acceleration = 0.05f * stackScale; float decceleration = -0.025f / speedMult; - float riseSpeed = 0.8f; // The speed the player rises when in water or rain + float riseSpeed = 0.8f * stackScale; // The speed the player rises when in water or rain float slipPower = 0.85f; //How strong the slippery effect is float bounceReduction = 0.9f; @@ -5384,7 +5386,7 @@ namespace CalamityMod.CalPlayer { if (baconOilSoundCooldown < soundCDMax) baconOilSoundCooldown += 30; - float pitch = 0.55f * Utils.GetLerpValue(0, soundCDMax, baconOilSoundCooldown, true); + float pitch = (0.55f * stackScale) * Utils.GetLerpValue(0, soundCDMax, baconOilSoundCooldown, true); SoundStyle boyoyoing = new("CalamityMod/Sounds/Item/BaconOilBounce"); SoundEngine.PlaySound(boyoyoing with { Volume = 0.45f, Pitch = hitSide ? pitch - 0.3f : pitch, MaxInstances = 5 }, Player.Center); } diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index ec21812c99..ed58cd05ea 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -190,14 +190,30 @@ namespace CalamityMod.CalPlayer #endregion #region Alcohol + var dripPlayer = Player.GetModPlayer(); + for (int l = 0; l < Player.MaxBuffs; l++) { int buff = Player.buffType[l]; - if (BuffDatasets.DebuffDataset[buff] is not null && BuffDatasets.DebuffDataset[buff].AlcoholLevel > 0) - alcoholPoisonLevel += BuffDatasets.DebuffDataset[buff].AlcoholLevel + (Player.GetModPlayer().HasAlcohol(AlcoholType.Everclear) ? 1 : 0); + if (buff <= 0) continue; + + var data = BuffDatasets.DebuffDataset[buff]; + if (data?.AlcoholLevel > 0) + alcoholPoisonLevel += data.AlcoholLevel; } - if (Player.Calamity().ivDrip) // +1 stack of poisoning while IV Drip is equipped - alcoholPoisonLevel++; + + if (dripPlayer.ivDripEquipped && dripPlayer.currentAlcohol != AlcoholType.None) + { + int ivBuffID = BuffDatasets.GetBuffIDFromAlcoholType(dripPlayer.currentAlcohol); + + if (ivBuffID != -1) + { + var ivData = BuffDatasets.DebuffDataset[ivBuffID]; + if (ivData?.AlcoholLevel > 0) + alcoholPoisonLevel += ivData.AlcoholLevel; + } + } + if (everclear) totalNegativeLifeRegen += Everclear.RegenLoss; if (Player.GetModPlayer().HasAlcohol(AlcoholType.Everclear)) @@ -347,7 +363,6 @@ namespace CalamityMod.CalPlayer } - var dripPlayer = Player.GetModPlayer(); if (dripPlayer.HasAlcohol(AlcoholType.TequilaSunrise)) { if (hadLifeRegenHinderingDebuff && !hasLifeRegenHinderingDebuff) diff --git a/DataStructures/DebuffData.cs b/DataStructures/DebuffData.cs index d76bf10843..2a70fe931f 100644 --- a/DataStructures/DebuffData.cs +++ b/DataStructures/DebuffData.cs @@ -1,5 +1,7 @@ using System; +using CalamityMod.Buffs.Alcohol; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Accessories; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -10,6 +12,7 @@ namespace CalamityMod.DataStructures [ReinitializeDuringResizeArrays] public static class BuffDatasets { + private static DebuffData Alch(int level) => new DebuffData() { AlcoholLevel = level }; public static DebuffData[] DebuffDataset = BuffID.Sets.Factory.CreateNamedSet("DebuffData") .Description("Stores DebuffData for a particular debuff") .RegisterCustomSet(null, @@ -24,8 +27,69 @@ namespace CalamityMod.DataStructures BuffID.Poisoned, DebuffData.Poisoned, BuffID.Venom, DebuffData.AcidVenom, BuffID.Electrified, DebuffData.Electrified, - BuffID.Oiled, DebuffData.Oiled + BuffID.Oiled, DebuffData.Oiled, + + BuffID.Tipsy, Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + ModContent.BuffType(), Alch(1), + + ModContent.BuffType(), Alch(2), + ModContent.BuffType(), Alch(3) ); + public static int GetBuffIDFromAlcoholType(AlcoholType type) + { + return type switch + { + AlcoholType.BaconOil => ModContent.BuffType(), + AlcoholType.BloodyMary => ModContent.BuffType(), + AlcoholType.CaribbeanRum => ModContent.BuffType(), + AlcoholType.CinnamonRoll => ModContent.BuffType(), + AlcoholType.Everclear => ModContent.BuffType(), + AlcoholType.EvergreenGin => ModContent.BuffType(), + AlcoholType.Fireball => ModContent.BuffType(), + AlcoholType.GrapeBeer => ModContent.BuffType(), + AlcoholType.Manhattan => ModContent.BuffType(), + AlcoholType.Margarita => ModContent.BuffType(), + AlcoholType.Moonshine => ModContent.BuffType(), + AlcoholType.MoscowMule => ModContent.BuffType(), + AlcoholType.OldFashioned => ModContent.BuffType(), + AlcoholType.PurpleHaze => ModContent.BuffType(), + AlcoholType.RedWine => ModContent.BuffType(), + AlcoholType.Rum => ModContent.BuffType(), + AlcoholType.Screwdriver => ModContent.BuffType(), + AlcoholType.StarBeamRye => ModContent.BuffType(), + AlcoholType.Tequila => ModContent.BuffType(), + AlcoholType.TequilaSunrise => ModContent.BuffType(), + AlcoholType.Vodka => ModContent.BuffType(), + AlcoholType.Whiskey => ModContent.BuffType(), + AlcoholType.WhiteWine => ModContent.BuffType(), + + // Vanilla treats both Ale and Sake as the "Tipsy" buff + AlcoholType.Ale => BuffID.Tipsy, + AlcoholType.Sake => BuffID.Tipsy, + + _ => -1 + }; + } } public class DebuffData { diff --git a/Items/Accessories/IVDripOnTheRocks.cs b/Items/Accessories/IVDripOnTheRocks.cs index 97aafbb425..dd58c8f289 100644 --- a/Items/Accessories/IVDripOnTheRocks.cs +++ b/Items/Accessories/IVDripOnTheRocks.cs @@ -16,6 +16,7 @@ namespace CalamityMod.Items.Accessories public enum AlcoholType { None, + BaconOil, BloodyMary, CaribbeanRum, CinnamonRoll, @@ -39,7 +40,7 @@ namespace CalamityMod.Items.Accessories Whiskey, WhiteWine, Ale, - Sake + Sake, } public interface IAlcoholItem @@ -57,14 +58,14 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { - Main.RegisterItemAnimation(Item.type, new Terraria.DataStructures.DrawAnimationVertical(1, 25)); + Main.RegisterItemAnimation(Item.type, new Terraria.DataStructures.DrawAnimationVertical(1, 26)); ItemID.Sets.AnimatesAsSoul[Item.type] = true; } public override void SetDefaults() { Item.width = 58; - Item.height = 62; + Item.height = 60; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; Item.accessory = true; @@ -189,7 +190,6 @@ namespace CalamityMod.Items.Accessories if (effectLine != null) { effectLine.Text = this.GetLocalizedValue("Empty"); - effectLine.OverrideColor = Color.Gray; } nameLine?.Hide(); return; @@ -220,7 +220,7 @@ namespace CalamityMod.Items.Accessories { Texture2D texture = TextureAssets.Item[Item.type].Value; - int frameHeight = texture.Height / 25; + int frameHeight = texture.Height / 26; int frameIndex = (int)currentAlcoholType; Rectangle targetFrame = new Rectangle(0, frameIndex * frameHeight, texture.Width, frameHeight); @@ -228,6 +228,21 @@ namespace CalamityMod.Items.Accessories spriteBatch.Draw(texture, position, targetFrame, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); return false; } + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D texture = TextureAssets.Item[Item.type].Value; + + int frameHeight = texture.Height / 26; + int frameIndex = (int)currentAlcoholType; + + Rectangle targetFrame = new Rectangle(0, frameIndex * frameHeight, texture.Width, frameHeight); + + Vector2 drawPosition = Item.position - Main.screenPosition + new Vector2(Item.width / 2, Item.height - frameHeight / 2); + Vector2 origin = targetFrame.Size() / 2f; + + spriteBatch.Draw(texture, drawPosition, targetFrame, lightColor, rotation, origin, scale, SpriteEffects.None, 0f); + return false; + } } public class IVDripPlayer : ModPlayer diff --git a/Items/Accessories/IVDripOnTheRocks.png b/Items/Accessories/IVDripOnTheRocks.png index 452d80ed70..24f80d57d7 100644 Binary files a/Items/Accessories/IVDripOnTheRocks.png and b/Items/Accessories/IVDripOnTheRocks.png differ diff --git a/Items/Potions/Alcohol/BaconOil.cs b/Items/Potions/Alcohol/BaconOil.cs index 29dd0948ff..d2f2d2a620 100644 --- a/Items/Potions/Alcohol/BaconOil.cs +++ b/Items/Potions/Alcohol/BaconOil.cs @@ -1,5 +1,6 @@ -using CalamityMod.Buffs.Alcohol; -using CalamityMod.Items.Materials; +using System; +using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Accessories; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -8,9 +9,17 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Potions.Alcohol { - public class BaconOil : ModItem, ILocalizedModType + public class BaconOil : ModItem, ILocalizedModType, IAlcoholItem { public new string LocalizationCategory => "Items.Potions"; + public LocalizedText DripEffectText => Language.GetText("Mods.CalamityMod.Items.Potions.BaconOil.DripEffect"); + public AlcoholType AlcoholVariant => AlcoholType.BaconOil; + public Action IVDripAlcoholEffect => ApplyBaconOilEffect; + + private static void ApplyBaconOilEffect(Player player, float intensity) + { + // See CalamityPlayer + } public override void SetStaticDefaults() { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index f80b7297eb..cee9d11302 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -1034,12 +1034,10 @@ IVDripOnTheRocks: { ''' [EFFECT] [NAME] - Counts as an alcohol stack toward Alcohol Poisoning - Drinking the same type of alcohol as in the IV drip does not contribute to Alcohol Poisoning + Inserted alcohols contribute toward alcohol poisoning {$Common.AlcoholWarning} [c/aaaaaa:Shift- this item in your inventory to empty its contents] [ceffect/drunk:'(drunken mumbling)'] - ''' Empty: Place an alcoholic beverage on this item in your inventory to pour its contents in CurrentAlcoholText: Filled with diff --git a/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson b/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson index dfc50640f6..d31e4bf699 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson @@ -181,6 +181,12 @@ BaconOil: { Counts as 3 alcohols for {$Buffs.AlcoholPoisoning.DisplayName} {$Common.AlcoholWarning} ''' + DripEffect: + ''' + Provides "good" mobility that scales with your damage stat boosts + Counts as 3 alcohols for {$Buffs.AlcoholPoisoning.DisplayName} + When combined with drinking Bacon Oil straight, mobility becomes zanier + ''' } BloodyMary: { @@ -242,7 +248,7 @@ Everclear: { ''' {0}% increased damage Reduces life regen by {1} HP/s and defense by {2}% - Counts as giving an additional stack of alcohol for {$Buffs.AlcoholPoisoning.DisplayName} + Counts as 2 alcohols for {$Buffs.AlcoholPoisoning.DisplayName} ''' }