[Commands] Cleanup #aggro Command. (#1799)

- Cleanup messages and logic.
- Cleanup constant names and references.
- Cleanup aggro description methods.
This commit is contained in:
Kinglykrab 2021-11-21 10:12:12 -05:00 committed by GitHub
parent 04fda24c8e
commit b9214bfdee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 512 additions and 319 deletions

View File

@ -20,31 +20,31 @@
#include "races.h" #include "races.h"
#include "rulesys.h" #include "rulesys.h"
const char *FactionValueToString(FACTION_VALUE fv) const char *FactionValueToString(FACTION_VALUE faction_value)
{ {
switch (fv) { switch (faction_value) {
case FACTION_ALLY: case FACTION_ALLY:
return ("Ally"); return "Ally";
case FACTION_WARMLY: case FACTION_WARMLY:
return ("Warmly"); return "Warmly";
case FACTION_KINDLY: case FACTION_KINDLY:
return ("Kindly"); return "Kindly";
case FACTION_AMIABLE: case FACTION_AMIABLY:
return ("Amiable"); return "Amiably";
case FACTION_INDIFFERENT: case FACTION_INDIFFERENTLY:
return ("Indifferent"); return "Indifferently";
case FACTION_APPREHENSIVE: case FACTION_APPREHENSIVELY:
return ("Apprehensive"); return "Apprehensively";
case FACTION_DUBIOUS: case FACTION_DUBIOUSLY:
return ("Dubious"); return "Dubiously";
case FACTION_THREATENLY: case FACTION_THREATENINGLY:
return ("Threatenly"); return "Threateningly";
case FACTION_SCOWLS: case FACTION_SCOWLS:
return ("Scowls, ready to attack."); return "Scowls";
default: default:
break; break;
} }
return ("Unknown Faction Con"); return "Unknown";
} }
@ -70,19 +70,19 @@ FACTION_VALUE CalculateFaction(FactionMods* fm, int32 tmpCharacter_value)
return FACTION_KINDLY; return FACTION_KINDLY;
} }
if (character_value >= RuleI(Faction, AmiablyFactionMinimum)) { if (character_value >= RuleI(Faction, AmiablyFactionMinimum)) {
return FACTION_AMIABLE; return FACTION_AMIABLY;
} }
if (character_value >= RuleI(Faction, IndifferentlyFactionMinimum)) { if (character_value >= RuleI(Faction, IndifferentlyFactionMinimum)) {
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
} }
if (character_value >= RuleI(Faction, ApprehensivelyFactionMinimum)) { if (character_value >= RuleI(Faction, ApprehensivelyFactionMinimum)) {
return FACTION_APPREHENSIVE; return FACTION_APPREHENSIVELY;
} }
if (character_value >= RuleI(Faction, DubiouslyFactionMinimum)) { if (character_value >= RuleI(Faction, DubiouslyFactionMinimum)) {
return FACTION_DUBIOUS; return FACTION_DUBIOUSLY;
} }
if (character_value >= RuleI(Faction, ThreateninglyFactionMinimum)) { if (character_value >= RuleI(Faction, ThreateninglyFactionMinimum)) {
return FACTION_THREATENLY; return FACTION_THREATENINGLY;
} }
return FACTION_SCOWLS; return FACTION_SCOWLS;
} }

View File

@ -27,13 +27,13 @@ enum FACTION_VALUE {
FACTION_ALLY = 1, FACTION_ALLY = 1,
FACTION_WARMLY = 2, FACTION_WARMLY = 2,
FACTION_KINDLY = 3, FACTION_KINDLY = 3,
FACTION_AMIABLE = 4, FACTION_AMIABLY = 4,
FACTION_INDIFFERENT = 5, FACTION_INDIFFERENTLY = 5,
FACTION_APPREHENSIVE = 6, FACTION_APPREHENSIVELY = 6,
FACTION_DUBIOUS = 7, FACTION_DUBIOUSLY = 7,
FACTION_THREATENLY = 8, FACTION_THREATENINGLY = 8,
FACTION_SCOWLS = 9 FACTION_SCOWLS = 9
}; };
@ -75,6 +75,6 @@ struct NPCFaction
uint8 temp; uint8 temp;
}; };
const char *FactionValueToString(FACTION_VALUE fv); const char *FactionValueToString(FACTION_VALUE faction_value);
FACTION_VALUE CalculateFaction(FactionMods* fm, int32 tmpCharacter_value); FACTION_VALUE CalculateFaction(FactionMods* fm, int32 tmpCharacter_value);
#endif #endif

View File

@ -204,7 +204,7 @@ enum { //some random constants
#define MIN_LEVEL_ALCHEMY 25 #define MIN_LEVEL_ALCHEMY 25
//chance ratio that a //chance ratio that a
#define THREATENLY_ARRGO_CHANCE 32 // 32/128 (25%) chance that a mob will arrgo on con Threatenly #define THREATENINGLY_AGGRO_CHANCE 32 // 32/128 (25%) chance that a mob will arrgo on con Threatenly
//max factions per npc faction list //max factions per npc faction list
#define MAX_NPC_FACTIONS 20 #define MAX_NPC_FACTIONS 20

View File

@ -38,190 +38,359 @@ extern Zone* zone;
//#define LOSDEBUG 6 //#define LOSDEBUG 6
void EntityList::DescribeAggro(Client *towho, NPC *from_who, float d, bool verbose) { void EntityList::DescribeAggro(Client *towho, NPC *from_who, float d, bool verbose) {
float d2 = d*d; float distance_squared = (d * d);
towho->Message(Chat::White, "Describing aggro for %s", from_who->GetName()); towho->Message(
Chat::White,
fmt::format(
"Describing aggro for {} ({}).",
from_who->GetCleanName(),
from_who->GetID()
).c_str()
);
bool engaged = from_who->IsEngaged(); bool is_engaged = from_who->IsEngaged();
if(engaged) { bool will_aggro_npcs = from_who->WillAggroNPCs();
if (is_engaged) {
Mob *top = from_who->GetHateTop(); Mob *top = from_who->GetHateTop();
towho->Message(Chat::White, ".. I am currently fighting with %s", top == nullptr?"(nullptr)":top->GetName()); towho->Message(
Chat::White,
fmt::format(
"I am currently engaged with {}.",
(
!top ?
"nothing" :
fmt::format(
"{} ({})",
top->GetCleanName(),
top->GetID()
)
)
).c_str()
);
} }
bool check_npcs = from_who->WillAggroNPCs();
if(verbose) { if (verbose) {
char namebuf[256]; int faction_id = from_who->GetPrimaryFaction();
Mob *owner = from_who->GetOwner();
int my_primary = from_who->GetPrimaryFaction(); if(owner) {
Mob *own = from_who->GetOwner(); faction_id = owner->GetPrimaryFaction();
if(own != nullptr)
my_primary = own->GetPrimaryFaction();
if(my_primary == 0) {
strcpy(namebuf, "(No faction)");
} else if(my_primary < 0) {
strcpy(namebuf, "(Special faction)");
} else {
if(!content_db.GetFactionName(my_primary, namebuf, sizeof(namebuf)))
strcpy(namebuf, "(Unknown)");
} }
towho->Message(Chat::White, ".. I am on faction %s (%d)\n", namebuf, my_primary);
std::string faction_name = (
faction_id > 0 ?
content_db.GetFactionName(faction_id) :
(
faction_id == 0 ?
"None" :
fmt::format(
"Special Faction {}",
faction_id
)
)
);
towho->Message(
Chat::White,
fmt::format(
"{} ({}) is on Faction {} ({}).",
from_who->GetCleanName(),
from_who->GetID(),
faction_name,
faction_id
).c_str()
);
} }
for (auto it = mob_list.begin(); it != mob_list.end(); ++it) { for (const auto& npc_entity : entity_list.GetNPCList()) {
Mob *mob = it->second; auto entity_id = npc_entity.first;
if (mob->IsClient()) //also ensures that mob != around auto npc = npc_entity.second;
if (npc == from_who) {
continue; continue;
}
if (DistanceSquared(mob->GetPosition(), from_who->GetPosition()) > d2) if (DistanceSquared(npc->GetPosition(), from_who->GetPosition()) > distance_squared) {
continue; continue;
}
if (engaged) { if (is_engaged) {
uint32 amm = from_who->GetHateAmount(mob); uint32 hate_amount = from_who->GetHateAmount(npc);
if (amm == 0) towho->Message(
towho->Message(Chat::White, "... %s is not on my hate list.", mob->GetName()); Chat::White,
else fmt::format(
towho->Message(Chat::White, "... %s is on my hate list with value %lu", mob->GetName(), (unsigned long)amm); "{} ({}) is {}on my hate list{}.",
} else if (!check_npcs && mob->IsNPC()) { npc->GetCleanName(),
towho->Message(Chat::White, "... %s is an NPC and my npc_aggro is disabled.", mob->GetName()); npc->GetID(),
!hate_amount ? "not " : "",
(
!hate_amount ?
"" :
fmt::format(
" with a hate amount of {}.",
hate_amount
)
)
).c_str()
);
} else if (!will_aggro_npcs) {
towho->Message(
Chat::White,
fmt::format(
"{} ({}) is an NPC and I cannot aggro NPCs.",
npc->GetCleanName(),
npc->GetID()
).c_str()
);
} else { } else {
from_who->DescribeAggro(towho, mob, verbose); from_who->DescribeAggro(towho, npc, verbose);
} }
} }
} }
void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) { void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) {
//this logic is duplicated from below, try to keep it up to date. //this logic is duplicated from below, try to keep it up to date.
float iAggroRange = GetAggroRange(); float aggro_range = GetAggroRange();
float x_range = std::abs(mob->GetX() - GetX());
float t1, t2, t3; float y_range = std::abs(mob->GetY() - GetY());
t1 = std::abs(mob->GetX() - GetX()); float z_range = std::abs(mob->GetZ() - GetZ());
t2 = std::abs(mob->GetY() - GetY()); if (
t3 = std::abs(mob->GetZ() - GetZ()); x_range > aggro_range ||
y_range > aggro_range ||
if(( t1 > iAggroRange) z_range > aggro_range
|| ( t2 > iAggroRange) ) {
|| ( t3 > iAggroRange) ) { towho->Message(
towho->Message(Chat::White, "...%s is out of range (fast). distances (%.3f,%.3f,%.3f), range %.3f", mob->GetName(), Chat::White,
t1, t2, t3, iAggroRange); fmt::format(
"{} ({}) is out of range. X Range: {} Y Range: {} Z Range: {} Aggro Range: {}",
mob->GetCleanName(),
mob->GetID(),
x_range,
y_range,
z_range,
aggro_range
).c_str()
);
return; return;
} }
if(mob->IsInvisible(this)) { if (mob->IsInvisible(this)) {
towho->Message(Chat::White, "...%s is invisible to me. ", mob->GetName()); towho->Message(
Chat::White,
fmt::format(
"{} ({}) is invisible to me. ",
mob->GetCleanName(),
mob->GetID()
).c_str()
);
return; return;
} }
if((mob->IsClient() &&
(!mob->CastToClient()->Connected() if (
|| mob->CastToClient()->IsLD() mob->IsClient() &&
|| mob->CastToClient()->IsBecomeNPC() (
|| mob->CastToClient()->GetGM() !mob->CastToClient()->Connected() ||
mob->CastToClient()->IsLD() ||
mob->CastToClient()->IsBecomeNPC() ||
mob->CastToClient()->GetGM()
) )
)) ) {
{ towho->Message(
towho->Message(Chat::White, "...%s is my owner. ", mob->GetName()); Chat::White,
fmt::format(
"{} ({}) is a GM or is not connected. ",
mob->GetCleanName(),
mob->GetID()
).c_str()
);
return; return;
} }
if(mob == GetOwner()) { if (mob == GetOwner()) {
towho->Message(Chat::White, "...%s a GM or is not connected. ", mob->GetName()); towho->Message(
Chat::White,
fmt::format(
"{} ({}) is my owner. ",
mob->GetCleanName(),
mob->GetID()
).c_str()
);
return; return;
} }
float dist2 = DistanceSquared(mob->GetPosition(), m_Position); float distance_squared = DistanceSquared(mob->GetPosition(), m_Position);
float aggro_range_squared = (aggro_range * aggro_range);
float iAggroRange2 = iAggroRange*iAggroRange; if (distance_squared > aggro_range_squared) {
if( dist2 > iAggroRange2 ) { towho->Message(
towho->Message(Chat::White, "...%s is out of range. %.3f > %.3f ", mob->GetName(), Chat::White,
dist2, iAggroRange2); fmt::format(
"{} ({}) is out of range. Distance: {:.2f} Aggro Range: {:.2f}",
mob->GetCleanName(),
mob->GetID(),
distance_squared,
aggro_range_squared
).c_str()
);
return; return;
} }
if (RuleB(Aggro, UseLevelAggro)) if (RuleB(Aggro, UseLevelAggro)) {
{ if (
if (GetLevel() < RuleI(Aggro, MinAggroLevel) && mob->GetLevelCon(GetLevel()) == CON_GRAY && GetBodyType() != 3 && !AlwaysAggro()) GetLevel() < RuleI(Aggro, MinAggroLevel) &&
{ mob->GetLevelCon(GetLevel()) == CON_GRAY &&
towho->Message(Chat::White, "...%s is red to me (basically)", mob->GetName(), dist2, iAggroRange2); GetBodyType() != BT_Undead &&
!AlwaysAggro()
) {
towho->Message(
Chat::White,
fmt::format(
"{} ({}) considers Red to me.",
mob->GetCleanName(),
mob->GetID()
).c_str()
);
return; return;
} }
} } else {
else if (
{ GetINT() > RuleI(Aggro, IntAggroThreshold) &&
if(GetINT() > RuleI(Aggro, IntAggroThreshold) && mob->GetLevelCon(GetLevel()) == CON_GRAY && !AlwaysAggro()) { mob->GetLevelCon(GetLevel()) == CON_GRAY &&
towho->Message(Chat::White, "...%s is red to me (basically)", mob->GetName(), !AlwaysAggro()
dist2, iAggroRange2); ) {
towho->Message(
Chat::White,
fmt::format(
"{} ({}) considers Red to me.",
mob->GetCleanName(),
mob->GetID()
).c_str()
);
return; return;
} }
} }
if(verbose) { if (verbose) {
int my_primary = GetPrimaryFaction(); int faction_id = GetPrimaryFaction();
int mob_primary = mob->GetPrimaryFaction(); int mob_faction_id = mob->GetPrimaryFaction();
Mob *own = GetOwner(); Mob *owner = GetOwner();
if(own != nullptr) if (owner) {
my_primary = own->GetPrimaryFaction(); faction_id = owner->GetPrimaryFaction();
own = mob->GetOwner(); }
if(mob_primary > 0 && own != nullptr)
mob_primary = own->GetPrimaryFaction();
if(mob_primary == 0) { owner = mob->GetOwner();
towho->Message(Chat::White, "...%s has no primary faction", mob->GetName()); if (mob_faction_id && owner) {
} else if(mob_primary < 0) { mob_faction_id = owner->GetPrimaryFaction();
towho->Message(Chat::White, "...%s is on special faction %d", mob->GetName(), mob_primary); }
if (!mob_faction_id) {
towho->Message(
Chat::White,
fmt::format(
"{} ({}) has no primary Faction.",
mob->GetCleanName(),
mob->GetID()
).c_str()
);
} else if (mob_faction_id < 0) {
towho->Message(
Chat::White,
fmt::format(
"{} ({}) is on special Faction {}.",
mob->GetCleanName(),
mob->GetID(),
mob_faction_id
).c_str()
);
} else { } else {
char namebuf[256]; auto faction_name = content_db.GetFactionName(mob_faction_id);
if(!content_db.GetFactionName(mob_primary, namebuf, sizeof(namebuf))) bool has_entry = false;
strcpy(namebuf, "(Unknown)"); for (auto faction : faction_list) {
std::list<struct NPCFaction*>::iterator cur,end; if (static_cast<int>(faction->factionID) == mob_faction_id) {
cur = faction_list.begin(); towho->Message(
end = faction_list.end(); Chat::White,
bool res = false; fmt::format(
for(; cur != end; ++cur) { "{} ({}) has {} standing with Faction {} ({}) with their Faction Level of {}",
struct NPCFaction* fac = *cur; mob->GetCleanName(),
if ((int32)fac->factionID == mob_primary) { mob->GetID(),
if (fac->npc_value > 0) { (
towho->Message(Chat::White, "...%s is on ALLY faction %s (%d) with %d", mob->GetName(), namebuf, mob_primary, fac->npc_value); faction->npc_value != 0 ?
res = true; (
break; faction->npc_value > 0 ?
} else if (fac->npc_value < 0) { "positive" :
towho->Message(Chat::White, "...%s is on ENEMY faction %s (%d) with %d", mob->GetName(), namebuf, mob_primary, fac->npc_value); "negative"
res = true; ) :
break; "neutral"
} else { ),
towho->Message(Chat::White, "...%s is on NEUTRAL faction %s (%d) with 0", mob->GetName(), namebuf, mob_primary); faction_name,
res = true; faction->factionID,
break; faction->npc_value
} ).c_str()
);
has_entry = true;
break;
} }
} }
if(!res) {
towho->Message(Chat::White, "...%s is on faction %s (%d), which I have no entry for.", mob->GetName(), namebuf, mob_primary); if (!has_entry) {
towho->Message(
Chat::White,
fmt::format(
"{} ({}) is on Faction {} ({}), for which I do not have an entry.",
mob->GetCleanName(),
mob->GetID(),
faction_name,
mob_faction_id
).c_str()
);
} }
} }
} }
FACTION_VALUE fv = mob->GetReverseFactionCon(this); auto faction_value = mob->GetReverseFactionCon(this);
if(!( if(
fv == FACTION_SCOWLS !(
|| faction_value == FACTION_THREATENINGLY ||
(mob->GetPrimaryFaction() != GetPrimaryFaction() && mob->GetPrimaryFaction() == -4 && GetOwner() == nullptr) faction_value == FACTION_SCOWLS ||
|| (
fv == FACTION_THREATENLY mob->GetPrimaryFaction() != GetPrimaryFaction() &&
)) { mob->GetPrimaryFaction() == -4 &&
towho->Message(Chat::White, "...%s faction not low enough. value='%s'", mob->GetName(), FactionValueToString(fv)); !GetOwner()
)
)
) {
towho->Message(
Chat::White,
fmt::format(
"{} ({}) does not have low enough faction, their Faction Level is {} ({}).",
mob->GetCleanName(),
mob->GetID(),
FactionValueToString(faction_value),
faction_value
).c_str()
);
return; return;
} }
if(fv == FACTION_THREATENLY) {
towho->Message(Chat::White, "...%s threatening to me, so they only have a %d chance per check of attacking.", mob->GetName());
}
if(!CheckLosFN(mob)) { if(!CheckLosFN(mob)) {
towho->Message(Chat::White, "...%s is out of sight.", mob->GetName()); towho->Message(
Chat::White,
fmt::format(
"{} ({}) is out of sight.",
mob->GetCleanName(),
mob->GetID()
).c_str()
);
} }
towho->Message(Chat::White, "...%s meets all conditions, I should be attacking them.", mob->GetName()); towho->Message(
Chat::White,
fmt::format(
"{} ({}) meets all conditions, I should be attacking them.",
mob->GetCleanName(),
mob->GetID()
).c_str()
);
} }
/* /*
@ -229,65 +398,87 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) {
to keep the #aggro command accurate. to keep the #aggro command accurate.
*/ */
bool Mob::CheckWillAggro(Mob *mob) { bool Mob::CheckWillAggro(Mob *mob) {
if(!mob) if(!mob) {
return false; return false;
}
//sometimes if a client has some lag while zoning into a dangerous place while either invis or a GM //sometimes if a client has some lag while zoning into a dangerous place while either invis or a GM
//they will aggro mobs even though it's supposed to be impossible, to lets make sure we've finished connecting //they will aggro mobs even though it's supposed to be impossible, to lets make sure we've finished connecting
if (mob->IsClient()) { if (mob->IsClient()) {
if (!mob->CastToClient()->ClientFinishedLoading() || mob->CastToClient()->IsHoveringForRespawn() || mob->CastToClient()->bZoning) if (
!mob->CastToClient()->ClientFinishedLoading() ||
mob->CastToClient()->IsHoveringForRespawn() ||
mob->CastToClient()->bZoning
) {
return false; return false;
}
} }
// We don't want to aggro clients outside of water if we're water only. // We don't want to aggro clients outside of water if we're water only.
if (mob->IsClient() && mob->CastToClient()->GetLastRegion() != RegionTypeWater && IsUnderwaterOnly()) { if (
mob->IsClient() &&
mob->CastToClient()->GetLastRegion() != RegionTypeWater &&
IsUnderwaterOnly()
) {
return false; return false;
} }
/** /**
* Pets shouldn't scan for aggro * Pets shouldn't scan for aggro
*/ */
if (this->GetOwner()) { if (GetOwner()) {
return false; return false;
} }
Mob *pet_owner = mob->GetOwner(); Mob *pet_owner = mob->GetOwner();
if (pet_owner && pet_owner->IsClient() && (!RuleB(Aggro, AggroPlayerPets) || pet_owner->CastToClient()->GetGM())) { if (
pet_owner &&
pet_owner->IsClient() &&
(
!RuleB(Aggro, AggroPlayerPets) ||
pet_owner->CastToClient()->GetGM()
)
) {
return false; return false;
} }
float iAggroRange = GetAggroRange();
// Check If it's invisible and if we can see invis // Check If it's invisible and if we can see invis
// Check if it's a client, and that the client is connected and not linkdead, // Check if it's a client, and that the client is connected and not linkdead,
// and that the client isn't Playing an NPC, with thier gm flag on // and that the client isn't Playing an NPC, with thier gm flag on
// Check if it's not a Interactive NPC // Check if it's not a Interactive NPC
// Trumpcard: The 1st 3 checks are low cost calcs to filter out unnessecary distance checks. Leave them at the beginning, they are the most likely occurence. // Trumpcard: The 1st 3 checks are low cost calcs to filter out unnessecary distance checks. Leave them at the beginning, they are the most likely occurence.
// Image: I moved this up by itself above faction and distance checks because if one of these return true, theres no reason to go through the other information // Image: I moved this up by itself above faction and distance checks because if one of these return true, theres no reason to go through the other information
float aggro_range = GetAggroRange();
float x_range = std::abs(mob->GetX() - GetX());
float y_range = std::abs(mob->GetY() - GetY());
float z_range = std::abs(mob->GetZ() - GetZ());
float t1, t2, t3; if (
t1 = std::abs(mob->GetX() - GetX()); x_range > aggro_range ||
t2 = std::abs(mob->GetY() - GetY()); y_range > aggro_range ||
t3 = std::abs(mob->GetZ() - GetZ()); z_range > aggro_range ||
mob->IsInvisible(this) ||
if(( t1 > iAggroRange) (
|| ( t2 > iAggroRange) mob->IsClient() &&
|| ( t3 > iAggroRange) (
|| (mob->IsInvisible(this)) !mob->CastToClient()->Connected()
|| (mob->IsClient() &&
(!mob->CastToClient()->Connected()
|| mob->CastToClient()->IsLD() || mob->CastToClient()->IsLD()
|| mob->CastToClient()->IsBecomeNPC() || mob->CastToClient()->IsBecomeNPC()
|| mob->CastToClient()->GetGM() || mob->CastToClient()->GetGM()
) )
)) )
{ ) {
return(false); return false;
} }
// Don't aggro new clients if we are already engaged unless PROX_AGGRO is set // Don't aggro new clients if we are already engaged unless PROX_AGGRO is set
if (IsEngaged() && (!GetSpecialAbility(PROX_AGGRO) || (GetSpecialAbility(PROX_AGGRO) && !CombatRange(mob)))) { if (IsEngaged() && (!GetSpecialAbility(PROX_AGGRO) || (GetSpecialAbility(PROX_AGGRO) && !CombatRange(mob)))) {
LogAggro("[{}] is in combat, and does not have prox_aggro, or does and is out of combat range with [{}]", GetName(), mob->GetName()); LogAggro(
"[{}] is in combat, and does not have prox_aggro, or does and is out of combat range with [{}]",
GetName(),
mob->GetName()
);
return false; return false;
} }
@ -296,105 +487,100 @@ bool Mob::CheckWillAggro(Mob *mob) {
//aggro this mob...??? //aggro this mob...???
//changed to be 'if I have an owner and this is it' //changed to be 'if I have an owner and this is it'
if(mob == GetOwner()) { if(mob == GetOwner()) {
return(false); return false;
} }
float dist2 = DistanceSquared(mob->GetPosition(), m_Position); float distance_squared = DistanceSquared(mob->GetPosition(), m_Position);
float iAggroRange2 = iAggroRange*iAggroRange; float aggro_range_squared = (aggro_range * aggro_range);
if( dist2 > iAggroRange2 ) { if (distance_squared > aggro_range_squared ) {
// Skip it, out of range // Skip it, out of range
return(false); return false;
} }
//Image: Get their current target and faction value now that its required //Image: Get their current target and faction value now that its required
//this function call should seem backwards //this function call should seem backwards
FACTION_VALUE fv = mob->GetReverseFactionCon(this); FACTION_VALUE faction_value = mob->GetReverseFactionCon(this);
// Make sure they're still in the zone // Make sure they're still in the zone
// Are they in range? // Are they in range?
// Are they kos? // Are they kos?
// Are we stupid or are they green // Are we stupid or are they green
// and they don't have their gm flag on // and they don't have their gm flag on
int heroicCHA_mod = mob->itembonuses.HeroicCHA/25; // 800 Heroic CHA cap int heroic_cha_mod = (mob->itembonuses.HeroicCHA / 25); // 800 Heroic CHA cap
if(heroicCHA_mod > THREATENLY_ARRGO_CHANCE) if(heroic_cha_mod > THREATENINGLY_AGGRO_CHANCE) {
heroicCHA_mod = THREATENLY_ARRGO_CHANCE; heroic_cha_mod = THREATENINGLY_AGGRO_CHANCE;
if (RuleB(Aggro, UseLevelAggro) && }
(
//old InZone check taken care of above by !mob->CastToClient()->Connected()
(
( GetLevel() >= RuleI(Aggro, MinAggroLevel))
||(GetBodyType() == 3) || AlwaysAggro()
||( mob->IsClient() && mob->CastToClient()->IsSitting() )
||( mob->GetLevelCon(GetLevel()) != CON_GRAY)
) if (
&& RuleB(Aggro, UseLevelAggro) &&
(
( (
fv == FACTION_SCOWLS GetLevel() >= RuleI(Aggro, MinAggroLevel) ||
|| GetBodyType() == BT_Undead ||
(mob->GetPrimaryFaction() != GetPrimaryFaction() && mob->GetPrimaryFaction() == -4 && GetOwner() == nullptr) AlwaysAggro() ||
||
( (
fv == FACTION_THREATENLY mob->IsClient() &&
&& zone->random.Roll(THREATENLY_ARRGO_CHANCE - heroicCHA_mod) mob->CastToClient()->IsSitting()
) ||
mob->GetLevelCon(GetLevel()) != CON_GRAY
) &&
(
faction_value == FACTION_SCOWLS ||
(
mob->GetPrimaryFaction() != GetPrimaryFaction() &&
mob->GetPrimaryFaction() == -4 &&
!GetOwner()
) ||
(
faction_value == FACTION_THREATENINGLY &&
zone->random.Roll(THREATENINGLY_AGGRO_CHANCE - heroic_cha_mod)
) )
) )
) ) {
)
)
{
//FatherNiwtit: make sure we can see them. last since it is very expensive
if(CheckLosFN(mob)) { if(CheckLosFN(mob)) {
LogAggro("Check aggro for [{}] target [{}]", GetName(), mob->GetName()); LogAggro("Check aggro for [{}] target [{}]", GetName(), mob->GetName());
return( mod_will_aggro(mob, this) ); return mod_will_aggro(mob, this);
} }
} } else {
else if (
{
if
(
//old InZone check taken care of above by !mob->CastToClient()->Connected()
(
( GetINT() <= RuleI(Aggro, IntAggroThreshold) )
|| AlwaysAggro()
||( mob->IsClient() && mob->CastToClient()->IsSitting() )
||( mob->GetLevelCon(GetLevel()) != CON_GRAY)
)
&&
(
( (
fv == FACTION_SCOWLS GetINT() <= RuleI(Aggro, IntAggroThreshold) ||
|| AlwaysAggro() ||
(mob->GetPrimaryFaction() != GetPrimaryFaction() && mob->GetPrimaryFaction() == -4 && GetOwner() == nullptr)
||
( (
fv == FACTION_THREATENLY mob->IsClient() &&
&& zone->random.Roll(THREATENLY_ARRGO_CHANCE - heroicCHA_mod) mob->CastToClient()->IsSitting()
) ||
mob->GetLevelCon(GetLevel()) != CON_GRAY
) &&
(
faction_value == FACTION_SCOWLS ||
(
mob->GetPrimaryFaction() != GetPrimaryFaction() &&
mob->GetPrimaryFaction() == -4 &&
!GetOwner()
) ||
(
faction_value == FACTION_THREATENINGLY
&& zone->random.Roll(THREATENINGLY_AGGRO_CHANCE - heroic_cha_mod)
) )
) )
) ) {
)
{
//FatherNiwtit: make sure we can see them. last since it is very expensive
if(CheckLosFN(mob)) { if(CheckLosFN(mob)) {
LogAggro("Check aggro for [{}] target [{}]", GetName(), mob->GetName()); LogAggro("Check aggro for [{}] target [{}]", GetName(), mob->GetName());
return( mod_will_aggro(mob, this) ); return mod_will_aggro(mob, this);
} }
} }
} }
LogAggro("Is In zone?:[{}]\n", mob->InZone()); LogAggro("Is In zone?:[{}]\n", mob->InZone());
LogAggro("Dist^2: [{}]\n", dist2); LogAggro("Dist^2: [{}]\n", distance_squared);
LogAggro("Range^2: [{}]\n", iAggroRange2); LogAggro("Range^2: [{}]\n", aggro_range_squared);
LogAggro("Faction: [{}]\n", fv); LogAggro("Faction: [{}]\n", faction_value);
LogAggro("AlwaysAggroFlag: [{}]\n", AlwaysAggro()); LogAggro("AlwaysAggroFlag: [{}]\n", AlwaysAggro());
LogAggro("Int: [{}]\n", GetINT()); LogAggro("Int: [{}]\n", GetINT());
LogAggro("Con: [{}]\n", GetLevelCon(mob->GetLevel())); LogAggro("Con: [{}]\n", GetLevelCon(mob->GetLevel()));
return(false); return false;
} }
int EntityList::GetHatedCount(Mob *attacker, Mob *exclude, bool inc_gray_con) int EntityList::GetHatedCount(Mob *attacker, Mob *exclude, bool inc_gray_con)

View File

@ -3471,7 +3471,7 @@ float Client::CalcPriceMod(Mob* other, bool reverse)
if (other) if (other)
{ {
int factionlvl = GetFactionLevel(CharacterID(), other->CastToNPC()->GetNPCTypeID(), GetFactionRace(), GetClass(), GetDeity(), other->CastToNPC()->GetPrimaryFaction(), other); int factionlvl = GetFactionLevel(CharacterID(), other->CastToNPC()->GetNPCTypeID(), GetFactionRace(), GetClass(), GetDeity(), other->CastToNPC()->GetPrimaryFaction(), other);
if (factionlvl >= FACTION_APPREHENSIVE) // Apprehensive or worse. if (factionlvl >= FACTION_APPREHENSIVELY) // Apprehensive or worse.
{ {
if (GetCHA() > 103) if (GetCHA() > 103)
{ {
@ -3486,7 +3486,7 @@ float Client::CalcPriceMod(Mob* other, bool reverse)
chaformula = 1*(RuleI(Merchant, PricePenaltyPct)); chaformula = 1*(RuleI(Merchant, PricePenaltyPct));
} }
} }
if (factionlvl <= FACTION_INDIFFERENT) // Indifferent or better. if (factionlvl <= FACTION_INDIFFERENTLY) // Indifferent or better.
{ {
if (GetCHA() > 75) if (GetCHA() > 75)
{ {
@ -7860,7 +7860,7 @@ FACTION_VALUE Client::GetReverseFactionCon(Mob* iOther) {
return GetSpecialFactionCon(iOther); return GetSpecialFactionCon(iOther);
if (iOther->GetPrimaryFaction() == 0) if (iOther->GetPrimaryFaction() == 0)
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
return GetFactionLevel(CharacterID(), 0, GetFactionRace(), GetClass(), GetDeity(), iOther->GetPrimaryFaction(), iOther); return GetFactionLevel(CharacterID(), 0, GetFactionRace(), GetClass(), GetDeity(), iOther->GetPrimaryFaction(), iOther);
} }
@ -7883,25 +7883,25 @@ FACTION_VALUE Client::GetFactionLevel(uint32 char_id, uint32 npc_id, uint32 p_ra
{ {
if (pFaction < 0) if (pFaction < 0)
return GetSpecialFactionCon(tnpc); return GetSpecialFactionCon(tnpc);
FACTION_VALUE fac = FACTION_INDIFFERENT; FACTION_VALUE fac = FACTION_INDIFFERENTLY;
int32 tmpFactionValue; int32 tmpFactionValue;
FactionMods fmods; FactionMods fmods;
// few optimizations // few optimizations
if (GetFeigned()) if (GetFeigned())
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
if(!zone->CanDoCombat()) if(!zone->CanDoCombat())
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
if (invisible_undead && tnpc && !tnpc->SeeInvisibleUndead()) if (invisible_undead && tnpc && !tnpc->SeeInvisibleUndead())
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
if (IsInvisible(tnpc)) if (IsInvisible(tnpc))
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
if (tnpc && tnpc->GetOwnerID() != 0) // pets con amiably to owner and indiff to rest if (tnpc && tnpc->GetOwnerID() != 0) // pets con amiably to owner and indiff to rest
{ {
if (char_id == tnpc->GetOwner()->CastToClient()->CharacterID()) if (char_id == tnpc->GetOwner()->CastToClient()->CharacterID())
return FACTION_AMIABLE; return FACTION_AMIABLY;
else else
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
} }
//First get the NPC's Primary faction //First get the NPC's Primary faction
@ -7921,15 +7921,15 @@ FACTION_VALUE Client::GetFactionLevel(uint32 char_id, uint32 npc_id, uint32 p_ra
} }
else else
{ {
return(FACTION_INDIFFERENT); return(FACTION_INDIFFERENTLY);
} }
// merchant fix // merchant fix
if (tnpc && tnpc->IsNPC() && tnpc->CastToNPC()->MerchantType && (fac == FACTION_THREATENLY || fac == FACTION_SCOWLS)) if (tnpc && tnpc->IsNPC() && tnpc->CastToNPC()->MerchantType && (fac == FACTION_THREATENINGLY || fac == FACTION_SCOWLS))
fac = FACTION_DUBIOUS; fac = FACTION_DUBIOUSLY;
if (tnpc != 0 && fac != FACTION_SCOWLS && tnpc->CastToNPC()->CheckAggro(this)) if (tnpc != 0 && fac != FACTION_SCOWLS && tnpc->CastToNPC()->CheckAggro(this))
fac = FACTION_THREATENLY; fac = FACTION_THREATENINGLY;
return fac; return fac;
} }

View File

@ -4875,7 +4875,7 @@ void Client::Handle_OP_Consider(const EQApplicationPacket *app)
if (tmob->IsNPC()) if (tmob->IsNPC())
{ {
if (GetFeigned()) if (GetFeigned())
con->faction = FACTION_INDIFFERENT; con->faction = FACTION_INDIFFERENTLY;
} }
if (!(con->faction == FACTION_SCOWLS)) if (!(con->faction == FACTION_SCOWLS))
@ -4883,21 +4883,21 @@ void Client::Handle_OP_Consider(const EQApplicationPacket *app)
if (tmob->IsNPC()) if (tmob->IsNPC())
{ {
if (tmob->CastToNPC()->IsOnHatelist(this)) if (tmob->CastToNPC()->IsOnHatelist(this))
con->faction = FACTION_THREATENLY; con->faction = FACTION_THREATENINGLY;
} }
} }
if (con->faction == FACTION_APPREHENSIVE) { if (con->faction == FACTION_APPREHENSIVELY) {
con->faction = FACTION_SCOWLS; con->faction = FACTION_SCOWLS;
} }
else if (con->faction == FACTION_DUBIOUS) { else if (con->faction == FACTION_DUBIOUSLY) {
con->faction = FACTION_THREATENLY; con->faction = FACTION_THREATENINGLY;
} }
else if (con->faction == FACTION_SCOWLS) { else if (con->faction == FACTION_SCOWLS) {
con->faction = FACTION_APPREHENSIVE; con->faction = FACTION_APPREHENSIVELY;
} }
else if (con->faction == FACTION_THREATENLY) { else if (con->faction == FACTION_THREATENINGLY) {
con->faction = FACTION_DUBIOUS; con->faction = FACTION_DUBIOUSLY;
} }
mod_consider(tmob, con); mod_consider(tmob, con);

View File

@ -116,7 +116,7 @@ int command_init(void)
if ( if (
command_add("acceptrules", "[acceptrules] - Accept the EQEmu Agreement", AccountStatus::Player, command_acceptrules) || command_add("acceptrules", "[acceptrules] - Accept the EQEmu Agreement", AccountStatus::Player, command_acceptrules) ||
command_add("advnpcspawn", "[maketype|makegroup|addgroupentry|addgroupspawn][removegroupspawn|movespawn|editgroupbox|cleargroupbox]", AccountStatus::GMLeadAdmin, command_advnpcspawn) || command_add("advnpcspawn", "[maketype|makegroup|addgroupentry|addgroupspawn][removegroupspawn|movespawn|editgroupbox|cleargroupbox]", AccountStatus::GMLeadAdmin, command_advnpcspawn) ||
command_add("aggro", "(range) [-v] - Display aggro information for all mobs 'range' distance from your target. -v is verbose faction info.", AccountStatus::QuestTroupe, command_aggro) || command_add("aggro", "[Distance] [-v] - Display aggro information for all mobs 'Distance' distance from your target. (-v is verbose Faction Information)", AccountStatus::QuestTroupe, command_aggro) ||
command_add("aggrozone", "[aggro] - Aggro every mob in the zone with X aggro. Default is 0. Not recommend if you're not invulnerable.", AccountStatus::GMAdmin, command_aggrozone) || command_add("aggrozone", "[aggro] - Aggro every mob in the zone with X aggro. Default is 0. Not recommend if you're not invulnerable.", AccountStatus::GMAdmin, command_aggrozone) ||
command_add("ai", "[factionid/spellslist/con/guard/roambox/stop/start] - Modify AI on NPC target", AccountStatus::GMAdmin, command_ai) || command_add("ai", "[factionid/spellslist/con/guard/roambox/stop/start] - Modify AI on NPC target", AccountStatus::GMAdmin, command_ai) ||
command_add("appearance", "[type] [value] - Send an appearance packet for you or your target", AccountStatus::GMLeadAdmin, command_appearance) || command_add("appearance", "[type] [value] - Send an appearance packet for you or your target", AccountStatus::GMLeadAdmin, command_appearance) ||

View File

@ -1033,14 +1033,14 @@ void EntityList::AESpell(
//which have bad faction with us //which have bad faction with us
if ( if (
!(caster_mob->CheckAggro(current_mob) || !(caster_mob->CheckAggro(current_mob) ||
faction_value == FACTION_THREATENLY || faction_value == FACTION_THREATENINGLY ||
faction_value == FACTION_SCOWLS)) { faction_value == FACTION_SCOWLS)) {
continue; continue;
} }
} }
else { else {
//only affect mobs we would assist. //only affect mobs we would assist.
if (!(faction_value <= FACTION_AMIABLE)) { if (!(faction_value <= FACTION_AMIABLY)) {
continue; continue;
} }
} }
@ -1209,13 +1209,13 @@ void EntityList::AEBardPulse(
if (is_detrimental_spell) { if (is_detrimental_spell) {
//affect mobs that are on our hate list, or //affect mobs that are on our hate list, or
//which have bad faction with us //which have bad faction with us
if (!(caster->CheckAggro(current_mob) || faction == FACTION_THREATENLY || faction == FACTION_SCOWLS)) { if (!(caster->CheckAggro(current_mob) || faction == FACTION_THREATENINGLY || faction == FACTION_SCOWLS)) {
continue; continue;
} }
} }
else { else {
//only affect mobs we would assist. //only affect mobs we would assist.
if (!(faction <= FACTION_AMIABLE)) { if (!(faction <= FACTION_AMIABLY)) {
continue; continue;
} }
} }

View File

@ -3671,7 +3671,7 @@ void EntityList::SendAlarm(Trap *trap, Mob *currenttarget, uint8 kos)
if (kos) { if (kos) {
uint8 factioncon = currenttarget->GetReverseFactionCon(cur); uint8 factioncon = currenttarget->GetReverseFactionCon(cur);
if (factioncon == FACTION_THREATENLY || factioncon == FACTION_SCOWLS) { if (factioncon == FACTION_THREATENINGLY || factioncon == FACTION_SCOWLS) {
cur->AddToHateList(currenttarget,1); cur->AddToHateList(currenttarget,1);
} }
} }

View File

@ -2,20 +2,27 @@
void command_aggro(Client *c, const Seperator *sep) void command_aggro(Client *c, const Seperator *sep)
{ {
if (c->GetTarget() == nullptr || !c->GetTarget()->IsNPC()) { int arguments = sep->argnum;
c->Message(Chat::White, "Error: you must have an NPC target."); if (!arguments || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #aggro [Distance] [-v] (-v is verbose Faction Information)");
return; return;
} }
float d = atof(sep->arg[1]);
if (d == 0.0f) {
c->Message(Chat::Red, "Error: distance argument required.");
return;
}
bool verbose = false;
if (sep->arg[2][0] == '-' && sep->arg[2][1] == 'v' && sep->arg[2][2] == '\0') {
verbose = true;
}
entity_list.DescribeAggro(c, c->GetTarget()->CastToNPC(), d, verbose); if (
!c->GetTarget() ||
(
c->GetTarget() &&
!c->GetTarget()->IsNPC()
)
) {
c->Message(Chat::White, "You must target an NPC to use this command.");
return;
}
NPC* target = c->GetTarget()->CastToNPC();
float distance = std::stof(sep->arg[1]);
bool verbose = !strcasecmp("-v", sep->arg[2]);
entity_list.DescribeAggro(c, target, distance, verbose);
} }

View File

@ -4193,11 +4193,11 @@ luabind::scope lua_register_faction() {
luabind::value("Ally", static_cast<int>(FACTION_ALLY)), luabind::value("Ally", static_cast<int>(FACTION_ALLY)),
luabind::value("Warmly", static_cast<int>(FACTION_WARMLY)), luabind::value("Warmly", static_cast<int>(FACTION_WARMLY)),
luabind::value("Kindly", static_cast<int>(FACTION_KINDLY)), luabind::value("Kindly", static_cast<int>(FACTION_KINDLY)),
luabind::value("Amiable", static_cast<int>(FACTION_AMIABLE)), luabind::value("Amiable", static_cast<int>(FACTION_AMIABLY)),
luabind::value("Indifferent", static_cast<int>(FACTION_INDIFFERENT)), luabind::value("Indifferent", static_cast<int>(FACTION_INDIFFERENTLY)),
luabind::value("Apprehensive", static_cast<int>(FACTION_APPREHENSIVE)), luabind::value("Apprehensive", static_cast<int>(FACTION_APPREHENSIVELY)),
luabind::value("Dubious", static_cast<int>(FACTION_DUBIOUS)), luabind::value("Dubious", static_cast<int>(FACTION_DUBIOUSLY)),
luabind::value("Threatenly", static_cast<int>(FACTION_THREATENLY)), luabind::value("Threatenly", static_cast<int>(FACTION_THREATENINGLY)),
luabind::value("Scowls", static_cast<int>(FACTION_SCOWLS)) luabind::value("Scowls", static_cast<int>(FACTION_SCOWLS))
]; ];
} }

View File

@ -5715,7 +5715,7 @@ void Mob::ClearItemFactionBonuses() {
FACTION_VALUE Mob::GetSpecialFactionCon(Mob* iOther) { FACTION_VALUE Mob::GetSpecialFactionCon(Mob* iOther) {
if (!iOther) if (!iOther)
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
iOther = iOther->GetOwnerOrSelf(); iOther = iOther->GetOwnerOrSelf();
Mob* self = this->GetOwnerOrSelf(); Mob* self = this->GetOwnerOrSelf();
@ -5726,9 +5726,9 @@ FACTION_VALUE Mob::GetSpecialFactionCon(Mob* iOther) {
int iOtherPrimaryFaction = iOther->GetPrimaryFaction(); int iOtherPrimaryFaction = iOther->GetPrimaryFaction();
if (selfPrimaryFaction >= 0 && selfAIcontrolled) if (selfPrimaryFaction >= 0 && selfAIcontrolled)
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
if (iOther->GetPrimaryFaction() >= 0) if (iOther->GetPrimaryFaction() >= 0)
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
/* special values: /* special values:
-2 = indiff to player, ally to AI on special values, indiff to AI -2 = indiff to player, ally to AI on special values, indiff to AI
-3 = dub to player, ally to AI on special values, indiff to AI -3 = dub to player, ally to AI on special values, indiff to AI
@ -5748,27 +5748,27 @@ FACTION_VALUE Mob::GetSpecialFactionCon(Mob* iOther) {
if (selfAIcontrolled && iOtherAIControlled) if (selfAIcontrolled && iOtherAIControlled)
return FACTION_ALLY; return FACTION_ALLY;
else else
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
case -3: // -3 = dub to player, ally to AI on special values, indiff to AI case -3: // -3 = dub to player, ally to AI on special values, indiff to AI
if (selfAIcontrolled && iOtherAIControlled) if (selfAIcontrolled && iOtherAIControlled)
return FACTION_ALLY; return FACTION_ALLY;
else else
return FACTION_DUBIOUS; return FACTION_DUBIOUSLY;
case -4: // -4 = atk to player, ally to AI on special values, indiff to AI case -4: // -4 = atk to player, ally to AI on special values, indiff to AI
if (selfAIcontrolled && iOtherAIControlled) if (selfAIcontrolled && iOtherAIControlled)
return FACTION_ALLY; return FACTION_ALLY;
else else
return FACTION_SCOWLS; return FACTION_SCOWLS;
case -5: // -5 = indiff to player, indiff to AI case -5: // -5 = indiff to player, indiff to AI
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
case -6: // -6 = dub to player, indiff to AI case -6: // -6 = dub to player, indiff to AI
if (selfAIcontrolled && iOtherAIControlled) if (selfAIcontrolled && iOtherAIControlled)
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
else else
return FACTION_DUBIOUS; return FACTION_DUBIOUSLY;
case -7: // -7 = atk to player, indiff to AI case -7: // -7 = atk to player, indiff to AI
if (selfAIcontrolled && iOtherAIControlled) if (selfAIcontrolled && iOtherAIControlled)
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
else else
return FACTION_SCOWLS; return FACTION_SCOWLS;
case -8: // -8 = indiff to players, ally to AI on same value, indiff to AI case -8: // -8 = indiff to players, ally to AI on same value, indiff to AI
@ -5776,25 +5776,25 @@ FACTION_VALUE Mob::GetSpecialFactionCon(Mob* iOther) {
if (selfPrimaryFaction == iOtherPrimaryFaction) if (selfPrimaryFaction == iOtherPrimaryFaction)
return FACTION_ALLY; return FACTION_ALLY;
else else
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
} }
else else
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
case -9: // -9 = dub to players, ally to AI on same value, indiff to AI case -9: // -9 = dub to players, ally to AI on same value, indiff to AI
if (selfAIcontrolled && iOtherAIControlled) { if (selfAIcontrolled && iOtherAIControlled) {
if (selfPrimaryFaction == iOtherPrimaryFaction) if (selfPrimaryFaction == iOtherPrimaryFaction)
return FACTION_ALLY; return FACTION_ALLY;
else else
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
} }
else else
return FACTION_DUBIOUS; return FACTION_DUBIOUSLY;
case -10: // -10 = atk to players, ally to AI on same value, indiff to AI case -10: // -10 = atk to players, ally to AI on same value, indiff to AI
if (selfAIcontrolled && iOtherAIControlled) { if (selfAIcontrolled && iOtherAIControlled) {
if (selfPrimaryFaction == iOtherPrimaryFaction) if (selfPrimaryFaction == iOtherPrimaryFaction)
return FACTION_ALLY; return FACTION_ALLY;
else else
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
} }
else else
return FACTION_SCOWLS; return FACTION_SCOWLS;
@ -5806,7 +5806,7 @@ FACTION_VALUE Mob::GetSpecialFactionCon(Mob* iOther) {
return FACTION_SCOWLS; return FACTION_SCOWLS;
} }
else else
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
case -12: // -12 = dub to players, ally to AI on same value, atk to AI case -12: // -12 = dub to players, ally to AI on same value, atk to AI
if (selfAIcontrolled && iOtherAIControlled) { if (selfAIcontrolled && iOtherAIControlled) {
if (selfPrimaryFaction == iOtherPrimaryFaction) if (selfPrimaryFaction == iOtherPrimaryFaction)
@ -5817,7 +5817,7 @@ FACTION_VALUE Mob::GetSpecialFactionCon(Mob* iOther) {
} }
else else
return FACTION_DUBIOUS; return FACTION_DUBIOUSLY;
case -13: // -13 = atk to players, ally to AI on same value, atk to AI case -13: // -13 = atk to players, ally to AI on same value, atk to AI
if (selfAIcontrolled && iOtherAIControlled) { if (selfAIcontrolled && iOtherAIControlled) {
if (selfPrimaryFaction == iOtherPrimaryFaction) if (selfPrimaryFaction == iOtherPrimaryFaction)
@ -5828,7 +5828,7 @@ FACTION_VALUE Mob::GetSpecialFactionCon(Mob* iOther) {
else else
return FACTION_SCOWLS; return FACTION_SCOWLS;
default: default:
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
} }
} }

View File

@ -1176,7 +1176,7 @@ public:
inline float GetCWPP() const { return(static_cast<float>(cur_wp_pause)); } inline float GetCWPP() const { return(static_cast<float>(cur_wp_pause)); }
inline int GetCWP() const { return(cur_wp); } inline int GetCWP() const { return(cur_wp); }
void SetCurrentWP(int waypoint) { cur_wp = waypoint; } void SetCurrentWP(int waypoint) { cur_wp = waypoint; }
virtual FACTION_VALUE GetReverseFactionCon(Mob* iOther) { return FACTION_INDIFFERENT; } virtual FACTION_VALUE GetReverseFactionCon(Mob* iOther) { return FACTION_INDIFFERENTLY; }
virtual const bool IsUnderwaterOnly() const { return false; } virtual const bool IsUnderwaterOnly() const { return false; }
inline bool IsTrackable() const { return(trackable); } inline bool IsTrackable() const { return(trackable); }

View File

@ -2907,7 +2907,7 @@ FACTION_VALUE NPC::GetReverseFactionCon(Mob* iOther) {
return GetSpecialFactionCon(iOther); return GetSpecialFactionCon(iOther);
if (primaryFaction == 0) if (primaryFaction == 0)
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
//if we are a pet, use our owner's faction stuff //if we are a pet, use our owner's faction stuff
Mob *own = GetOwner(); Mob *own = GetOwner();
@ -2917,7 +2917,7 @@ FACTION_VALUE NPC::GetReverseFactionCon(Mob* iOther) {
//make sure iOther is an npc //make sure iOther is an npc
//also, if we dont have a faction, then they arnt gunna think anything of us either //also, if we dont have a faction, then they arnt gunna think anything of us either
if(!iOther->IsNPC() || GetPrimaryFaction() == 0) if(!iOther->IsNPC() || GetPrimaryFaction() == 0)
return(FACTION_INDIFFERENT); return(FACTION_INDIFFERENTLY);
//if we get here, iOther is an NPC too //if we get here, iOther is an NPC too
@ -2941,7 +2941,7 @@ FACTION_VALUE NPC::CheckNPCFactionAlly(int32 other_faction) {
else if (fac->npc_value < 0) else if (fac->npc_value < 0)
return FACTION_SCOWLS; return FACTION_SCOWLS;
else else
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
} }
} }
@ -2953,7 +2953,7 @@ FACTION_VALUE NPC::CheckNPCFactionAlly(int32 other_faction) {
if (GetPrimaryFaction() == other_faction) if (GetPrimaryFaction() == other_faction)
return FACTION_ALLY; return FACTION_ALLY;
else else
return FACTION_INDIFFERENT; return FACTION_INDIFFERENTLY;
} }
bool NPC::IsFactionListAlly(uint32 other_faction) { bool NPC::IsFactionListAlly(uint32 other_faction) {
@ -3421,7 +3421,7 @@ void NPC::AIYellForHelp(Mob *sender, Mob *attacker)
} }
} }
if (sender->GetReverseFactionCon(mob) <= FACTION_AMIABLE) { if (sender->GetReverseFactionCon(mob) <= FACTION_AMIABLY) {
//attacking someone on same faction, or a friend //attacking someone on same faction, or a friend
//Father Nitwit: make sure we can see them. //Father Nitwit: make sure we can see them.
if (mob->CheckLosFN(sender)) { if (mob->CheckLosFN(sender)) {

View File

@ -3105,19 +3105,19 @@ uint8 QuestManager::FactionValue()
case FACTION_SCOWLS: case FACTION_SCOWLS:
newfac = 1; newfac = 1;
break; break;
case FACTION_THREATENLY: case FACTION_THREATENINGLY:
newfac = 2; newfac = 2;
break; break;
case FACTION_DUBIOUS: case FACTION_DUBIOUSLY:
newfac = 3; newfac = 3;
break; break;
case FACTION_APPREHENSIVE: case FACTION_APPREHENSIVELY:
newfac = 4; newfac = 4;
break; break;
case FACTION_INDIFFERENT: case FACTION_INDIFFERENTLY:
newfac = 5; newfac = 5;
break; break;
case FACTION_AMIABLE: case FACTION_AMIABLY:
newfac = 6; newfac = 6;
break; break;
case FACTION_KINDLY: case FACTION_KINDLY:

View File

@ -6181,13 +6181,13 @@ void Mob::BeamDirectional(uint16 spell_id, int16 resist_adjust)
auto fac = (*iter)->GetReverseFactionCon(this); auto fac = (*iter)->GetReverseFactionCon(this);
if (beneficial_targets) { if (beneficial_targets) {
// only affect mobs we would assist. // only affect mobs we would assist.
if (!(fac <= FACTION_AMIABLE)) { if (!(fac <= FACTION_AMIABLY)) {
++iter; ++iter;
continue; continue;
} }
} else { } else {
// affect mobs that are on our hate list, or which have bad faction with us // affect mobs that are on our hate list, or which have bad faction with us
if (!(CheckAggro(*iter) || fac == FACTION_THREATENLY || fac == FACTION_SCOWLS)) { if (!(CheckAggro(*iter) || fac == FACTION_THREATENINGLY || fac == FACTION_SCOWLS)) {
++iter; ++iter;
continue; continue;
} }
@ -6256,13 +6256,13 @@ void Mob::ConeDirectional(uint16 spell_id, int16 resist_adjust)
auto fac = (*iter)->GetReverseFactionCon(this); auto fac = (*iter)->GetReverseFactionCon(this);
if (beneficial_targets) { if (beneficial_targets) {
// only affect mobs we would assist. // only affect mobs we would assist.
if (!(fac <= FACTION_AMIABLE)) { if (!(fac <= FACTION_AMIABLY)) {
++iter; ++iter;
continue; continue;
} }
} else { } else {
// affect mobs that are on our hate list, or which have bad faction with us // affect mobs that are on our hate list, or which have bad faction with us
if (!(CheckAggro(*iter) || fac == FACTION_THREATENLY || fac == FACTION_SCOWLS)) { if (!(CheckAggro(*iter) || fac == FACTION_THREATENINGLY || fac == FACTION_SCOWLS)) {
++iter; ++iter;
continue; continue;
} }