EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SentryAI Class Reference

#include "SentryAI.h"

Collaboration diagram for SentryAI:

Public Member Functions

 ~SentryAI ()
 
void ClearTargets ()
 
void DisableRepTimers ()
 
bool IsIdle ()
 
bool IsFighting ()
 
uint16 GetOptimalRange ()
 
uint32 GetFalloff ()
 
uint32 GetAttackRange ()
 
double GetTrackingSpeed ()
 

Protected Types

enum  State { Idle = 1, Engaged = 2, Signaling = 3 }
 

Protected Attributes

State m_state
 

Private Attributes

bool m_webber: 1
 
bool m_warpScram: 1
 
bool m_useSigRadius: 1
 
bool m_useTargSwitching: 1
 
bool m_useSecondTarget: 1
 
float m_switchTargChance
 
uint16 m_preferedSigRadius
 
uint16 m_attackSpeed
 
uint16 m_targetRange
 
uint16 m_optimalRange
 
uint16 m_damageMultiplier
 
uint32 m_sigRadius
 
uint32 m_falloff
 
uint32 m_sightRange
 
uint32 m_maxAttackRange
 
double m_trackingSpeed
 
Sentrym_npc
 
TurretFormulas m_formula
 
Timer m_processTimer
 
Timer m_mainAttackTimer
 
Timer m_beginFindTarget
 
Timer m_warpScramblerTimer
 
Timer m_webifierTimer
 

SentryAI.h

Sentry AI class : Allan

Date
: 23 April 2017
Version
0.10
 SentryAI (Sentry *who)
 
void Process ()
 
void Target (SystemEntity *by_who)
 
void Targeted (SystemEntity *by_who)
 
void TargetLost (SystemEntity *by_who)
 
void ClearAllTargets ()
 
void SetIdle ()
 
void Attack (SystemEntity *pTarget)
 
void SetEngaged (SystemEntity *pTarget)
 
void ClearTarget (SystemEntity *pTarget)
 
void AttackTarget (SystemEntity *pTarget)
 
void SetSignaling (SystemEntity *pTarget)
 
void CheckDistance (SystemEntity *pTarget)
 
double GetTargetTime ()
 
std::string GetStateName (State name)
 

Detailed Description

Definition at line 19 of file SentryAI.h.

Member Enumeration Documentation

enum SentryAI::State
protected
Enumerator
Idle 
Engaged 
Signaling 

Definition at line 21 of file SentryAI.h.

21  {
22  Idle = 1, // not doing anything....idle.
23  Engaged = 2, // actively fighting
24  Signaling = 3 // calling for help
25  };

Constructor & Destructor Documentation

SentryAI::SentryAI ( Sentry who)

Definition at line 20 of file SentryAI.cpp.

References AttrAI_ChanceToNotTargetSwitch, AttrAI_PreferredSignatureRadius, AttrAI_ShouldUseSecondaryTarget, AttrAI_ShouldUseSignatureRadius, AttrAI_ShouldUseTargetSwitching, AttrDamageMultiplier, AttrEntityAttackRange, AttrFalloff, AttrMaxRange, AttrSignatureRadius, AttrSpeed, AttrTrackingSpeed, Timer::Disable(), EvilNumber::get_float(), EvilNumber::get_int(), InventoryItem::GetAttribute(), SystemEntity::GetSelf(), InventoryItem::HasAttribute(), m_attackSpeed, m_beginFindTarget, m_damageMultiplier, m_falloff, m_mainAttackTimer, m_maxAttackRange, m_optimalRange, m_preferedSigRadius, m_processTimer, m_sightRange, m_sigRadius, m_switchTargChance, m_trackingSpeed, m_useSecondTarget, m_useSigRadius, m_useTargSwitching, m_warpScram, m_warpScramblerTimer, m_webber, m_webifierTimer, and Timer::Start().

22 m_npc(who),
23 m_mainAttackTimer(1000),
24 m_processTimer(5000), //arbitrary.
25 m_beginFindTarget(5000), //arbitrary.
26 m_warpScramblerTimer(5000), //arbitrary.
27 m_webifierTimer(5000) //arbitrary.
28 {
29  m_webifierTimer.Disable(); //not implemented yet
30  m_beginFindTarget.Disable(); //arbitrary.
31  m_mainAttackTimer.Disable(); //waiting till engaged
32  m_warpScramblerTimer.Disable(); //not implemented yet
33 
34  m_webber = false;
35  m_warpScram = false;
36 
38 
39  /* set npc ship speeds and distances */
43 
44  // Optimal Range
46  // Accuracy falloff (distance past maximum range at which accuracy has fallen by half)
49  // max firing range default:10000
51  if (!m_maxAttackRange)
52  m_maxAttackRange = 10000;
53  // 'sight' range
54  m_sightRange = 20000;
57 
58  // advanced AI variables only used by sleepers for now. will update advanced npcs to use these also
60  m_useTargSwitching = true;
61  } else {
62  m_useTargSwitching = false;
63  }
65  m_useSecondTarget = true;
66  } else {
67  m_useSecondTarget = false;
68  }
70  m_useSigRadius = true;
72  } else {
73  m_useSigRadius = false;
75  }
78  } else {
79  m_switchTargChance = 0.0f;
80  }
81 }
bool m_webber
Definition: SentryAI.h:66
double m_trackingSpeed
Definition: SentryAI.h:84
bool m_useTargSwitching
Definition: SentryAI.h:69
void Disable()
Definition: timer.h:39
uint32 m_maxAttackRange
Definition: SentryAI.h:82
bool HasAttribute(const uint16 attrID) const
State m_state
Definition: SentryAI.h:61
uint32 m_sigRadius
Definition: SentryAI.h:79
float m_switchTargChance
Definition: SentryAI.h:71
uint16 m_preferedSigRadius
Definition: SentryAI.h:72
uint16 m_optimalRange
Definition: SentryAI.h:76
Timer m_processTimer
Definition: SentryAI.h:90
InventoryItemRef GetSelf()
Definition: SystemEntity.h:202
int64 get_int()
Definition: EvilNumber.cpp:166
uint16 m_attackSpeed
Definition: SentryAI.h:74
uint32 m_sightRange
Definition: SentryAI.h:81
uint32 m_falloff
Definition: SentryAI.h:80
bool m_useSigRadius
Definition: SentryAI.h:68
Timer m_warpScramblerTimer
Definition: SentryAI.h:93
bool m_warpScram
Definition: SentryAI.h:67
uint16 m_damageMultiplier
Definition: SentryAI.h:77
Timer m_beginFindTarget
Definition: SentryAI.h:92
Sentry * m_npc
Definition: SentryAI.h:86
EvilNumber GetAttribute(const uint16 attrID) const
bool m_useSecondTarget
Definition: SentryAI.h:70
float get_float()
Definition: EvilNumber.cpp:184
Timer m_mainAttackTimer
Definition: SentryAI.h:91
Timer m_webifierTimer
Definition: SentryAI.h:94
void Start(uint32 setTimerTime=0, bool changeResetTimer=true)
Definition: timer.cpp:81

Here is the call graph for this function:

SentryAI::~SentryAI ( )
inline

Definition at line 29 of file SentryAI.h.

29 { /* do nothing here */ }

Member Function Documentation

void SentryAI::Attack ( SystemEntity pTarget)
protected

Definition at line 272 of file SentryAI.cpp.

References _log, AttackTarget(), TargetManager::CanAttack(), Timer::Check(), ClearTarget(), SystemEntity::DestinyMgr(), SystemEntity::GetID(), SystemEntity::GetName(), SystemEntity::GetPosition(), SystemBubble::InBubble(), DestinyManager::IsCloaked(), m_mainAttackTimer, m_npc, SystemEntity::SysBubble(), and SystemEntity::TargetMgr().

Referenced by CheckDistance().

