when life gives you lemons...

This commit is contained in:
doze-zoze committed 2026-03-05 15:51:49 -06:00
1 parent d2c73395a1
commit db1659a7a0
11 files changed
+425

No files matched your search

+70
View File
@@ -0,0 +1,70 @@
using System;
using CalamityMod.Utilities;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Dusts
{
public class LemonNadeExplodeDust : ModDust
{
public override string Texture => "CalamityMod/Particles/LemonNadeExplode";
Color RandomColor
{
get
{
switch (Main.rand.Next(4))
{
case 0: return new Color(54, 54, 54);
case 1: return new Color(76, 36, 36);
case 2: return new Color(132, 106, 56);
case 3: return new Color(50, 45, 37);
}
return Color.White;
}
}
public override void OnSpawn(Dust dust)
{
dust.color = RandomColor;
dust.dataAsFloat = 0.75f;
dust.rotation = Main.rand.NextFloat(0, MathHelper.TwoPi);
}
public override bool MidUpdate(Dust dust)
{
return true;
}
public override bool Update(Dust dust)
{
dust.dataAsFloat *= 0.96f;
dust.position += dust.velocity;
dust.velocity *= 0.925f;
dust.rotation += MathF.Sin(dust.dustIndex * 0.1f)*0.2f * dust.dataAsFloat;
if (dust.dataAsFloat <= 0.01f)
dust.active = false;
return false;
}
static Asset<Texture2D> tex;
public override bool PreDraw(Dust dust)
{
tex ??= ModContent.Request<Texture2D>("CalamityMod/Particles/LemonNadeExplode");
Main.EntitySpriteDraw(
tex.Value,
dust.position - Main.screenPosition,
null,
dust.color * dust.dataAsFloat,
dust.rotation,
tex.Size() * 0.5f,
dust.scale * 0.1f * (0.75f + 0.25f * dust.dataAsFloat),
SpriteEffects.None,
0
);
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

+56
View File
@@ -0,0 +1,56 @@
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Melee.Spears;
using CalamityMod.Projectiles.Rogue;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Rogue
{
public class LemonNade : RogueWeapon
{
public override void SetDefaults()
{
Item.width = 32;
Item.height = 32;
Item.damage = 75;
Item.DamageType = RogueDamageClass.Instance;
Item.autoReuse = true;
Item.noMelee = true;
Item.noUseGraphic = true;
Item.useTime = 30;
Item.useAnimation = 30;
Item.useStyle = ItemUseStyleID.Swing;
Item.knockBack = 3;
Item.value = CalamityGlobalItem.RarityLightRedBuyPrice;
Item.rare = ItemRarityID.LightRed;
Item.UseSound = SoundID.Item1;
Item.channel = true;
Item.shootSpeed = 13f;
Item.shoot = ModContent.ProjectileType<LemonNadeHoldout>();
}
public override float StealthVelocityMultiplier => 1f;
public override float StealthDamageMultiplier => 1f;
public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 4;
public override void HoldItem(Player player)
{
if (player.ownedProjectileCounts[Item.shoot] <= 0)
player.Calamity().rogueStealth = 0;
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
return true;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<Supernova>().
AddIngredient(ItemID.Lemon).
Register();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

@@ -1394,3 +1394,15 @@ Pumpkaboom: {
Stealth strikes throw larger pumpkins which pull enemies in before releasing a larger explosion
'''
}
LemonNade: {
DisplayName: Lemon 'nade
Tooltip:
'''
Disables normal stealth generation
Hold <left> to pull the pin and generate stealth, and release to throw
The longer it is held, the shorter the fuse once the 'nade is thrown
Stealth strikes explode into exploding lemon seeds
'Burn their house down!'
'''
}
@@ -334,3 +334,5 @@ WrathwingFireball.DisplayName: Wrathwing Fireball
WrathwingSpear.DisplayName: Wrathwing
WulfrumKnifeProj.DisplayName: Wulfrum Knife
NanoblackLightspeedCarveSlashVisual.DisplayName: Nanoblack Light-speed Carve Visuals
LemonNadeHoldout.DisplayName: Lemon 'nade
LemonNadeProjectile.DisplayName: Lemon 'nade
Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

+143
View File
@@ -0,0 +1,143 @@
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Particles;
using CalamityMod.Projectiles.BaseProjectiles;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class LemonNadeHoldout : BaseSwordHoldoutProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Rogue";
public override string Texture => "CalamityMod/Projectiles/Rogue/LemonNadeProjectile";
public override bool useMeleeSpeed => false;
public override bool useMeleeSize => false;
public override int swingWidth => 180;
public override Item BaseItem => ModContent.GetModItem(ModContent.ItemType<LemonNade>()).Item;
public override int AfterImageLength => 0;
public override int StartupTime { get; set; }
public override int CooldownTime { get; set; }
bool isChannelable = false;
int explodeTimer = 0;
public override void Defaults()
{
Projectile.width = 22; Projectile.height = 28;
Projectile.MaxUpdates = 4;
Projectile.noEnchantmentVisuals = true;
Projectile.DamageType = RogueDamageClass.Instance;
Projectile.ContinuouslyUpdateDamageStats = true;
}
public override void Spawn()
{
//This sets variables for the spear in general, as well as the secondary attack
//The secondary attack is the "default" because it was coded first
var player = Main.player[Projectile.owner];
var modplayer = player.GetModPlayer<BaseSwordHoldoutPlayer>();
StartupTime = 10;
CooldownTime = 10;
swingTime -= StartupTime + CooldownTime;
OffsetDistance = 24;
modplayer.swingNum = 0;
}
public override void AdditionalAI()
{
var player = Main.player[Projectile.owner];
var cplayer = player.Calamity();
if (Projectile.Opacity > 0)
{
cplayer.temporaryStealthMax = 10;
cplayer.temporaryStealthTimer = 2;
}
//MOVE SECONDS TO LemonNade.cs ITEM
var avgStealth = 0.8f * cplayer.stealthGenMoving + 0.2f * cplayer.stealthGenStandstill;
var explodeTimeGoal = CalamityUtils.SecondsToFrames(2) / avgStealth;
var stealthTime = explodeTimeGoal * 0.9f;
if (Projectile.FinalExtraUpdate() && inStartup)
if (explodeTimer < explodeTimeGoal)
explodeTimer++;
else
{
Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, angle * -10, ModContent.ProjectileType<LemonNadeProjectile>(), Projectile.damage, Projectile.knockBack, Projectile.owner, explodeTimer, explodeTimeGoal).hostile = true;
Projectile.Opacity = 0;
return;
}
cplayer.rogueStealth = Projectile.Opacity <= 0 ? 0 : Math.Max(cplayer.temporaryStealthMax, cplayer.rogueStealthMax) * MathHelper.Clamp(explodeTimer / stealthTime, 0f, 1f);
if (timer == 1)
{
if (!Main.dedServ)
{
SoundEngine.PlaySound(SoundID.DD2_JavelinThrowersAttack with { pitch = 1f });
Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.position, Vector2.UnitY * -8 + angle, Mod.Find<ModGore>("LemonNadePin").Type, 1);
}
}
//When channeling, the internal timer will not progress
if (player.channel && inStartup)
{
if (timer >= StartupTime - 1)
{
timer--;
Projectile.timeLeft++;
}
}
if (explodeTimer >= explodeTimeGoal && inCooldown && !Projectile.FinalExtraUpdate())
{
timer--;
Projectile.timeLeft++;
}
if (inSwing)
{
if (swingTimer == (int)(swingTime * 0.75f))
{
if (Projectile.owner == Main.myPlayer && Projectile.Opacity > 0)
{
var p = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, angle * -10, ModContent.ProjectileType<LemonNadeProjectile>(), Projectile.damage, Projectile.knockBack, Projectile.owner, explodeTimer-30, explodeTimeGoal);
if (player.Calamity().StealthStrikeAvailable())
{
p.Calamity().stealthStrike = true;
}
}
Projectile.Opacity = 0;
}
}
}
public override float SwingFunction()
{
if (inStartup)
return MathHelper.ToRadians(MathHelper.SmoothStep(swingWidth * -0.33f, swingWidth * -0.7f, MathF.Pow(StartupCompletion, 4f)));
if (inCooldown)
return MathHelper.ToRadians(MathHelper.Lerp(swingWidth * 0.2f, swingWidth * 0.33f, 1 - MathF.Pow(1 - CooldownCompletion, 3f)));
return MathHelper.ToRadians(MathHelper.SmoothStep(swingWidth * -0.7f, swingWidth * 0.2f, SwingCompletion));
}
public override bool? CanHitNPC(NPC target)
{
return false;
}
public override bool CanHitPlayer(Player target)
{
return false;
}
}
}
+134
View File
@@ -0,0 +1,134 @@
using System;
using System.Reflection.Metadata;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Dusts;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Packets.Entities;
using CalamityMod.Particles;
using CalamityMod.Projectiles.BaseProjectiles;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class LemonNadeProjectile : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Rogue";
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Type] = 3;
ProjectileID.Sets.TrailingMode[Type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 16;
Projectile.height = 16;
Projectile.friendly = true;
Projectile.tileCollide = true;
Projectile.penetrate = -1;
Projectile.MaxUpdates = 2;
Projectile.timeLeft = 300;
Projectile.DamageType = RogueDamageClass.Instance;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10;
}
public override void AI()
{
if (Projectile.ai[2] == 1)
{
Projectile.idStaticNPCHitCooldown = 2;
Projectile.usesIDStaticNPCImmunity = true;
Projectile.damage = 0;
}
Projectile.rotation += 0.175f * Projectile.direction;
if (Projectile.timeLeft < 280 && Projectile.ai[2] != 1)
Projectile.velocity.Y += 0.22f;
Projectile.ai[0]++;
if (Projectile.ai[0] > Projectile.ai[1] || Projectile.timeLeft == 2)
{
if (Projectile.ai[2] == 1)
Projectile.damage = Projectile.originalDamage;
if (Projectile.Calamity().stealthStrike)
{
var frags = 6f;
for (var i = 0; i < frags; i++)
Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.UnitY.RotatedBy(i/frags * MathHelper.TwoPi) * -10, ModContent.ProjectileType<LemonNadeProjectile>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 20,1);
}
Projectile.Resize(360, 360);
Projectile.ResetLocalNPCHitImmunity();
Projectile.damage *= 10;
Projectile.Damage();
for (var i = 0; i < 40; i++)
{
var d = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType<LemonNadeExplodeDust>(),Main.rand.NextVector2CircularEdge(15,15) * Main.rand.NextFloat(0.25f,1f),Scale:Main.rand.NextFloat(0.75f,1.25f));
}
SoundEngine.PlaySound(SoundID.Item62 with {pitch = 1f },Projectile.Center);
SoundEngine.PlaySound(SoundID.Item111 with { pitch = 0.5f }, Projectile.Center);
Projectile.Kill();
}
}
public override bool PreDraw(ref Color lightColor)
{
if (Projectile.ai[2] == 1)
{
Main.instance.LoadItem(ItemID.PumpkinSeed);
var tex = TextureAssets.Item[ItemID.PumpkinSeed];
Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, null, lightColor, Projectile.velocity.ToRotation() - MathHelper.PiOver2, tex.Size() * 0.5f, Projectile.scale,0);
return false;
}
return true;
}
public override void ModifyHitPlayer(Player target, ref Player.HurtModifiers modifiers)
{
modifiers.SourceDamage *= 0.002f;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
Projectile.velocity.X *= -0.65f;
Projectile.velocity.Y = -3f;
if (Projectile.ai[1] - Projectile.ai[0] < 30)
Projectile.ai[0] += 15;
}
// Make it bounce on tiles.
public override bool OnTileCollide(Vector2 oldVelocity)
{
// Impacts the terrain even though it bounces off.
if (Projectile.width < 100)
{
SoundEngine.PlaySound(SoundID.Dig, Projectile.Center);
Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height);
}
if (Projectile.velocity.X != oldVelocity.X)
{
Projectile.velocity.X = -oldVelocity.X;
}
if (Projectile.velocity.Y != oldVelocity.Y)
{
Projectile.velocity.Y = -oldVelocity.Y;
}
Projectile.velocity *= 0.75f;
return false;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

+8
View File
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using Terraria;
namespace CalamityMod.Utilities
@@ -7,6 +8,13 @@ namespace CalamityMod.Utilities
{
extension(Dust dust)
{
public float dataAsFloat
{
get => (float)dust.customData;
set => dust.customData = value;
}
[Obsolete("DO NOT USE. It is an unsafe fix to an even more unsafe vanilla method.")]
public static Dust BetterCloneDust(Dust rf)
{