EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DungeonMgr.cpp
Go to the documentation of this file.
1 
12 #include "eve-server.h"
13 
14 #include "EVEServerConfig.h"
15 #include "PyServiceMgr.h"
16 #include "StaticDataMgr.h"
17 #include "system/SystemBubble.h"
22 
24 {
26 }
27 
29 {
30  // for now, we are deleting all saved dungeons on startup. will fix this later as system matures.
32 
33  Populate();
34  sLog.Blue(" DungeonDataMgr", "Dungeon Data Manager Initialized.");
35  return 1;
36 }
37 
39 {
40  double start = GetTimeMSeconds();
41  DBQueryResult* res = new DBQueryResult();
42  DBResultRow row;
43 
45  while (res->GetRow(row)) {
46  // SELECT dunTemplateID, dunTemplateName, dunEntryID, dunSpawnID, dunRoomID FROM dunTemplates
47  Dungeon::Template dtemplates = Dungeon::Template();
48  dtemplates.dunName = row.GetText(1);
49  dtemplates.dunRoomID = row.GetInt(4);
50  dtemplates.dunEntryID = row.GetInt(2);
51  dtemplates.dunSpawnClass = row.GetInt(3);
52  templates.emplace(row.GetInt(0), dtemplates);
53  }
54 
55  //res->Reset();
57  while (res->GetRow(row)) {
58  // SELECT dunRoomID, dunGroupID, xpos, ypos, zpos FROM dunRoomData
60  drooms.dunGroupID = row.GetInt(1);
61  drooms.x = row.GetInt(2);
62  drooms.y = row.GetInt(3);
63  drooms.z = row.GetInt(4);
64  rooms.emplace(row.GetInt(0), drooms);
65  }
66 
67  //res->Reset();
69  while (res->GetRow(row)) {
70  // SELECT d.dunGroupID, d.itemTypeID, d.itemGroupID, t.typeName, t.groupID, g.categoryID, t.radius, d.xpos, d.ypos, d.zpos FROM dunGroupData
72  dgroups.typeID = row.GetInt(1);
73  dgroups.typeName = row.GetText(3);
74  dgroups.typeGrpID = row.GetInt(4);
75  dgroups.typeCatID = row.GetInt(5);
76  dgroups.radius = row.GetInt(6);
77  dgroups.x = row.GetInt(7);
78  dgroups.y = row.GetInt(8);
79  dgroups.z = row.GetInt(9);
80  groups.emplace(row.GetInt(0), dgroups);
81  }
82 
83  //res->Reset();
85  while (res->GetRow(row)) {
86  //SELECT dunEntryID, xpos, ypos, zpos FROM dunEntryData
88  dentry.x = row.GetInt(1);
89  dentry.y = row.GetInt(2);
90  dentry.z = row.GetInt(3);
91  entrys.emplace(row.GetInt(0), dentry);
92  }
93 
94  /* not ready yet
95  //res->Reset();
96  ManagerDB::GetDunSpawnInfo(*res);
97  while (res->GetRow(row)) {
98  //SELECT dunRoomSpawnID, dunRoomSpawnType, xpos, ypos, zpos
99  Dungeon::RoomSpawnInfo spawn = Dungeon::RoomSpawnInfo();
100  spawn.dunRoomSpawnID = row.GetInt(0);
101  spawn.dunRoomSpawnType = row.GetInt(1);
102  spawn.x = row.GetInt(2);
103  spawn.y = row.GetInt(3);
104  spawn.z = row.GetInt(4);
105  groups.emplace(spawn.dunRoomSpawnID, spawn);
106  } */
107 
108  // sort/save template room/group data to avoid compilation later?
109 
110  //cleanup
111  SafeDelete(res);
112 
113  //sLog.Cyan(" DungeonDataMgr", "%u rooms in %u buckets and %u groups in %u buckets for %u dungeon templates loaded in %.3fms.",\
114  rooms.size(), rooms.bucket_count(), groups.size(), groups.bucket_count(), templates.size(), (GetTimeMSeconds() - start));
115 
116  sLog.Cyan(" DungeonDataMgr", "%u entrys, %u rooms and %u groups for %u dungeon templates loaded in %.3fms.",\
117  entrys.size(), rooms.size(), groups.size(), templates.size(), (GetTimeMSeconds() - start));
118 }
119 
121 {
122  activeDungeons.emplace(dungeon.systemID, dungeon);
123  _log(COSMIC_MGR__DEBUG, "Added Dungeon %u (%u) in systemID %u to active dungeon list.", dungeon.dunItemID, dungeon.dunTemplateID, dungeon.systemID);
124  //ManagerDB::SaveActiveDungeon(dungeon);
125 }
126 
127 void DungeonDataMgr::GetDungeons(std::vector<Dungeon::ActiveData>& dunList)
128 {
129  for (auto cur : activeDungeons)
130  dunList.push_back(cur.second);
131 }
132 
134  std::map<uint32, Dungeon::Template>::iterator itr = templates.find(templateID);
135  if (itr == templates.end()) {
136  _log(COSMIC_MGR__ERROR, "DungeonDataMgr - templateID %u not found.", templateID);
137  return false;
138  }
139  dTemplate = itr->second;
140  return true;
141 }
142 
144 {
145  switch (typeID) {
146  case Dungeon::Type::Mission: return "Mission";
147  case Dungeon::Type::Gravimetric: return "Gravimetric";
148  case Dungeon::Type::Magnetometric: return "Magnetometric";
149  case Dungeon::Type::Radar: return "Radar";
150  case Dungeon::Type::Ladar: return "Ladar";
151  case Dungeon::Type::Rated: return "Rated";
152  case Dungeon::Type::Anomaly: return "Anomaly";
153  case Dungeon::Type::Unrated: return "Unrated";
154  case Dungeon::Type::Escalation: return "Escalation";
155  case Dungeon::Type::Wormhole: return "Wormhole";
156  default: return "Invalid";
157  }
158 }
159 
160 
162 : m_system(mgr),
163 m_services(svc),
164 m_anomMgr(nullptr),
165 m_spawnMgr(nullptr)
166 {
167  m_initalized = false;
168  m_anomalyItems.clear();
169 }
170 
172 {
173  //for now we're deleting everything till i can write proper item handling code
174 
175  /* this is not needed as all items are temp at this time.
176  for (auto cur : m_dungeonList)
177  for (auto item : cur.second)
178  InventoryDB::DeleteItem(item);
179  */
180 }
181 
182 bool DungeonMgr::Init(AnomalyMgr* anomMgr, SpawnMgr* spawnMgr)
183 {
184  m_anomMgr = anomMgr;
185  m_spawnMgr = spawnMgr;
186 
187  if (m_anomMgr == nullptr) {
188  _log(COSMIC_MGR__ERROR, "System Init Fault. anomMgr == nullptr. Not Initializing Dungeon Manager for %s(%u)", m_system->GetName(), m_system->GetID());
189  return m_initalized;
190  }
191 
192  if (m_spawnMgr == nullptr) {
193  _log(COSMIC_MGR__ERROR, "System Init Fault. spawnMgr == nullptr. Not Initializing Dungeon Manager for %s(%u)", m_system->GetName(), m_system->GetID());
194  return m_initalized;
195  }
196 
197  if (!sConfig.cosmic.DungeonEnabled){
198  _log(COSMIC_MGR__MESSAGE, "Dungeon System Disabled. Not Initializing Dungeon Manager for %s(%u)", m_system->GetName(), m_system->GetID());
199  return true;
200  }
201 
202  if (!sConfig.cosmic.AnomalyEnabled) {
203  _log(COSMIC_MGR__MESSAGE, "Anomaly System Disabled. Not Initializing Dungeon Manager for %s(%u)", m_system->GetName(), m_system->GetID());
204  return true;
205  }
206 
207  if (!sConfig.npc.RoamingSpawns and !sConfig.npc.StaticSpawns) {
208  _log(COSMIC_MGR__MESSAGE, "SpawnMgr Disabled. Not Initializing Dungeon Manager for %s(%u)", m_system->GetName(), m_system->GetID());
209  return true;
210  }
211 
212  if (!sConfig.cosmic.BeltEnabled) {
213  _log(COSMIC_MGR__MESSAGE, "BeltMgr Disabled. Not Initializing Dungeon Manager for %s(%u)", m_system->GetName(), m_system->GetID());
214  return true;
215  }
216 
217  m_spawnMgr->SetDungMgr(this);
218  Load();
219 
220  _log(COSMIC_MGR__MESSAGE, "DungeonMgr Initialized for %s(%u)", m_system->GetName(), m_system->GetID());
221 
222  m_initalized = true;
223 
224  return m_initalized;
225 }
226 
227 // called from systemMgr
229  if (!m_initalized)
230  return;
231 
232  // this is used to remove empty/completed/timed-out dungons....eventually
233 }
234 
236 {
237  std::vector<Dungeon::ActiveData> dungeons;
255 }
256 
258 {
259  Dungeon::Template dTemplate = Dungeon::Template();
260  if (!sDunDataMgr.GetTemplate(templateID, dTemplate))
261  return false;
262 
263  if (dTemplate.dunRoomID == 0) {
264  _log(COSMIC_MGR__ERROR, "DungeonMgr::Create() - roomID is 0 for template %u.", templateID);
265  return false;
266  }
267 
268  if ((sig.dungeonType < Dungeon::Type::Wormhole) // 1 - 5
269  or (sig.ownerID == factionRogueDrones)) {
270  sig.sigName = dTemplate.dunName;
271  } else {
272  sig.sigName = sDataMgr.GetFactionName(sig.ownerID);
273  sig.sigName += dTemplate.dunName;
274  }
275 
276  // spawn and save actual anomaly item // typeID, ownerID, locationID, flag, name, &_position
278  /*
279  std::string info = "Dungeon: ";
280  info += sig.sigName;
281  info += " in ";
282  info += m_system->GetName();
283  */
284  ItemData iData(sig.sigTypeID, sig.ownerID, sig.systemID, flagNone, sig.sigName.c_str(), sig.position/*, info*/);
285  InventoryItemRef iRef = InventoryItem::SpawnItem(sItemFactory.GetNextTempID(), iData);
286  if (iRef.get() == nullptr) // make error and exit
287  return false;
288  CelestialSE* cSE = new CelestialSE(iRef, *(m_system->GetServiceMgr()), m_system);
289  if (cSE == nullptr)
290  return false; // we'll get over it.
291  // dont add signal thru sysMgr. signal is added when this returns to anomMgr
292  m_system->AddEntity(cSE, false);
293  sig.sigItemID = iRef->itemID();
294  sig.bubbleID = cSE->SysBubble()->GetID();
295 
296  _log(COSMIC_MGR__TRACE, "DungeonMgr::Create() - %s using templateID %u and roomID %i", sig.sigName.c_str(), templateID, dTemplate.dunRoomID);
297 
298  /* do we need this? persistent dungeons?
299  if ((typeID == 1) or (typeID == 8) or (typeID == 9) or (typeID == 10)) {
300  // setup data to save active dungeon
301  ActiveDungeon dungeon = ActiveDungeon();
302  dungeon.dunExpiryTime = Win32TimeNow() + (EvE::Time::Day * 3); // 3 days - i know this isnt right. just for testing.
303  dungeon.dunTemplateID = templateID;
304  dungeon.dunItemID = sig.sigItemID;
305  dungeon.state = 0; //dunType here.
306  dungeon.systemID = sig.systemID;
307  dungeon.x = sig.x;
308  dungeon.y = sig.y;
309  dungeon.z = sig.z;
310  sDunDataMgr.AddDungeon(dungeon);
311  } */
312 
313  /* roomID format. ABCD
314  * A = roomtype - 1:combat, 2:rescue, 3:capture, 4:salvage, 5:relic, 6:hacking, 7:roids, 8:clouds, 9:recon
315  * B = level - 0:none, 1:f, 2:d, 3:c, 4:af/ad, 5:bc, 6:ac, 7:bs, 8:abs, 9:hard
316  * C = amount/size - 0:code defined 1:small(1-5), 2:medium(2-10), 3:large(5-25), 4:enormous(10-50), 5:colossal(20-100), 6-9:ice
317  * D = faction - 0=drone, 1:Serpentis, 2:Angel, 3:Blood, 4:Guristas, 5:Sansha, 6:Amarr, 7:Caldari, 8:Gallente, 9:Minmatar
318  * D = sublevel - 0:gas, 1-5:ore, 6-9:ice
319  */
320 
321  int16 x=0, y=0, z=0;
322  Dungeon::GroupData grp;
323  auto roomRange = sDunDataMgr.rooms.equal_range(dTemplate.dunRoomID);
324  for (auto it = roomRange.first; it != roomRange.second; ++it) {
325  x = it->second.x;
326  y = it->second.y;
327  z = it->second.z;
328  auto groupRange = sDunDataMgr.groups.equal_range(it->second.dunGroupID);
329  for (auto it2 = groupRange.first; it2 != groupRange.second; ++it2) {
330  grp.typeCatID = it2->second.typeCatID;
331  grp.typeGrpID = it2->second.typeGrpID;
332  grp.typeName = it2->second.typeName;
333  grp.typeID = it2->second.typeID;
334  grp.x = (x + it2->second.x);
335  grp.y = (y + it2->second.y);
336  grp.z = (z + it2->second.z);
337  m_anomalyItems.push_back(grp);
338  }
339  }
341  // dungeon template for grav sites just give 'extra' roid data
342  int16 size = m_anomalyItems.size();
343  uint8 divisor = 10;
344  if (size < 100)
345  divisor = 100;
346  float chance = (100.0 /size) /divisor;
347  if (chance < 0.01)
348  chance = 0.01;
349  std::unordered_multimap<float, uint16> roidTypes;
350  for (auto cur : m_anomalyItems)
351  roidTypes.emplace(chance, cur.typeID);
352 
353  m_system->GetBeltMgr()->Create(sig, roidTypes);
354  // clear out extra roids data to continue with room deco
355  m_anomalyItems.clear();
356  } else {
357  // other types have a chance for roids.
358  }
359 
360  // create deco items for this dungeon
361  CreateDeco(templateID, sig);
362 
363  // item spawning method
364  uint32 systemID = m_system->GetID();
365  std::vector<uint32> items;
366  GPoint pos2(NULL_ORIGIN);
367  std::vector<Dungeon::GroupData>::iterator itr = m_anomalyItems.begin(), end = m_anomalyItems.end();
368  while (itr != end) {
369  pos2.x = sig.position.x + itr->x;
370  pos2.y = sig.position.y + itr->y;
371  pos2.z = sig.position.z + itr->z;
372  // typeID, ownerID, locationID, flag, name, &_position
373  ItemData dData(itr->typeID, sig.ownerID, systemID, flagNone, itr->typeName.c_str(), pos2);
374  iRef = InventoryItem::SpawnItem(sItemFactory.GetNextTempID(), dData);
375  if (iRef.get() == nullptr) // we'll survive...
376  continue;
377  // should ALL of these be CelestialSEs?
378  cSE = new CelestialSE(iRef, *(m_system->GetServiceMgr()), m_system);
379  m_system->AddEntity(cSE, false);
380  items.push_back(iRef->itemID());
381  ++itr;
382  }
383 
384  if (dTemplate.dunSpawnClass > 0)
386 
387  _log(COSMIC_MGR__TRACE, "DungeonMgr::Create() - dungeonID %u created for %s with %u items.", \
388  sig.sigItemID, sig.sigName.c_str(), m_anomalyItems.size());
389 
390  m_anomalyItems.clear();
391  if (!items.empty())
392  m_dungeonList.emplace(sig.sigItemID, items);
393 
394  return true;
395 }
396 
397 /*
398  * Band 1/5 1/10 1/15 1/20 1/25 1/40 1/45 1/60 1/80
399  * Percentage 20.0% 10.0% 6.67% 5.0% 4.0% 2.5% 2.22% 1.67% 1.25%
400  */
401 
402 /* templateID format. ABCDE
403  * A = site - 1:mission, 2:grav, 3:mag, 4:radar, 5:ladar, 6:ded, 7:anomaly, 8:unrated, 9:escalation
404  * B = sec - mission: 1-9 (incomplete); others - sysSec: 1=hi, 2=lo, 3=null, 4=mid;
405  * C = type - grav: ore 0-5, ice 6-9; anomaly: 1-5; mission: 1-9; mag: *see below*; ded: 1-8; ladar/radar: 1-8
406  * D = level - mission: 1-9; grav: ore 1-3, ice 0; mag: *see below*; radar: 1-norm; 2-digital(nullsec); ladar: 1; anomaly: 1-5
407  * E = faction - 0=code defined, 1=Serpentis, 2=Angel, 3=Blood, 4=Guristas, 5=Sansha, 6=Drones, 7=region sov, 8=region rat, 9=other
408  *
409  * NOTE: mag sites have multiple types and levels based on other variables.
410  * types are defined as relic(1), salvage(2), and drone(3), with salvage being dominant.
411  * for hisec and losec, levels are 1-8 for relic and salvage. there are no drone mag sites here
412  * for nullsec, relic site levels are 1-8, salvage site levels are 1-4, and drone site levels are 1-7
413  *
414  * NOTE: faction can only be 8 for grav and anomaly sites, unless drones (6). all others MUST use 1-6
415  */
416 
418 {
419  float secRating = m_system->GetSystemSecurityRating();
420  int8 sec = 1; // > 0.6
421  if (secRating < -0.2) {
422  sec = 3;
423  } else if (secRating < 0.2) {
424  sec = 4;
425  } else if (secRating < 0.6) {
426  sec = 2;
427  }
428 
429  float level(1.0f);
430  int8 type(1);
431  // need to determine region sov, region rat or other here also
432  int8 faction(GetFaction(sig.ownerID));
433 
434  using namespace Dungeon::Type;
435  switch (sig.dungeonType) {
436  case Gravimetric: { // 2
437  faction = 8; // region rat
438  // all roid types can spawn in grav sites.
439  level = MakeRandomFloat();
440  if (level < 0.1) {
441  level = 3;
442  } else if (level < 0.3) {
443  level = 2;
444  } else {
445  level = 1;
446  }
447  // sigStrength depends on roid types as well as trueSec
448  if (sec == 1) { // hi sec
449  sig.sigStrength = 0.2 /level; // 1/5 base
450  //sig.sigStrength = 0.0125; // testing 1/80
451  type = MakeRandomInt(0,5);
452  } else if (sec == 2) { // lo sec
453  sig.sigStrength = 0.1 /level; // 1/10 base
454  type = MakeRandomInt(0,3);
455  } else if (sec == 4) { // mid sec
456  sig.sigStrength = 0.0667 /level; // 1/15 base
457  type = MakeRandomInt(0,2);
458  } else { // null sec
459  sig.sigStrength = 0.05 /level; // 1/20 base
460  type = MakeRandomInt(0,2);
461  }
462  } break;
463  case Magnetometric: { // 3
464  level = MakeRandomFloat();
465  if (sec == 3) { // nullsec
466  if (level < 0.1) { // 10% to be drone site
467  level = 3;
468  type = MakeRandomInt(1,7);
469  sig.sigStrength = 0.0125; // 1/80
470  } else if (level < 0.3) { // 20% to be relic site
471  level = 1;
472  type = MakeRandomInt(1,8);
473  sig.sigStrength = 0.025; // 1/40
474  } else { // else salvage site
475  level = 1;
476  type = MakeRandomInt(1,4);
477  sig.sigStrength = 0.05; // 1/20
478  }
479  } else { // hi, mid and lo sec
480  type = MakeRandomInt(1,8);
481  if (level < 0.3) { // 20% to be relic site
482  level = 1;
483  sig.sigStrength = 0.05; // 1/20
484  } else {
485  level = 2;
486  sig.sigStrength = 0.1; // 1/10
487  }
488  }
489  if (level == 3) {
490  faction = 6; // drone
491  } else if (faction == 6) {
492  // lvls 1&2 cannot be drone. set to region pirate
493  faction = GetFaction(sDataMgr.GetRegionRatFaction(m_system->GetRegionID()));
494  }
495  } break;
496  case Radar: { // 4
497  // type 1, level 1 are covert research (ghost sites)
498  // level 2 are digital sites and region-specific (only in nullsec)
499  // both are incomplete and will be harder than reg sites.
500  type = MakeRandomInt(1,8);
501  if (sec == 1) {
502  sig.sigStrength = 0.1; // 1/10
503  if (type == 1) { // Covert Research
504  level = 1;
505  sig.sigStrength = 0.05; // 1/20
506  }
507  } else if (sec == 2) {
508  sig.sigStrength = 0.05; // 1/20
509  if (type == 1) { // Covert Research
510  level = 1;
511  sig.sigStrength = 0.025; // 1/40
512  }
513  } else if (sec == 3) {
514  sig.sigStrength = 0.025; // 1/40
515  if (faction == 0) { // this should not hit
516  level = 2;
517  sig.sigStrength = 0.0222; // 1/45
518  } else if (type == 1) { // Covert Research
519  level = 1;
520  sig.sigStrength = 0.0167; // 1/60
521  }
522  }
523  } break;
524  case Ladar: { // 5
525  faction = 0;
526  type = MakeRandomInt(1,8);
527  if (sec == 1) {
528  sig.sigStrength = 0.1; // 1/10
529  } else if (sec == 2) {
530  sig.sigStrength = 0.05; // 1/20
531  } else if (sec == 3) {
532  sig.sigStrength = 0.025; // 1/40
533  }
534  } break;
535  case Anomaly: { // 7
536  type = MakeRandomInt(1,5);
537  // if anomaly is non-drone, set template variables for types.
538  // looking over this again (years later) it dont make much sense.
539  // will have to look deeper when i have time.
540  if (faction != 6) {
541  faction = 8;
542  if (sec == 1) {
543  if (type == 1) {
544  level = GetRandLevel();
545  }
546  } else if (sec == 2) {
547  if (type == 2) {
548  level = GetRandLevel();
549  } else if (type == 4) {
550  level = GetRandLevel();
551  }
552  } else if (sec == 3) {
553  if (type == 1) {
554  level = GetRandLevel();
555  } else if (type == 3) {
556  level = GetRandLevel();
557  }
558  }
559  }
560  } break;
561  // yes, these will 'fall thru' to 'Unrated' here. this is on purpose
562  case Escalation: // 9
563  case Rated: { // 10
564  //sig.dungeonType = 9;
565  };
566  case Mission: { // 1
567  // not sure how im gonna do this one yet...make it unrated for now
568  sig.dungeonType = 8;
569  };
570  case Unrated: { // 8
571  if (faction == 6) {
572  type = MakeRandomInt(1,3);
573  } else {
574  faction = 0;
575  type = MakeRandomInt(1,5);
576  }
577  } break;
578  case 0:
579  default: {
580  sig.dungeonType = 7;
581  MakeDungeon(sig);
582  } break;
583  }
584 
585  if (faction == 7) {
586  // faction is defined to be region sovereign holder.
587  // this hasnt been written yet, so default to region rats
588  faction = GetFaction(sDataMgr.GetRegionRatFaction(m_system->GetRegionID()));
589  }
590 
591  uint32 templateID = (sig.dungeonType * 10000) + (sec * 1000) + (type * 100) + (level * 10) + faction;
592 
593  _log(COSMIC_MGR__TRACE, "DungeonMgr::MakeDungeon() - Calling Create for type %s(%u) using templateID %u", \
594  sDunDataMgr.GetDungeonType(sig.dungeonType), sig.dungeonType, templateID);
595 
596  return Create(templateID, sig);
597 }
598 
600 {
601  switch (factionID) {
602  case factionAngel: return 2;
603  case factionSanshas: return 5;
604  case factionGuristas: return 4;
605  case factionSerpentis: return 1;
606  case factionBloodRaider: return 3;
607  case factionRogueDrones: return 6;
608  case 0: return 7;
609  // these are incomplete. set to default (region rat)
610  case factionAmarr:
611  case factionAmmatar:
612  case factionCaldari:
613  case factionGallente:
614  case factionMinmatar:
615  default:
616  return GetFaction(sDataMgr.GetRegionRatFaction(m_system->GetRegionID()));
617  }
618 }
619 
621 {
622  double level = MakeRandomFloat();
623  _log(COSMIC_MGR__TRACE, "DungeonMgr::GetRandLevel() - level = %.2f", level);
624 
625  if (level < 0.15) {
626  return 4;
627  } else if (level < 0.25) {
628  return 3;
629  } else if (level < 0.50) {
630  return 2;
631  } else {
632  return 1;
633  }
634 }
635 
636 /*
637 struct CosmicSignature {
638  std::string sigID; // this is unique xxx-nnn id displayed in scanner
639  std::string sigName;
640  uint32 ownerID;
641  uint32 systemID;
642  uint32 sigItemID; // itemID of this entry
643  uint8 dungeonType;
644  uint16 sigTypeID;
645  uint16 sigGroupID;
646  uint16 scanGroupID;
647  uint16 scanAttributeID;
648  GPoint position;
649 };
650 */
652 {
654  /* templateID format. ABCDE
655  * A = site - 1:mission, 2:grav, 3:mag, 4:radar, 5:ladar, 6:ded, 7:anomaly, 8:unrated, 9:escalation
656  * B = sec - mission: 1-9 (incomplete); others - sysSec: 1=hi, 2=lo, 3=null, 4=mid;
657  * C = type - grav: ore 0-5, ice 6-9; anomaly: 1-5; mission: 1-9; mag: *see below*; ded: 1-8; ladar/radar: 1-8
658  * D = level - mission: 1-9; grav: ore 1-3, ice 0; mag: *see below*; radar: 1-norm; 2-digital(nullsec); ladar: 1; anomaly: 1-5
659  * E = faction - 0=code defined, 1=Serpentis, 2=Angel, 3=Blood, 4=Guristas, 5=Sansha, 6=Drones, 7=region sov, 8=region rat, 9=other
660  *
661  * NOTE: mag sites have multiple types and levels based on other variables.
662  * levels are defined as relic(1), salvage(2), and drone(3), with salvage being dominant.
663  * for hisec and losec, types are 1-8 for relic and salvage. there are no drone mag sites here
664  * for nullsec, relic site types are 1-8, salvage site types are 1-4, and drone site types are 1-7
665  *
666  * NOTE: faction can only be 8 for grav and anomaly sites, unless drones (6). all others MUST use 1-6
667  */
668 
669  // templateID = (sig.dungeonType *10000) + (sec *1000) + (type *100) + (level *10) + factionID;
670  uint8 factionID = templateID % 10;
671  uint8 level = templateID / 10 % 10;
672  uint8 type = templateID / 100 % 10;
673  //uint8 sec = templateID / 1000 % 10;
674 
675  // create groupIDs for this dungeon, and add to vector
676  // NOTE: these are NOT invGroups here....
677  std::vector<uint16> groupVec;
678  groupVec.clear();
679  // all groups get the worthless mining types and misc deco items
680  groupVec.push_back(131); //misc roids
681  groupVec.push_back(132); //worthless mining types
682  groupVec.push_back(691); // misc
683  // add worthless shit to vector
684  AddDecoToVector(sig.dungeonType, templateID, groupVec);
685  // clear out vector before adding specific types
686  groupVec.clear();
687 
688  using namespace Dungeon::Type;
689  switch (sig.dungeonType) {
690  case Mission: { //1
691  } break;
692  case Gravimetric: { //2
693  groupVec.push_back(130); //named roids
694  groupVec.push_back(160); //asteroid colony items
695  groupVec.push_back(620); // Starbase
696  groupVec.push_back(630); // Habitation
697  } break;
698  case Magnetometric: { //3
699  groupVec.push_back(620); // Starbase
700  groupVec.push_back(630); // Habitation
701  groupVec.push_back(640); // Stationary
702  groupVec.push_back(650); // Indestructible
703  groupVec.push_back(660); // Forcefield
704  groupVec.push_back(670); // Shipyard
705  groupVec.push_back(680); // Construction
706  groupVec.push_back(690); // Storage
707  } break;
708  case Radar: { //4
709  groupVec.push_back(130); //named roids
710  groupVec.push_back(160); //asteroid colony items
711  groupVec.push_back(630); // Habitation
712  groupVec.push_back(640); // Stationary
713  } break;
714  case Ladar: { //5
715  groupVec.push_back(160); //asteroid colony items
716  groupVec.push_back(670); // Shipyard
717  groupVec.push_back(680); // Construction
718  groupVec.push_back(690); // Storage
719  } break;
720  case Anomaly: //7
721  case Rated: { //10
722  groupVec.push_back(430); //lco misc
723  groupVec.push_back(431); //lco Habitation
724  groupVec.push_back(432); //lco drug labs
725  groupVec.push_back(433); //lco Starbase
726  groupVec.push_back(630); // Habitation
727  groupVec.push_back(640); // Stationary
728  groupVec.push_back(650); // Indestructible
729  } break;
730  case Unrated: { //8
731  groupVec.push_back(430); //lco misc
732  groupVec.push_back(431); //lco Habitation
733  groupVec.push_back(432); //lco drug labs
734  groupVec.push_back(433); //lco Starbase
735  } break;
736  case Escalation: { //9
737  groupVec.push_back(640); // Stationary
738  groupVec.push_back(650); // Indestructible
739  } break;
740  }
741  // add misc shit to vector
742  AddDecoToVector(sig.dungeonType, templateID, groupVec);
743  // clear out vector before adding specific faction types
744  groupVec.clear();
745  switch (sig.dungeonType) {
746  case Anomaly: //7
747  case Unrated: //8
748  case Escalation: //9
749  case Rated: { //10
750  switch (factionID) {
751  case 1: { //Serpentis
752  groupVec.push_back(401); //faction lco
753  groupVec.push_back(601); //faction base
754  } break;
755  case 2: { //Angel
756  groupVec.push_back(402); //faction lco
757  groupVec.push_back(602); //faction base
758  } break;
759  case 3: { //Blood
760  groupVec.push_back(403); //faction lco
761  groupVec.push_back(603); //faction base
762  } break;
763  case 4: { //Guristas
764  groupVec.push_back(404); //faction lco
765  groupVec.push_back(604); //faction base
766  } break;
767  case 5: { //Sansha
768  groupVec.push_back(405); //faction lco
769  groupVec.push_back(605); //faction base
770  } break;
771  case 6: { //Drones
772  groupVec.push_back(406); //faction lco
773  groupVec.push_back(606); //faction base
774  } break;
775  // make error for default or 0 here?
776  }
777  }
778  }
779  AddDecoToVector(sig.dungeonType, templateID, groupVec);
780 }
781 
782 void DungeonMgr::AddDecoToVector(uint8 dunType, uint32 templateID, std::vector<uint16>& groupVec)
783 {
784  // templateID = (sig.dungeonType *10000) + (sec *1000) + (type *100) + (level *10) + factionID;
785  uint8 factionID = templateID % 10;
786  uint8 level = templateID / 10 % 10;
787  uint8 type = templateID / 100 % 10;
788  uint8 sec = templateID / 1000 % 10;
789 
790  int8 step = 0;
791  uint16 count = 0, radius = 0, pos = 10000 * level;
792  double theta = 0;
793 
794  // level is 0 to 9, system multiplier is 0.1 to 2.0 (x10 is 1-20)
795  level *= (m_system->GetSecValue() *10); // config variable here?
796  // set origLevel 0 to 18, rounding up
797  uint8 origLevel = ceil(level /10);
798  if (origLevel < 1)
799  origLevel = 1;
800  for (auto cur : groupVec) {
801  level = origLevel;
802  count = sDunDataMgr.groups.count(cur);
803  if (count < 1)
804  continue;
805 
806  _log(COSMIC_MGR__DEBUG, "DungeonMgr::AddDecoToVector() - %s(%u): faction %u, group %u, type %u, level %u, count %u, baseLvl %u",\
807  sDunDataMgr.GetDungeonType(dunType), dunType, factionID, \
808  cur, type, level, count, origLevel);
809 
810  auto groupRange = sDunDataMgr.groups.equal_range(cur);
811  auto it = groupRange.first;
812  double degreeSeparation = (250/level);
813  // make 1-20 random items in the anomaly based on system trusec
814  for (uint8 i=0; i < level; ++i) {
816  step = MakeRandomInt(1,count);
817  std::advance(it,step); // this is some fancy shit here
818  grp.typeID = it->second.typeID;
819  grp.typeName = it->second.typeName;
820  grp.typeGrpID = it->second.typeGrpID;
821  grp.typeCatID = it->second.typeCatID;
822  // site size and item radius determine position
823  radius = it->second.radius;
824  //if (sig.dungeonType == Gravimetric) {
825  theta = EvE::Trig::Deg2Rad(degreeSeparation * i);
826  //theta = MakeRandomFloat(0, EvE::Trig::Pi);
827  grp.x = (radius + pos * std::cos(theta)) * (IsEven(MakeRandomInt(0,10)) ? -1 : 1);
828  grp.z = (radius + pos * std::sin(theta)) * -1;
829  /*
830  grp.y = MakeRandomFloat(-radius, radius);
831  } else if (IsEven(MakeRandomInt(0,10))) {
832  grp.x = (pos + it->second.x + (radius*2)) * (IsEven(MakeRandomInt(0,10)) ? -1 : 1);
833  grp.z = pos + it->second.z + radius;
834  } else {
835  grp.x = (pos + it->second.x + radius) * -1;
836  grp.z = (pos + it->second.z + (radius*2)) * -1;
837  } */
838  grp.y = it->second.y + MakeRandomInt(-5000, radius * 2);
839  m_anomalyItems.push_back(grp);
840  it = groupRange.first;
841  }
842  }
843 }
844 
845 
846 /* groupID format
847  ABB - item def groups
848  A = group type - 1:deco, 2:system effect beacon, 3:mining, 4:lco, 5:ships, 6:base, 7:station gun, 8:station wrecks, 9:misc
849  B = 1:space objects, 2:effect beacons, 3:roid types, 4:ice types, 5:, 6:asteroid colony, 7:, 8:, 9:misc
850  B = ship/gun faction: 1:Amarr, 2:Caldari, 3:Gallente, 4:Minmatar, 5:Sentinel, 6:Guardian
851  B = faction: 00:none, 01:Serpentis, 02:Angel, 03:Blood, 04:Guristas, 05:Sansha, 06:Drones, 07:Amarr, 08:Caldari, 09:Gallente,
852  10:Minmatar, 11:Sleeper, 12:Talocan, 13:Ammatar
853 
854 1xx deco items
855 110 wormholes
856 13x mining types
857 130 named roids
858 131 misc roids
859 132 worthless mining types
860 140 infested items
861 160 Asteroid Colony
862 191 Monument
863 
864 2xx effect beacons **incomplete
865 211 Electronic
866 212 omni
867 22x Incursion
868 23x Black Hole
869 24x Magnetar
870 25x Pulsar
871 26x Red Giant
872 27x Wolf Rayet
873 28x Cataclysmic Variable
874 
875 3xx mining objects
876 30x ore
877 34x ice
878 36x clouds
879 
880 4xx lco
881 401 Serpentis
882 402 Angel
883 403 Blood
884 404 Guristas
885 405 Sansha
886 406 drone
887 407 Amarr
888 408 Caldari
889 409 Gallente
890 410 Minmatar
891 42x lco ships
892 43x lco structures
893 430 lco misc
894 431 lco Habitation
895 432 lco drug labs
896 433 lco Starbase
897 
898 5xx ships
899 51x Amarr
900 52x Caldari
901 53x Gallente
902 54x Minmatar
903 
904 6xx base
905 601 Serpentis
906 602 Angel
907 603 Blood
908 604 Guristas
909 605 Sansha
910 606 drone
911 607 Amarr
912 608 Caldari
913 609 Gallente
914 610 Minmatar
915 611 Sleeper
916 612 Talocan
917 613 Ammatar
918 
919 620 Starbase
920 630 Habitation
921 640 Stationary
922 650 Indestructible
923 660 Forcefield
924 670 Shipyard
925 680 Construction
926 690 Storage
927 691 misc
928 
929 7xx station guns **incomplete
930 
931 8xx station and structure ruins **incomplete
932 80x Sansha
933 81x Amarr
934 82x Caldari
935 83x Gallente
936 84x Minmatar
937 85x misc ruined parts
938 86x misc debris
939 
940 9xx misc **incomplete
941 91x comets
942 92x clouds
943 93x environment
944 96x event lco/lcs
945 */
946 
947  /*
948  In player-owned sovereign nullsec, using Ore Prospecting Arrays,
949  (23510,'Small Asteroid Cluster',0,2,0,1,0,0,0),
950  (23520,'Moderate Asteroid Cluster',0,2,0,15,0,0,0),
951  (23530,'Large Asteroid Cluster',0,2,0,29,0,0,0),
952  (23540,' Enormous Asteroid Cluster ',0,2,0,29,0,0,0),
953  (23550,'Colossal Asteroid Cluster',0,2,0,29,0,0,0),
954  */
bool Init(AnomalyMgr *anomMgr, SpawnMgr *spawnMgr)
Definition: DungeonMgr.cpp:182
#define sConfig
A macro for easier access to the singleton.
unsigned __int8 uint8
Definition: eve-compat.h:46
void AddEntity(SystemEntity *pSE, bool addSignal=true)
const char * GetText(uint32 index) const
Definition: dbcore.h:104
itemID[count] Create count or of the specified() x() y(z)-Jump to the specified position in space.Stopped." ) COMMAND( translocate
static InventoryItemRef SpawnItem(uint32 itemID, const ItemData &data)
#define _log(type, fmt,...)
Definition: logsys.h:124
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
bool MakeDungeon(CosmicSignature &sig)
Definition: DungeonMgr.cpp:417
static void GetDunRoomData(DBQueryResult &res)
Definition: ManagerDB.cpp:621
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
void Process()
Definition: DungeonMgr.cpp:228
void GetDungeons(std::vector< Dungeon::ActiveData > &dunList)
Definition: DungeonMgr.cpp:127
double MakeRandomFloat(double low, double high)
Generates random real from interval [low; high].
Definition: misc.cpp:114
DunEntryDef entrys
Definition: DungeonMgr.h:67
bool Create(CosmicSignature &sig, std::unordered_multimap< float, uint16 > &roidTypes)
Definition: BeltMgr.cpp:244
const float GetSystemSecurityRating()
Definition: SystemManager.h:86
uint32 GetID() const
Definition: SystemManager.h:80
bool Create(uint32 templateID, CosmicSignature &sig)
Definition: DungeonMgr.cpp:257
static void GetDunGroupData(DBQueryResult &res)
Definition: ManagerDB.cpp:610
std::string sigName
GaFloat x
Definition: GaTypes.h:207
#define DUNGEON_ID
Definition: EVE_Defines.h:187
signed __int8 int8
Definition: eve-compat.h:45
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
Definition: SafeMem.h:83
DunTemplateDef templates
Definition: DungeonMgr.h:63
std::map< uint32, std::vector< uint32 > > m_dungeonList
Definition: DungeonMgr.h:128
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
SystemManager * m_system
Definition: DungeonMgr.h:117
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
Definition: gpoint.h:33
bool IsEven(int64 number)
Definition: misc.h:88
double GetTimeMSeconds()
Definition: utils_time.cpp:104
static void GetDunTemplates(DBQueryResult &res)
Definition: ManagerDB.cpp:639
std::vector< Dungeon::GroupData > m_anomalyItems
Definition: DungeonMgr.h:126
DunRoomsDef rooms
Definition: DungeonMgr.h:68
double Deg2Rad(double deg)
Definition: Trig.h:25
uint16 GetID()
Definition: SystemBubble.h:91
static const GPoint NULL_ORIGIN(0, 0, 0)
void AddDecoToVector(uint8 dunType, uint32 templateID, std::vector< uint16 > &groupVec)
Definition: DungeonMgr.cpp:782
BeltMgr * GetBeltMgr()
float GetSecValue()
void SetDungMgr(DungeonMgr *pDmgr)
Definition: SpawnMgr.h:34
void Load()
Definition: DungeonMgr.cpp:235
void CreateDeco(uint32 templateID, CosmicSignature &sig)
Definition: DungeonMgr.cpp:651
bool m_initalized
Definition: DungeonMgr.h:113
bool GetTemplate(uint32 templateID, Dungeon::Template &dTemplate)
Definition: DungeonMgr.cpp:133
unsigned __int32 uint32
Definition: eve-compat.h:50
PyServiceMgr * GetServiceMgr()
Definition: SystemManager.h:88
void DoSpawnForAnomaly(SystemBubble *pBubble, uint8 spawnClass)
Definition: SpawnMgr.cpp:309
GaFloat y
Definition: GaTypes.h:207
static void ClearDungeons()
Definition: ManagerDB.cpp:690
#define sDunDataMgr
Definition: DungeonMgr.h:78
AnomalyMgr * m_anomMgr
Definition: DungeonMgr.h:115
ActiveDungeonDef activeDungeons
Definition: DungeonMgr.h:66
const char * GetName() const
Definition: SystemManager.h:84
uint32 m_dungeonID
Definition: DungeonMgr.h:74
int64 MakeRandomInt(int64 low, int64 high)
Generates random integer from interval [low; high].
Definition: misc.cpp:109
void AddDungeon(Dungeon::ActiveData &dungeon)
Definition: DungeonMgr.cpp:120
static void GetDunEntryData(DBQueryResult &res)
Definition: ManagerDB.cpp:604
DungeonMgr(SystemManager *system, PyServiceMgr &svc)
Definition: DungeonMgr.cpp:161
const char * GetDungeonType(int8 typeID)
Definition: DungeonMgr.cpp:143
std::string dunName
Definition: EVE_Dungeon.h:167
signed __int16 int16
Definition: eve-compat.h:47
std::string typeName
Definition: EVE_Dungeon.h:193
uint32 GetRegionID()
Definition: SystemManager.h:81
int8 GetRandLevel()
Definition: DungeonMgr.cpp:620
static bool GetSavedDungeons(uint32 systemID, std::vector< Dungeon::ActiveData > &into)
Definition: ManagerDB.cpp:645
#define sItemFactory
Definition: ItemFactory.h:165
int8 GetFaction(uint32 factionID)
Definition: DungeonMgr.cpp:599
#define sBubbleMgr
unsigned __int16 uint16
Definition: eve-compat.h:48
entityID heal the character with the entityID note giving you detailed ship status information gives a list of all dynamic entities and players and their destinyState in this bubble shows some current destiny variables save all items
SpawnMgr * m_spawnMgr
Definition: DungeonMgr.h:116
GaFloat z
Definition: GaTypes.h:207
DunGroupsDef groups
Definition: DungeonMgr.h:69
#define sDataMgr