Merge branch 'master' into 303

Conflicts:
	src/game/Creature.cpp
This commit is contained in:
tomrus88 2008-11-26 19:44:03 +03:00
commit af6acab8f8
23 changed files with 288 additions and 129 deletions

View file

@ -91,6 +91,27 @@ VendorItem const* VendorItemData::FindItem(uint32 item_id) const
return NULL;
}
bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{
Unit* victim = Unit::GetUnit(m_owner, m_victim);
if (victim)
{
while (!m_assistants.empty())
{
Creature* assistant = (Creature*)Unit::GetUnit(m_owner, *m_assistants.begin());
m_assistants.pop_front();
if (assistant && assistant->CanAssistTo(&m_owner, victim))
{
assistant->SetNoCallAssistance(true);
if(assistant->AI())
assistant->AI()->AttackStart(victim);
}
}
}
return true;
}
Creature::Creature() :
Unit(), i_AI(NULL),
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0),
@ -98,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_isVehicle(false),
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_regenTimer = 200;
@ -1659,13 +1680,13 @@ 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_ASSISTEMCE_RADIUS);
float radius = sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS);
if(radius > 0)
{
std::list<Creature*> assistList;
@ -1685,16 +1706,46 @@ void Creature::CallAssistence()
cell_lock->Visit(cell_lock, grid_creature_searcher, *GetMap());
}
for(std::list<Creature*>::iterator iter = assistList.begin(); iter != assistList.end(); ++iter)
if (!assistList.empty())
{
(*iter)->SetNoCallAssistence(true);
if((*iter)->AI())
(*iter)->AI()->AttackStart(getVictim());
AssistDelayEvent *e = new AssistDelayEvent(getVictim()->GetGUID(), *this);
while (!assistList.empty())
{
// Pushing guids because in delay can happen some creature gets despawned => invalid pointer
e->AddAssistant((*assistList.begin())->GetGUID());
assistList.pop_front();
}
m_Events.AddEvent(e, m_Events.CalculateTime(sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY)));
}
}
}
}
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)