Correct DoLosChecks

This commit is contained in:
nytmyr
2025-01-26 09:44:46 -06:00
parent 764715f625
commit fbb2341fca
10 changed files with 113 additions and 42 deletions
+49 -24
View File
@@ -8679,33 +8679,54 @@ bool Mob::IsInGroupOrRaid(Mob* other, bool same_raid_group) {
return group && group == other_group;
}
bool Mob::DoLosChecks(Mob* who, Mob* other) {
if (!who->CheckLosFN(other) || !who->CheckWaterLoS(other)) {
if (who->CheckLosCheatExempt(who, other)) {
return true;
}
if (CheckLosCheat(who, other)) {
bool Mob::DoLosChecks(Mob* other) {
if (!CheckLosFN(other) || !CheckWaterLoS(other)) {
if (CheckLosCheatExempt(other)) {
return true;
}
return false;
}
if (!CheckLosCheat(other)) {
return false;
}
return true;
}
bool Mob::CheckLosCheat(Mob* who, Mob* other) {
bool Mob::CheckLosCheat(Mob* other) {
if (RuleB(Map, CheckForLoSCheat)) {
for (auto itr : entity_list.GetDoorsList()) {
Doors* d = itr.second;
if (d && !d->IsDoorOpen() && (d->GetTriggerType() == 255 || d->GetLockpick() != 0 || d->GetKeyItem() != 0 || d->GetNoKeyring() != 0)) {
if (DistanceNoZ(who->GetPosition(), d->GetPosition()) <= 50) {
auto who_to_door = DistanceNoZ(who->GetPosition(), d->GetPosition());
auto other_to_door = DistanceNoZ(other->GetPosition(), d->GetPosition());
auto who_to_other = DistanceNoZ(who->GetPosition(), other->GetPosition());
auto distance_difference = who_to_other - (who_to_door + other_to_door);
if (
!d->IsDoorOpen() &&
(
d->GetKeyItem() ||
d->GetLockpick() ||
d->IsDoorOpen() ||
d->IsDoorBlacklisted() ||
d->GetNoKeyring() != 0 ||
d->GetDoorParam() > 0
)
) {
// If the door is a trigger door, check if the trigger door is open
if (d->GetTriggerDoorID() > 0) {
auto td = entity_list.GetDoorsByDoorID(d->GetTriggerDoorID());
if (td) {
if (Strings::RemoveNumbers(d->GetDoorName()) != Strings::RemoveNumbers(td->GetDoorName())) {
continue;
}
}
}
if (DistanceNoZ(GetPosition(), d->GetPosition()) <= 50) {
auto who_to_door = DistanceNoZ(GetPosition(), d->GetPosition());
auto other_to_door = DistanceNoZ(other->GetPosition(), d->GetPosition());
auto who_to_other = DistanceNoZ(GetPosition(), other->GetPosition());
auto distance_difference = who_to_other - (who_to_door + other_to_door);
if (distance_difference >= (-1 * RuleR(Maps, RangeCheckForLoSCheat)) && distance_difference <= RuleR(Maps, RangeCheckForLoSCheat)) {
return false;
}
@@ -8717,19 +8738,23 @@ bool Mob::CheckLosCheat(Mob* who, Mob* other) {
return true;
}
bool Mob::CheckLosCheatExempt(Mob* who, Mob* other) {
bool Mob::CheckLosCheatExempt(Mob* other) {
if (RuleB(Map, EnableLoSCheatExemptions)) {
/* This is an exmaple of how to configure exemptions for LoS checks.
glm::vec4 exempt_check_who;
glm::vec4 exempt_check_other;
/* This is an exmaple of how to configure exemptions for LoS checks.
if (zone->GetZoneID() == 222) { //PoEarthB
exempt_check_who.x = 2051; exempt_check_who.y = 407; exempt_check_who.z = -219; //Middle of councilman spawns
//check to be sure the player and the target are in the pit to PoEarthB
//if the player is inside the cove they cannot be higher than the ceiling (no exploiting from uptop)
//otherwise they can pass LoS checks even if they don't have true LoS
if (who->GetZ() <= -171 && other->GetZ() <= -171 && DistanceNoZ(other->GetPosition(), exempt_check_who) <= 800 && DistanceNoZ(who->GetPosition(), exempt_check_who) <= 800) {
return true;
}
switch (zone->GetZoneID()) {
case POEARTHB:
exempt_check_who.x = 2051; exempt_check_who.y = 407; exempt_check_who.z = -219; //Middle of councilman spawns
//exempt_check_other.x = 1455; exempt_check_other.y = 415; exempt_check_other.z = -242;
//check to be sure the player and the target are outside of the councilman area
//if the player is inside the cove they cannot be higher than the ceiling (no exploiting from uptop)
if (GetZ() <= -171 && other->GetZ() <= -171 && DistanceNoZ(other->GetPosition(), exempt_check_who) <= 800 && DistanceNoZ(GetPosition(), exempt_check_who) <= 800) {
return true;
}
default:
return false;
}
*/
}