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

#include "Concord.h"

Collaboration diagram for ConcordAI:

Public Member Functions

virtual ~ConcordAI ()
 

Protected Types

enum  State {
  Idle, Chasing, Following, Engaged,
  Fleeing, Signaling
}
 

Protected Attributes

State m_state
 

Private Attributes

double m_sigRadius
 
double m_attackSpeed
 
double m_entityFlyRange
 
double m_entityOrbitRange
 
double m_entityChaseRange
 
double m_entityAttackRange
 
double m_armorRepairChance
 
double m_shieldBoosterChance
 
uint16 m_chaseSpeed
 
uint16 m_cruiseSpeed
 
uint16 m_armorRepairDuration
 
uint16 m_shieldBoosterDuration
 
uint32 m_targetRange
 
Concordm_npc
 
TurretFormulas m_formula
 
Timer m_processTimer
 
Timer m_mainAttackTimer
 
Timer m_shieldBoosterTimer
 
Timer m_armorRepairTimer
 
Timer m_beginFindTarget
 
Timer m_warpScramblerTimer
 
Timer m_webifierTimer
 

Concord.cpp

this file is for Concord AI and other concord-specific code as it is written.

: Allan

Date
: 09 March 2016
 ConcordAI (Concord *who)
 
void Process ()
 
void Target (SystemEntity *by_who)
 
void Targeted (SystemEntity *by_who)
 
void TargetLost (SystemEntity *by_who)
 
void ClearTargets ()
 
void ClearAllTargets ()
 
void DisableRepTimers ()
 
void Attack (SystemEntity *pTarget)
 
void AttackTarget (SystemEntity *pTarget)
 
void SetIdle ()
 
void SetChasing (SystemEntity *pTarget)
 
void SetFollowing (SystemEntity *pTarget)
 
void SetEngaged (SystemEntity *pTarget)
 
void SetFleeing (SystemEntity *pTarget)
 
void SetSignaling (SystemEntity *pTarget)
 
void CheckDistance (SystemEntity *pTarget)
 
double GetTargetTime ()
 

Detailed Description

Definition at line 98 of file Concord.h.

Member Enumeration Documentation

enum ConcordAI::State
protected
Enumerator
Idle 
Chasing 
Following 
Engaged 
Fleeing 
Signaling 

Definition at line 128 of file Concord.h.

128  {
129  Idle, // not doing anything....idle.
130  Chasing, // target out of range to attack/follow, but within npc sight range....use mwd/ab if equiped
131  Following, // too close to chase, but to far to engage
132  Engaged, // actively fighting
133  Fleeing, // running away
134  Signaling // calling for help
135  } State;

Constructor & Destructor Documentation

ConcordAI::ConcordAI ( Concord who)
Todo:
change this to use config file

Definition at line 266 of file Concord.cpp.

References AttrEntityArmorRepairDelayChanceLarge, AttrEntityArmorRepairDelayChanceSmall, AttrEntityShieldBoostDelayChanceLarge, AttrEntityShieldBoostDelayChanceSmall, Timer::Disable(), EvilNumber::get_float(), InventoryItem::GetAttribute(), SystemEntity::GetSelf(), m_armorRepairChance, m_armorRepairTimer, m_beginFindTarget, m_entityAttackRange, m_mainAttackTimer, m_processTimer, m_shieldBoosterChance, m_shieldBoosterTimer, m_warpScramblerTimer, m_webifierTimer, and Timer::Start().

267 : m_state(Idle),
268 m_npc(who),
269 m_mainAttackTimer(1000),
270 m_processTimer(5000), //arbitrary.
271 m_shieldBoosterTimer(10000), //arbitrary.
272 m_armorRepairTimer(8000), //arbitrary.
273 m_beginFindTarget(5000), //arbitrary.
274 m_warpScramblerTimer(5000), //arbitrary.
275 m_webifierTimer(5000), //arbitrary.
286 {
287  m_processTimer.Start(5000); //arbitrary.
288 
289  m_webifierTimer.Disable(); //not implemented yet
290  m_beginFindTarget.Disable(); //arbitrary.
291  m_mainAttackTimer.Disable(); // dont start timer until we have a target
292  m_armorRepairTimer.Disable(); //waiting till engaged
293  m_warpScramblerTimer.Disable(); //not implemented yet
294  m_shieldBoosterTimer.Disable(); //waiting till engaged
295 
300 
305 
307  m_entityAttackRange = 300000;
308 }
void Disable()
Definition: timer.h:39
double m_entityOrbitRange
Definition: Concord.h:143
Concord * m_npc
Definition: Concord.h:156
uint16 m_shieldBoosterDuration
Definition: Concord.h:152
Timer m_mainAttackTimer
Definition: Concord.h:161
double m_armorRepairChance
Definition: Concord.h:146
double m_sigRadius
Definition: Concord.h:140
double m_attackSpeed
Definition: Concord.h:141
Timer m_beginFindTarget
Definition: Concord.h:164
Timer m_shieldBoosterTimer
Definition: Concord.h:162
Timer m_webifierTimer
Definition: Concord.h:166
InventoryItemRef GetSelf()
Definition: SystemEntity.h:202
int64 get_int()
Definition: EvilNumber.cpp:166
double m_entityChaseRange
Definition: Concord.h:144
uint16 m_armorRepairDuration
Definition: Concord.h:151
double m_shieldBoosterChance
Definition: Concord.h:147
Timer m_processTimer
Definition: Concord.h:160
uint16 m_chaseSpeed
Definition: Concord.h:149
double m_entityAttackRange
Definition: Concord.h:145
State m_state
Definition: Concord.h:136
double m_entityFlyRange
Definition: Concord.h:142
EvilNumber GetAttribute(const uint16 attrID) const
Timer m_warpScramblerTimer
Definition: Concord.h:165
float get_float()
Definition: EvilNumber.cpp:184
Timer m_armorRepairTimer
Definition: Concord.h:163
uint16 m_cruiseSpeed
Definition: Concord.h:150
void Start(uint32 setTimerTime=0, bool changeResetTimer=true)
Definition: timer.cpp:81

