mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
Mobs fleeing and getting assistance feature implementaion.
Signed-off-by: VladimirMangos <vladimir@getmangos.com> Also rename ACTION_T_FLEE to ACTION_T_FLEE_FOR_ASSIST for clear use
This commit is contained in:
parent
f332c000d1
commit
fa03b3663a
21 changed files with 238 additions and 19 deletions
|
|
@ -111,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;
|
||||
|
|
@ -506,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
|
||||
|
|
@ -1473,6 +1503,7 @@ void Creature::setDeathState(DeathState s)
|
|||
if (canFly() && FallGround())
|
||||
return;
|
||||
|
||||
SetNoSearchAssistance(false);
|
||||
Unit::setDeathState(CORPSE);
|
||||
}
|
||||
if(s == JUST_ALIVED)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue