EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
NPCAI.h
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Zhur
24  Updates: Allan
25 */
26 
27 #ifndef __NPCAI_H_INCL__
28 #define __NPCAI_H_INCL__
29 
30 #include "ship/Missile.h"
32 
33 namespace NPCAI {
34  namespace State {
35  enum {
36  Invalid = -1,
37  Idle = 1, // not doing anything....idle.
38  Chasing = 2, // target out of range to attack/follow, but within npc sight range....use mwd/ab if equiped
39  Following = 3, // too close to chase, but to far to engage
40  Engaged = 4, // actively fighting
41  Fleeing = 5, // running away
42  Signaling = 6, // calling for help
43  WarpOut = 7, // leaving bubble
44  WarpFollow = 8 // will follow warping ship to their destination (adv)
45  };
46  }
47 }
48 
49 class NPC;
50 class SystemEntity;
51 class Timer;
52 class EvilNumber;
53 
54 class NPCAIMgr {
55 protected:
56 public:
57  NPCAIMgr(NPC *who);
58  ~NPCAIMgr() { /* do nothing here */ }
59 
60  // this is called from NPC::Process() which is called from SystemManager::Process()
61  void Process();
62 
63  void Target(SystemEntity* pSE);
64  void Targeted(SystemEntity* pSE);
65  void TargetLost(SystemEntity* pSE);
66 
67  void DisableRepTimers(bool shield=true, bool armor=true);
68 
69  // public methods to enable calls from other classes (namely, TurretFormulas.cpp)
70  bool IsIdle() { return (m_state == NPCAI::State::Idle); }
71  bool IsFighting();
74  uint32 GetFalloff() { return m_falloff; }
76  double GetTrackingSpeed() { return m_trackingSpeed; }
77 
78  // npcAI methods
81 
82  void LaunchMissile(uint16 typeID, SystemEntity* pSE); // us to them
83  void MissileLaunched(Missile* pMissile); // them to us
84 
85 protected:
86  void Attack(SystemEntity* pSE);
87  void SetIdle();
88  void WarpOut();
89  void SetWander();
90  void SetChasing(SystemEntity* pSE);
91  void SetEngaged(SystemEntity* pSE);
92  void SetFleeing(SystemEntity* pSE);
93  void ClearTarget(SystemEntity* pSE);
94  void SetFollowing(SystemEntity* pSE);
95  void SetSignaling(SystemEntity* pSE);
96  void AttackTarget(SystemEntity* pSE);
97  void CheckDistance(SystemEntity* pSE);
98 
99  float GetTargetTime();
100 
102 
103  std::string GetStateName(int8 stateID);
104 
105 private:
106  bool m_webber :1;
107  bool m_warpScram :1;
108  bool m_isWandering :1;
109  bool m_useSigRadius :1;
112 
113  float m_switchTargChance; //fuzzy logic
115 
116  //these attributes are cached to reduce access times. (much faster but uses more memory)
125  uint16 m_targetRange; // max targeting range default: m_maxAttackRange (unused)
127  uint16 m_boostRange; // distance for Speed Boost activation default:2500
130 
132  uint32 m_falloff;// distance past maximum range at which accuracy has fallen by half
133  uint32 m_flyRange; // npc tries to stay at this distance from active target default:500
135  uint32 m_maxAttackRange;// max firing range default:15000
137 
141 
144 
148 
150 
160 };
161 
162 #endif
uint32 GetAttackRange()
Definition: NPCAI.h:75
unsigned __int8 uint8
Definition: eve-compat.h:46
void Target(SystemEntity *pSE)
Definition: NPCAI.cpp:587
double m_damageMultiplier
Definition: NPCAI.h:143
uint16 m_optimalRange
Definition: NPCAI.h:126
TurretFormulas m_formula
Definition: NPCAI.h:149
bool m_isWandering
Definition: NPCAI.h:108
void SetIdle()
Definition: NPCAI.cpp:446
void Disable()
Definition: timer.h:39
uint16 m_launcherCycleTime
Definition: NPCAI.h:122
float GetTargetTime()
Definition: NPCAI.cpp:830
~NPCAIMgr()
Definition: NPCAI.h:58
bool m_warpScram
Definition: NPCAI.h:107
void Process()
Definition: NPCAI.cpp:271
uint16 m_boostRange
Definition: NPCAI.h:127
Timer m_armorRepairTimer
Definition: NPCAI.h:155
uint16 GetSigRes()
Definition: NPCAI.h:73
Timer m_shieldBoosterTimer
Definition: NPCAI.h:154
bool IsFighting()
Definition: NPCAI.cpp:372
bool IsIdle()
Definition: NPCAI.h:70
void WarpOut()
Definition: NPCAI.cpp:377
InventoryItemRef m_self
Definition: NPCAI.h:147
uint16 m_orbitSpeed
Definition: NPCAI.h:124
void Attack(SystemEntity *pSE)
Definition: NPCAI.cpp:689
this is a class that kinda mimics how python polymorph's numbers.
Definition: EvilNumber.h:59
uint16 m_sigResolution
Definition: NPCAI.h:123
uint16 m_targetRange
Definition: NPCAI.h:125
Timer m_mainAttackTimer
Definition: NPCAI.h:152
void SetWander()
Definition: NPCAI.cpp:409
signed __int8 int8
Definition: eve-compat.h:45
Timer m_webifierTimer
Definition: NPCAI.h:159
void CheckDistance(SystemEntity *pSE)
Definition: NPCAI.cpp:554
uint16 m_maxSpeed
Definition: NPCAI.h:119
void SetEngaged(SystemEntity *pSE)
Definition: NPCAI.cpp:507
uint32 m_falloff
Definition: NPCAI.h:132
Timer m_missileTimer
Definition: NPCAI.h:153
void SetFollowing(SystemEntity *pSE)
Definition: NPCAI.cpp:493
DestinyManager * m_destiny
Definition: NPCAI.h:146
uint16 m_armorRepairDuration
Definition: NPCAI.h:128
Timer m_beginFindTarget
Definition: NPCAI.h:156
void SetChasing(SystemEntity *pSE)
Definition: NPCAI.cpp:478
uint32 m_maxAttackRange
Definition: NPCAI.h:135
void WarpOutComplete()
Definition: NPCAI.h:80
bool m_useSecondTarget
Definition: NPCAI.h:111
bool m_useTargSwitching
Definition: NPCAI.h:110
NPCAIMgr(NPC *who)
Definition: NPCAI.cpp:51
Definition: NPC.h:41
uint16 m_shieldBoosterDuration
Definition: NPCAI.h:129
double m_trackingSpeed
Definition: NPCAI.h:142
uint8 m_maxAttackTargets
Definition: NPCAI.h:117
float m_warpScramChance
Definition: NPCAI.h:138
bool m_webber
Definition: NPCAI.h:106
uint16 m_preferedSigRadius
Definition: NPCAI.h:114
float m_armorRepairDelayChance
Definition: NPCAI.h:139
uint16 m_attackSpeed
Definition: NPCAI.h:120
void DisableWarpOutTimer()
Definition: NPCAI.h:79
unsigned __int32 uint32
Definition: eve-compat.h:50
NPC * m_npc
Definition: NPCAI.h:145
Definition: NPCAI.h:33
uint16 GetOptimalRange()
Definition: NPCAI.h:72
void MissileLaunched(Missile *pMissile)
Definition: NPCAI.cpp:820
void TargetLost(SystemEntity *pSE)
Definition: NPCAI.cpp:665
void DisableRepTimers(bool shield=true, bool armor=true)
Definition: NPCAI.cpp:852
Timer m_warpScramblerTimer
Definition: NPCAI.h:158
uint32 m_sigRadius
Definition: NPCAI.h:131
float m_switchTargChance
Definition: NPCAI.h:113
uint32 GetFalloff()
Definition: NPCAI.h:74
uint32 m_flyRange
Definition: NPCAI.h:133
Definition: NPCAI.h:54
void LaunchMissile(uint16 typeID, SystemEntity *pSE)
Definition: NPCAI.cpp:777
std::string GetStateName(int8 stateID)
Definition: NPCAI.cpp:860
uint32 m_sightRange
Definition: NPCAI.h:134
void AttackTarget(SystemEntity *pSE)
Definition: NPCAI.cpp:735
Timer m_processTimer
Definition: NPCAI.h:151
uint8 m_maxLockedTargets
Definition: NPCAI.h:118
void SetSignaling(SystemEntity *pSE)
Definition: NPCAI.cpp:538
Definition: timer.h:30
void Targeted(SystemEntity *pSE)
Definition: NPCAI.cpp:615
bool m_useSigRadius
Definition: NPCAI.h:109
unsigned __int16 uint16
Definition: eve-compat.h:48
Timer m_warpOutTimer
Definition: NPCAI.h:157
void ClearTarget(SystemEntity *pSE)
Definition: NPCAI.cpp:724
int8 m_state
Definition: NPCAI.h:101
void SetFleeing(SystemEntity *pSE)
Definition: NPCAI.cpp:522
uint32 m_warpScramRange
Definition: NPCAI.h:136
uint16 m_missileTypeID
Definition: NPCAI.h:121
double GetTrackingSpeed()
Definition: NPCAI.h:76
float m_shieldBoosterDelayChance
Definition: NPCAI.h:140