[6846] Fixed some more typos. Added post check for assistance conditions into event execute.

Signed-off-by: ApoC <apoc@nymfe.net>
This commit is contained in:
ApoC 2008-11-24 03:03:30 +01:00
parent 359d4d7dd3
commit 64fd2dc881
5 changed files with 40 additions and 31 deletions

View file

@ -101,9 +101,9 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
Creature* assistant = (Creature*)Unit::GetUnit(m_owner, *m_assistants.begin());
m_assistants.pop_front();
if (assistant)
if (assistant && assistant->CanAssistTo(&m_owner, victim))
{
assistant->SetNoCallAssistence(true);
assistant->SetNoCallAssistance(true);
if(assistant->AI())
assistant->AI()->AttackStart(victim);
}
@ -119,7 +119,7 @@ m_lootMoney(0), m_lootRecipient(0),
m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f),
m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false),
m_regenTimer(2000), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0),
m_AlreadyCallAssistence(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false),
m_AlreadyCallAssistance(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false),
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),m_creatureInfo(NULL), m_DBTableGuid(0)
{
m_valuesCount = UNIT_END;
@ -1684,11 +1684,11 @@ bool Creature::IsVisibleInGridForPlayer(Player* pl) const
return false;
}
void Creature::CallAssistence()
void Creature::CallAssistance()
{
if( !m_AlreadyCallAssistence && getVictim() && !isPet() && !isCharmed())
if( !m_AlreadyCallAssistance && getVictim() && !isPet() && !isCharmed())
{
SetNoCallAssistence(true);
SetNoCallAssistance(true);
float radius = sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS);
if(radius > 0)
@ -1725,6 +1725,31 @@ void Creature::CallAssistence()
}
}
bool Creature::CanAssistTo(const Unit* u, const Unit* enemy) const
{
// we don't need help from zombies :)
if( !isAlive() )
return false;
// skip fighting creature
if( isInCombat() )
return false;
// only from same creature faction
if(getFaction() != u->getFaction() )
return false;
// only free creature
if( GetCharmerOrOwnerGUID() )
return false;
// skip non hostile to caster enemy creatures
if( !IsHostileTo(enemy) )
return false;
return true;
}
void Creature::SaveRespawnTime()
{
if(isPet() || !m_DBTableGuid)