123 lines
4.8 KiB
C#
123 lines
4.8 KiB
C#
using System.Collections.Generic;
|
|
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" +
|
|
"Melee attacks have 4% chance to fire a Trinity Beam";
|
|
|
|
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;
|
|
|
|
base.UpdateAccessory(player, hideVisual);
|
|
}
|
|
|
|
public override void ModifyTooltips(List<TooltipLine> tooltips)
|
|
{
|
|
tooltips.Add(new TooltipLine(mod, "trinity", "Trinity")
|
|
{
|
|
overrideColor = ChatManager.WaveColor(Color.Yellow)
|
|
});
|
|
}
|
|
|
|
public static void MindEffect(Player player, Entity target)
|
|
{
|
|
if (Main.rand.NextBool(25) && (player.HasEquippedAccessory(ModContent.ItemType<Mind>()) || player.HasEquippedAccessory(ModContent.ItemType<Trinity>())))
|
|
{
|
|
bool targetIsPlayer = target.GetType() == typeof(Player);
|
|
|
|
// Target
|
|
Entity projTarget = null;
|
|
float lastDistance = float.MaxValue;
|
|
if (targetIsPlayer)
|
|
{
|
|
for (int p = 0; p < Main.player.Length; p++)
|
|
{
|
|
Player playerTarget = Main.player[p];
|
|
if (playerTarget != null)
|
|
{
|
|
float distance = playerTarget.Distance(target.position);
|
|
if (playerTarget.active && !playerTarget.dead &&
|
|
playerTarget.whoAmI != player.whoAmI && playerTarget.whoAmI != target.whoAmI &&
|
|
distance < 1000f && distance < lastDistance)
|
|
{
|
|
projTarget = playerTarget;
|
|
lastDistance = distance;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for (int n = 0; n < Main.npc.Length; n++)
|
|
{
|
|
NPC npcTarget = Main.npc[n];
|
|
if (npcTarget != null)
|
|
{
|
|
float distance = npcTarget.Distance(target.position);
|
|
if (npcTarget.active && !npcTarget.friendly && (targetIsPlayer || npcTarget.whoAmI != target.whoAmI) &&
|
|
distance < 1000f && distance < lastDistance)
|
|
{
|
|
projTarget = npcTarget;
|
|
lastDistance = distance;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (projTarget != null)
|
|
{
|
|
Vector2 velocity = projTarget.Center - target.Center;
|
|
velocity.Normalize();
|
|
velocity *= TrinityBeamSpeed;
|
|
|
|
Projectile.NewProjectile(target.Center, velocity, ModContent.ProjectileType<TrinityBeam>(), TrinityBeamDamage, 2f,
|
|
player.whoAmI);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class MindItemEffects : GlobalItem
|
|
{
|
|
public override void OnHitNPC(Item item, Player player, NPC target, int damage, float knockBack, bool crit)
|
|
{
|
|
Mind.MindEffect(player, target);
|
|
}
|
|
|
|
public override void OnHitPvp(Item item, Player player, Player target, int damage, bool crit)
|
|
{
|
|
Mind.MindEffect(player, target);
|
|
}
|
|
}
|
|
} |