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

#include "NPC.h"

Inheritance diagram for NPC:
Collaboration diagram for NPC:

Public Member Functions

 NPC (InventoryItemRef self, PyServiceMgr &services, SystemManager *system, const FactionData &data, SpawnMgr *spawnMgr=nullptr)
 
virtual ~NPC ()
 
virtual NPCGetNPCSE ()
 
virtual bool IsNPCSE ()
 
virtual void Process ()
 
virtual void TargetLost (SystemEntity *who)
 
virtual void TargetedAdd (SystemEntity *who)
 
virtual void EncodeDestiny (Buffer &into)
 
virtual void Killed (Damage &fatal_blow)
 
virtual bool Load ()
 
virtual void MissileLaunched (Missile *pMissile)
 
void SaveNPC ()
 
void RemoveNPC ()
 
void SetResists ()
 
void UseHullRepairer ()
 
void UseArmorRepairer ()
 
void UseShieldRecharge ()
 
void Orbit (SystemEntity *who)
 
void ForceSetSpawner (SpawnMgr *spawnMgr)
 
float GetThermal ()
 
float GetEM ()
 
float GetKinetic ()
 
float GetExplosive ()
 
NPCAIMgrGetAIMgr ()
 
SpawnMgrGetSpawnMgr ()
 
void CmdDropLoot ()
 
- Public Member Functions inherited from DynamicSystemEntity
 DynamicSystemEntity (InventoryItemRef self, PyServiceMgr &services, SystemManager *system)
 
virtual ~DynamicSystemEntity ()
 
virtual DynamicSystemEntityGetDynamicSE ()
 
virtual bool IsDynamicEntity ()
 
virtual void UpdateDamage ()
 
virtual void MakeDamageState (DoDestinyDamageState &into)
 
virtual PyDictMakeSlimItem ()
 
virtual bool IsInvul ()
 
virtual bool IsFrozen ()
 
void AwardBounty (Client *pClient)
 
void SetInvul (bool invul=false)
 
void SetFrozen (bool frozen=false)
 
- Public Member Functions inherited from SystemEntity
 SystemEntity (InventoryItemRef self, PyServiceMgr &services, SystemManager *system)
 
virtual ~SystemEntity ()
 
virtual bool ProcessTic ()
 
virtual SystemEntityGetSE ()
 
virtual StaticSystemEntityGetStaticSE ()
 
virtual StationSEGetStationSE ()
 
virtual PlanetSEGetPlanetSE ()
 
virtual MoonSEGetMoonSE ()
 
virtual StargateSEGetGateSE ()
 
virtual BeltSEGetBeltSE ()
 
virtual ItemSystemEntityGetItemSE ()
 
virtual ContainerSEGetContSE ()
 
virtual WreckSEGetWreckSE ()
 
virtual AnomalySEGetAnomalySE ()
 
virtual WormholeSEGetWormholeSE ()
 
virtual FieldSEGetFieldSE ()
 
virtual ProbeSEGetProbeSE ()
 
virtual ObjectSystemEntityGetObjectSE ()
 
virtual AsteroidSEGetAsteroidSE ()
 
virtual StructureSEGetPOSSE ()
 
virtual StructureSEGetJammerSE ()
 
virtual JumpBridgeSEGetJumpBridgeSE ()
 
virtual StructureSEGetOutpostSE ()
 
virtual TowerSEGetTowerSE ()
 
virtual ArraySEGetArraySE ()
 
virtual WeaponSEGetWeaponSE ()
 
virtual BatterySEGetBatterySE ()
 
virtual DeployableSEGetDeployableSE ()
 
virtual SentryGetSentrySE ()
 
virtual ModuleSEGetModuleSE ()
 
virtual ReactorSEGetReactorSE ()
 
virtual CustomsSEGetCOSE ()
 
virtual TCUSEGetTCUSE ()
 
virtual SBUSEGetSBUSE ()
 
virtual IHubSEGetIHubSE ()
 
virtual DroneSEGetDroneSE ()
 
virtual MissileGetMissileSE ()
 
virtual ShipSEGetShipSE ()
 
virtual ConcordGetConcordSE ()
 
virtual bool isGlobal ()
 
virtual bool IsSystemEntity ()
 
virtual bool IsInanimateSE ()
 
virtual bool IsStaticEntity ()
 
virtual bool IsBeltSE ()
 
virtual bool IsGateSE ()
 
virtual bool IsPlanetSE ()
 
virtual bool IsMoonSE ()
 
virtual bool IsStationSE ()
 
virtual bool IsItemEntity ()
 
virtual bool IsAnomalySE ()
 
virtual bool IsWormholeSE ()
 
virtual bool IsCelestialSE ()
 
virtual bool IsContainerSE ()
 
virtual bool IsFieldSE ()
 
virtual bool IsProbeSE ()
 
virtual bool IsObjectEntity ()
 
virtual bool IsSentrySE ()
 
virtual bool IsPOSSE ()
 
virtual bool IsCOSE ()
 
virtual bool IsTCUSE ()
 
virtual bool IsSBUSE ()
 
virtual bool IsIHubSE ()
 
virtual bool IsTowerSE ()
 
virtual bool IsArraySE ()
 
virtual bool IsJammerSE ()
 
virtual bool IsWeaponSE ()
 
virtual bool IsBatterySE ()
 
virtual bool IsModuleSE ()
 
virtual bool IsMoonMiner ()
 
