Files
CalamityModPublic/Projectiles/Melee/DragonRageFireball.cs
T
doze-zoze 128f3d8a51 Horrible + Dragon Rage + Ale rebalance
- Horrible new stats: -33% damage, +100% size
- Ale: 15 -> 25% melee size
- Dragon Rage is 15% smaller (counterbalance the 15% boost from titan glove)
- Dragon Rage 1075 dmg -> 888 damage
- Dragon Rage has pierce falloff, every target hit within each 5 frame window takes 25% less damage (additive). Resets every 5 frames. This ignores armored targets and carries over to the explosion, but not the fireballs
- Dragon Rage fireballs 1/8 -> 1/2 damage, 60 -> 120 frame coodlown, no longer needs 10 hits to proc, and now homes in on highest HP target. Is unable to hit NPCs it is not targeting. Has tighter turning speed
- BaseSwordHoldout-based projectiles properly get all types of melee scale
2026-05-04 18:59:10 -05:00

191 lines
8.0 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Melee
{
public class DragonRageFireball : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public override string Texture => "CalamityMod/Projectiles/Rogue/DragonShit";
public NPC target;
private int lifeTime = 420;
public override void SetStaticDefaults()
{
Main.projFrames[Type] = 5;
ProjectileID.Sets.CultistIsResistantTo[Type] = true;
}
public override void SetDefaults()
{
Projectile.width = 64;
Projectile.height = 66;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.penetrate = 1;
Projectile.timeLeft = lifeTime;
Projectile.DamageType = DamageClass.Melee;
}
public override void ModifyDamageHitbox(ref Rectangle hitbox)
{
Vector2 newSize = new Point(hitbox.Width, hitbox.Height).ToVector2() * Projectile.scale;
hitbox = new Rectangle(hitbox.X - (int)((newSize.X - hitbox.Width) / 2f), hitbox.Y - (int)((newSize.Y - hitbox.Height) / 2f), (int)newSize.X, (int)newSize.Y);
}
public override void AI()
{
if (Projectile.ai[0] == 0f)
{
Projectile.ai[0] = Main.rand.NextFloat(20f, 40f);
Projectile.ai[1] = Main.rand.NextFloat(35f, 55f);
}
if (target != null && !target.CanBeChasedBy())
target = null;
if (target is null)
target = GetTargetInRange(1200f);
Projectile.frameCounter++;
if (Projectile.frameCounter > 4)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame >= Main.projFrames[Type])
{
Projectile.frame = 0;
}
Projectile.velocity *= 1.01f;
if (target != null && Projectile.timeLeft < lifeTime - 10)
{
float inertia = Projectile.ai[0];
float speed = Projectile.ai[1];
Vector2 moveDirection = Projectile.SafeDirectionTo(target.Center, Vector2.UnitY);
Projectile.velocity = (Projectile.velocity * (inertia - 1f) + moveDirection * speed) / inertia;
}
}
NPC GetTargetInRange(float range)
{
var player = Main.player[Projectile.owner];
NPC gotTarget = null;
int currentHP = -1;
float distance = range;
foreach (var npc in Main.ActiveNPCs)
{
if (Projectile.localNPCImmunity[npc.whoAmI] > 0)
continue;
var myDistance = npc.Distance(Projectile.Center);
if (npc.CanBeChasedBy() && ((myDistance < range && currentHP < npc.life) || (myDistance < distance && currentHP <= npc.life)))
{
distance = myDistance;
currentHP = npc.life;
gotTarget = npc;
}
}
return gotTarget;
}
public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, Projectile.alpha);
public override bool PreDraw(ref Color lightColor)
{
Texture2D projectileTexture = Terraria.GameContent.TextureAssets.Projectile[Type].Value;
int frameHeight = Terraria.GameContent.TextureAssets.Projectile[Type].Value.Height / Main.projFrames[Type];
int frameY = frameHeight * Projectile.frame;
Main.spriteBatch.Draw(projectileTexture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameY, projectileTexture.Width, frameHeight)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)projectileTexture.Width / 2f, (float)frameHeight / 2f), Projectile.scale, SpriteEffects.None, 0);
return false;
}
public override void OnKill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Item14, Projectile.Center);
Projectile.ExpandHitboxBy(80 * Projectile.scale);
for (int d = 0; d < 5; d++)
{
int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 100, default, 1f);
Main.dust[idx].velocity *= 3f;
if (Main.rand.NextBool())
{
Main.dust[idx].scale = 0.5f;
Main.dust[idx].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
}
}
for (int d = 0; d < 8; d++)
{
int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 100, default, 2f);
Main.dust[idx].noGravity = true;
Main.dust[idx].velocity *= 5f;
idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 100, default, 1f);
Main.dust[idx].velocity *= 2f;
}
if (!Main.dedServ)
{
Vector2 goreSource = Projectile.Center;
int goreAmt = 3;
Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f);
for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++)
{
float velocityMult = 0.33f;
if (goreIndex < (goreAmt / 3))
{
velocityMult = 0.66f;
}
if (goreIndex >= (2 * goreAmt / 3))
{
velocityMult = 1f;
}
Mod mod = ModContent.GetInstance<CalamityMod>();
int type = Main.rand.Next(61, 64);
int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f);
Gore gore = Main.gore[smoke];
gore.velocity *= velocityMult;
gore.velocity.X += 1f;
gore.velocity.Y += 1f;
type = Main.rand.Next(61, 64);
smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f);
gore = Main.gore[smoke];
gore.velocity *= velocityMult;
gore.velocity.X -= 1f;
gore.velocity.Y += 1f;
type = Main.rand.Next(61, 64);
smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f);
gore = Main.gore[smoke];
gore.velocity *= velocityMult;
gore.velocity.X += 1f;
gore.velocity.Y -= 1f;
type = Main.rand.Next(61, 64);
smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f);
gore = Main.gore[smoke];
gore.velocity *= velocityMult;
gore.velocity.X -= 1f;
gore.velocity.Y -= 1f;
}
}
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10;
Projectile.Damage();
}
public override bool? CanHitNPC(NPC target)
{
if (this.target != null && target.whoAmI != this.target.whoAmI)
return false;
return base.CanHitNPC(target);
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
target.AddBuff(ModContent.BuffType<Dragonfire>(), 120);
}
}
}