Here is the call graph for this function:

virtual ConcordAI::~ConcordAI ( )
inlinevirtual

Definition at line 102 of file Concord.h.

102 { /* do nothing here */ }

Member Function Documentation

void ConcordAI::Attack ( SystemEntity pTarget)
protected

Definition at line 602 of file Concord.cpp.

References _log, AttackTarget(), TargetManager::CanAttack(), Timer::Check(), TargetManager::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().

603 {
604  if (m_mainAttackTimer.Check()) {
605  if (!pSE) return;
606  // Check to see if the target still in the bubble (Client warped out)
607  if (!m_npc->SysBubble()->InBubble(pSE->GetPosition())) {
608  _log(CONCORD__AI_TRACE, "%s(%u): Target %s(%u) no longer in bubble. Clear target and move on",
609  m_npc->GetName(), m_npc->GetID(), pSE->GetName(), pSE->GetID());
610 
611  m_npc->TargetMgr()->ClearTarget(pSE);
612  //m_npc->TargetMgr()->OnTarget(pSE, TargMgr::Mode::Lost);
613  return;
614  }
615  DestinyManager* pDestiny = pSE->DestinyMgr();
616  if (!pDestiny) {
617  _log(CONCORD__AI_TRACE, "%s(%u): Target %s(%u) has no destiny manager. Clear target and move on",
618  m_npc->GetName(), m_npc->GetID(), pSE->GetName(), pSE->GetID());
619 
620  m_npc->TargetMgr()->ClearTarget(pSE);
621  //m_npc->TargetMgr()->OnTarget(pSE, TargMgr::Mode::Lost);
622  return;
623  }
624  // Check to see if the target is not cloaked:
625  if (pDestiny->IsCloaked()) {
626  _log(CONCORD__AI_TRACE, "%s(%u): Target %s(%u) is cloaked. Clear target and move on",
627  m_npc->GetName(), m_npc->GetID(), pSE->GetName(), pSE->GetID());
628  m_npc->TargetMgr()->ClearTarget(pSE);
629  //m_npc->TargetMgr()->OnTarget(pSE, TargMgr::Mode::Lost);
630  return;
631  }
632 
633  if (m_npc->TargetMgr()->CanAttack())
634  AttackTarget(pSE);
635  }
636 }
#define _log(type, fmt,...)
Definition: logsys.h:124
void ClearTarget(SystemEntity *tSE)
Concord * m_npc
Definition: Concord.h:156
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
bool InBubble(const GPoint &pt, bool inWarp=false) const
TargetManager * TargetMgr()
Definition: SystemEntity.h:197
Timer m_mainAttackTimer
Definition: Concord.h:161
void AttackTarget(SystemEntity *pTarget)
Definition: Concord.cpp:641
uint32 GetID()
Definition: SystemEntity.h:207
bool Check(bool reset=true)
Definition: timer.cpp:62
const char * GetName() const
Definition: SystemEntity.h:210

Here is the call graph for this function:

Here is the caller graph for this function:

void ConcordAI::AttackTarget ( SystemEntity pTarget)
protected

Definition at line 641 of file Concord.cpp.

References SystemEntity::ApplyDamage(), AttrDamageMultiplier, SystemEntity::DestinyMgr(), EvilNumber::get_float(), InventoryItem::GetAttribute(), Concord::GetEM(), Concord::GetExplosive(), SystemEntity::GetID(), Concord::GetKinetic(), TurretFormulas::GetNPCToHit(), SystemEntity::GetSelf(), Concord::GetThermal(), InventoryItem::itemID(), m_attackSpeed, m_formula, m_npc, DestinyManager::SendSpecialEffect(), targetAttack, and InventoryItem::typeID().

Referenced by Attack().

641  {
642  std::string guid = "effects.Laser";
644  m_npc->GetSelf()->itemID(),
645  m_npc->GetSelf()->typeID(), //m_npc->GetSelf()->GetAttribute(AttrGfxTurretID).get_int(),
646  pTarget->GetID(),
647  0,guid,1,1,1,m_attackSpeed,0);
648 
649  Damage d(m_npc,
650  m_npc->GetSelf(),
651  m_npc->GetKinetic(),
652  m_npc->GetThermal(),
653  m_npc->GetEM(),
654  m_npc->GetExplosive(),
655  m_formula.GetNPCToHit(m_npc, pTarget),
657  );
658 
660  pTarget->ApplyDamage(d);
661 }
Concord * m_npc
Definition: Concord.h:156
float GetEM()
Definition: Concord.h:63
float GetKinetic()
Definition: Concord.h:64
double m_attackSpeed
Definition: Concord.h:141
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
InventoryItemRef GetSelf()
Definition: SystemEntity.h:202
Definition: Damage.h:33
float GetExplosive()
Definition: Concord.h:65
uint32 GetID()
Definition: SystemEntity.h:207
EvilNumber GetAttribute(const uint16 attrID) const
float get_float()
Definition: EvilNumber.cpp:184
TurretFormulas m_formula
Definition: Concord.h:158
float GetNPCToHit(NPC *pNPC, SystemEntity *pTarget)
bool ApplyDamage(Damage &d)
Definition: Damage.cpp:108
float GetThermal()
Definition: Concord.h:62
uint16 typeID() const
uint32 itemID() const
Definition: InventoryItem.h:98

Here is the call graph for this function:

Here is the caller graph for this function:

void ConcordAI::CheckDistance ( SystemEntity pTarget)
protected

Definition at line 478 of file Concord.cpp.

References _log, Attack(), TargetManager::ClearTarget(), Timer::Enabled(), SystemEntity::GetID(), SystemEntity::GetName(), SystemEntity::GetPosition(), TargetManager::HasNoTargets(), Idle, Ga::GaVec3::length(), m_armorRepairDuration, m_armorRepairTimer, m_attackSpeed, m_entityAttackRange, m_entityChaseRange, m_entityFlyRange, m_mainAttackTimer, m_npc, m_shieldBoosterDuration, m_shieldBoosterTimer, m_state, SetChasing(), SetEngaged(), SetFollowing(), SetIdle(), Timer::Start(), and SystemEntity::TargetMgr().

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

479 {
480  //rewrote distance checks for correct logic this time
481  GVector usToThem(m_npc->GetPosition(), pSE->GetPosition());
482  //double dist = m_npc->GetPosition().distance(pSE->GetPosition()); // this throws occasional errors (segfault)
483  double dist = usToThem.length();
484  if (dist > m_entityAttackRange) {
485  _log(CONCORD__AI_TRACE, "%s(%u): CheckDistance: %s(%u) is too far away (%u). Return to Idle.", \
486  m_npc->GetName(), m_npc->GetID(), pSE->GetName(), pSE->GetID(), dist);
487  if (m_state != Idle) {
488  // target is no longer in npc's "sight range". unlock target and return to idle.
489  // should we do anything else here? search for another target? wander around?
490  m_npc->TargetMgr()->ClearTarget(pSE);
491  //m_npc->TargetMgr()->OnTarget(pSE, TargMgr::Mode::Lost);
492  if (m_npc->TargetMgr()->HasNoTargets())
493  SetIdle();
494  }
495  return;
496  } else if (dist < m_entityFlyRange) { //within weapon max (and within falloff)
497  SetEngaged(pSE); //engage and orbit
498  } else if (dist < m_entityChaseRange) { //within follow
499  SetFollowing(pSE);
500  } else if (dist < m_entityAttackRange) { //within sight
501  SetChasing(pSE);
502  return;
503  }
504 
509 
510  if (!m_mainAttackTimer.Enabled())
512 
513  Attack(pSE);
514 }
GaExpInl GaFloat length() const
Definition: GaTypes.h:156
#define _log(type, fmt,...)
Definition: logsys.h:124
void ClearTarget(SystemEntity *tSE)
void SetChasing(SystemEntity *pTarget)
Definition: Concord.cpp:422
Concord * m_npc
Definition: Concord.h:156
uint16 m_shieldBoosterDuration
Definition: Concord.h:152
void SetEngaged(SystemEntity *pTarget)
Definition: Concord.cpp:442
void SetIdle()
Definition: Concord.cpp:402
TargetManager * TargetMgr()
Definition: SystemEntity.h:197
const GPoint & GetPosition() const
Definition: SystemEntity.h:211
Timer m_mainAttackTimer
Definition: Concord.h:161
double m_attackSpeed
Definition: Concord.h:141
Timer m_shieldBoosterTimer
Definition: Concord.h:162
bool Enabled() const
Definition: timer.h:41
double m_entityChaseRange
Definition: Concord.h:144
uint16 m_armorRepairDuration
Definition: Concord.h:151
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
double m_entityAttackRange
Definition: Concord.h:145
State m_state
Definition: Concord.h:136
double m_entityFlyRange
Definition: Concord.h:142
bool HasNoTargets() const
void Attack(SystemEntity *pTarget)
Definition: Concord.cpp:602
Definition: gpoint.h:70
void SetFollowing(SystemEntity *pTarget)
Definition: Concord.cpp:432
Timer m_armorRepairTimer
Definition: Concord.h:163
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 ConcordAI::ClearAllTargets ( )

