Fixed The Body not ricocheting projectiles.
This commit is contained in:
parent
326f22714f
commit
3e441699c9
@ -1,4 +1,3 @@
|
||||
using System.Collections.Generic;
|
||||
using Decimation.Lib.Util;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
@ -54,26 +53,46 @@ namespace Decimation.Content.Items.Accessories.Trinity
|
||||
|
||||
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;
|
||||
|
||||
if (Main.expertMode && Main.rand.NextBool(10) &&
|
||||
target.GetModPlayer().HasEquippedAccessory(ModContent.ItemType<Body>()))
|
||||
{
|
||||
Entity newTarget = null;
|
||||
float lastDistance = float.MaxValue;
|
||||
for (int i = 0; i < (isPlayer ? Main.player.Length : Main.npc.Length); i++)
|
||||
if (isPlayer)
|
||||
{
|
||||
Entity entity = isPlayer ? (Entity) Main.player[i] : Main.npc[i];
|
||||
if (entity != null && entity.active && target.CanHit(newTarget))
|
||||
for (int i = 0; i < Main.player.Length; i++)
|
||||
{
|
||||
float distance = projectile.Distance(entity.Center);
|
||||
Player player = Main.player[i];
|
||||
if (player != null && player.active && !player.dead && player.whoAmI != target.whoAmI)
|
||||
{
|
||||
float distance = projectile.Distance(player.Center);
|
||||
if (distance < 1000f && distance < lastDistance)
|
||||
{
|
||||
lastDistance = distance;
|
||||
newTarget = entity;
|
||||
newTarget = player;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < Main.npc.Length; i++)
|
||||
{
|
||||
NPC npc = Main.npc[i];
|
||||
if (npc != null && npc.active && !npc.friendly)
|
||||
{
|
||||
float distance = projectile.Distance(npc.Center);
|
||||
if (distance < 1000f && distance < lastDistance)
|
||||
{
|
||||
lastDistance = distance;
|
||||
newTarget = npc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newTarget == null) return false;
|
||||
Main.NewText(newTarget.position);
|
||||
|
||||
float speed = projectile.velocity.Length();
|
||||
Vector2 velocity = newTarget.Center - projectile.Center;
|
||||
@ -87,5 +106,8 @@ namespace Decimation.Content.Items.Accessories.Trinity
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user