TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
npc_doctor::npc_doctorAI Struct Reference

Public Member Functions

 npc_doctorAI (Creature *creature)
 
void Initialize ()
 
void Reset () override
 
void BeginEvent (Player *player)
 
void PatientDied (Position const *point)
 
void PatientSaved (Creature *, Player *player, Position const *point)
 
void UpdateAI (uint32 diff) override
 
void EnterCombat (Unit *) override
 
- Public Member Functions inherited from ScriptedAI
 ScriptedAI (Creature *creature)
 
virtual ~ScriptedAI ()
 
void AttackStartNoMove (Unit *target)
 
void DamageTaken (Unit *, uint32 &) override
 
void JustDied (Unit *) override
 
void KilledUnit (Unit *) override
 
void JustSummoned (Creature *) override
 
void SummonedCreatureDespawn (Creature *) override
 
void SpellHit (Unit *, SpellInfo const *) override
 
void SpellHitTarget (Unit *, SpellInfo const *) override
 
void OnPossess (bool)
 
void AttackStart (Unit *) override
 
void DoStartMovement (Unit *target, float distance=0.0f, float angle=0.0f)
 
void DoStartNoMovement (Unit *target)
 
void DoStopAttack ()
 
void DoCastSpell (Unit *target, SpellInfo const *spellInfo, bool triggered=false)
 
void DoPlaySoundToSet (WorldObject *source, uint32 soundId)
 
void DoResetThreat ()
 
float DoGetThreat (Unit *unit)
 
void DoModifyThreatPercent (Unit *unit, int32 pct)
 
void DoTeleportTo (float x, float y, float z, uint32 time=0)
 
void DoTeleportTo (float const pos[4])
 
void DoTeleportPlayer (Unit *unit, float x, float y, float z, float o)
 
void DoTeleportAll (float x, float y, float z, float o)
 
UnitDoSelectLowestHpFriendly (float range, uint32 minHPDiff=1)
 
std::list< Creature * > DoFindFriendlyCC (float range)
 
std::list< Creature * > DoFindFriendlyMissingBuff (float range, uint32 spellId)
 
PlayerGetPlayerAtMinimumRange (float minRange)
 
CreatureDoSpawnCreature (uint32 entry, float offsetX, float offsetY, float offsetZ, float angle, uint32 type, uint32 despawntime)
 
bool HealthBelowPct (uint32 pct) const
 
bool HealthAbovePct (uint32 pct) const
 
SpellInfo constSelectSpell (Unit *target, uint32 school, uint32 mechanic, SelectTargetType targets, float rangeMin, float rangeMax, SelectEffect effect)
 
void SetEquipmentSlots (bool loadDefault, int32 mainHand=EQUIP_NO_CHANGE, int32 offHand=EQUIP_NO_CHANGE, int32 ranged=EQUIP_NO_CHANGE)
 
void SetCombatMovement (bool allowMovement)
 
bool IsCombatMovementAllowed () const
 
bool IsHeroic () const
 
Difficulty GetDifficulty () const
 
bool Is25ManRaid () const
 
template<class T >
const T & DUNGEON_MODE (const T &normal5, const T &heroic10) const
 
template<class T >
const T & RAID_MODE (const T &normal10, const T &normal25) const
 
template<class T >
const T & RAID_MODE (const T &normal10, const T &normal25, const T &heroic10, const T &heroic25) const
 
- Public Member Functions inherited from CreatureAI
void Talk (uint8 id, WorldObject const *whisperTarget=nullptr)
 
 CreatureAI (Creature *creature)
 
virtual ~CreatureAI ()
 
void MoveInLineOfSight_Safe (Unit *who)
 == Reactions At ================================= More...
 
void TriggerAlert (Unit const *who) const
 
virtual bool CanRespawn ()
 
virtual void EnterEvadeMode (EvadeReason why=EVADE_REASON_OTHER)
 
virtual void IsSummonedBy (Unit *)
 
virtual void SummonedCreatureDies (Creature *, Unit *)
 
virtual void AttackedBy (Unit *)
 
virtual bool IsEscorted () const
 
virtual void JustRespawned ()
 
virtual void MovementInform (uint32, uint32)
 
void OnCharmed (bool apply) override
 
virtual void JustReachedHome ()
 
void DoZoneInCombat (Creature *creature=NULL, float maxRangeToNearestTarget=50.0f)
 
virtual void ReceiveEmote (Player *, uint32)
 
virtual void OwnerAttackedBy (Unit *)
 
virtual void OwnerAttacked (Unit *)
 
virtual void CorpseRemoved (uint32 &)
 == Triggered Actions Requested ================== More...
 
virtual void PassengerBoarded (Unit *, int8, bool)
 == Fields ======================================= More...
 
virtual void OnSpellClick (Unit *, bool &)
 
