48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using System;
|
|
using System.Linq;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
using ForgottenWawiTech.Content.Rarities;
|
|
|
|
namespace ForgottenWawiTech.Content.Items.Accessories
|
|
{
|
|
public class EssenceOfClutches : ModItem
|
|
{
|
|
public override void SetDefaults()
|
|
{
|
|
Item.width = 28;
|
|
Item.height = 28;
|
|
Item.accessory = true;
|
|
Item.rare = ModContent.RarityType<FWTDeveloperItem>();
|
|
Item.value = Item.sellPrice(platinum: 90);
|
|
}
|
|
|
|
public override void UpdateAccessory(Player player, bool hideVisual)
|
|
{
|
|
// The more players have died during a boss, the more damage you both deal and take (up to a maximum of +50% damage dealt and +50% damage taken).
|
|
|
|
// Count the number of dead players during a boss fight
|
|
int deadPlayerCount = 0;
|
|
if (Main.npc.Any(npc => npc.active && npc.boss))
|
|
{
|
|
for (int i = 0; i < Main.maxPlayers; i++)
|
|
{
|
|
Player otherPlayer = Main.player[i];
|
|
if (otherPlayer.active && otherPlayer.dead)
|
|
{
|
|
deadPlayerCount++;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Each dead player grants +10% damage dealt and +10% damage taken, capped at 5 dead players (50%)
|
|
float damageBonus = Math.Min(deadPlayerCount * 0.10f, 0.50f);
|
|
|
|
if (damageBonus > 0)
|
|
{
|
|
player.GetDamage(DamageClass.Generic) += damageBonus;
|
|
player.endurance -= damageBonus; // Negative endurance means taking more damage
|
|
}
|
|
}
|
|
}
|
|
} |