112 bool killTimer =
true;
115 if (itr->second.enabled) {
121 _log(SPAWN__TRACE,
"Process() calling Respawn for SpawnEntryID %u (0x%X)", \
122 itr->second.spawnID, &itr->second);
125 itr->second.enabled =
false;
132 _log(SPAWN__MESSAGE,
"SpawnMgr::Process() - Rat Spawn Groups full (or no spawns) for %s(%u). RatGroup Timer disabled.", \
137 if (
sConfig.debug.UseProfiling)
145 if (pBubble ==
nullptr)
148 _log(SPAWN__TRACE,
"MoveSpawn() called by %s(%u) from bubbleID %u to bubbleID %u", pNPC->
GetName(), npcID, pNPC->
SysBubble()->
GetID(), pBubble->
GetID() );
152 auto itr = range.first;
153 while (itr != range.second) {
154 if (itr->second.itemID == npcID) {
173 if (pBubble ==
nullptr)
178 auto itr = range.first;
179 while (itr != range.second) {
180 if (itr->second.enabled) {
185 if (rNPC ==
nullptr) {
190 rNPC->GetAIMgr()->DisableWarpOutTimer();
211 _log(SPAWN__MESSAGE,
"SpawnMgr::StartRatTimer() - Main Spawn Timer started for %s(%u) at %u ms.", \
225 _log(SPAWN__MESSAGE,
"SpawnMgr::StartRatGroupTimer() - Group Spawn Timer started for %s(%u) at %us.", \
231 if (pBubble ==
nullptr)
234 _log(SPAWN__DEPOP,
"SpawnMgr::SpawnKilled::Belt - called by %u.", itemID);
239 auto itr = range.first;
240 while (itr != range.second) {
241 if (itr->second.itemID == itemID) {
243 itr->second.enabled =
true;
245 if (!itr->second.enabled)
250 _log(SPAWN__DEPOP,
"SpawnMgr::SpawnKilled - Belt Spawn has been destoyed. Resetting spawn checks for bubble %u.", pBubble->
GetID());
260 }
else if (pBubble->
IsGate()) {
261 _log(SPAWN__DEPOP,
"SpawnMgr::SpawnKilled::Gate - called by %u.", itemID);
267 _log(SPAWN__DEPOP,
"SpawnMgr::SpawnKilled::Anomaly - called by %u.", itemID);
270 SpawnEntryDef::iterator itr =
m_spawns.find(pBubble->
GetID());
273 MakeSpawn(pBubble, itr->second.factionID, itr->second.spawnClass, itr->second.level);
291 _log(SPAWN__DEPOP,
"SpawnMgr::SpawnKilled::Mission - called by %u.", itemID);
301 _log(SPAWN__DEPOP,
"SpawnMgr::SpawnKilled::Incursion - called by %u.", itemID);
304 _log(SPAWN__DEPOP,
"SpawnMgr::SpawnKilled::Other - called by %u.", itemID);
311 if (pBubble ==
nullptr)
319 if (pBubble ==
nullptr)
329 if (pBubble ==
nullptr)
348 if (pBubble ==
nullptr)
353 _log(SPAWN__TRACE,
"SpawnMgr::FindSpawnForBubble() returned true for bubble %u.", pBubble->
GetID());
360 _log(SPAWN__TRACE,
"SpawnMgr::PrepSpawn() returned false for bubble %u.", pBubble->
GetID());
371 if (
sConfig.debug.UseProfiling)
378 if (pBubble ==
nullptr)
381 bool anomaly =
false;
385 factionID =
sConfig.npc.RatFaction;
391 _log(SPAWN__MESSAGE,
"SpawnMgr::PrepSpawn() - faction: %s, region %u. (config set %s)", \
396 if ((secRating < 0.2) and pBubble->
IsBelt()) {
405 }
else if (rand < 0.15) {
407 }
else if (rand < 0.25) {
422 if (secRating < -0.7) {
424 }
else if (secRating < -0.4) {
426 }
else if (secRating < -0.1) {
428 }
else if (secRating < 0.3) {
430 }
else if (secRating < 0.6) {
432 }
else if (secRating < 0.85) {
441 }
else if (pBubble->
IsGate()) {
442 if (secRating < -0.7) {
444 }
else if (secRating < -0.4) {
446 }
else if (secRating < -0.1) {
448 }
else if (secRating < 0.3) {
461 _log(SPAWN__MESSAGE,
"SpawnMgr::PrepSpawn() - m_factionGroups size is %u.",
m_factionGroups.size());
463 _log(SPAWN__ERROR,
"SpawnMgr::PrepSpawn() - No RatFaction data for faction %u. Cancelling spawn.", factionID);
468 if (
sDataMgr.GetNPCClasses(sClass, spawnEntry)) {
470 _log(SPAWN__MESSAGE,
"SpawnMgr::PrepSpawn() - spawnEntry - size: %u, class: %s(%u).", spawnEntry.size(),
GetSpawnClassName(sClass).c_str(), sClass);
472 _log(SPAWN__ERROR,
"SpawnMgr::PrepSpawn() - No NPC Class data for %u (%s). Cancelling spawn.", sClass,
GetSpawnClassName(sClass).c_str());
480 if (spawnEntry.size() < level) {
481 _log(SPAWN__ERROR,
"SpawnMgr::PrepSpawn() - spawnEntry.size (%u) < level (%u) for anomaly class %s. Cancelling spawn.", spawnEntry.size(), level,
GetSpawnClassName(sClass).c_str());
493 else if (secRating < 0.7) { level = 2; }
503 uint8 f = spawnEntry.at(level).f;
504 uint8 af = spawnEntry.at(level).af;
505 uint8 d = spawnEntry.at(level).d;
506 uint8 c = spawnEntry.at(level).c;
507 uint8 ac = spawnEntry.at(level).ac;
508 uint8 bc = spawnEntry.at(level).bc;
509 uint8 bs = spawnEntry.at(level).bs;
510 uint8 h = spawnEntry.at(level).h;
511 uint8 o = spawnEntry.at(level).o;
512 uint8 cf = spawnEntry.at(level).cf;
513 uint8 cd = spawnEntry.at(level).cd;
514 uint8 cc = spawnEntry.at(level).cc;
515 uint8 cbc = spawnEntry.at(level).cbc;
516 uint8 cbs = spawnEntry.at(level).cbs;
601 if ((bc > 0) or (bs > 0)) {
608 toSpawn.
quantity = ((bs > 0 ? bs : bc) *4);
627 _log(SPAWN__MESSAGE,
"SpawnMgr::PrepSpawn() - toSpawn size is %u.",
m_toSpawn.size());
628 MakeSpawn(pBubble, factionID, sClass, level, anomaly);
631 _log(SPAWN__ERROR,
"SpawnMgr::PrepSpawn() - Nothing to spawn.");
657 _log(SPAWN__MESSAGE,
"SpawnMgr::MakeSpawn() - Creating spawn class %s for %s in bubbleID %u (anomaly = %s).", \
671 GPoint warpToPoint(startPos);
673 std::string name =
"BeltRat";
679 startPos.MakeRandomPointOnSphere(
MakeRandomInt(10, 15) *100000);
697 for (
uint8 x=0; x < cur.quantity; ++x) {
699 if (iRef.
get() ==
nullptr) {
700 _log(SPAWN__ERROR,
"Failed to spawn item type %u.", cur.typeID);
704 _log(SPAWN__POP,
"SpawnMgr::MakeSpawn - Spawning NPC type %u (%u)", cur.typeID, iRef->
itemID());
711 _log(SPAWN__ERROR,
"Failed to load NPC data for NPC %u with type %u, depoping.", pNPC->GetID(), pNPC->GetSelf()->typeID());
718 pNPC->DestinyMgr()->SetPosition(startPos);
723 GPoint warpTo(warpToPoint);
725 pNPC->DestinyMgr()->WarpTo(warpTo, (
MakeRandomInt(-5, 10) *1000));
732 se.
total = cur.quantity;
747 _log(SPAWN__TRACE,
"MakeSpawn() adding SpawnEntry with ID %u to m_spawns. Class: %s, Group:%s, Level: %u.", \
759 _log(SPAWN__TRACE,
"MakeSpawn() completed in %s(%u) with %u bubbles in m_bubbles and %u entities in m_spawns.", \
769 GPoint warpToPoint(startPos);
770 startPos.MakeRandomPointOnSphere(
MakeRandomInt(10, 15) *100000);
771 _log(SPAWN__TRACE,
"ReSpawn() data for spawnEntryID %u 0x%X is type:%u, corp:%u, faction:%u, #:%u of %u", \
779 if (iRef.get() ==
nullptr) {
780 _log(SPAWN__ERROR,
"Failed to spawn item type %u.", spawnEntry.
typeID);
784 _log(SPAWN__POP,
"SpawnMgr::ReSpawn - Spawning NPC %s(%u)", iRef->name(), iRef->itemID());
788 data.corporationID = spawnEntry.
corpID;
790 data.ownerID = spawnEntry.
corpID;
792 if (pNPC ==
nullptr) {
793 _log(SPAWN__ERROR,
"Failed to create NPC SE for item type %u.", spawnEntry.
typeID);
798 _log(SPAWN__ERROR,
"Failed to load NPC data for NPC %u with type %u, depoping.", pNPC->
GetID(), pNPC->
GetSelf()->
typeID());
806 spawnEntry.
stamp = 0;
808 _log(SPAWN__TRACE,
"ReSpawn() completed for spawnEntryID %u 0x%X in bubble %u.", spawnEntry.
spawnID, &spawnEntry, pBubble->
GetID());
823 groupID = itr->second;
824 return sDataMgr.GetRandRatType(sClass, groupID);
830 auto range =
m_spawns.equal_range(bubbleID);
831 auto itr = range.first;
832 while (itr != range.second) {
833 if (itr->second.enabled);
843 auto range =
m_spawns.equal_range(bubbleID);
844 auto itr = range.first;
845 while (itr != range.second) {
846 if (itr->second.itemID == itemID) {
847 _log(SPAWN__TRACE,
"RemoveSpawn() found item %u in spawnID %u and removed it.", itemID, itr->second.spawnID);
854 _log(SPAWN__TRACE,
"RemoveSpawn() did not find item %u in bubble %u, out of %u total spawns in the map.", itemID, bubbleID,
m_spawns.size());
947 default:
return "Invalid";
1016 default:
return "Invalid";
#define sConfig
A macro for easier access to the singleton.
void StartRatGroupTimer()
#define _log(type, fmt,...)
NPC * GetNPCSE(uint32 entityID) const
void RemoveSpawnBubble(SystemBubble *pBubble)
SystemBubble * SysBubble()
double MakeRandomFloat(double low, double high)
Generates random real from interval [low; high].
bool IsChaining(uint16 bubbleID)
std::vector< RatSpawnClass > RatSpawnClassVec
SpawnMgr(SystemManager *mgr, PyServiceMgr &svc)
void SpawnKilled(SystemBubble *pBubble, uint32 itemID)
void DoSpawnForIncursion(SystemBubble *pBubble, uint32 regionID)
uint32 GetRemainingTime() const
void SetMission(bool set=true)
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
void MakeSpawn(SystemBubble *pBubble, uint32 factionID, uint8 sClass, uint8 level, bool anomaly=false)
const ItemType & type() const
#define is_log_enabled(type)
void MoveSpawn(NPC *pNPC, SystemBubble *pBubble)
bool PrepSpawn(SystemBubble *pBubble, uint8 sClass=Spawn::Class::None, uint8 level=0)
DestinyManager * DestinyMgr()
void SetAnomaly(bool set=true)
InventoryItemRef GetSelf()
void SetIncursion(bool set=true)
void WarpOutSpawn(NPC *pNPC, SystemBubble *pBubble)
bool Check(bool reset=true)
bool FindSpawnForBubble(uint16 bubbleID)
const char * GetName() const
void ReSpawn(SystemBubble *pBubble, SpawnEntry &spawnEntry)
void ResetBubbleRatSpawn()
RatSpawnClassVec m_ratSpawnClass
void RemoveSpawn(uint16 bubbleID, uint32 itemID)
void DoSpawnForMission(SystemBubble *pBubble, uint32 regionID)
void DoSpawnForAnomaly(SystemBubble *pBubble, uint8 spawnClass)
RatFactionGroupsMap m_factionGroups
uint16 m_groupTimerSetTime
std::string GetSpawnGroupName(int8 sGroup)
void WarpTo(const GPoint &where, int32 distance=0, bool autoPilot=false, SystemEntity *pSE=nullptr)
const char * GetName() const
int64 MakeRandomInt(int64 low, int64 high)
Generates random integer from interval [low; high].
std::string GetSpawnClassName(int8 sClass)
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type()() itemID() copy() materialLevel()() itemID(attributeID)-Retrieves attribute value." ) COMMAND( setattr
void SetSpawned(bool set=true)
uint8 GetSpawnGroup(uint8 sClass)
uint16 GetRandTypeID(uint8 sClass)
PyServiceMgr & m_services
void MakeRandomPointOnSphere(double radius)
#define IsRegionID(itemID)
bool DoSpawnForBubble(SystemBubble *pBubble)
RatSpawnGroupVec m_toSpawn
RatSpawningVec m_ratSpawns
void Start(uint32 setTimerTime=0, bool changeResetTimer=true)