273 {
274  if (m_mainAttackTimer.Check()) {
275  if (!pTarget) return;
276  // Check to see if the target still in the bubble (Client warped out)
277  if (!m_npc->SysBubble()->InBubble(pTarget->GetPosition())) {
278  _log(NPC__AI_TRACE, "%s(%u): Target %s(%u) no longer in bubble. Clear target and move on",
279  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
280  ClearTarget(pTarget);
281  return;
282  }
283  if (!pTarget->DestinyMgr()) {
284  _log(NPC__AI_TRACE, "%s(%u): Target %s(%u) has no destiny manager. Clear target and move on",
285  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
286  ClearTarget(pTarget);
287  return;
288  }
289  // Check to see if the target is not cloaked:
290  if (pTarget->DestinyMgr()->IsCloaked()) {
291  _log(NPC__AI_TRACE, "%s(%u): Target %s(%u) is cloaked. Clear target and move on",
292  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
293  ClearTarget(pTarget);
294  return;
295  }
296  if (m_npc->TargetMgr()->CanAttack())
297  AttackTarget(pTarget);
298  }
299 }
#define _log(type, fmt,...)
Definition: logsys.h:124
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
bool InBubble(const GPoint &pt, bool inWarp=false) const
TargetManager * TargetMgr()
Definition: SystemEntity.h:197
const GPoint & GetPosition() const
Definition: SystemEntity.h:211
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
uint32 GetID()
Definition: SystemEntity.h:207
bool Check(bool reset=true)
Definition: timer.cpp:62
const char * GetName() const
Definition: SystemEntity.h:210
Sentry * m_npc
Definition: SentryAI.h:86
void AttackTarget(SystemEntity *pTarget)
Definition: SentryAI.cpp:304
Timer m_mainAttackTimer
Definition: SentryAI.h:91
void ClearTarget(SystemEntity *pTarget)
Definition: SentryAI.cpp:200

Here is the call graph for this function:

Here is the caller graph for this function:

void SentryAI::AttackTarget ( SystemEntity pTarget)
protected

Definition at line 304 of file SentryAI.cpp.

References SystemEntity::ApplyDamage(), SystemEntity::DestinyMgr(), Sentry::GetEM(), Sentry::GetExplosive(), SystemEntity::GetID(), Sentry::GetKinetic(), SystemEntity::GetSelf(), TurretFormulas::GetSentryToHit(), Sentry::GetThermal(), InventoryItem::itemID(), m_attackSpeed, m_damageMultiplier, m_formula, m_npc, DestinyManager::SendSpecialEffect(), targetAttack, and InventoryItem::typeID().

Referenced by Attack().

304  {
305  // some npcs use missiles.....write code for using missiles -- entityMissileTypeID
306  std::string guid = "effects.Laser";
307  // sentry does NOT have a destiny manager...use target's destiny manager for sending fx
308  pTarget->DestinyMgr()->SendSpecialEffect(m_npc->GetSelf()->itemID(),
309  m_npc->GetSelf()->itemID(),
310  m_npc->GetSelf()->typeID(), //m_npc->GetSelf()->GetAttribute(AttrGfxTurretID).get_int(),
311  pTarget->GetID(),
312  0,guid,1,1,1,m_attackSpeed,0);
313 
314  Damage d(m_npc,
315  m_npc->GetSelf(),
316  m_npc->GetKinetic(),
317  m_npc->GetThermal(),
318  m_npc->GetEM(),
319  m_npc->GetExplosive(),
320  m_formula.GetSentryToHit(m_npc, pTarget),
322  );
323 
324  d *= m_damageMultiplier;
325  pTarget->ApplyDamage(d);
326 }
void SendSpecialEffect(uint32 entityID, uint32 moduleID, uint32 moduleTypeID, uint32 targetID, uint32 chargeTypeID, std::string guid, bool isOffensive, bool start, bool isActive, int32 duration, uint32 repeat, int32 graphicInfo=0) const
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
TurretFormulas m_formula
Definition: SentryAI.h:88
InventoryItemRef GetSelf()
Definition: SystemEntity.h:202
Definition: Damage.h:33
float GetThermal()
Definition: Sentry.h:46
uint16 m_attackSpeed
Definition: SentryAI.h:74
uint32 GetID()
Definition: SystemEntity.h:207
float GetExplosive()
Definition: Sentry.h:49
uint16 m_damageMultiplier
Definition: SentryAI.h:77
Sentry * m_npc
Definition: SentryAI.h:86
float GetEM()
Definition: Sentry.h:47
float GetKinetic()
Definition: Sentry.h:48
bool ApplyDamage(Damage &d)
Definition: Damage.cpp:108
uint16 typeID() const
float GetSentryToHit(Sentry *pSentry, SystemEntity *pTarget)
uint32 itemID() const
Definition: InventoryItem.h:98

Here is the call graph for this function:

Here is the caller graph for this function:

void SentryAI::CheckDistance ( SystemEntity pTarget)
protected

Definition at line 177 of file SentryAI.cpp.

References _log, Attack(), ClearTarget(), Ga::GaVec3::distance(), Timer::Enabled(), SystemEntity::GetID(), SystemEntity::GetName(), SystemEntity::GetPosition(), PI::Pin::State::Idle, TargetManager::IsTargetedBy(), m_attackSpeed, m_mainAttackTimer, m_npc, m_sightRange, m_state, SetEngaged(), Timer::Start(), and SystemEntity::TargetMgr().

Referenced by Process(), and Target().

178 {
179  double dist = m_npc->GetPosition().distance(pTarget->GetPosition());
180  if ((dist > m_sightRange) and (!m_npc->TargetMgr()->IsTargetedBy(pTarget))) {
181  _log(NPC__AI_TRACE, "%s(%u): CheckDistance: %s(%u) is too far away (%u). Return to Idle.", \
182  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID(), dist);
183  if (m_state != State::Idle) {
184  // target is no longer in npc's "sight range" and is NOT targeting this npc. unlock target and return to idle.
185  // should we do anything else here? search for another target? wander around? yes..later
186  // if npc is targeted greater than this distance, it will chase
187  ClearTarget(pTarget);
188  }
189  return;
190  }
191 
192  SetEngaged(pTarget);
193 
194  if (!m_mainAttackTimer.Enabled())
196 
197  Attack(pTarget);
198 }
#define _log(type, fmt,...)
Definition: logsys.h:124
State m_state
Definition: SentryAI.h:61
void SetEngaged(SystemEntity *pTarget)
Definition: SentryAI.cpp:159
TargetManager * TargetMgr()
Definition: SystemEntity.h:197
const GPoint & GetPosition() const
Definition: SystemEntity.h:211
bool Enabled() const
Definition: timer.h:41
uint16 m_attackSpeed
Definition: SentryAI.h:74
uint32 m_sightRange
Definition: SentryAI.h:81
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
Sentry * m_npc
Definition: SentryAI.h:86
void Attack(SystemEntity *pTarget)
Definition: SentryAI.cpp:272
GaExpInl GaFloat distance(const GaVec3 &oth) const
Definition: GaTypes.h:158
Timer m_mainAttackTimer
Definition: SentryAI.h:91
bool IsTargetedBy(SystemEntity *pSE)
void ClearTarget(SystemEntity *pTarget)
Definition: SentryAI.cpp:200
void Start(uint32 setTimerTime=0, bool changeResetTimer=true)
Definition: timer.cpp:81

Here is the call graph for this function:

Here is the caller graph for this function:

void SentryAI::ClearAllTargets ( )

Definition at line 208 of file SentryAI.cpp.

References TargetManager::ClearAllTargets(), m_npc, and SystemEntity::TargetMgr().

208  {
210  //m_npc->TargetMgr()->OnTarget(nullptr, TargMgr::Mode::Clear, TargMgr::Msg::ClientReq);
211 }
void ClearAllTargets(bool notify=true)
TargetManager * TargetMgr()
Definition: SystemEntity.h:197
Sentry * m_npc
Definition: SentryAI.h:86

Here is the call graph for this function:

void SentryAI::ClearTarget ( SystemEntity pTarget)
protected

Definition at line 200 of file SentryAI.cpp.

References TargetManager::ClearTarget(), TargetManager::HasNoTargets(), m_npc, SetIdle(), and SystemEntity::TargetMgr().

Referenced by Attack(), CheckDistance(), and Process().

200  {
201  m_npc->TargetMgr()->ClearTarget(pTarget);
202  //m_npc->TargetMgr()->OnTarget(pTarget, TargMgr::Mode::Lost);
203 
204  if (m_npc->TargetMgr()->HasNoTargets())
205  SetIdle();
206 }
void ClearTarget(SystemEntity *tSE)
void SetIdle()
Definition: SentryAI.cpp:146
TargetManager * TargetMgr()
Definition: SystemEntity.h:197
Sentry * m_npc
Definition: SentryAI.h:86
bool HasNoTargets() const

Here is the call graph for this function:

Here is the caller graph for this function:

void SentryAI::ClearTargets ( )
void SentryAI::DisableRepTimers ( )
uint32 SentryAI::GetAttackRange ( )
inline

Definition at line 47 of file SentryAI.h.

References m_maxAttackRange.

47 { return m_maxAttackRange; }
uint32 m_maxAttackRange
Definition: SentryAI.h:82
uint32 SentryAI::GetFalloff ( )
inline

Definition at line 46 of file SentryAI.h.

References m_falloff.

46 { return m_falloff; }
uint32 m_falloff
Definition: SentryAI.h:80
uint16 SentryAI::GetOptimalRange ( )
inline

Definition at line 45 of file SentryAI.h.

References m_optimalRange.

45 { return m_optimalRange; }
uint16 m_optimalRange
Definition: SentryAI.h:76
std::string SentryAI::GetStateName ( SentryAI::State  name)
protected

Definition at line 350 of file SentryAI.cpp.

References DroneAI::State::Engaged, PI::Pin::State::Idle, and NPCAI::State::Signaling.

Referenced by Process().

351 {
352  switch (name) {
353  case State::Idle: return "Idle";
354  case State::Engaged: return "Engaged";
355  case State::Signaling: return "Signaling";
356  }
357  return "Undefined";
358 }

Here is the caller graph for this function:

double SentryAI::GetTargetTime ( )
protected

Definition at line 328 of file SentryAI.cpp.

References AttrRadius, AttrScanSpeed, EvilNumber::get_float(), EvilNumber::get_int(), InventoryItem::GetAttribute(), SystemEntity::GetSelf(), and m_npc.

Referenced by Target(), and Targeted().

329 {
330  double targetTime = (m_npc->GetSelf()->GetAttribute(AttrScanSpeed).get_int());
331  float radius = m_npc->GetSelf()->GetAttribute(AttrRadius).get_float();
332  if (!targetTime) {
333  if (radius < 30) {
334  targetTime = 1500;
335  } else if (radius < 60) {
336  targetTime = 2500;
337  } else if (radius < 150) {
338  targetTime = 4000;
339  } else if (radius < 280) {
340  targetTime = 6000;
341  } else if (radius < 550) {
342  targetTime = 8000;
343  } else {
344  targetTime = 13000;
345  }
346  }
347  return targetTime;
348 }
InventoryItemRef GetSelf()
Definition: SystemEntity.h:202
int64 get_int()
Definition: EvilNumber.cpp:166
Sentry * m_npc
Definition: SentryAI.h:86
EvilNumber GetAttribute(const uint16 attrID) const
float get_float()
Definition: EvilNumber.cpp:184

Here is the call graph for this function:

Here is the caller graph for this function:

double SentryAI::GetTrackingSpeed ( )
inline

Definition at line 48 of file SentryAI.h.

References m_trackingSpeed.

48 { return m_trackingSpeed; }
double m_trackingSpeed
Definition: SentryAI.h:84
bool SentryAI::IsFighting ( )
inline

Definition at line 44 of file SentryAI.h.

References PI::Pin::State::Idle, and m_state.

44 { return (m_state != State::Idle); }
State m_state
Definition: SentryAI.h:61
bool SentryAI::IsIdle ( )
inline

Definition at line 43 of file SentryAI.h.

References PI::Pin::State::Idle, and m_state.

43 { return (m_state == State::Idle); }
State m_state
Definition: SentryAI.h:61
void SentryAI::Process ( )
Todo:
this needs work if (cur->IsLogin() or cur->IsInvul() or cur->InPod()) continue; if (!cur->GetShipTarget()) continue; if ((!cur->GetShipTarget()->DestinyMgr()) or (!cur->GetShipTarget()->SysBubble())) // this shouldnt be needed, but whatever... continue; pDestiny = cur->GetShipTarget()->DestinyMgr(); if (pDestiny->IsCloaked() or pDestiny->IsWarping()) continue; if (m_npc->GetPosition().distance(cur->GetShipTarget()->GetPosition()) > m_sightRange) continue; Target(cur->GetShipTarget());

Definition at line 83 of file SentryAI.cpp.

References _log, Timer::Check(), CheckDistance(), ClearTarget(), Timer::Enabled(), DroneAI::State::Engaged, TargetManager::GetFirstTarget(), SystemEntity::GetID(), SystemEntity::GetName(), SystemBubble::GetPlayers(), GetStateName(), TargetManager::HasNoTargets(), SystemBubble::HasPlayers(), PI::Pin::State::Idle, m_attackSpeed, m_beginFindTarget, m_npc, m_processTimer, m_state, SetIdle(), NPCAI::State::Signaling, Timer::Start(), SystemEntity::SysBubble(), and SystemEntity::TargetMgr().

Referenced by Sentry::Process().

83  {
84  if ((!m_processTimer.Check()) or (!m_npc->SysBubble()->HasPlayers()))
85  return;
86 
87  /* NPC::State definitions -allan 25July15 (UD 1June16)
88  * Idle, // not doing anything, nothing in sight....idle.
89  * Engaged, // actively fighting.
90  * Signaling // calling for help
91  */
92  switch(m_state) {
93  case State::Idle: {
94  // The parameter proximityRange (154) tells us how far we "see" (npc's dont have this, but drones do)
95  if (m_beginFindTarget.Check()) {
96  std::vector<Client*> clientVec;
97  clientVec.clear();
98  DestinyManager* pDestiny(nullptr);
99  m_npc->SysBubble()->GetPlayers(clientVec); // what about player drones? yes...later
100  for (auto cur : clientVec) {
115  return;
116  }
117  } else {
118  if (!m_beginFindTarget.Enabled())
119  m_beginFindTarget.Start(m_attackSpeed); //find target is based on npc attack speed.
120  }
121  } break;
122  case State::Engaged: {
123  if (m_npc->TargetMgr()->HasNoTargets()) {
124  _log(NPC__AI_TRACE, "%s(%u): Stopped %s, HasNoTargets = true.", m_npc->GetName(), m_npc->GetID(), GetStateName(m_state).c_str());
125  SetIdle();
126  return;
127  }
128  SystemEntity* pTarget = m_npc->TargetMgr()->GetFirstTarget(false);
129  if (!pTarget) {
130  _log(NPC__AI_TRACE, "%s(%u): Stopped %s, GetFirstTarget() returned NULL.", m_npc->GetName(), m_npc->GetID(), GetStateName(m_state).c_str());
131  SetIdle();
132  return;
133  } else if (!pTarget->SysBubble()) {
134  ClearTarget(pTarget);
135  return;
136  }
137  CheckDistance(pTarget);
138  } break;
139  case State::Signaling: {
140  _log(NPC__AI_TRACE, "%s(%u): Called %s, needs to be completed.", m_npc->GetName(), m_npc->GetID(), GetStateName(m_state).c_str());
141  // not sure how im gonna do this
142  } break;
143  }
144 }
#define _log(type, fmt,...)
Definition: logsys.h:124
State m_state
Definition: SentryAI.h:61
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
std::string GetStateName(State name)
Definition: SentryAI.cpp:350
Timer m_processTimer
Definition: SentryAI.h:90
void SetIdle()
Definition: SentryAI.cpp:146
TargetManager * TargetMgr()
Definition: SystemEntity.h:197
SystemEntity * GetFirstTarget(bool need_locked=false)
bool Enabled() const
Definition: timer.h:41
uint16 m_attackSpeed
Definition: SentryAI.h:74
uint32 GetID()
Definition: SystemEntity.h:207
bool HasPlayers() const
Definition: SystemBubble.h:85
bool Check(bool reset=true)
Definition: timer.cpp:62
const char * GetName() const
Definition: SystemEntity.h:210
Timer m_beginFindTarget
Definition: SentryAI.h:92
Sentry * m_npc
Definition: SentryAI.h:86
bool HasNoTargets() const
void CheckDistance(SystemEntity *pTarget)
Definition: SentryAI.cpp:177
void ClearTarget(SystemEntity *pTarget)
Definition: SentryAI.cpp:200
void GetPlayers(std::vector< Client * > &into) const
void Start(uint32 setTimerTime=0, bool changeResetTimer=true)
Definition: timer.cpp:81

Here is the call graph for this function:

Here is the caller graph for this function:

void SentryAI::SetEngaged ( SystemEntity pTarget)
protected

Definition at line 159 of file SentryAI.cpp.

References _log, DroneAI::State::Engaged, SystemEntity::GetID(), SystemEntity::GetName(), m_npc, and m_state.

Referenced by CheckDistance().

159  {
160  if (m_state == State::Engaged)
161  return;
162  _log(NPC__AI_TRACE, "%s(%u): Engaged: Begin engaging. Target is %s(%u).", \
163  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
164  // actively fighting
166 }
#define _log(type, fmt,...)
Definition: logsys.h:124
State m_state
Definition: SentryAI.h:61
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
Sentry * m_npc
Definition: SentryAI.h:86

Here is the call graph for this function:

Here is the caller graph for this function:

void SentryAI::SetIdle ( )
protected

Definition at line 146 of file SentryAI.cpp.

References _log, Timer::Disable(), SystemEntity::GetID(), SystemEntity::GetName(), PI::Pin::State::Idle, m_beginFindTarget, m_mainAttackTimer, m_npc, m_state, m_warpScramblerTimer, and m_webifierTimer.

Referenced by ClearTarget(), Process(), Target(), Targeted(), and TargetLost().

146  {
147  if (m_state == State::Idle) return;
148  // not doing anything....idle.
149  _log(NPC__AI_TRACE, "%s(%u): Idle: returning to idle.", \
150  m_npc->GetName(), m_npc->GetID());
152 
157 }
#define _log(type, fmt,...)
Definition: logsys.h:124
void Disable()
Definition: timer.h:39
State m_state
Definition: SentryAI.h:61
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
Timer m_warpScramblerTimer
Definition: SentryAI.h:93
Timer m_beginFindTarget
Definition: SentryAI.h:92
Sentry * m_npc
Definition: SentryAI.h:86
Timer m_mainAttackTimer
Definition: SentryAI.h:91
Timer m_webifierTimer
Definition: SentryAI.h:94

Here is the call graph for this function:

Here is the caller graph for this function:

void SentryAI::SetSignaling ( SystemEntity pTarget)
protected

Definition at line 168 of file SentryAI.cpp.

References _log, SystemEntity::GetID(), SystemEntity::GetName(), m_npc, m_state, and NPCAI::State::Signaling.

168  {
169  if (m_state == State::Signaling)
170  return;
171  _log(NPC__AI_TRACE, "%s(%u): Signaling: Begin signaling. Target is %s(%u).", \
172  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
173  // actively signaling
175 }
#define _log(type, fmt,...)
Definition: logsys.h:124
State m_state
Definition: SentryAI.h:61
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
Sentry * m_npc
Definition: SentryAI.h:86

Here is the call graph for this function:

void SentryAI::Target ( SystemEntity by_who)

Definition at line 213 of file SentryAI.cpp.

References _log, AttrMaxAttackTargets, CheckDistance(), Timer::Disable(), EvilNumber::get_int(), InventoryItem::GetAttribute(), SystemEntity::GetID(), SystemEntity::GetName(), SystemEntity::GetSelf(), GetTargetTime(), m_beginFindTarget, m_npc, m_sightRange, SetIdle(), TargetManager::StartTargeting(), and SystemEntity::TargetMgr().

213  {
214  double targetTime = GetTargetTime();
215  bool chase = false;
216 
217  if (!m_npc->TargetMgr()->StartTargeting(pTarget, targetTime, (uint8)m_npc->GetSelf()->GetAttribute(AttrMaxAttackTargets).get_int(), m_sightRange, chase)) {
218  if (!chase) {
219  _log(NPC__AI_TRACE, "%s(%u): Targeting of %s(%u) failed. Clear Target and Return to Idle.", \
220  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
221  SetIdle();
222  }
223  return;
224  }
226  CheckDistance(pTarget);
227 }
unsigned __int8 uint8
Definition: eve-compat.h:46
#define _log(type, fmt,...)
Definition: logsys.h:124
void Disable()
Definition: timer.h:39
void SetIdle()
Definition: SentryAI.cpp:146
TargetManager * TargetMgr()
Definition: SystemEntity.h:197
InventoryItemRef GetSelf()
Definition: SystemEntity.h:202
double GetTargetTime()
Definition: SentryAI.cpp:328
int64 get_int()
Definition: EvilNumber.cpp:166
uint32 m_sightRange
Definition: SentryAI.h:81
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
Timer m_beginFindTarget
Definition: SentryAI.h:92
Sentry * m_npc
Definition: SentryAI.h:86
EvilNumber GetAttribute(const uint16 attrID) const
void CheckDistance(SystemEntity *pTarget)
Definition: SentryAI.cpp:177
bool StartTargeting(SystemEntity *tSE, ShipItemRef sRef)

Here is the call graph for this function:

void SentryAI::Targeted ( SystemEntity by_who)
Todo:
determine if new targetedby entity is weaker than current target. use optimalSigRadius to test for 'optimal' target

Definition at line 229 of file SentryAI.cpp.

References _log, AttrMaxAttackTargets, Timer::Disable(), DroneAI::State::Engaged, EvilNumber::get_int(), InventoryItem::GetAttribute(), SystemEntity::GetID(), SystemEntity::GetName(), SystemEntity::GetSelf(), GetTargetTime(), PI::Pin::State::Idle, m_beginFindTarget, m_npc, m_sightRange, m_state, SetIdle(), NPCAI::State::Signaling, TargetManager::StartTargeting(), and SystemEntity::TargetMgr().

Referenced by Sentry::TargetedAdd().

229  {
230  double targetTime = GetTargetTime();
231  switch(m_state) {
232  case State::Idle: {
233  _log(NPC__AI_TRACE, "%s(%u): Targeted by %s(%u) in Idle. Begin Targeting sequence.", \
234  m_npc->GetName(), m_npc->GetID(), pAgressor->GetName(), pAgressor->GetID());
235 
236  bool chase = false;
237  if (!m_npc->TargetMgr()->StartTargeting( pAgressor, targetTime, (uint8)m_npc->GetSelf()->GetAttribute(AttrMaxAttackTargets).get_int(), m_sightRange, chase)) {
238  if (!chase) {
239  _log(NPC__AI_TRACE, "%s(%u): Targeting of %s(%u) failed. Clear Target and Return to Idle.", \
240  m_npc->GetName(), m_npc->GetID(), pAgressor->GetName(), pAgressor->GetID());
241  SetIdle();
242  }
243  }
245  } break;
247  case State::Engaged: {
248  _log(NPC__AI_TRACE, "%s(%u): Targeted by %s(%u) while engaged.", \
249  m_npc->GetName(), m_npc->GetID(), pAgressor->GetName(), pAgressor->GetID());
250  } break;
251  case State::Signaling: {
252  _log(NPC__AI_TRACE, "%s(%u): Targeted by %s(%u) while signaling.", \
253  m_npc->GetName(), m_npc->GetID(), pAgressor->GetName(), pAgressor->GetID());
254  } break;
255  }
256 }
unsigned __int8 uint8
Definition: eve-compat.h:46
#define _log(type, fmt,...)
Definition: logsys.h:124
void Disable()
Definition: timer.h:39
State m_state
Definition: SentryAI.h:61
void SetIdle()
Definition: SentryAI.cpp:146
TargetManager * TargetMgr()
Definition: SystemEntity.h:197
InventoryItemRef GetSelf()
Definition: SystemEntity.h:202
double GetTargetTime()
Definition: SentryAI.cpp:328
int64 get_int()
Definition: EvilNumber.cpp:166
uint32 m_sightRange
Definition: SentryAI.h:81
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
Timer m_beginFindTarget
Definition: SentryAI.h:92
Sentry * m_npc
Definition: SentryAI.h:86
EvilNumber GetAttribute(const uint16 attrID) const
bool StartTargeting(SystemEntity *tSE, ShipItemRef sRef)

Here is the call graph for this function:

Here is the caller graph for this function:

void SentryAI::TargetLost ( SystemEntity by_who)
Todo:
engage weakest target in current list

Definition at line 258 of file SentryAI.cpp.

References _log, DroneAI::State::Engaged, SystemEntity::GetID(), SystemEntity::GetName(), TargetManager::HasNoTargets(), m_npc, m_state, SetIdle(), and SystemEntity::TargetMgr().

Referenced by Sentry::TargetLost().

258  {
259  if (m_state == State::Engaged) {
260  if (m_npc->TargetMgr()->HasNoTargets()) {
261  _log(NPC__AI_TRACE, "%s(%u): Target %s(%u) lost. No targets remain. Return to Idle.", \
262  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
263  SetIdle();
264  } else {
265  _log(NPC__AI_TRACE, "%s(%u): Target %s(%u) lost, but more targets remain.", \
266  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
268  }
269  }
270 }
#define _log(type, fmt,...)
Definition: logsys.h:124
State m_state
Definition: SentryAI.h:61
void SetIdle()
Definition: SentryAI.cpp:146
TargetManager * TargetMgr()
Definition: SystemEntity.h:197
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
Sentry * m_npc
Definition: SentryAI.h:86
bool HasNoTargets() const

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

uint16 SentryAI::m_attackSpeed
private

Definition at line 74 of file SentryAI.h.

Referenced by AttackTarget(), CheckDistance(), Process(), and SentryAI().

Timer SentryAI::m_beginFindTarget
private

Definition at line 92 of file SentryAI.h.

Referenced by Process(), SentryAI(), SetIdle(), Target(), and Targeted().

uint16 SentryAI::m_damageMultiplier
private

Definition at line 77 of file SentryAI.h.

Referenced by AttackTarget(), and SentryAI().

uint32 SentryAI::m_falloff
private

Definition at line 80 of file SentryAI.h.

Referenced by GetFalloff(), and SentryAI().

TurretFormulas SentryAI::m_formula
private

Definition at line 88 of file SentryAI.h.

Referenced by AttackTarget().

Timer SentryAI::m_mainAttackTimer
private

Definition at line 91 of file SentryAI.h.

Referenced by Attack(), CheckDistance(), SentryAI(), and SetIdle().

uint32 SentryAI::m_maxAttackRange
private

Definition at line 82 of file SentryAI.h.

Referenced by GetAttackRange(), and SentryAI().

uint16 SentryAI::m_optimalRange
private

Definition at line 76 of file SentryAI.h.

Referenced by GetOptimalRange(), and SentryAI().

uint16 SentryAI::m_preferedSigRadius
private

Definition at line 72 of file SentryAI.h.

Referenced by SentryAI().

Timer SentryAI::m_processTimer
private

Definition at line 90 of file SentryAI.h.

Referenced by Process(), and SentryAI().

uint32 SentryAI::m_sightRange
private

Definition at line 81 of file SentryAI.h.

Referenced by CheckDistance(), SentryAI(), Target(), and Targeted().

uint32 SentryAI::m_sigRadius
private

Definition at line 79 of file SentryAI.h.

Referenced by SentryAI().

State SentryAI::m_state
protected
float SentryAI::m_switchTargChance
private

Definition at line 71 of file SentryAI.h.

Referenced by SentryAI().

uint16 SentryAI::m_targetRange
private

Definition at line 75 of file SentryAI.h.

double SentryAI::m_trackingSpeed
private

Definition at line 84 of file SentryAI.h.

Referenced by GetTrackingSpeed(), and SentryAI().

bool SentryAI::m_useSecondTarget
private

Definition at line 70 of file SentryAI.h.

Referenced by SentryAI().

bool SentryAI::m_useSigRadius
private

Definition at line 68 of file SentryAI.h.

Referenced by SentryAI().

bool SentryAI::m_useTargSwitching
private

Definition at line 69 of file SentryAI.h.

Referenced by SentryAI().

bool SentryAI::m_warpScram
private

Definition at line 67 of file SentryAI.h.

Referenced by SentryAI().

Timer SentryAI::m_warpScramblerTimer
private

Definition at line 93 of file SentryAI.h.

Referenced by SentryAI(), and SetIdle().

bool SentryAI::m_webber
private

Definition at line 66 of file SentryAI.h.

Referenced by SentryAI().

Timer SentryAI::m_webifierTimer
private

Definition at line 94 of file SentryAI.h.

Referenced by SentryAI(), and SetIdle().


The documentation for this class was generated from the following files: