Port more AE functions to use flexible GetCloseMobList call

This commit is contained in:
Akkadius 2019-12-29 03:28:48 -06:00
parent e531e68b6d
commit 0f9c34cf3c
2 changed files with 70 additions and 38 deletions

View File

@ -673,27 +673,42 @@ void Client::SendDisciplineTimer(uint32 timer_id, uint32 duration)
} }
} }
/**
* @param taunter
* @param range
* @param bonus_hate
*/
void EntityList::AETaunt(Client *taunter, float range, int32 bonus_hate) void EntityList::AETaunt(Client *taunter, float range, int32 bonus_hate)
{ {
if (range == 0)
range = 40; //Live AE taunt range - Hardcoded.
range = range * range; /**
* Live AE taunt range - Hardcoded.
*/
if (range == 0) {
range = 40;
}
auto it = npc_list.begin(); float range_squared = range * range;
while (it != npc_list.end()) {
NPC *them = it->second; for (auto &it : entity_list.GetCloseMobList(taunter, range)) {
float zdiff = taunter->GetZ() - them->GetZ(); Mob *them = it.second;
if (zdiff < 0)
zdiff *= -1; if (!them->IsNPC()) {
if (zdiff < 10 continue;
}
float z_difference = taunter->GetZ() - them->GetZ();
if (z_difference < 0) {
z_difference *= -1;
}
if (z_difference < 10
&& taunter->IsAttackAllowed(them) && taunter->IsAttackAllowed(them)
&& DistanceSquaredNoZ(taunter->GetPosition(), them->GetPosition()) <= range) { && DistanceSquaredNoZ(taunter->GetPosition(), them->GetPosition()) <= range_squared) {
if (taunter->CheckLosFN(them)) { if (taunter->CheckLosFN(them)) {
taunter->Taunt(them, true, 0, true, bonus_hate); taunter->Taunt(them, true, 0, true, bonus_hate);
} }
} }
++it;
} }
} }
@ -1014,33 +1029,50 @@ void EntityList::AEBardPulse(
} }
} }
// Rampage and stuff for clients. Normal and Duration rampages /**
//NPCs handle it differently in Mob::Rampage * Rampage - Normal and Duration rampages
void EntityList::AEAttack(Mob *attacker, float dist, int Hand, int count, bool IsFromSpell) { * NPCs handle it differently in Mob::Rampage
//Dook- Will need tweaking, currently no pets or players or horses *
Mob *curmob = nullptr; * @param attacker
* @param distance
* @param Hand
* @param count
* @param is_from_spell
*/
void EntityList::AEAttack(
Mob *attacker,
float distance,
int Hand,
int count,
bool is_from_spell)
{
Mob *current_mob = nullptr;
float distance_squared = distance * distance;
int hit_count = 0;
float dist2 = dist * dist; for (auto &it : entity_list.GetCloseMobList(attacker, distance)) {
current_mob = it.second;
int hit = 0; if (current_mob->IsNPC()
&& current_mob != attacker //this is not needed unless NPCs can use this
for (auto it = mob_list.begin(); it != mob_list.end(); ++it) { && (attacker->IsAttackAllowed(current_mob))
curmob = it->second; && current_mob->GetRace() != 216 && current_mob->GetRace() != 472 /* dont attack horses */
if (curmob->IsNPC() && (DistanceSquared(current_mob->GetPosition(), attacker->GetPosition()) <= distance_squared)
&& curmob != attacker //this is not needed unless NPCs can use this
&&(attacker->IsAttackAllowed(curmob))
&& curmob->GetRace() != 216 && curmob->GetRace() != 472 /* dont attack horses */
&& (DistanceSquared(curmob->GetPosition(), attacker->GetPosition()) <= dist2)
) { ) {
if (!attacker->IsClient() || attacker->GetClass() == MONK || attacker->GetClass() == RANGER)
attacker->Attack(curmob, Hand, false, false, IsFromSpell); if (!attacker->IsClient() || attacker->GetClass() == MONK || attacker->GetClass() == RANGER) {
else attacker->Attack(current_mob, Hand, false, false, is_from_spell);
attacker->CastToClient()->DoAttackRounds(curmob, Hand, IsFromSpell); }
hit++; else {
if (count != 0 && hit >= count) attacker->CastToClient()->DoAttackRounds(current_mob, Hand, is_from_spell);
}
hit_count++;
if (count != 0 && hit_count >= count) {
return; return;
} }
} }
} }
}

View File

@ -398,10 +398,10 @@ public:
void AEAttack( void AEAttack(
Mob *attacker, Mob *attacker,
float dist, float distance,
int Hand = EQEmu::invslot::slotPrimary, int Hand = EQEmu::invslot::slotPrimary,
int count = 0, int count = 0,
bool IsFromSpell = false bool is_from_spell = false
); );
void AETaunt(Client *caster, float range = 0, int32 bonus_hate = 0); void AETaunt(Client *caster, float range = 0, int32 bonus_hate = 0);
void AESpell( void AESpell(