mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
Tweak NPC AI Heal logic a bit
New rule: Spells:AI_HealHPPct defaults to 50 This is the default maximum HP and NPC will start a heal The spell AI fields min_hp and max_hp are now used to override the HP percentages they will heal at
This commit is contained in:
+9
-4
@@ -97,10 +97,11 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint32 iSpellTypes, bool bInnates
|
||||
continue;
|
||||
}
|
||||
|
||||
if (AIspells[i].min_hp != 0 && GetIntHPRatio() < AIspells[i].min_hp)
|
||||
// we reuse these fields for heal overrides
|
||||
if (AIspells[i].type != SpellType_Heal && AIspells[i].min_hp != 0 && GetIntHPRatio() < AIspells[i].min_hp)
|
||||
continue;
|
||||
|
||||
if (AIspells[i].max_hp != 0 && GetIntHPRatio() > AIspells[i].max_hp)
|
||||
if (AIspells[i].type != SpellType_Heal && AIspells[i].max_hp != 0 && GetIntHPRatio() > AIspells[i].max_hp)
|
||||
continue;
|
||||
|
||||
if (iSpellTypes & AIspells[i].type) {
|
||||
@@ -137,9 +138,13 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint32 iSpellTypes, bool bInnates
|
||||
&& tar->DontHealMeBefore() < Timer::GetCurrentTime()
|
||||
&& !(tar->IsPet() && tar->GetOwner()->IsClient()) //no buffing PC's pets
|
||||
) {
|
||||
uint8 hpr = (uint8)tar->GetHPRatio();
|
||||
|
||||
if(hpr <= 35 || (!IsEngaged() && hpr <= 50) || (tar->IsClient() && hpr <= 99)) {
|
||||
auto hp_ratio = tar->GetIntHPRatio();
|
||||
|
||||
int min_hp = AIspells[i].min_hp; // well 0 is default, so no special case here
|
||||
int max_hp = AIspells[i].max_hp ? AIspells[i].max_hp : RuleI(Spells, AI_HealHPPct);
|
||||
|
||||
if (EQEmu::ValueWithin(hp_ratio, min_hp, max_hp) || (tar->IsClient() && hp_ratio <= 99)) { // not sure about client bit, leaving it
|
||||
uint32 tempTime = 0;
|
||||
AIDoSpellCast(i, tar, mana_cost, &tempTime);
|
||||
tar->SetDontHealMeBefore(tempTime);
|
||||
|
||||
Reference in New Issue
Block a user