Skip to content

Commit 81d666c

Browse files
authored
fix: (Day) Fixes issue where taunted NPCs did not cast spells/projectiles to non-taunted targets (AscensionGameDev#2105)
1 parent d00bc42 commit 81d666c

File tree

2 files changed

+43
-31
lines changed

2 files changed

+43
-31
lines changed

Intersect.Server.Core/Entities/Entity.cs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,20 +1470,6 @@ public virtual void TryAttack(Entity target,
14701470
return;
14711471
}
14721472

1473-
//Check for taunt status and trying to attack a target that has not taunted you.
1474-
foreach (var status in CachedStatuses)
1475-
{
1476-
if (status.Type == SpellEffect.Taunt)
1477-
{
1478-
if (Target != target)
1479-
{
1480-
PacketSender.SendActionMsg(this, Strings.Combat.miss, CustomColors.Combat.Missed);
1481-
1482-
return;
1483-
}
1484-
}
1485-
}
1486-
14871473
if (parentSpell != null)
14881474
{
14891475
TryAttack(target, parentSpell);
@@ -1575,23 +1561,6 @@ public virtual void TryAttack(
15751561
return;
15761562
}
15771563

1578-
//Check for taunt status and trying to attack a target that has not taunted you.
1579-
if (!trapTrigger) //Traps ignore taunts.
1580-
{
1581-
foreach (var status in CachedStatuses)
1582-
{
1583-
if (status.Type == SpellEffect.Taunt)
1584-
{
1585-
if (Target != target)
1586-
{
1587-
PacketSender.SendActionMsg(this, Strings.Combat.miss, CustomColors.Combat.Missed);
1588-
1589-
return;
1590-
}
1591-
}
1592-
}
1593-
}
1594-
15951564
var deadAnimations = new List<KeyValuePair<Guid, Direction>>();
15961565
var aliveAnimations = new List<KeyValuePair<Guid, Direction>>();
15971566

Intersect.Server.Core/Entities/Player.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,9 +1420,52 @@ public override void TryAttack(Entity target,
14201420
}
14211421
}
14221422

1423+
//Check for taunt status and trying to attack a target that has not taunted you.
1424+
if (!ValidTauntTarget(target))
1425+
{
1426+
return;
1427+
}
1428+
14231429
base.TryAttack(target, projectile, parentSpell, parentItem, projectileDir);
14241430
}
14251431

1432+
//Attacking with spell
1433+
public override void TryAttack(
1434+
Entity target,
1435+
SpellBase spellBase,
1436+
bool onHitTrigger = false,
1437+
bool trapTrigger = false
1438+
)
1439+
{
1440+
if (!trapTrigger && !ValidTauntTarget(target)) //Traps ignore taunts.
1441+
{
1442+
return;
1443+
}
1444+
1445+
base.TryAttack(target, spellBase, onHitTrigger, trapTrigger);
1446+
}
1447+
1448+
/// <summary>
1449+
/// Check for taunt status and trying to attack a target that has not taunted you.
1450+
/// </summary>
1451+
/// <param name="target">The target the player is attempting to attack</param>
1452+
/// <returns>True if the player can attack that target according to their taunt status</returns>
1453+
public bool ValidTauntTarget(Entity target)
1454+
{
1455+
if (CachedStatuses?.All(status => status.Type != SpellEffect.Taunt) ?? true)
1456+
{
1457+
return true;
1458+
}
1459+
1460+
if (Target != target)
1461+
{
1462+
PacketSender.SendActionMsg(this, Strings.Combat.miss, CustomColors.Combat.Missed);
1463+
return false;
1464+
}
1465+
1466+
return true;
1467+
}
1468+
14261469
public void TryAttack(Entity target)
14271470
{
14281471
if (IsCasting)

0 commit comments

Comments
 (0)