mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
* add support for FoeType * add support for Tolerance.Target and possible Tolerance.Monster ? * upgraded Tolerance handling * fix null exception from DnF testing
55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using System;
|
|
using System.Linq;
|
|
using ACE.Server.Entity;
|
|
using ACE.Entity.Enum;
|
|
using ACE.Entity.Enum.Properties;
|
|
|
|
namespace ACE.Server.WorldObjects
|
|
{
|
|
/// <summary>
|
|
/// Handles player->monster visibility checks
|
|
/// </summary>
|
|
partial class Player
|
|
{
|
|
/// <summary>
|
|
/// Wakes up any monsters within the applicable range
|
|
/// </summary>
|
|
public void CheckMonsters()
|
|
{
|
|
if (!Attackable || Teleporting) return;
|
|
|
|
var visibleObjs = PhysicsObj.ObjMaint.GetVisibleObjectsValuesOfTypeCreature();
|
|
|
|
foreach (var monster in visibleObjs)
|
|
{
|
|
if (monster is Player) continue;
|
|
|
|
//if (Location.SquaredDistanceTo(monster.Location) <= monster.VisualAwarenessRangeSq)
|
|
if (PhysicsObj.get_distance_sq_to_object(monster.PhysicsObj, true) <= monster.VisualAwarenessRangeSq)
|
|
AlertMonster(monster);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when this player attacks a monster
|
|
/// </summary>
|
|
public void OnAttackMonster(Creature monster)
|
|
{
|
|
if (monster == null || !Attackable) return;
|
|
|
|
/*Console.WriteLine($"{Name}.OnAttackMonster({monster.Name})");
|
|
Console.WriteLine($"Attackable: {monster.Attackable}");
|
|
Console.WriteLine($"Tolerance: {monster.Tolerance}");*/
|
|
|
|
// faction mobs will retaliate against players belonging to the same faction
|
|
if (SameFaction(monster))
|
|
monster.AddRetaliateTarget(this);
|
|
|
|
if (monster.MonsterState != State.Awake && (monster.Tolerance & PlayerCombatPet_RetaliateExclude) == 0)
|
|
{
|
|
monster.AttackTarget = this;
|
|
monster.WakeUp();
|
|
}
|
|
}
|
|
}
|
|
}
|