virtual bool CanSeeAlways (WorldObject const *)
 
int32 VisualizeBoundary (uint32 duration, Unit *owner=nullptr, bool fill=false) const
 
virtual bool CheckInRoom ()
 
CreatureBoundary constGetBoundary () const
 
- Public Member Functions inherited from UnitAI
 UnitAI (Unit *unit)
 
virtual ~UnitAI ()
 
virtual bool CanAIAttack (Unit const *) const
 
virtual void InitializeAI ()
 
virtual void DoAction (int32)
 
virtual uint32 GetData (uint32) const
 
virtual void SetData (uint32, uint32)
 
virtual void SetGUID (ObjectGuid, int32=0)
 
virtual ObjectGuid GetGUID (int32=0) const
 
UnitSelectTarget (SelectAggroTarget targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, int32 aura=0)
 
template<class PREDICATE >
UnitSelectTarget (SelectAggroTarget targetType, uint32 position, PREDICATE const &predicate)
 
void SelectTargetList (std::list< Unit * > &targetList, uint32 num, SelectAggroTarget targetType, float dist=0.0f, bool playerOnly=false, int32 aura=0)
 
template<class PREDICATE >
void SelectTargetList (std::list< Unit * > &targetList, PREDICATE const &predicate, uint32 maxTargets, SelectAggroTarget targetType)
 
virtual void DamageDealt (Unit *, uint32 &, DamageEffectType)
 
virtual void HealReceived (Unit *, uint32 &)
 
virtual void HealDone (Unit *, uint32 &)
 
virtual void SpellInterrupted (uint32, uint32)
 
void AttackStartCaster (Unit *victim, float dist)
 
void DoCast (uint32 spellId)
 
void DoCast (Unit *victim, uint32 spellId, bool triggered=false)
 
void DoCastVictim (uint32 spellId, bool triggered=false)
 
void DoCastAOE (uint32 spellId, bool triggered=false)
 
void DoMeleeAttackIfReady ()
 
bool DoSpellAttackIfReady (uint32 spellId)
 
virtual void sGossipHello (Player *)
 
virtual void sGossipSelect (Player *, uint32, uint32)
 
virtual void sGossipSelectCode (Player *, uint32, uint32, char const *)
 
virtual void sQuestAccept (Player *, Quest const *)
 
virtual void sQuestSelect (Player *, Quest const *)
 
virtual void sQuestReward (Player *, Quest const *, uint32)
 
virtual bool sOnDummyEffect (Unit *, uint32, SpellEffIndex)
 
virtual void sOnGameEvent (bool, uint16)
 

Public Attributes

ObjectGuid PlayerGUID
 
uint32 SummonPatientTimer
 
uint32 SummonPatientCount
 
uint32 PatientDiedCount
 
uint32 PatientSavedCount
 
bool Event
 
GuidList Patients
 
std::vector< Position const * > Coordinates
 
- Public Attributes inherited from ScriptedAI
bool IsFleeing
 

Additional Inherited Members

- Public Types inherited from CreatureAI
enum  EvadeReason { EVADE_REASON_NO_HOSTILES, EVADE_REASON_BOUNDARY, EVADE_REASON_SEQUENCE_BREAK, EVADE_REASON_OTHER }
 
- Static Public Member Functions inherited from UnitAI
static void FillAISpellInfo ()
 
- Static Public Attributes inherited from UnitAI
static AISpellInfoTypeAISpellInfo
 
- Protected Member Functions inherited from CreatureAI
bool UpdateVictim ()
 
bool UpdateVictimWithGaze ()
 
void SetGazeOn (Unit *target)
 
