Added The Body trinity item.
This commit is contained in:
parent
b3585374fe
commit
326f22714f
91
Content/Items/Accessories/Trinity/Body.cs
Normal file
91
Content/Items/Accessories/Trinity/Body.cs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Decimation.Lib.Util;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Terraria;
|
||||||
|
using Terraria.ModLoader;
|
||||||
|
|
||||||
|
namespace Decimation.Content.Items.Accessories.Trinity
|
||||||
|
{
|
||||||
|
public class Body : TrinityAccessory
|
||||||
|
{
|
||||||
|
protected override string ItemName => "The Body";
|
||||||
|
|
||||||
|
protected override string ItemTooltip => "I feel all...\n" +
|
||||||
|
"Increase maximum life by 50\n" +
|
||||||
|
"You deal 10% more melee damage\n" +
|
||||||
|
"Your melee critical hit chances are increase by 10%\n" +
|
||||||
|
"Hostile projectiles have 10% chance to ricochet off you\nand target your enemies with 50% increased damage";
|
||||||
|
|
||||||
|
protected override void InitAccessory()
|
||||||
|
{
|
||||||
|
item.width = 10;
|
||||||
|
item.height = 16;
|
||||||
|
item.expert = true;
|
||||||
|
item.expertOnly = true;
|
||||||
|
item.rare = Rarity.Rainbow.GetRarityValue();
|
||||||
|
item.value = Item.sellPrice(gold: 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void UpdateAccessory(Player player, bool hideVisual)
|
||||||
|
{
|
||||||
|
player.statLifeMax2 += 50;
|
||||||
|
player.meleeDamage *= 1.10f;
|
||||||
|
player.meleeCrit = (int) (player.meleeCrit * 1.10f);
|
||||||
|
|
||||||
|
base.UpdateAccessory(player, hideVisual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class BodyProjectileEffects : GlobalProjectile
|
||||||
|
{
|
||||||
|
public override void ModifyHitPvp(Projectile projectile, Player target, ref int damage, ref bool crit)
|
||||||
|
{
|
||||||
|
Ricochet(projectile, target, true, ref damage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ModifyHitPlayer(Projectile projectile, Player target, ref int damage, ref bool crit)
|
||||||
|
{
|
||||||
|
if (Ricochet(projectile, target, false, ref damage))
|
||||||
|
{
|
||||||
|
projectile.hostile = false;
|
||||||
|
projectile.friendly = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool Ricochet(Projectile projectile, Player target, bool isPlayer, ref int damage)
|
||||||
|
{
|
||||||
|
if (!Main.expertMode || !Main.rand.NextBool(10) ||
|
||||||
|
!target.GetModPlayer().HasEquippedAccessory(ModContent.ItemType<Body>())) return false;
|
||||||
|
|
||||||
|
Entity newTarget = null;
|
||||||
|
float lastDistance = float.MaxValue;
|
||||||
|
for (int i = 0; i < (isPlayer ? Main.player.Length : Main.npc.Length); i++)
|
||||||
|
{
|
||||||
|
Entity entity = isPlayer ? (Entity) Main.player[i] : Main.npc[i];
|
||||||
|
if (entity != null && entity.active && target.CanHit(newTarget))
|
||||||
|
{
|
||||||
|
float distance = projectile.Distance(entity.Center);
|
||||||
|
if (distance < 1000f && distance < lastDistance)
|
||||||
|
{
|
||||||
|
lastDistance = distance;
|
||||||
|
newTarget = entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newTarget == null) return false;
|
||||||
|
|
||||||
|
float speed = projectile.velocity.Length();
|
||||||
|
Vector2 velocity = newTarget.Center - projectile.Center;
|
||||||
|
velocity.Normalize();
|
||||||
|
velocity *= speed;
|
||||||
|
|
||||||
|
projectile.velocity = velocity;
|
||||||
|
projectile.damage = (int) (projectile.damage * 1.5f);
|
||||||
|
|
||||||
|
damage = 0;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
Content/Items/Accessories/Trinity/Body.png
Normal file
BIN
Content/Items/Accessories/Trinity/Body.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 201 B |
14
Content/Items/Accessories/Trinity/TrinityAccessory.cs
Normal file
14
Content/Items/Accessories/Trinity/TrinityAccessory.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using Decimation.Lib.Items;
|
||||||
|
using Decimation.Lib.Util;
|
||||||
|
using Terraria;
|
||||||
|
|
||||||
|
namespace Decimation.Content.Items.Accessories.Trinity
|
||||||
|
{
|
||||||
|
public abstract class TrinityAccessory : DecimationAccessory
|
||||||
|
{
|
||||||
|
public override bool CanEquipAccessory(Player player, int slot)
|
||||||
|
{
|
||||||
|
return !player.HasEquippedAccessory(item.type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user