Files
TCPlayerbotCore/src/game/PassiveAI.cpp
T

82 lines
2.4 KiB
C++
Raw Normal View History

2008-10-02 16:23:55 -05:00
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
2008-10-14 11:57:03 -05:00
*
2010-01-16 20:19:18 +03:00
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
2008-10-02 16:23:55 -05:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2008-10-14 11:57:03 -05:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2008-10-02 16:23:55 -05:00
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
2008-10-14 11:57:03 -05:00
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2008-10-02 16:23:55 -05:00
*/
2009-08-23 14:20:07 -05:00
#include "PassiveAI.h"
2009-01-28 20:16:11 -06:00
#include "Creature.h"
#include "TemporarySummon.h"
2008-10-02 16:23:55 -05:00
PassiveAI::PassiveAI(Creature *c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); }
PossessedAI::PossessedAI(Creature *c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); }
NullCreatureAI::NullCreatureAI(Creature *c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); }
2009-08-10 15:50:19 -05:00
void PassiveAI::UpdateAI(const uint32)
2008-10-02 16:23:55 -05:00
{
2009-11-19 03:53:49 -08:00
if (me->isInCombat() && me->getAttackers().empty())
EnterEvadeMode();
2008-10-02 16:23:55 -05:00
}
2009-01-28 20:16:11 -06:00
void PossessedAI::AttackStart(Unit *target)
{
me->Attack(target, true);
}
void PossessedAI::UpdateAI(const uint32 diff)
{
if(me->getVictim())
{
if(!me->canAttack(me->getVictim()))
me->AttackStop();
else
DoMeleeAttackIfReady();
}
}
void PossessedAI::JustDied(Unit *u)
{
// We died while possessed, disable our loot
me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
}
void PossessedAI::KilledUnit(Unit* victim)
{
// We killed a creature, disable victim's loot
if (victim->GetTypeId() == TYPEID_UNIT)
victim->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
}
2009-01-28 20:16:11 -06:00
void CritterAI::DamageTaken(Unit *done_by, uint32 &)
{
2009-11-19 03:53:49 -08:00
if (!me->hasUnitState(UNIT_STAT_FLEEING))
2009-01-28 20:16:11 -06:00
me->SetControlled(true, UNIT_STAT_FLEEING);
}
void CritterAI::EnterEvadeMode()
{
2009-11-19 03:53:49 -08:00
if (me->hasUnitState(UNIT_STAT_FLEEING))
2009-01-28 20:16:11 -06:00
me->SetControlled(false, UNIT_STAT_FLEEING);
CreatureAI::EnterEvadeMode();
}
void TriggerAI::IsSummonedBy(Unit *summoner)
{
2009-11-19 03:53:49 -08:00
if (me->m_spells[0])
me->CastSpell(me, me->m_spells[0], false, 0, 0, summoner->GetGUID());
}