Definition at line 520 of file Concord.cpp.

References TargMgr::Mode::Clear, TargMgr::Msg::ClientReq, m_npc, and SystemEntity::TargetMgr().

Referenced by Target().

520  {
521 
522  //m_npc->TargetMgr()->ClearAllTargets();
524 }
Concord * m_npc
Definition: Concord.h:156
TargetManager * TargetMgr()
Definition: SystemEntity.h:197

Here is the call graph for this function:

Here is the caller graph for this function:

void ConcordAI::ClearTargets ( )

Definition at line 516 of file Concord.cpp.

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

516  {
518 }
Concord * m_npc
Definition: Concord.h:156
void ClearTargets(bool notify=true)
TargetManager * TargetMgr()
Definition: SystemEntity.h:197

Here is the call graph for this function:

void ConcordAI::DisableRepTimers ( )

Definition at line 684 of file Concord.cpp.

References Timer::Disable(), m_armorRepairTimer, and m_shieldBoosterTimer.

Referenced by Concord::UseArmorRepairer(), and Concord::UseShieldRecharge().

685 {
688 }
void Disable()
Definition: timer.h:39
Timer m_shieldBoosterTimer
Definition: Concord.h:162
Timer m_armorRepairTimer
Definition: Concord.h:163

Here is the call graph for this function:

Here is the caller graph for this function:

double ConcordAI::GetTargetTime ( )
protected

Definition at line 663 of file Concord.cpp.

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

Referenced by Target(), and Targeted().

664 {
665  double targetTime = (m_npc->GetSelf()->GetAttribute(AttrScanSpeed).get_int());
666  float radius = m_npc->GetSelf()->GetAttribute(AttrRadius).get_float();
667  if (!targetTime) {
668  if (radius < 30)
669  targetTime = 1500;
670  else if (radius < 60)
671  targetTime = 2500;
672  else if (radius < 150)
673  targetTime = 4000;
674  else if (radius < 280)
675  targetTime = 6000;
676  else if (radius < 550)
677  targetTime = 8000;
678  else
679  targetTime = 13000;
680  }
681  return targetTime;
682 }
Concord * m_npc
Definition: Concord.h:156
InventoryItemRef GetSelf()
Definition: SystemEntity.h:202
int64 get_int()
Definition: EvilNumber.cpp:166
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:

void ConcordAI::Process ( )

Definition at line 310 of file Concord.cpp.

References Chasing, Timer::Check(), CheckDistance(), TargetManager::ClearTarget(), SystemEntity::DestinyMgr(), Timer::Enabled(), Engaged, Fleeing, Following, TargetManager::GetFirstTarget(), TargetManager::HasNoTargets(), SystemBubble::HasPlayers(), Idle, DestinyManager::IsWarping(), m_armorRepairChance, m_armorRepairTimer, m_npc, m_processTimer, m_shieldBoosterChance, m_shieldBoosterTimer, m_state, MakeRandomFloat(), SetIdle(), Signaling, SystemEntity::SysBubble(), SystemEntity::TargetMgr(), Concord::UseArmorRepairer(), and Concord::UseShieldRecharge().

Referenced by Concord::Process().

