using AcDream.Core.Items; namespace AcDream.Core.Combat; /// /// Eligibility policy for automatic monster acquisition. /// public static class CombatTargetPolicy { /// /// Returns true only for a live-data creature that is attackable, is not a /// player, and is not a pet. Friendly NPCs and non-creatures are rejected. /// /// /// The attackability core is retail /// ClientCombatSystem::ObjectIsAttackable @ 0x0056A600. Retail /// AutoTarget @ 0x0056BC80 falls back to /// SelectNext(SELECTION_TYPE_COMPASS_ITEM), whose combat filter also /// uses ObjectIsAttackable. acdream deliberately narrows that set to /// non-player monsters for its automatic acquisition policy; explicit /// player-selection commands remain separate. /// public static bool IsHostileMonster( uint playerId, ClientObject? player, ClientObject? candidate) { if (candidate is null || candidate.ObjectId == playerId || (candidate.Type & ItemType.Creature) == 0 || (candidate.PublicWeenieBitfield.GetValueOrDefault() & SelectedObjectHealthPolicy.BfPlayer) != 0 || candidate.PetOwnerId != 0) return false; return SelectedObjectHealthPolicy.ObjectIsAttackable( playerId, player, candidate.ObjectId, candidate); } }