CreatureDoSummon (uint32 entry, Position const &pos, uint32 despawnTime=30000, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
 
CreatureDoSummon (uint32 entry, WorldObject *obj, float radius=5.0f, uint32 despawnTime=30000, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
 
CreatureDoSummonFlyer (uint32 entry, WorldObject *obj, float flightZ, float radius=5.0f, uint32 despawnTime=30000, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
 
bool CheckBoundary (Position const *who=nullptr) const
 
void SetBoundary (CreatureBoundary const *boundary)
 
virtual void MoveInLineOfSight (Unit *)
 
bool _EnterEvadeMode (EvadeReason why=EVADE_REASON_OTHER)
 
- Protected Attributes inherited from CreatureAI
Creature *const me
 
CreatureBoundary const_boundary
 
- Protected Attributes inherited from UnitAI
Unit *const me
 

Constructor & Destructor Documentation

npc_doctor::npc_doctorAI::npc_doctorAI ( Creature creature)
inline
647  : ScriptedAI(creature)
648  {
649  Initialize();
650  }
ScriptedAI(Creature *creature)
Definition: ScriptedCreature.cpp:100
void Initialize()
Definition: npcs_special.cpp:652

+ Here is the call graph for this function:

Member Function Documentation

void npc_doctor::npc_doctorAI::BeginEvent ( Player player)
inline
686  {
687  PlayerGUID = player->GetGUID();
688 
689  SummonPatientTimer = 10000;
690  SummonPatientCount = 0;
691  PatientDiedCount = 0;
692  PatientSavedCount = 0;
693 
694  switch (me->GetEntry())
695  {
696  case DOCTOR_ALLIANCE:
697  for (uint8 i = 0; i < ALLIANCE_COORDS; ++i)
698  Coordinates.push_back(&AllianceCoords[i]);
699  break;
700  case DOCTOR_HORDE:
701  for (uint8 i = 0; i < HORDE_COORDS; ++i)
702  Coordinates.push_back(&HordeCoords[i]);
703  break;
704  }
705 
706  Event = true;
708  }
Definition: npcs_special.cpp:587
Position const HordeCoords[]
Definition: npcs_special.cpp:608
Position const AllianceCoords[]
Definition: npcs_special.cpp:592
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
std::vector< Position const * > Coordinates
Definition: npcs_special.cpp:677
Creature *const me
Definition: CreatureAI.h:71
ObjectGuid PlayerGUID
Definition: npcs_special.cpp:667
bool Event
Definition: npcs_special.cpp:674
Definition: npcs_special.cpp:588
uint32 SummonPatientTimer
Definition: npcs_special.cpp:669
Definition: npcs_special.cpp:589
uint32 SummonPatientCount
Definition: npcs_special.cpp:670
uint32 PatientSavedCount
Definition: npcs_special.cpp:672
Definition: UpdateFields.h:109
Definition: npcs_special.cpp:586
uint8_t uint8
Definition: Define.h:152
uint32 GetEntry() const
Definition: Object.h:107
uint32 PatientDiedCount
Definition: npcs_special.cpp:671
Definition: Unit.h:698

+ Here is the call graph for this function:

void npc_doctor::npc_doctorAI::EnterCombat ( Unit )
inlineoverridevirtual

Reimplemented from ScriptedAI.

770 { }
void npc_doctor::npc_doctorAI::Initialize ( void  )
inline
653  {
654  PlayerGUID.Clear();
655 
656  SummonPatientTimer = 10000;
657  SummonPatientCount = 0;
658  PatientDiedCount = 0;
659  PatientSavedCount = 0;
660 
661  Patients.clear();
662  Coordinates.clear();
663 
664  Event = false;
665  }
std::vector< Position const * > Coordinates
Definition: npcs_special.cpp:677
ObjectGuid PlayerGUID
Definition: npcs_special.cpp:667
bool Event
Definition: npcs_special.cpp:674
uint32 SummonPatientTimer
Definition: npcs_special.cpp:669
uint32 SummonPatientCount
Definition: npcs_special.cpp:670
uint32 PatientSavedCount
Definition: npcs_special.cpp:672
void Clear()
Definition: ObjectGuid.h:215
uint32 PatientDiedCount
Definition: npcs_special.cpp:671
GuidList Patients
Definition: npcs_special.cpp:676

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void npc_doctor::npc_doctorAI::PatientDied ( Position const point)
inline
711  {
713  if (player && ((player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)))
714  {
716 
717  if (PatientDiedCount > 5 && Event)
718  {
719  if (player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE)
720  player->FailQuest(6624);
721  else if (player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)
722  player->FailQuest(6622);
723 
724  Reset();
725  return;
726  }
727 
728  Coordinates.push_back(point);
729  }
730  else
731  // If no player or player abandon quest in progress
732  Reset();
733  }
std::vector< Position const * > Coordinates
Definition: npcs_special.cpp:677
Creature *const me
Definition: CreatureAI.h:71
void Reset() override
Definition: npcs_special.cpp:679
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:184
ObjectGuid PlayerGUID
Definition: npcs_special.cpp:667
bool Event
Definition: npcs_special.cpp:674
Definition: QuestDef.h:113
uint32 PatientDiedCount
Definition: npcs_special.cpp:671

+ Here is the call graph for this function:

void npc_doctor::npc_doctorAI::PatientSaved ( Creature ,
Player player,
Position const point 
)
inline
736  {
737  if (player && PlayerGUID == player->GetGUID())
738  {
739  if ((player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE))
740  {
742 
743  if (PatientSavedCount == 15)
744  {
745  if (!Patients.empty())
746  {
747  for (GuidList::const_iterator itr = Patients.begin(); itr != Patients.end(); ++itr)
748  {
749  if (Creature* patient = ObjectAccessor::GetCreature(*me, *itr))
750  patient->setDeathState(JUST_DIED);
751  }
752  }
753 
754  if (player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE)
755  player->AreaExploredOrEventHappens(6624);
756  else if (player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)
757  player->AreaExploredOrEventHappens(6622);
758 
759  Reset();
760  return;
761  }
762 
763  Coordinates.push_back(point);
764  }
765  }
766  }
Definition: Unit.h:542
Definition: Creature.h:467
std::vector< Position const * > Coordinates
Definition: npcs_special.cpp:677
Creature *const me
Definition: CreatureAI.h:71
void Reset() override
Definition: npcs_special.cpp:679
ObjectGuid PlayerGUID
Definition: npcs_special.cpp:667
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174
uint32 PatientSavedCount
Definition: npcs_special.cpp:672
Definition: QuestDef.h:113
GuidList Patients
Definition: npcs_special.cpp:676

+ Here is the call graph for this function:

void npc_doctor::npc_doctorAI::Reset ( )
inlineoverridevirtual

Reimplemented from ScriptedAI.

680  {
681  Initialize();
683  }
void Initialize()
Definition: npcs_special.cpp:652
Creature *const me
Definition: CreatureAI.h:71
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
Definition: UpdateFields.h:109
Definition: Unit.h:698

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void npc_doctor::npc_doctorAI::UpdateAI ( uint32  diff)
overridevirtual

Reimplemented from ScriptedAI.

913 {
914  if (Event && SummonPatientCount >= 20)
915  {
916  Reset();
917  return;
918  }
919 
920  if (Event)
921  {
922  if (SummonPatientTimer <= diff)
923  {
924  if (Coordinates.empty())
925  return;
926 
927  uint32 patientEntry = 0;
928 
929  switch (me->GetEntry())
930  {
931  case DOCTOR_ALLIANCE:
932  patientEntry = AllianceSoldierId[rand32() % 3];
933  break;
934  case DOCTOR_HORDE:
935  patientEntry = HordeSoldierId[rand32() % 3];
936  break;
937  default:
938  TC_LOG_ERROR("scripts", "Invalid entry for Triage doctor. Please check your database");
939  return;
940  }
941 
942  std::vector<Position const*>::iterator point = Coordinates.begin();
943  std::advance(point, urand(0, Coordinates.size() - 1));
944 
945  if (Creature* Patient = me->SummonCreature(patientEntry, **point, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000))
946  {
947  //303, this flag appear to be required for client side item->spell to work (TARGET_SINGLE_FRIEND)
948  Patient->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
949 
950  Patients.push_back(Patient->GetGUID());
951  ENSURE_AI(npc_injured_patient::npc_injured_patientAI, Patient->AI())->DoctorGUID = me->GetGUID();
952  ENSURE_AI(npc_injured_patient::npc_injured_patientAI, Patient->AI())->Coord = *point;
953 
954  Coordinates.erase(point);
955  }
956 
957  SummonPatientTimer = 10000;
959  }
960  else
961  SummonPatientTimer -= diff;
962  }
963 }
Definition: npcs_special.cpp:587
uint32 const AllianceSoldierId[3]
Definition: npcs_special.cpp:623
Definition: Creature.h:467
std::vector< Position const * > Coordinates
Definition: npcs_special.cpp:677
void advance(octet_iterator &it, distance_type n, octet_iterator end)
Definition: checked.h:190
Creature *const me
Definition: CreatureAI.h:71
#define ENSURE_AI(a, b)
Definition: ScriptedCreature.h:29
uint32 const HordeSoldierId[3]
Definition: npcs_special.cpp:630
void Reset() override
Definition: npcs_special.cpp:679
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
uint32_t uint32
Definition: Define.h:150
bool Event
Definition: npcs_special.cpp:674
uint32 SummonPatientTimer
Definition: npcs_special.cpp:669
uint32 SummonPatientCount
Definition: npcs_special.cpp:670
Definition: npcs_special.cpp:796
Definition: Unit.h:676
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: UpdateFields.h:109
uint32 rand32()
Definition: Random.cpp:64
Definition: npcs_special.cpp:586
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
GuidList Patients
Definition: npcs_special.cpp:676
TempSummon * SummonCreature(uint32 id, Position const &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0) const
Definition: Object.cpp:2346

+ Here is the call graph for this function:

Member Data Documentation

std::vector<Position const*> npc_doctor::npc_doctorAI::Coordinates
bool npc_doctor::npc_doctorAI::Event
uint32 npc_doctor::npc_doctorAI::PatientDiedCount
GuidList npc_doctor::npc_doctorAI::Patients
uint32 npc_doctor::npc_doctorAI::PatientSavedCount
ObjectGuid npc_doctor::npc_doctorAI::PlayerGUID
uint32 npc_doctor::npc_doctorAI::SummonPatientCount
uint32 npc_doctor::npc_doctorAI::SummonPatientTimer

The documentation for this struct was generated from the following file: