[PVP] Pvp guard assist code. (Guards will assist in PvP based on faction) (#1367)

* Added Guard Assist Code

* Added PvP Rule and Detrimental Spell Check

* Added IsGuard() Method

* Change from uint to bool

* Added a faction check to IsGuard()

* Simplified Guard Checks, reduced costs

* Added IsNPC check to guard check

* simplified pet check

* Removed Magic numbers

* Formatting Fix

* Code fixes

* Fixed constants

Co-authored-by: ProducerZekServer <go@away.com>
This commit is contained in:
RoTPvP
2021-05-30 18:22:52 -07:00
committed by GitHub
parent 542ec38660
commit 71e9dd5a3c
7 changed files with 97 additions and 1 deletions
+37
View File
@@ -1522,6 +1522,25 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b
other->AddToHateList(this, hate);
//Guard Assist Code
if (RuleB(Character, PVPEnableGuardFactionAssist)) {
if (IsClient() || (HasOwner() && GetOwner()->IsClient())) {
auto& mob_list = entity_list.GetCloseMobList(other);
for (auto& e : mob_list) {
auto mob = e.second;
if (mob->IsNPC() && mob->CastToNPC()->IsGuard()) {
float distance = Distance(other->CastToClient()->m_Position, mob->GetPosition());
if ((mob->CheckLosFN(other) || mob->CheckLosFN(this)) && distance <= 70) {
auto petorowner = GetOwnerOrSelf();
if (other->GetReverseFactionCon(mob) <= petorowner->GetReverseFactionCon(mob)) {
mob->AddToHateList(this);
}
}
}
}
}
}
///////////////////////////////////////////////////////////
////// Send Attack Damage
///////////////////////////////////////////////////////////
@@ -2002,6 +2021,24 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool
}
}
//Guard Assist Code
if (RuleB(Character, PVPEnableGuardFactionAssist)) {
if (IsClient() || (HasOwner() && GetOwner()->IsClient())) {
auto& mob_list = entity_list.GetCloseMobList(other);
for (auto& e : mob_list) {
auto mob = e.second;
if (mob->IsNPC() && mob->CastToNPC()->IsGuard()) {
float distance = Distance(other->GetPosition(), mob->GetPosition());
if ((mob->CheckLosFN(other) || mob->CheckLosFN(this)) && distance <= 70) {
if (other->GetReverseFactionCon(mob) <= GetOwner()->GetReverseFactionCon(mob)) {
mob->AddToHateList(this);
}
}
}
}
}
}
int weapon_damage = GetWeaponDamage(other, weapon);
//do attack animation regardless of whether or not we can hit below