mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-10 15:00:25 +00:00
[Bug Fix] NPC Faction War prevention. (#3595)
* [Bug] NPC Faction War prevention. This should assist with prevention of NPC Faction waring. I have been using this code on my server for over 5 years with no coredumps or any noted bugs. This was brought up as users have reported a few events where they can trigger NPC's to fight each other. * Correct a few entries to line up with updated code. * Re-add missing RestTimer functionality
This commit is contained in:
+29
-31
@@ -4244,41 +4244,39 @@ bool Mob::SpellOnTarget(
|
||||
spelltar->DamageShield(this, true);
|
||||
}
|
||||
|
||||
if (
|
||||
spelltar->IsAIControlled() &&
|
||||
IsDetrimentalSpell(spell_id) &&
|
||||
!IsHarmonySpell(spell_id)
|
||||
) {
|
||||
auto aggro_amount = CheckAggroAmount(spell_id, spelltar, isproc);
|
||||
LogSpells("Spell [{}] cast on [{}] generated [{}] hate", spell_id,
|
||||
spelltar->GetName(), aggro_amount);
|
||||
if (aggro_amount > 0) {
|
||||
spelltar->AddToHateList(this, aggro_amount);
|
||||
} else {
|
||||
int64 newhate = spelltar->GetHateAmount(this) + aggro_amount;
|
||||
spelltar->SetHateAmountOnEnt(this, std::max(newhate, static_cast<int64>(1)));
|
||||
}
|
||||
} else if (IsBeneficialSpell(spell_id) && !IsSummonPCSpell(spell_id)) {
|
||||
if (this != spelltar && IsClient()){
|
||||
if (spelltar->IsClient()) {
|
||||
CastToClient()->UpdateRestTimer(spelltar->CastToClient()->GetRestTimer());
|
||||
} else if (spelltar->IsPet()) {
|
||||
auto* owner = spelltar->GetOwner();
|
||||
if (owner && owner != this && owner->IsClient()) {
|
||||
CastToClient()->UpdateRestTimer(owner->CastToClient()->GetRestTimer());
|
||||
if (!(spelltar->IsNPC() && IsNPC() && !(IsPet() && GetOwner()->IsClient()))) {
|
||||
if (spelltar->IsAIControlled() && IsDetrimentalSpell(spell_id) && !IsHarmonySpell(spell_id)) {
|
||||
auto aggro_amount = CheckAggroAmount(spell_id, spelltar, isproc);
|
||||
LogSpellsDetail("Spell {} cast on {} generated {} hate", spell_id,
|
||||
spelltar->GetName(), aggro_amount);
|
||||
if (aggro_amount > 0) {
|
||||
spelltar->AddToHateList(this, aggro_amount);
|
||||
} else {
|
||||
int64 newhate = spelltar->GetHateAmount(this) + aggro_amount;
|
||||
spelltar->SetHateAmountOnEnt(this, std::max(newhate, static_cast<int64>(1)));
|
||||
}
|
||||
} else if (IsBeneficialSpell(spell_id) && !IsSummonPCSpell(spell_id)) {
|
||||
if (this != spelltar && IsClient()){
|
||||
if (spelltar->IsClient()) {
|
||||
CastToClient()->UpdateRestTimer(spelltar->CastToClient()->GetRestTimer());
|
||||
} else if (spelltar->IsPet()) {
|
||||
auto* owner = spelltar->GetOwner();
|
||||
if (owner && owner != this && owner->IsClient()) {
|
||||
CastToClient()->UpdateRestTimer(owner->CastToClient()->GetRestTimer());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entity_list.AddHealAggro(
|
||||
spelltar,
|
||||
this,
|
||||
CheckHealAggroAmount(
|
||||
spell_id,
|
||||
entity_list.AddHealAggro(
|
||||
spelltar,
|
||||
(spelltar->GetMaxHP() - spelltar->GetHP())
|
||||
)
|
||||
);
|
||||
this,
|
||||
CheckHealAggroAmount(
|
||||
spell_id,
|
||||
spelltar,
|
||||
(spelltar->GetMaxHP() - spelltar->GetHP())
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// make sure spelltar is high enough level for the buff
|
||||
|
||||
Reference in New Issue
Block a user