Files
CalamityModPublic/Items/Accessories/ToxicHeart.cs
T
tomat 67bceff6e7 Initial dotnet format pass.
This commit formats the entire codebase according to `dotnet format` and its limited understanding of our provided `.editorconfig`.
2024-02-28 21:49:50 -08:00

70 lines
2.6 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.CalPlayer;
using CalamityMod.Items.Potions.Alcohol;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Accessories
{
public class ToxicHeart : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Accessories";
public override void SetDefaults()
{
Item.width = 28;
Item.height = 32;
Item.value = CalamityGlobalItem.Rarity8BuyPrice;
Item.rare = ItemRarityID.Yellow;
Item.accessory = true;
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
CalamityPlayer modPlayer = player.Calamity();
modPlayer.toxicHeart = true;
player.buffImmune[ModContent.BuffType<Plague>()] = true;
int plagueCounter = 0;
Lighting.AddLight((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f), 0.05f, 1f, 0.1f);
int plagueDebuff = ModContent.BuffType<Plague>();
bool shouldInflictPlague = plagueCounter % 60 == 0;
int auraDamage = (int)player.GetBestClassDamage().ApplyTo(50);
auraDamage = player.ApplyArmorAccDamageBonusesTo(auraDamage);
int random = Main.rand.Next(10);
var source = player.GetSource_Accessory(Item);
if (player.whoAmI == Main.myPlayer)
{
if (random == 0)
{
for (int l = 0; l < Main.maxNPCs; l++)
{
NPC nPC = Main.npc[l];
if (nPC.IsAnEnemy() && !nPC.dontTakeDamage && !nPC.buffImmune[plagueDebuff] && Vector2.Distance(player.Center, nPC.Center) <= 300f)
{
if (nPC.FindBuffIndex(plagueDebuff) == -1)
{
nPC.AddBuff(plagueDebuff, 120, false);
}
if (shouldInflictPlague)
{
if (player.whoAmI == Main.myPlayer)
{
Projectile.NewProjectileDirect(source, nPC.Center, Vector2.Zero, ModContent.ProjectileType<DirectStrike>(), auraDamage, 0f, player.whoAmI, l);
}
}
}
}
}
}
plagueCounter++;
if (plagueCounter >= 180)
{
}
}
}
}