Merge commit 'origin/master' into 310

Conflicts:
	src/game/TargetedMovementGenerator.cpp
	win/VC71/shared.vcproj
This commit is contained in:
tomrus88 2009-05-21 20:17:19 +04:00
commit 52effd119c
39 changed files with 523 additions and 7161 deletions

View file

@ -85,8 +85,7 @@ VendorItem const* VendorItemData::FindItem(uint32 item_id) const
bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{
Unit* victim = Unit::GetUnit(m_owner, m_victim);
if (victim)
if(Unit* victim = Unit::GetUnit(m_owner, m_victim))
{
while (!m_assistants.empty())
{
@ -112,7 +111,7 @@ m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_resp
m_gossipOptionLoaded(false), m_isPet(false), m_isVehicle(false), m_isTotem(false),
m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0), m_AlreadyCallAssistance(false),
m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),
m_creatureInfo(NULL), m_isActiveObject(false)
m_creatureInfo(NULL), m_isActiveObject(false), m_AlreadySearchedAssistance(false)
{
m_regenTimer = 200;
m_valuesCount = UNIT_END;
@ -507,6 +506,36 @@ void Creature::RegenerateHealth()
ModifyHealth(addvalue);
}
void Creature::DoFleeToGetAssistance()
{
if (!getVictim())
return;
float radius = sWorld.getConfig(CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS);
if (radius >0)
{
Creature* pCreature = NULL;
CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY()));
Cell cell(p);
cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
MaNGOS::NearestAssistCreatureInCreatureRangeCheck u_check(this, getVictim(), radius);
MaNGOS::CreatureLastSearcher<MaNGOS::NearestAssistCreatureInCreatureRangeCheck> searcher(this, pCreature, u_check);
TypeContainerVisitor<MaNGOS::CreatureLastSearcher<MaNGOS::NearestAssistCreatureInCreatureRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher);
CellLock<GridReadGuard> cell_lock(cell, p);
cell_lock->Visit(cell_lock, grid_creature_searcher, *GetMap());
SetNoSearchAssistance(true);
if(!pCreature)
SetFeared(true, getVictim()->GetGUID(), 0 ,sWorld.getConfig(CONFIG_CREATURE_FAMILY_FLEE_DELAY));
else
GetMotionMaster()->MoveSeekAssistance(pCreature->GetPositionX(), pCreature->GetPositionY(), pCreature->GetPositionZ());
}
}
bool Creature::AIM_Initialize()
{
// make sure nothing can change the AI during AI update
@ -1474,6 +1503,7 @@ void Creature::setDeathState(DeathState s)
if (canFly() && FallGround())
return;
SetNoSearchAssistance(false);
Unit::setDeathState(CORPSE);
}
if(s == JUST_ALIVED)
@ -1725,26 +1755,34 @@ void Creature::CallAssistance()
}
}
bool Creature::CanAssistTo(const Unit* u, const Unit* enemy) const
bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const
{
// we don't need help from zombies :)
if( !isAlive() )
if (!isAlive())
return false;
// skip fighting creature
if( isInCombat() )
return false;
// only from same creature faction
if(getFaction() != u->getFaction() )
if (isInCombat())
return false;
// only free creature
if( GetCharmerOrOwnerGUID() )
if (GetCharmerOrOwnerGUID())
return false;
// only from same creature faction
if (checkfaction)
{
if (getFaction() != u->getFaction())
return false;
}
else
{
if (!IsFriendlyTo(u))
return false;
}
// skip non hostile to caster enemy creatures
if( !IsHostileTo(enemy) )
if (!IsHostileTo(enemy))
return false;
return true;