310  {
311  /* concord ai needs to be written, so for now we'll just return immediatly */
312  return;
313 
314  if ((!m_processTimer.Check()) || (!m_npc->SysBubble()->HasPlayers()) || m_npc->DestinyMgr()->IsWarping())
315  return;
316 
320 
324 
325  /* NPC::State definitions -allan 25July15
326  * Idle, // not doing anything, nothing in sight....idle.
327  * Chasing, // target out of range to attack or follow, but within npc sight range....use mwd/ab if equipped
328  * Following, // too close to chase, but to far to engage...use half of max speed
329  * Engaged, // actively fighting (in orbit)...use full cruise to quarter max speed.
330  * Fleeing, // running away....use mwd/ab (if equipped) then warp away when out of range (does this make sense??)
331  * Signaling // calling for help..use full cruise to half of max speed to speed tank while calling for reinforcements
332  */
333  switch(m_state) {
334  case Idle: {
335  /* make timer here for them to leave */
336  } break;
337 
338  case Chasing: {
339  //NOTE: getting our target like this is pretty weak...
340  SystemEntity* pTarget = m_npc->TargetMgr()->GetFirstTarget(true);
341  if (!pTarget) {
342  if (m_npc->TargetMgr()->HasNoTargets()) {
343  //_log(CONCORD__AI_TRACE, "%s(%u): Stopped chasing, GetFirstTarget() returned NULL.", m_npc->GetName(), m_npc->GetID());
344  m_state = Idle;
345  }
346  return;
347  } else if (!pTarget->SysBubble()) {
348 
349  m_npc->TargetMgr()->ClearTarget(pTarget);
350  //m_npc->TargetMgr()->OnTarget(pTarget, TargMgr::Mode::Lost);
351  return;
352  }
353  CheckDistance(pTarget);
354  } break;
355 
356  case Following: {
357  //NOTE: getting our target like this is pretty weak...
358  SystemEntity* pTarget = m_npc->TargetMgr()->GetFirstTarget(true);
359  if (!pTarget) {
360  if (m_npc->TargetMgr()->HasNoTargets()) {
361  //_log(CONCORD__AI_TRACE, "%s(%u): Stopped following, GetFirstTarget() returned NULL.", m_npc->GetName(), m_npc->GetID());
362  m_state = Idle;
363  }
364  return;
365  } else if (!pTarget->SysBubble()) {
366  m_npc->TargetMgr()->ClearTarget(pTarget);
367  //m_npc->TargetMgr()->OnTarget(pTarget, TargMgr::Mode::Lost);
368  return;
369  }
370  CheckDistance(pTarget);
371  } break;
372 
373  case Engaged: {
374  //NOTE: getting our pTarget like this is pretty weak...
375  SystemEntity* pTarget = m_npc->TargetMgr()->GetFirstTarget(true);
376  if (!pTarget) {
377  if (m_npc->TargetMgr()->HasNoTargets()) {
378  //_log(CONCORD__AI_TRACE, "%s(%u): Stopped engagement, GetFirstTarget() returned NULL.", m_npc->GetName(), m_npc->GetID());
379  SetIdle();
380  }
381  return;
382  } else if (!pTarget->SysBubble()) {
383  m_npc->TargetMgr()->ClearTarget(pTarget);
384  //m_npc->TargetMgr()->OnTarget(pTarget, TargMgr::Mode::Lost);
385  return;
386  }
387  CheckDistance(pTarget);
388  } break;
389 
390  case Fleeing: {
391  // not sure how im gonna do this one yet.
392  } break;
393 
394  case Signaling: {
395  // not sure how im gonna do this one yet.
396  } break;
397 
398  //no default on purpose
399  }
400 }
void ClearTarget(SystemEntity *tSE)
void UseShieldRecharge()
Definition: Concord.cpp:207
Concord * m_npc
Definition: Concord.h:156
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
void CheckDistance(SystemEntity *pTarget)
Definition: Concord.cpp:478
double MakeRandomFloat(double low, double high)
Generates random real from interval [low; high].
Definition: misc.cpp:114
void SetIdle()
Definition: Concord.cpp:402
TargetManager * TargetMgr()
Definition: SystemEntity.h:197
double m_armorRepairChance
Definition: Concord.h:146
SystemEntity * GetFirstTarget(bool need_locked=false)
Timer m_shieldBoosterTimer
Definition: Concord.h:162
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
bool Enabled() const
Definition: timer.h:41
void UseArmorRepairer()
Definition: Concord.cpp:221
bool HasPlayers() const
Definition: SystemBubble.h:85
bool Check(bool reset=true)
Definition: timer.cpp:62
double m_shieldBoosterChance
Definition: Concord.h:147
Timer m_processTimer
Definition: Concord.h:160
State m_state
Definition: Concord.h:136
bool HasNoTargets() const
Timer m_armorRepairTimer
Definition: Concord.h:163

Here is the call graph for this function:

Here is the caller graph for this function:

void ConcordAI::SetChasing ( SystemEntity pTarget)
protected

Definition at line 422 of file Concord.cpp.

References Chasing, SystemEntity::DestinyMgr(), DestinyManager::Follow(), SystemEntity::GetID(), SystemEntity::GetName(), m_chaseSpeed, m_entityOrbitRange, m_npc, m_state, and DestinyManager::SetMaxVelocity().

Referenced by CheckDistance(), and Targeted().

422  {
423  if (m_state == Chasing) return;
424  //_log(CONCORD__AI_TRACE, "%s(%u): SetChasing: %s(%u) begin chasing.",
425  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
426  // target out of range to attack/follow, but within npc sight range....use mwd/ab if equiped
428  m_npc->DestinyMgr()->Follow(pTarget, m_entityOrbitRange); //try to get inside orbit range
429  m_state = Chasing;
430 }
double m_entityOrbitRange
Definition: Concord.h:143
Concord * m_npc
Definition: Concord.h:156
void SetMaxVelocity(float maxVelocity)
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
uint16 m_chaseSpeed
Definition: Concord.h:149
State m_state
Definition: Concord.h:136
void Follow(SystemEntity *pSE, uint32 distance)

Here is the call graph for this function:

Here is the caller graph for this function:

void ConcordAI::SetEngaged ( SystemEntity pTarget)
protected

Definition at line 442 of file Concord.cpp.

References SystemEntity::DestinyMgr(), Engaged, SystemEntity::GetID(), SystemEntity::GetName(), m_chaseSpeed, m_cruiseSpeed, m_entityOrbitRange, m_npc, m_state, MakeRandomFloat(), DestinyManager::Orbit(), and DestinyManager::SetMaxVelocity().

Referenced by CheckDistance().

