108 lines
3.8 KiB
C#
108 lines
3.8 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using Decimation.Content.Projectiles.Item.Accessory.Trinity;
|
|
using Decimation.Lib.Util;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
using Terraria.UI.Chat;
|
|
|
|
namespace Decimation.Content.Items.Accessories.Trinity
|
|
{
|
|
public class Mind : TrinityAccessory
|
|
{
|
|
private static readonly float TrinityBeamSpeed = 8f;
|
|
private static readonly int TrinityBeamDamage = 35;
|
|
|
|
protected override string ItemName => "The Mind";
|
|
|
|
protected override string ItemTooltip => "I know all...\n" +
|
|
"Increases block placement and mining speed by 10%\n" +
|
|
"Increases ranged and thrown damage by 10%\n" +
|
|
"Increases ranged and thrown critical hit chances by 10%\n" +
|
|
"Increases view range\n" +
|
|
"Each second, there is 4% chance to fire a Trinity Beam toward a near enemy";
|
|
|
|
private int _trinityBeamCounter;
|
|
|
|
protected override void InitAccessory()
|
|
{
|
|
item.width = 10;
|
|
item.height = 16;
|
|
item.expert = true;
|
|
item.rare = Rarity.Rainbow.GetRarityValue();
|
|
item.value = Item.sellPrice(gold: 5);
|
|
}
|
|
|
|
public override void UpdateAccessory(Player player, bool hideVisual)
|
|
{
|
|
player.pickSpeed *= 1.10f;
|
|
player.tileSpeed *= 1.10f;
|
|
player.rangedDamage *= 1.10f;
|
|
player.rangedCrit = (int) (player.rangedCrit * 1.10f);
|
|
player.thrownDamage *= 1.10f;
|
|
player.thrownCrit = (int) (player.thrownCrit * 1.10f);
|
|
player.scope = true;
|
|
|
|
if (_trinityBeamCounter >= 60)
|
|
{
|
|
MindEffect(player);
|
|
_trinityBeamCounter = 0;
|
|
}
|
|
_trinityBeamCounter++;
|
|
|
|
base.UpdateAccessory(player, hideVisual);
|
|
}
|
|
|
|
public override void ModifyTooltips(List<TooltipLine> tooltips)
|
|
{
|
|
tooltips.Add(new TooltipLine(mod, "trinity", "Trinity")
|
|
{
|
|
overrideColor = ChatManager.WaveColor(Color.Yellow)
|
|
});
|
|
}
|
|
|
|
public override void NetSend(BinaryWriter writer)
|
|
{
|
|
writer.Write(_trinityBeamCounter);
|
|
}
|
|
|
|
public override void NetRecieve(BinaryReader reader)
|
|
{
|
|
_trinityBeamCounter = reader.ReadInt32();
|
|
}
|
|
|
|
public static void MindEffect(Player player)
|
|
{
|
|
if (Main.rand.NextBool(25))
|
|
{
|
|
NPC target = null;
|
|
float lastDistance = float.MaxValue;
|
|
for (int n = 0; n < Main.npc.Length; n++)
|
|
{
|
|
NPC npcTarget = Main.npc[n];
|
|
if (npcTarget != null)
|
|
{
|
|
float distance = npcTarget.Distance(player.position);
|
|
if (npcTarget.active && !npcTarget.friendly && distance < 1000f && distance < lastDistance)
|
|
{
|
|
target = npcTarget;
|
|
lastDistance = distance;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (target != null)
|
|
{
|
|
Vector2 velocity = target.Center - player.Center;
|
|
velocity.Normalize();
|
|
velocity *= TrinityBeamSpeed;
|
|
|
|
Projectile.NewProjectile(player.Center, velocity, ModContent.ProjectileType<TrinityBeam>(),
|
|
TrinityBeamDamage, 2f,
|
|
player.whoAmI);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |