Grape Beer changes

This commit is contained in:
doze-zoze authored and Cameron Ewell committed 2026-04-07 19:25:08 -04:00
1 parent 661f305212
commit ca768f1ede
5 files changed
+56 -11

No files matched your search

-1
View File
@@ -20,7 +20,6 @@ namespace CalamityMod.Buffs.Alcohol
{
var cplayer = player.Calamity();
cplayer.grapeBeer = true;
cplayer.critDamage -= GrapeBeer.CritLoss * 0.01f;
}
}
}
+5 -3
View File
@@ -11,9 +11,11 @@ namespace CalamityMod.Items.Potions.Alcohol
public class GrapeBeer : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Potions";
public static float CritLoss = 50;
public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(CritLoss);
public static float CloseRangeDistance = 160;
public static float LongRangeDistance = 800;
public static float CloseRangeDamage = 1f;
public static float LongRangeDamage = 0.5f;
public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(LongRangeDamage,LongRangeDistance/16f);
public override void SetStaticDefaults()
{
@@ -45,7 +45,7 @@ FireballBuff: {
GrapeBeerBuff: {
DisplayName: Grape Beer
Description: Ranged projectiles gain homing, reduced critical strike damage
Description: Ranged projectiles gain homing, reduced damage to distant foes
}
ManhattanBuff: {
@@ -241,7 +241,8 @@ GrapeBeer: {
Tooltip:
'''
Bullets, Arrows, Darts, and Rockets gain homing
{0}% reduced critical strike damage
Projectiles deal less damage the further the enemy is.
This reaches a minimum of {0}x damage at {1} tiles away
{$Common.AlcoholWarning}
'''
}
+48 -5
View File
@@ -201,6 +201,15 @@ namespace CalamityMod.Projectiles
/// </summary>
public bool grapeBeer = false;
/// <summary>
/// How strong grape beer homing is on this. It speeds up the longer the target is targeted.
/// </summary>
public float grapeBeerHomingPower = 0.01f;
/// <summary>
/// ID of last target from grapebeer
/// </summary>
public int grapeBeerHomingTarget = -1;
/// <summary>
/// Variable used for storing the actual amount of extra updates a projectile has.<br/>
/// This is NOT set automatically, and must be set whenever it is needed.
@@ -327,7 +336,7 @@ namespace CalamityMod.Projectiles
void ApplyGrapeBeer()
{
grapeBeer = true;
conditionalHomingRange = 600;
conditionalHomingRange = 300;
if (projectile.timeLeft > 300 * projectile.MaxUpdates)
projectile.timeLeft = 300 * projectile.MaxUpdates;
//Calamity adds a hybrid iframe system when both local and static are set to true, so this works fine for both global and static projectiles.
@@ -4291,16 +4300,43 @@ namespace CalamityMod.Projectiles
// Grape beer-specific homing. If the projectile is aligned a certain amount to the direction to the target, it will home in.
else if (conditionalHomingRange > 0f && Main.player[projectile.owner].heldProj != projectile.whoAmI && projectile.aiStyle != ProjAIStyleID.HeldProjectile && grapeBeer)
{
NPC target = projectile.Center.ClosestNPCAt(conditionalHomingRange);
float npcDistCompare = 25000f; // Initializing the value to a large number so the first entry is basically guaranteed to replace it.
NPC target = null;
foreach (NPC n in Main.ActiveNPCs)
{
float extraDistance = (n.width / 2) + (n.height / 2);
if (!n.CanBeChasedBy(projectile, false) || !projectile.WithinRange(n.Center, conditionalHomingRange + extraDistance) || ((projectile.localNPCImmunity[n.whoAmI] > 0 || projectile.localNPCImmunity[n.whoAmI] == -1 || n.immune[projectile.owner] > 0)))
continue;
float currentNPCDist = Vector2.Distance(n.Center, projectile.Center);
if (Projectile.perIDStaticNPCImmunity[projectile.type][n.whoAmI] > Main.GameUpdateCount)
currentNPCDist += 1600; //Prioritize things that don't currently have iframes, but still home in on stuff that has static iframes if needed.
if ((currentNPCDist < npcDistCompare) && (!projectile.tileCollide || Collision.CanHit(projectile.Center, 1, 1, n.Center, 1, 1)))
{
npcDistCompare = currentNPCDist;
target = n;
}
}
if (target is not null)
{
if (grapeBeerHomingTarget == target.whoAmI)
{
grapeBeerHomingPower += 0.004f;
} else {
grapeBeerHomingPower = 0.015f;
}
HomingTarget = grapeBeerHomingTarget = target.whoAmI;
Vector2 targetDirection = projectile.SafeDirectionTo(target.Center);
float trackingSpeed = Vector2.Dot(targetDirection, projectile.velocity.SafeNormalize(Vector2.UnitX)) > 0.835f ? 0.01325f : 0f; // Delicate values, please test changes you make to them
float trackingSpeed = grapeBeerHomingPower;// Vector2.Dot(targetDirection, projectile.velocity.SafeNormalize(Vector2.UnitX)) > 0.835f ? 0.01325f : 0f; // Delicate values, please test changes you make to them
Vector2 currVelocity = projectile.velocity;
var currVelocity = projectile.velocity.Length();
if (currVelocity < 8)
currVelocity += grapeBeerHomingPower;
projectile.velocity = projectile.velocity.ToRotation().AngleTowards(targetDirection.ToRotation(), trackingSpeed).ToRotationVector2() * currVelocity.Length();
projectile.velocity = projectile.velocity.ToRotation().AngleTowards(targetDirection.ToRotation(), trackingSpeed).ToRotationVector2() * currVelocity;
}
}
@@ -4580,6 +4616,13 @@ namespace CalamityMod.Projectiles
Player player = Main.player[projectile.owner];
CalamityPlayer modPlayer = player.Calamity();
if (grapeBeer)
{
var dis = target.Distance(Main.player[projectile.owner].Center);
float remap = Utils.Remap(dis, GrapeBeer.CloseRangeDistance, GrapeBeer.LongRangeDistance, GrapeBeer.CloseRangeDamage, GrapeBeer.LongRangeDamage);
modifiers.SourceDamage *= remap;
}
// Old Fashioned buffs (or debuffs) apply if the player has Old Fashioned
// IV Drip on the Rocks inherits the same logic as Old Fashioned
if (modPlayer.oldFashioned && buffedByOldFashioned.HasValue)