442  {
443  if (m_state == Engaged) return;
444  //_log(CONCORD__AI_TRACE, "%s(%u): SetEngaged: %s(%u) begin engaging.",
445  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
446  // actively fighting
447  // not sure of the actual orbit speed of npc's, but their 'cruise speed' seems a bit slow.
448  // this sets orbit speed between cruise speed and quarter of max speed (whether mwb or ab)
449  // this will also enable this npc to have a variable speed, instead of fixed upon creation.
451  m_npc->DestinyMgr()->Orbit(pTarget, m_entityOrbitRange); //try to get inside orbit range
452  m_state = Engaged;
453 }
double m_entityOrbitRange
Definition: Concord.h:143
Concord * m_npc
Definition: Concord.h:156
double MakeRandomFloat(double low, double high)
Generates random real from interval [low; high].
Definition: misc.cpp:114
void SetMaxVelocity(float maxVelocity)
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
uint16 m_chaseSpeed
Definition: Concord.h:149
State m_state
Definition: Concord.h:136
void Orbit(SystemEntity *pSE, uint32 distance=0)
uint16 m_cruiseSpeed
Definition: Concord.h:150

Here is the call graph for this function:

Here is the caller graph for this function:

void ConcordAI::SetFleeing ( SystemEntity pTarget)
protected

Definition at line 455 of file Concord.cpp.

References SystemEntity::DestinyMgr(), Fleeing, SystemEntity::GetID(), SystemEntity::GetName(), m_chaseSpeed, m_npc, m_state, and DestinyManager::SetMaxVelocity().

455  {
456  if (m_state == Fleeing) return;
457  //_log(CONCORD__AI_TRACE, "%s(%u): SetFleeing: %s(%u) begin fleeing.",
458  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
459  // actively fleeing
460  // use superspeed to disengage, then warp. << both these will need to be written.
461  // this state is only usable by higher-class npcs.
463  m_state = Fleeing;
464 }
Concord * m_npc
Definition: Concord.h:156
void SetMaxVelocity(float maxVelocity)
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
uint16 m_chaseSpeed
Definition: Concord.h:149
State m_state
Definition: Concord.h:136

Here is the call graph for this function:

void ConcordAI::SetFollowing ( SystemEntity pTarget)
protected

Definition at line 432 of file Concord.cpp.

References SystemEntity::DestinyMgr(), DestinyManager::Follow(), Following, SystemEntity::GetID(), SystemEntity::GetName(), m_chaseSpeed, m_entityOrbitRange, m_npc, m_state, and DestinyManager::SetMaxVelocity().

Referenced by CheckDistance().

432  {
433  if (m_state == Following) return;
434  //_log(CONCORD__AI_TRACE, "%s(%u): SetFollowing: %s(%u) begin following.",
435  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
436  // too close to chase, but to far to engage
438  m_npc->DestinyMgr()->Follow(pTarget, m_entityOrbitRange); //try to get inside orbit range
439  m_state = Following;
440 }
double m_entityOrbitRange
Definition: Concord.h:143
Concord * m_npc
Definition: Concord.h:156
void SetMaxVelocity(float maxVelocity)
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
uint16 m_chaseSpeed
Definition: Concord.h:149
State m_state
Definition: Concord.h:136
void Follow(SystemEntity *pSE, uint32 distance)

Here is the call graph for this function:

Here is the caller graph for this function:

void ConcordAI::SetIdle ( )
protected

Definition at line 402 of file Concord.cpp.

References SystemEntity::DestinyMgr(), Timer::Disable(), SystemEntity::GetID(), SystemEntity::GetName(), Idle, m_armorRepairTimer, m_beginFindTarget, m_cruiseSpeed, m_mainAttackTimer, m_npc, m_shieldBoosterTimer, m_state, m_warpScramblerTimer, m_webifierTimer, DestinyManager::SetMaxVelocity(), and DestinyManager::Stop().

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

402  {
403  if (m_state == Idle) return;
404  // not doing anything....idle.
405  //_log(CONCORD__AI_TRACE, "%s(%u): SetIdle: returning to idle.",
406  m_npc->GetName(), m_npc->GetID());
407  m_state = Idle;
408  m_npc->DestinyMgr()->Stop();
410 
417 
418  // write code to enable npcs to wander around when idle?
419  // sounds like a good idea, but will take process power away from other shit.
420 }
void Disable()
Definition: timer.h:39
Concord * m_npc
Definition: Concord.h:156
void SetMaxVelocity(float maxVelocity)
Timer m_mainAttackTimer
Definition: Concord.h:161
Timer m_beginFindTarget
Definition: Concord.h:164
Timer m_shieldBoosterTimer
Definition: Concord.h:162
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
Timer m_webifierTimer
Definition: Concord.h:166
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
State m_state
Definition: Concord.h:136
Timer m_warpScramblerTimer
Definition: Concord.h:165
Timer m_armorRepairTimer
Definition: Concord.h:163
uint16 m_cruiseSpeed
Definition: Concord.h:150

Here is the call graph for this function:

Here is the caller graph for this function:

void ConcordAI::SetSignaling ( SystemEntity pTarget)
protected

Definition at line 466 of file Concord.cpp.

References SystemEntity::DestinyMgr(), SystemEntity::GetID(), SystemEntity::GetName(), m_chaseSpeed, m_cruiseSpeed, m_entityOrbitRange, m_npc, m_state, MakeRandomFloat(), DestinyManager::Orbit(), DestinyManager::SetMaxVelocity(), and Signaling.

466  {
467  if (m_state == Signaling) return;
468  //_log(CONCORD__AI_TRACE, "%s(%u): SetSignaling: %s(%u) begin signaling.",
469  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
470  // actively signaling
471  // start speedtanking while signaling. (im sure this is cheating, but fuckem.)
472  // this state is only usable by higher-class npcs.
474  m_npc->DestinyMgr()->Orbit(pTarget, m_entityOrbitRange); //try to get inside orbit range
475  m_state = Signaling;
476 }
double m_entityOrbitRange
Definition: Concord.h:143
Concord * m_npc
Definition: Concord.h:156
double MakeRandomFloat(double low, double high)
Generates random real from interval [low; high].
Definition: misc.cpp:114
void SetMaxVelocity(float maxVelocity)
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
uint16 m_chaseSpeed
Definition: Concord.h:149
State m_state
Definition: Concord.h:136
void Orbit(SystemEntity *pSE, uint32 distance=0)
uint16 m_cruiseSpeed
Definition: Concord.h:150

Here is the call graph for this function:

void ConcordAI::Target ( SystemEntity by_who)

Definition at line 526 of file Concord.cpp.

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

526  {
527  double targetTime = GetTargetTime();
528 
530  //_log(CONCORD__AI_TRACE, "%s(%u): Targeting of %s(%u) failed. Clear Target and Return to Idle.", \
531  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
532  ClearAllTargets();
533  SetIdle();
534  return;
535  }
537  CheckDistance(pTarget);
538 }
unsigned __int8 uint8
Definition: eve-compat.h:46
void Disable()
Definition: timer.h:39
double GetTargetTime()
Definition: Concord.cpp:663
Concord * m_npc
Definition: Concord.h:156
void CheckDistance(SystemEntity *pTarget)
Definition: Concord.cpp:478
void SetIdle()
Definition: Concord.cpp:402
TargetManager * TargetMgr()
Definition: SystemEntity.h:197
Timer m_beginFindTarget
Definition: Concord.h:164
InventoryItemRef GetSelf()
Definition: SystemEntity.h:202
int64 get_int()
Definition: EvilNumber.cpp:166
void ClearAllTargets()
Definition: Concord.cpp:520
double m_entityAttackRange
Definition: Concord.h:145
EvilNumber GetAttribute(const uint16 attrID) const
bool StartTargeting(SystemEntity *tSE, ShipItemRef sRef)

Here is the call graph for this function:

void ConcordAI::Targeted ( SystemEntity by_who)

Definition at line 540 of file Concord.cpp.

References _log, AttrMaxAttackTargets, Chasing, CheckDistance(), Timer::Disable(), Engaged, Fleeing, Following, EvilNumber::get_int(), InventoryItem::GetAttribute(), SystemEntity::GetID(), SystemEntity::GetName(), SystemEntity::GetSelf(), GetTargetTime(), Idle, m_beginFindTarget, m_entityAttackRange, m_npc, m_state, SetChasing(), SetIdle(), Signaling, TargetManager::StartTargeting(), and SystemEntity::TargetMgr().

Referenced by Concord::TargetedAdd().

540  {
541  double targetTime = GetTargetTime();
542 
543  switch(m_state) {
544  case Idle: {
545  _log(CONCORD__AI_TRACE, "%s(%u): Targeted by %s(%u) in Idle. Begin Approaching and start Targeting sequence.", \
546  m_npc->GetName(), m_npc->GetID(), pAgressor->GetName(), pAgressor->GetID());
547  SetChasing(pAgressor);
548 
550  SetIdle();
551  return;
552  }
554  CheckDistance(pAgressor);
555  } break;
556  case Chasing: {
557  _log(CONCORD__AI_TRACE, "%s(%u): Targeted by %s(%u) while chasing.",
558  m_npc->GetName(), m_npc->GetID(), pAgressor->GetName(), pAgressor->GetID());
559  } break;
560  case Following: {
561  _log(CONCORD__AI_TRACE, "%s(%u): Targeted by %s(%u) while following.",
562  m_npc->GetName(), m_npc->GetID(), pAgressor->GetName(), pAgressor->GetID());
563  } break;
564  case Engaged: {
565  _log(CONCORD__AI_TRACE, "%s(%u): Targeted by %s(%u) while engaged.",
566  m_npc->GetName(), m_npc->GetID(), pAgressor->GetName(), pAgressor->GetID());
567  } break;
568  case Fleeing: {
569  _log(CONCORD__AI_TRACE, "%s(%u): Targeted by %s(%u) while fleeing.",
570  m_npc->GetName(), m_npc->GetID(), pAgressor->GetName(), pAgressor->GetID());
571  } break;
572  case Signaling: {
573  _log(CONCORD__AI_TRACE, "%s(%u): Targeted by %s(%u) while signaling.",
574  m_npc->GetName(), m_npc->GetID(), pAgressor->GetName(), pAgressor->GetID());
575  } break;
576 
577  //no default on purpose
578  }
579 }
unsigned __int8 uint8
Definition: eve-compat.h:46
#define _log(type, fmt,...)
Definition: logsys.h:124
void Disable()
Definition: timer.h:39
void SetChasing(SystemEntity *pTarget)
Definition: Concord.cpp:422
double GetTargetTime()
Definition: Concord.cpp:663
Concord * m_npc
Definition: Concord.h:156
void CheckDistance(SystemEntity *pTarget)
Definition: Concord.cpp:478
void SetIdle()
Definition: Concord.cpp:402
TargetManager * TargetMgr()
Definition: SystemEntity.h:197
Timer m_beginFindTarget
Definition: Concord.h:164
InventoryItemRef GetSelf()
Definition: SystemEntity.h:202
int64 get_int()
Definition: EvilNumber.cpp:166
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
double m_entityAttackRange
Definition: Concord.h:145
State m_state
Definition: Concord.h:136
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 ConcordAI::TargetLost ( SystemEntity by_who)

Definition at line 581 of file Concord.cpp.

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

Referenced by Concord::TargetLost().

581  {
582  switch(m_state) {
583  case Chasing:
584  case Following:
585  case Engaged: {
586  if (m_npc->TargetMgr()->HasNoTargets()) {
587  _log(CONCORD__AI_TRACE, "%s(%u): Target %s(%u) lost. No targets remain. Return to Idle.",
588  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
589  SetIdle();
590  } else {
591  _log(CONCORD__AI_TRACE, "%s(%u): Target %s(%u) lost, but more targets remain.",
592  m_npc->GetName(), m_npc->GetID(), pTarget->GetName(), pTarget->GetID());
593  }
594 
595  } break;
596 
597  default:
598  break;
599  }
600 }
#define _log(type, fmt,...)
Definition: logsys.h:124
Concord * m_npc
Definition: Concord.h:156
void SetIdle()
Definition: Concord.cpp:402
TargetManager * TargetMgr()
Definition: SystemEntity.h:197
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
State m_state
Definition: Concord.h:136
bool HasNoTargets() const

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

double ConcordAI::m_armorRepairChance
private

Definition at line 146 of file Concord.h.

Referenced by ConcordAI(), and Process().

uint16 ConcordAI::m_armorRepairDuration
private

Definition at line 151 of file Concord.h.

Referenced by CheckDistance().

Timer ConcordAI::m_armorRepairTimer
private

Definition at line 163 of file Concord.h.

Referenced by CheckDistance(), ConcordAI(), DisableRepTimers(), Process(), and SetIdle().

double ConcordAI::m_attackSpeed
private

Definition at line 141 of file Concord.h.

Referenced by AttackTarget(), and CheckDistance().

Timer ConcordAI::m_beginFindTarget
private

Definition at line 164 of file Concord.h.

Referenced by ConcordAI(), SetIdle(), Target(), and Targeted().

uint16 ConcordAI::m_chaseSpeed
private

Definition at line 149 of file Concord.h.

Referenced by SetChasing(), SetEngaged(), SetFleeing(), SetFollowing(), and SetSignaling().

uint16 ConcordAI::m_cruiseSpeed
private

Definition at line 150 of file Concord.h.

Referenced by SetEngaged(), SetIdle(), and SetSignaling().

double ConcordAI::m_entityAttackRange
private

Definition at line 145 of file Concord.h.

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

double ConcordAI::m_entityChaseRange
private

Definition at line 144 of file Concord.h.

Referenced by CheckDistance().

double ConcordAI::m_entityFlyRange
private

Definition at line 142 of file Concord.h.

Referenced by CheckDistance().

double ConcordAI::m_entityOrbitRange
private

Definition at line 143 of file Concord.h.

Referenced by SetChasing(), SetEngaged(), SetFollowing(), and SetSignaling().

TurretFormulas ConcordAI::m_formula
private

Definition at line 158 of file Concord.h.

Referenced by AttackTarget().

Timer ConcordAI::m_mainAttackTimer
private

Definition at line 161 of file Concord.h.

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

Timer ConcordAI::m_processTimer
private

Definition at line 160 of file Concord.h.

Referenced by ConcordAI(), and Process().

double ConcordAI::m_shieldBoosterChance
private

Definition at line 147 of file Concord.h.

Referenced by ConcordAI(), and Process().

uint16 ConcordAI::m_shieldBoosterDuration
private

Definition at line 152 of file Concord.h.

Referenced by CheckDistance().

Timer ConcordAI::m_shieldBoosterTimer
private

Definition at line 162 of file Concord.h.

Referenced by CheckDistance(), ConcordAI(), DisableRepTimers(), Process(), and SetIdle().

double ConcordAI::m_sigRadius
private

Definition at line 140 of file Concord.h.

State ConcordAI::m_state
protected
uint32 ConcordAI::m_targetRange
private

Definition at line 154 of file Concord.h.

Timer ConcordAI::m_warpScramblerTimer
private

Definition at line 165 of file Concord.h.

Referenced by ConcordAI(), and SetIdle().

Timer ConcordAI::m_webifierTimer
private

Definition at line 166 of file Concord.h.

Referenced by ConcordAI(), and SetIdle().


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