virtual bool IsOutpostSE ()
 
virtual bool IsAsteroidSE ()
 
virtual bool IsDeployableSE ()
 
virtual bool IsJumpBridgeSE ()
 
virtual bool IsReactorSE ()
 
virtual bool IsOperSE ()
 
virtual bool IsLogin ()
 
virtual bool IsDroneSE ()
 
virtual bool IsWreckSE ()
 
virtual bool IsMissileSE ()
 
virtual bool IsShipSE ()
 
virtual bool IsConcord ()
 
PyServiceMgrGetServices ()
 
SystemBubbleSysBubble ()
 
SystemManagerSystemMgr ()
 
TargetManagerTargetMgr ()
 
DestinyManagerDestinyMgr ()
 
InventoryItemRef GetSelf ()
 
uint16 GetTypeID ()
 
uint32 GetGroupID ()
 
uint8 GetCategoryID ()
 
EVEItemFlags GetFlag ()
 
uint32 GetID ()
 
double GetRadius ()
 
uint32 GetLocationID ()
 
const char * GetName () const
 
const GPointGetPosition () const
 
void SetPosition (const GPoint &pos)
 
double x ()
 
double y ()
 
double z ()
 
int32 GetAllianceID ()
 
int32 GetWarFactionID ()
 
uint32 GetCorporationID ()
 
uint32 GetOwnerID ()
 
uint32 GetFleetID ()
 
void SetFleetID (uint32 set)
 
int8 GetHarmonic ()
 
void SetHarmonic (int8 set)
 
void DropLoot (WreckContainerRef wreckRef, uint32 groupID, uint32 owner)
 
void AwardSecurityStatus (InventoryItemRef iRef, Character *pChar)
 
void SendDamageStateChanged ()
 
bool ApplyDamage (Damage &d)
 
double DistanceTo2 (const SystemEntity *other)
 
PyTupleMakeDamageState ()
 
virtual void Abandon ()
 
const bool IsDead ()
 
const GVectorGetVelocity ()
 
virtual bool LoadExtras ()
 
virtual void Delete ()
 
virtual void SetPilot (Client *pClient)
 
virtual bool HasPilot ()
 
virtual ClientGetPilot ()
 

Protected Attributes

NPCAIMgrm_AI
 
SpawnMgrm_spawnMgr
 
- Protected Attributes inherited from SystemEntity
SystemBubblem_bubble
 
SystemManagerm_system
 
TargetManagerm_targMgr
 
DestinyManagerm_destiny
 
PyServiceMgrm_services
 
InventoryItemRef m_self
 
bool m_killed
 
double m_radius
 
int32 m_harmonic
 
int32 m_warID
 
int32 m_allyID
 
uint32 m_corpID
 
uint32 m_fleetID
 
uint32 m_ownerID
 

Private Attributes

uint32 m_orbitingID
 
float m_emDamage
 
float m_expDamage
 
float m_kinDamage
 
float m_therDamage
 
float m_hullDamage
 
float m_armorDamage
 
float m_shieldCharge
 
float m_shieldCapacity
 

Detailed Description

Definition at line 41 of file NPC.h.

Constructor & Destructor Documentation

NPC::NPC ( InventoryItemRef  self,
PyServiceMgr services,
SystemManager system,
const FactionData data,
SpawnMgr spawnMgr = nullptr 
)

Definition at line 45 of file NPC.cpp.

References _log, FactionData::allianceID, AttrArmorDamage, AttrCapacitorCapacity, AttrCapacitorCharge, AttrCapacity, AttrDamage, AttrEmDamage, AttrExplosiveDamage, AttrInertia, AttrKineticDamage, AttrMass, AttrRadius, AttrShieldCapacity, AttrShieldCharge, AttrThermalDamage, AttrVolume, AttrWarpCapacitorNeed, ItemType::capacity(), FactionData::corporationID, EvilOne, EvilZero, FactionData::factionID, RefPtr< X >::get(), EvilNumber::get_float(), InventoryItem::GetAttribute(), InventoryItem::itemID(), SystemEntity::m_allyID, m_armorDamage, SystemEntity::m_corpID, m_emDamage, m_expDamage, m_hullDamage, m_kinDamage, SystemEntity::m_ownerID, SystemEntity::m_self, m_shieldCapacity, m_shieldCharge, m_therDamage, SystemEntity::m_warID, ItemType::mass(), InventoryItem::name(), FactionData::ownerID, ItemType::radius(), InventoryItem::SetAttribute(), InventoryItem::type(), and ItemType::volume().

46 : DynamicSystemEntity(self, services, system),
47 m_spawnMgr(spawnMgr),
48 m_AI(new NPCAIMgr(this))
49 {
50  m_allyID = data.allianceID;
51  m_warID = data.factionID;
52  m_corpID = data.corporationID;
53  m_ownerID = data.ownerID;
54 
55  // Create default dynamic attributes in the AttributeMap:
59  m_self->SetAttribute(AttrWarpCapacitorNeed, 0.00001, false);
60  m_self->SetAttribute(AttrMass, m_self->type().mass(), false);
66 
67  /* Gets the value from the NPC and put on our own vars */
76 
77  _log(NPC__TRACE, "Created NPC object for %s (%u) - Data: O:%u, C:%u, A:%u, W:%u", \
78  m_self.get()->name(), m_self.get()->itemID(), \
80 }
float m_armorDamage
Definition: NPC.h:99
#define _log(type, fmt,...)
Definition: logsys.h:124
float m_hullDamage
Definition: NPC.h:98
uint32 m_ownerID
Definition: SystemEntity.h:283
SpawnMgr * m_spawnMgr
Definition: NPC.h:89
const char * name()
float capacity() const
Definition: ItemType.h:71
float m_shieldCapacity
Definition: NPC.h:101
EvilNumber EvilZero
Definition: EvilNumber.cpp:32
NPCAIMgr * m_AI
Definition: NPC.h:88
const ItemType & type() const
InventoryItemRef m_self
Definition: SystemEntity.h:269
uint32 m_corpID
Definition: SystemEntity.h:281
float mass() const
Definition: ItemType.h:69
float m_emDamage
Definition: NPC.h:94
float m_shieldCharge
Definition: NPC.h:100
void SetAttribute(uint16 attrID, int num, bool notify=true)
float m_expDamage
Definition: NPC.h:95
X * get() const
Definition: RefPtr.h:213
uint32 corporationID
EvilNumber GetAttribute(const uint16 attrID) const
Definition: NPCAI.h:54
float radius() const
Definition: ItemType.h:68
float volume() const
Definition: ItemType.h:70
EvilNumber EvilOne
Definition: EvilNumber.cpp:34
float get_float()
Definition: EvilNumber.cpp:184
DynamicSystemEntity(InventoryItemRef self, PyServiceMgr &services, SystemManager *system)
float m_therDamage
Definition: NPC.h:97
float m_kinDamage
Definition: NPC.h:96
uint32 itemID() const
Definition: InventoryItem.h:98

Here is the call graph for this function:

NPC::~NPC ( )
virtual

Definition at line 82 of file NPC.cpp.

References m_AI, and SafeDelete().

82  {
84 }
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
Definition: SafeMem.h:83
NPCAIMgr * m_AI
Definition: NPC.h:88

Here is the call graph for this function:

Member Function Documentation

void NPC::CmdDropLoot ( )
Todo:
finish this

Definition at line 391 of file NPC.cpp.

References SystemEntity::m_destiny, and DestinyManager::SendJettisonPacket().

392 {
395  //DropLoot(wreckItemRef, m_self->groupID());
396 }
DestinyManager * m_destiny
Definition: SystemEntity.h:265
void SendJettisonPacket() const

Here is the call graph for this function:

void NPC::EncodeDestiny ( Buffer into)
virtual

Reimplemented from DynamicSystemEntity.

Definition at line 127 of file NPC.cpp.

References _log, Destiny::MassSector::allianceID, Buffer::Append(), Destiny::MassSector::cloak, Destiny::MassSector::corporationID, Destiny::WARP_Struct::effectStamp, Destiny::BallHeader::entityID, Destiny::BallHeader::flags, Destiny::Ball::Mode::FOLLOW, Destiny::FOLLOW_Struct::followID, Destiny::WARP_Struct::followID, Destiny::FOLLOW_Struct::followRange, Destiny::WARP_Struct::followRange, Destiny::ORBIT_Struct::followRange, Destiny::GOTO_Struct::formationID, Destiny::FOLLOW_Struct::formationID, Destiny::STOP_Struct::formationID, Destiny::WARP_Struct::formationID, Destiny::ORBIT_Struct::formationID, DestinyManager::GetFollowDistance(), SystemEntity::GetID(), DestinyManager::GetInertia(), DestinyManager::GetMass(), DestinyManager::GetMaxVelocity(), SystemEntity::GetName(), SystemEntity::GetRadius(), DestinyManager::GetSpeedFraction(), DestinyManager::GetState(), DestinyManager::GetTargetID(), DestinyManager::GetTargetPoint(), DestinyManager::GetVelocity(), DestinyManager::GetWarpSpeed(), Destiny::Ball::Mode::GOTO, Destiny::MassSector::harmonic, Destiny::DataSector::inertia, IsAlliance, DestinyManager::IsCloaked(), Destiny::Ball::Flag::IsFree, Destiny::Ball::Flag::IsMassive, SystemEntity::m_allyID, SystemEntity::m_corpID, SystemEntity::m_destiny, SystemEntity::m_harmonic, main(), Destiny::MassSector::mass, Destiny::DataSector::maxSpeed, Destiny::BallHeader::mode, Destiny::Ball::Mode::ORBIT, Destiny::BallHeader::posX, Destiny::BallHeader::posY, Destiny::BallHeader::posZ, Destiny::BallHeader::radius, Destiny::WARP_Struct::speed, Destiny::DataSector::speedfraction, Destiny::ORBIT_Struct::targetID, Destiny::WARP_Struct::targX, Destiny::WARP_Struct::targY, Destiny::WARP_Struct::targZ, Destiny::DataSector::velX, Destiny::DataSector::velY, Destiny::DataSector::velZ, Destiny::Ball::Mode::WARP, Destiny::GOTO_Struct::x, Ga::GaVec3::x, SystemEntity::x(), Destiny::GOTO_Struct::y, Ga::GaVec3::y, SystemEntity::y(), Destiny::GOTO_Struct::z, Ga::GaVec3::z, and SystemEntity::z().

128 {
129  using namespace Destiny;
130 
131  uint8 mode = m_destiny->GetState(); //Ball::Mode::STOP;
132 
133  BallHeader head = BallHeader();
134  head.entityID = GetID();
135  head.mode = mode;
136  head.radius = GetRadius();
137  head.posX = x();
138  head.posY = y();
139  head.posZ = z();
141  into.Append( head );
142  MassSector mass = MassSector();
143  mass.mass = m_destiny->GetMass();
144  mass.cloak = (m_destiny->IsCloaked() ? 1 : 0);
145  mass.harmonic = m_harmonic;
146  mass.corporationID = m_corpID;
147  mass.allianceID = (IsAlliance(m_allyID) ? m_allyID : -1);
148  into.Append( mass );
149  DataSector data = DataSector();
151  data.velX = m_destiny->GetVelocity().x;
152  data.velY = m_destiny->GetVelocity().y;
153  data.velZ = m_destiny->GetVelocity().z;
154  data.inertia = m_destiny->GetInertia();
156  into.Append( data );
157  switch (mode) {
158  case Ball::Mode::WARP: {
159  GPoint target = m_destiny->GetTargetPoint();
160  WARP_Struct warp;
161  warp.formationID = 0xFF;
162  warp.targX = target.x;
163  warp.targY = target.y;
164  warp.targZ = target.z;
165  warp.speed = m_destiny->GetWarpSpeed(); //ship warp speed x10 (dont ask...this is what it is...more dumb ccp shit)
166  // warp timing. see Ship::EncodeDestiny() for notes/updates
167  warp.effectStamp = -1; //m_destiny->GetStateStamp(); //timestamp when warp started
168  warp.followRange = 0; //this isnt right
169  warp.followID = 0; //this isnt right
170  into.Append( warp );
171  } break;
172  case Ball::Mode::FOLLOW: {
173  FOLLOW_Struct follow;
174  follow.followID = m_destiny->GetTargetID();
176  follow.formationID = 0xFF;
177  into.Append( follow );
178  } break;
179  case Ball::Mode::ORBIT: {
180  ORBIT_Struct orbit;
181  orbit.targetID = m_destiny->GetTargetID();
183  orbit.formationID = 0xFF;
184  into.Append( orbit );
185  } break;
186  case Ball::Mode::GOTO: {
187  GPoint target = m_destiny->GetTargetPoint();
188  GOTO_Struct go;
189  go.formationID = 0xFF;
190  go.x = target.x;
191  go.y = target.y;
192  go.z = target.z;
193  into.Append( go );
194  } break;
195  default: {
197  main.formationID = 0xFF;
198  into.Append( main );
199  } break;
200  }
201 
202  std::string modeStr = "Goto";
203  switch (mode) {
204  case 1: modeStr = "Follow"; break;
205  case 2: modeStr = "Stop"; break;
206  case 3: modeStr = "Warp"; break;
207  case 4: modeStr = "Orbit"; break;
208  case 5: modeStr = "Missile"; break;
209  case 6: modeStr = "Mushroom"; break;
210  case 7: modeStr = "Boid"; break;
211  case 8: modeStr = "Troll"; break;
212  case 9: modeStr = "Miniball"; break;
213  case 10: modeStr = "Field"; break;
214  case 11: modeStr = "Rigid"; break;
215  case 12: modeStr = "Formation"; break;
216  }
217 
218  _log(SE__DESTINY, "NPC::EncodeDestiny(): %s - id:%li, mode:%s, flags:0x%X, Vel:%.1f, %.1f, %.1f", \
219  GetName(), head.entityID, modeStr.c_str(), head.flags, data.velX, data.velY, data.velZ);
220 }
void Append(const T &value)
Appends a single value to buffer.
Definition: Buffer.h:437
unsigned __int8 uint8
Definition: eve-compat.h:46
double GetFollowDistance()
#define _log(type, fmt,...)
Definition: logsys.h:124
DestinyManager * m_destiny
Definition: SystemEntity.h:265
double GetRadius()
Definition: SystemEntity.h:208
double y()
Definition: SystemEntity.h:214
const GVector & GetVelocity() const
GaFloat x
Definition: GaTypes.h:207
int32 m_harmonic
Definition: SystemEntity.h:276
uint32 GetTargetID()
float GetSpeedFraction()
Definition: gpoint.h:33
int32 GetWarpSpeed()
uint32 m_corpID
Definition: SystemEntity.h:281
double GetMaxVelocity()
double GetInertia()
double z()
Definition: SystemEntity.h:215
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
double x()
Definition: SystemEntity.h:213
GaFloat y
Definition: GaTypes.h:207
GPoint GetTargetPoint()
int main(int argc, char *argv[])
#define IsAlliance(itemID)
Definition: EVE_Defines.h:244
GaFloat z
Definition: GaTypes.h:207

Here is the call graph for this function:

void NPC::ForceSetSpawner ( SpawnMgr spawnMgr)
inline

Definition at line 74 of file NPC.h.

References m_spawnMgr.

74 { m_spawnMgr = spawnMgr; }
SpawnMgr * m_spawnMgr
Definition: NPC.h:89
NPCAIMgr* NPC::GetAIMgr ( )
inline

Definition at line 81 of file NPC.h.

References m_AI.

Referenced by DestinyManager::BeginMovement(), TurretFormulas::GetNPCToHit(), and DestinyManager::WarpStop().

81 { return m_AI; }
NPCAIMgr * m_AI
Definition: NPC.h:88

Here is the caller graph for this function:

float NPC::GetEM ( )
inline

Definition at line 77 of file NPC.h.

References m_emDamage.

Referenced by NPCAIMgr::AttackTarget().

77 { return m_emDamage; }
float m_emDamage
Definition: NPC.h:94

Here is the caller graph for this function:

float NPC::GetExplosive ( )
inline

Definition at line 79 of file NPC.h.

References m_expDamage.

Referenced by NPCAIMgr::AttackTarget().

79 { return m_expDamage; }
float m_expDamage
Definition: NPC.h:95

Here is the caller graph for this function:

float NPC::GetKinetic ( )
inline

Definition at line 78 of file NPC.h.

References m_kinDamage.

Referenced by NPCAIMgr::AttackTarget().

78 { return m_kinDamage; }
float m_kinDamage
Definition: NPC.h:96

Here is the caller graph for this function:

virtual NPC* NPC::GetNPCSE ( )
inlinevirtual

Reimplemented from SystemEntity.

Definition at line 49 of file NPC.h.

49 { return this; }
SpawnMgr* NPC::GetSpawnMgr ( )
inline

Definition at line 82 of file NPC.h.

References m_spawnMgr.

Referenced by NPCAIMgr::Process(), NPCAIMgr::SetIdle(), NPCAIMgr::SetWander(), and NPCAIMgr::WarpOut().

82 { return m_spawnMgr; }
SpawnMgr * m_spawnMgr
Definition: NPC.h:89

Here is the caller graph for this function:

float NPC::GetThermal ( )
inline

Definition at line 76 of file NPC.h.

References m_therDamage.

Referenced by NPCAIMgr::AttackTarget().

76 { return m_therDamage; }
float m_therDamage
Definition: NPC.h:97

Here is the caller graph for this function:

virtual bool NPC::IsNPCSE ( )
inlinevirtual

Reimplemented from SystemEntity.

Definition at line 51 of file NPC.h.

51 { return true; }
void NPC::Killed ( Damage fatal_blow)
virtual

Reimplemented from SystemEntity.

Definition at line 304 of file NPC.cpp.

References _log, MapDB::AddFactionKill(), MapDB::AddKill(), DBSystemDynamicEntity::allianceID, DynamicSystemEntity::AwardBounty(), SystemEntity::AwardSecurityStatus(), SystemManager::BuildDynamicEntity(), DBSystemDynamicEntity::categoryID, EVEDB::invCategories::Celestial, DBSystemDynamicEntity::corporationID, SystemEntity::DropLoot(), DBSystemDynamicEntity::factionID, factionRogueDrones, flagNone, RefPtr< X >::get(), SystemEntity::GetAllianceID(), Client::GetChar(), Client::GetCharacterID(), SystemEntity::GetCorporationID(), SystemEntity::GetID(), SystemEntity::GetLocationID(), SystemEntity::GetName(), SystemEntity::GetPilot(), DestinyManager::GetPosition(), SystemEntity::GetSelf(), SystemManager::GetSystemSecurityRating(), SystemEntity::GetWarFactionID(), InventoryItem::groupID(), DBSystemDynamicEntity::groupID, SystemEntity::HasPilot(), is_log_enabled, SystemEntity::IsDroneSE(), Ga::GaVec3::isNaN(), IsWreckTypeID, InventoryItem::itemID(), DBSystemDynamicEntity::itemID, InventoryItem::itemName(), DBSystemDynamicEntity::itemName, itoa(), SystemEntity::m_allyID, SystemEntity::m_bubble, SystemEntity::m_destiny, SystemEntity::m_self, m_spawnMgr, SystemEntity::m_system, SystemEntity::m_warID, MakeRandomFloat(), InventoryItem::name(), InventoryItem::ownerID(), DBSystemDynamicEntity::ownerID, DBSystemDynamicEntity::position, sConfig, sDataMgr, DestinyManager::SendJettisonPacket(), sEntityList, sItemFactory, sLog, SpawnMgr::SpawnKilled(), Damage::srcSE, InventoryItem::typeID(), DBSystemDynamicEntity::typeID, EVEDB::invGroups::Wreck, Ga::GaVec3::x, SystemEntity::x(), Ga::GaVec3::y, SystemEntity::y(), Ga::GaVec3::z, and SystemEntity::z().

Referenced by Command_kill().

304  {
305  if ((m_bubble == nullptr) or (m_destiny == nullptr) or (m_system == nullptr))
306  return; // make error here?
307 
308  //notify our spawn manager that we are gone.
309  if ((m_spawnMgr != nullptr) and (m_self.get() != nullptr))
311 
312  uint32 killerID = 0;
313  Client* pClient(nullptr);
314  SystemEntity *killer(fatal_blow.srcSE);
315 
316  if (killer->HasPilot()) {
317  pClient = killer->GetPilot();
318  killerID = pClient->GetCharacterID();
319  } else if (killer->IsDroneSE()) {
320  pClient = sEntityList.FindClientByCharID( killer->GetSelf()->ownerID() );
321  if (pClient == nullptr) {
322  sLog.Error("NPC::Killed()", "killer == IsDrone and pPlayer == nullptr");
323  } else {
324  killerID = pClient->GetCharacterID();
325  }
326  } else {
327  killerID = killer->GetID();
328  }
329 
330  uint32 locationID = GetLocationID();
331  // log faction kill in dynamic data -allan
332  MapDB::AddKill(locationID);
333  MapDB::AddFactionKill(locationID);
334 
335  if (pClient != nullptr) {
336  //award kill bounty.
337  AwardBounty( pClient );
339  AwardSecurityStatus(m_self, pClient->GetChar().get()); // this awards secStatusChange for npcs in empire space
340  }
341 
342  GPoint wreckPosition = m_destiny->GetPosition();
343  if (wreckPosition.isNaN()) {
344  sLog.Error("NPC::Killed()", "Wreck Position is NaN");
345  return;
346  }
347  uint32 wreckTypeID = sDataMgr.GetWreckID(m_self->typeID());
348  if (!IsWreckTypeID(wreckTypeID)) {
349  sLog.Error("NPC::Killed()", "Could not get wreckType for %s of type %u", m_self->name(), m_self->typeID());
350  // default to generic frigate wreck till i get better checks and/or complete wreck data
351  wreckTypeID = 26557;
352  }
353 
354  std::string wreck_name = m_self->itemName();
355  wreck_name += " Wreck";
356  ItemData wreckItemData(wreckTypeID, killerID, locationID, flagNone, wreck_name.c_str(), wreckPosition, itoa(m_allyID));
357  WreckContainerRef wreckItemRef = sItemFactory.SpawnWreckContainer( wreckItemData );
358  if (wreckItemRef.get() == nullptr) {
359  sLog.Error("NPC::Killed()", "Creating Wreck Item Failed for %s of type %u", wreck_name.c_str(), wreckTypeID);
360  return;
361  }
362 
363  if (is_log_enabled(PHYSICS__TRACE))
364  _log(PHYSICS__TRACE, "NPC::Killed() - NPC %s(%u) Position: %.2f,%.2f,%.2f. Wreck %s(%u) Position: %.2f,%.2f,%.2f.", \
365  GetName(), GetID(), x(), y(), z(), wreckItemRef->name(), wreckItemRef->itemID(), wreckPosition.x, wreckPosition.y, wreckPosition.z);
366 
368  wreckEntity.allianceID = (killer->GetAllianceID() == 0 ? m_allyID : killer->GetAllianceID());
370  wreckEntity.corporationID = killer->GetCorporationID();
371  wreckEntity.factionID = (killer->GetWarFactionID() == 0 ? m_warID : killer->GetWarFactionID());
372  wreckEntity.groupID = EVEDB::invGroups::Wreck;
373  wreckEntity.itemID = wreckItemRef->itemID();
374  wreckEntity.itemName = wreck_name;
375  wreckEntity.ownerID = killerID;
376  wreckEntity.typeID = wreckTypeID;
377  wreckEntity.position = wreckPosition;
378 
379  if (!m_system->BuildDynamicEntity(wreckEntity, m_self->itemID())) {
380  sLog.Error("NPC::Killed()", "Spawning Wreck Failed for typeID %u", wreckTypeID);
381  wreckItemRef->Delete();
382  return;
383  }
385 
386  if ((MakeRandomFloat() < sConfig.npc.LootDropChance) or (m_allyID == factionRogueDrones))
387  DropLoot(wreckItemRef, m_self->groupID(), killerID);
388 }
#define sConfig
A macro for easier access to the singleton.
#define _log(type, fmt,...)
Definition: logsys.h:124
#define IsWreckTypeID(typeID)
Definition: EVE_Defines.h:203
DestinyManager * m_destiny
Definition: SystemEntity.h:265
void SendJettisonPacket() const
double MakeRandomFloat(double low, double high)
Generates random real from interval [low; high].
Definition: misc.cpp:114
double y()
Definition: SystemEntity.h:214
GaExpInl bool isNaN() const
Definition: GaTypes.h:194
SpawnMgr * m_spawnMgr
Definition: NPC.h:89
static void AddKill(uint32 sysID)
Definition: MapDB.cpp:250
SystemBubble * m_bubble
Definition: SystemEntity.h:262
static void AddFactionKill(uint32 sysID)
Definition: MapDB.cpp:256
SystemEntity * srcSE
Definition: Damage.h:84
#define sEntityList
Definition: EntityList.h:208
const float GetSystemSecurityRating()
Definition: SystemManager.h:86
void SpawnKilled(SystemBubble *pBubble, uint32 itemID)
Definition: SpawnMgr.cpp:229
const char * name()
GaFloat x
Definition: GaTypes.h:207
bool BuildDynamicEntity(const DBSystemDynamicEntity &entity, uint32 launcherID=0)
uint16 groupID() const
#define is_log_enabled(type)
Definition: logsys.h:78
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
Definition: gpoint.h:33
InventoryItemRef m_self
Definition: SystemEntity.h:269
uint32 GetLocationID()
Definition: SystemEntity.h:209
SystemManager * m_system
Definition: SystemEntity.h:263
double z()
Definition: SystemEntity.h:215
uint32 GetID()
Definition: SystemEntity.h:207
X * get() const
Definition: RefPtr.h:213
const char * GetName() const
Definition: SystemEntity.h:210
double x()
Definition: SystemEntity.h:213
Definition: Client.h:66
unsigned __int32 uint32
Definition: eve-compat.h:50
void AwardBounty(Client *pClient)
GaFloat y
Definition: GaTypes.h:207
const std::string & itemName() const
void DropLoot(WreckContainerRef wreckRef, uint32 groupID, uint32 owner)
void AwardSecurityStatus(InventoryItemRef iRef, Character *pChar)
const GPoint & GetPosition() const
#define sItemFactory
Definition: ItemFactory.h:165
uint16 typeID() const
GaFloat z
Definition: GaTypes.h:207
const char * itoa(int64 num)
Convers num to string.
uint32 itemID() const
Definition: InventoryItem.h:98
#define sDataMgr

Here is the call graph for this function:

Here is the caller graph for this function:

bool NPC::Load ( )
virtual

Reimplemented from DynamicSystemEntity.

Definition at line 86 of file NPC.cpp.

References DynamicSystemEntity::Load(), SystemEntity::m_destiny, SetResists(), and DestinyManager::UpdateShipVariables().

Referenced by DynamicEntityFactory::BuildEntity(), and SpawnMgr::ReSpawn().

87 {
89 
90  SetResists();
91 
93 }
DestinyManager * m_destiny
Definition: SystemEntity.h:265
virtual bool Load()
Definition: SystemEntity.h:492
void SetResists()
Definition: NPC.cpp:285

Here is the call graph for this function:

Here is the caller graph for this function:

void NPC::MissileLaunched ( Missile pMissile)
virtual

Reimplemented from SystemEntity.

Definition at line 269 of file NPC.cpp.

References m_AI, and NPCAIMgr::MissileLaunched().

270 {
271  m_AI->MissileLaunched(pMissile);
272 }
NPCAIMgr * m_AI
Definition: NPC.h:88
void MissileLaunched(Missile *pMissile)
Definition: NPCAI.cpp:820

Here is the call graph for this function:

void NPC::Orbit ( SystemEntity who)

Definition at line 111 of file NPC.cpp.

References SystemEntity::GetID(), and m_orbitingID.

111  {
112  if (who == nullptr) {
113  m_orbitingID = 0;
114  } else {
115  m_orbitingID = who->GetID();
116  }
117 }
uint32 GetID()
Definition: SystemEntity.h:207
uint32 m_orbitingID
Definition: NPC.h:92

Here is the call graph for this function:

void NPC::Process ( )
virtual

Reimplemented from SystemEntity.

Definition at line 96 of file NPC.cpp.

References GetTimeUSeconds(), m_AI, SystemEntity::m_killed, Profile::npc, NPCAIMgr::Process(), SystemEntity::Process(), sConfig, and sProfiler.

96  {
97  if (m_killed)
98  return;
99 
100  double profileStartTime = GetTimeUSeconds();
101 
102  /* Enable base call to Process Targeting and Movement */
104 
105  m_AI->Process();
106 
107  if (sConfig.debug.UseProfiling)
108  sProfiler.AddTime(Profile::npc, GetTimeUSeconds() - profileStartTime);
109 }
#define sConfig
A macro for easier access to the singleton.
virtual void Process()
void Process()
Definition: NPCAI.cpp:271
#define sProfiler
Definition: dbcore.cpp:39
NPCAIMgr * m_AI
Definition: NPC.h:88
double GetTimeUSeconds()
Definition: utils_time.cpp:116

Here is the call graph for this function:

void NPC::RemoveNPC ( )

Definition at line 279 of file NPC.cpp.

References InventoryItem::Delete(), and SystemEntity::m_self.

Referenced by SystemManager::RemoveNPC().

280 {
281  //this is called from SystemManager::RemoveNPC() which calls other SE* methods as needed
282  m_self->Delete();
283 }
InventoryItemRef m_self
Definition: SystemEntity.h:269
virtual void Delete()

Here is the call graph for this function:

Here is the caller graph for this function:

void NPC::SaveNPC ( )

Definition at line 274 of file NPC.cpp.

References SystemEntity::m_self, and InventoryItem::SaveItem().

275 {
276  m_self->SaveItem();
277 }
InventoryItemRef m_self
Definition: SystemEntity.h:269

Here is the call graph for this function:

void NPC::SetResists ( )

Definition at line 285 of file NPC.cpp.

References AttrArmorEmDamageResonance, AttrArmorExplosiveDamageResonance, AttrArmorKineticDamageResonance, AttrArmorThermalDamageResonance, AttrEmDamageResonance, AttrExplosiveDamageResonance, AttrKineticDamageResonance, AttrShieldEmDamageResonance, AttrShieldExplosiveDamageResonance, AttrShieldKineticDamageResonance, AttrShieldThermalDamageResonance, AttrThermalDamageResonance, EvilOne, InventoryItem::HasAttribute(), SystemEntity::m_self, and InventoryItem::SetAttribute().

Referenced by Load().

285  {
286  /* fix for missing resist attribs -allan 18April16 */
287  // Shield Resonance
292  // Armor Resonance
297  // Hull Resonance
302 }
bool HasAttribute(const uint16 attrID) const
InventoryItemRef m_self
Definition: SystemEntity.h:269
void SetAttribute(uint16 attrID, int num, bool notify=true)
EvilNumber EvilOne
Definition: EvilNumber.cpp:34

Here is the call graph for this function:

Here is the caller graph for this function:

void NPC::TargetedAdd ( SystemEntity who)
virtual

Definition at line 123 of file NPC.cpp.

References m_AI, and NPCAIMgr::Targeted().

Referenced by TargetManager::TargetedAdd().

123  {
124  m_AI->Targeted(who);
125 }
NPCAIMgr * m_AI
Definition: NPC.h:88
void Targeted(SystemEntity *pSE)
Definition: NPCAI.cpp:615

Here is the call graph for this function:

Here is the caller graph for this function:

void NPC::TargetLost ( SystemEntity who)
virtual

Definition at line 119 of file NPC.cpp.

References m_AI, and NPCAIMgr::TargetLost().

Referenced by TargetManager::TargetLost().

119  {
120  m_AI->TargetLost(who);
121 }
NPCAIMgr * m_AI
Definition: NPC.h:88
void TargetLost(SystemEntity *pSE)
Definition: NPCAI.cpp:665

Here is the call graph for this function:

Here is the caller graph for this function:

void NPC::UseArmorRepairer ( )

Definition at line 238 of file NPC.cpp.

References AttrArmorDamage, AttrEntityArmorRepairAmount, NPCAIMgr::DisableRepTimers(), EvilNumber::get_float(), InventoryItem::GetAttribute(), m_AI, m_armorDamage, SystemEntity::m_self, InventoryItem::SetAttribute(), and DynamicSystemEntity::UpdateDamage().

Referenced by NPCAIMgr::Process().

239 {
240  if (m_armorDamage > 0) {
242  if (m_armorDamage < 0.0)
243  m_armorDamage = 0.0;
245  } else {
246  m_AI->DisableRepTimers(false, true);
247  }
248 
249  // TODO: Need to send SpecialFX / amount update
250  UpdateDamage();
251 }
float m_armorDamage
Definition: NPC.h:99
NPCAIMgr * m_AI
Definition: NPC.h:88
InventoryItemRef m_self
Definition: SystemEntity.h:269
void SetAttribute(uint16 attrID, int num, bool notify=true)
void DisableRepTimers(bool shield=true, bool armor=true)
Definition: NPCAI.cpp:852
EvilNumber GetAttribute(const uint16 attrID) const
virtual void UpdateDamage()
float get_float()
Definition: EvilNumber.cpp:184

Here is the call graph for this function:

Here is the caller graph for this function:

void NPC::UseHullRepairer ( )

Definition at line 253 of file NPC.cpp.

References AttrDamage, NPCAIMgr::DisableRepTimers(), m_AI, m_hullDamage, SystemEntity::m_self, InventoryItem::SetAttribute(), and DynamicSystemEntity::UpdateDamage().

254 {
255  if (m_hullDamage > 0) {
256  //m_hullDamage -= m_self->GetAttribute(AttrEntityhullRepairAmount).get_float(); << NSA - create later
257  if (m_hullDamage < 0.0)
258  m_hullDamage = 0.0;
260  } else {
261  m_AI->DisableRepTimers(false, false);
262  }
263 
264  // TODO: Need to send SpecialFX / amount update
265  // gfxBoosterID
266  UpdateDamage();
267 }
float m_hullDamage
Definition: NPC.h:98
NPCAIMgr * m_AI
Definition: NPC.h:88
InventoryItemRef m_self
Definition: SystemEntity.h:269
void SetAttribute(uint16 attrID, int num, bool notify=true)
void DisableRepTimers(bool shield=true, bool armor=true)
Definition: NPCAI.cpp:852
virtual void UpdateDamage()

Here is the call graph for this function:

void NPC::UseShieldRecharge ( )

Definition at line 222 of file NPC.cpp.

References AttrEntityShieldBoostAmount, AttrShieldCapacity, AttrShieldCharge, NPCAIMgr::DisableRepTimers(), EvilNumber::get_float(), InventoryItem::GetAttribute(), m_AI, SystemEntity::m_self, m_shieldCharge, InventoryItem::SetAttribute(), and DynamicSystemEntity::UpdateDamage().

Referenced by NPCAIMgr::Process().

223 {
224  // We recharge our shield until it's full.
230  } else {
231  m_AI->DisableRepTimers(true, false);
232  }
233 
234  // TODO: Need to send SpecialFX / amount update
235  UpdateDamage();
236 }
NPCAIMgr * m_AI
Definition: NPC.h:88
InventoryItemRef m_self
Definition: SystemEntity.h:269
float m_shieldCharge
Definition: NPC.h:100
void SetAttribute(uint16 attrID, int num, bool notify=true)
void DisableRepTimers(bool shield=true, bool armor=true)
Definition: NPCAI.cpp:852
EvilNumber GetAttribute(const uint16 attrID) const
virtual void UpdateDamage()
float get_float()
Definition: EvilNumber.cpp:184

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

float NPC::m_armorDamage
private

Definition at line 99 of file NPC.h.

Referenced by NPC(), and UseArmorRepairer().

float NPC::m_emDamage
private

Definition at line 94 of file NPC.h.

Referenced by GetEM(), and NPC().

float NPC::m_expDamage
private

Definition at line 95 of file NPC.h.

Referenced by GetExplosive(), and NPC().

float NPC::m_hullDamage
private

Definition at line 98 of file NPC.h.

Referenced by NPC(), and UseHullRepairer().

float NPC::m_kinDamage
private

Definition at line 96 of file NPC.h.

Referenced by GetKinetic(), and NPC().

uint32 NPC::m_orbitingID
private

Definition at line 92 of file NPC.h.

Referenced by Orbit().

float NPC::m_shieldCapacity
private

Definition at line 101 of file NPC.h.

Referenced by NPC().

float NPC::m_shieldCharge
private

Definition at line 100 of file NPC.h.

Referenced by NPC(), and UseShieldRecharge().

SpawnMgr* NPC::m_spawnMgr
protected

Definition at line 89 of file NPC.h.

Referenced by ForceSetSpawner(), GetSpawnMgr(), and Killed().

float NPC::m_therDamage
private

Definition at line 97 of file NPC.h.

Referenced by GetThermal(), and NPC().


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