EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SystemEntity.cpp
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  Rewrite: Allan
25 */
26 
27 #include "eve-server.h"
28 
29 #include "ConsoleCommands.h"
30 #include "Client.h"
31 #include "Container.h"
32 #include "EVEServerConfig.h"
33 #include "PyServiceMgr.h"
34 #include "StatisticMgr.h"
35 #include "account/AccountService.h"
36 #include "character/Character.h"
37 #include "fleet/FleetService.h"
39 #include "planet/CustomsOffice.h"
40 #include "planet/Planet.h"
41 #include "pos/Structure.h"
42 #include "standing/StandingMgr.h"
43 #include "system/DestinyManager.h"
44 #include "station/Station.h"
45 #include "system/SystemBubble.h"
46 #include "system/SystemEntity.h"
47 #include "system/SystemManager.h"
48 
49 
50 
52 :m_self(self),
53 m_services(services),
54 m_system(system),
55 m_bubble(nullptr),
56 m_destiny(nullptr),
57 m_targMgr(nullptr),
58 m_killed(false)
59 {
60  assert(m_system != nullptr);
61  assert(m_self.get() != nullptr);
62 
63  m_warID = 0;
64  m_allyID = 0;
65  m_corpID = 0;
66  m_fleetID = 0;
67  m_ownerID = 1;
68 
70 
72 
73  _log(SE__DEBUG, "Created SE for item %s (%u) with radius of %.1f.", self->name(), self->itemID(), m_radius);
74 }
75 
77  if (m_killed) {
78  _log(SE__DEBUG, "SE::Process() - %s(%u) is dead but still in system.", m_self->name(), m_self->itemID());
79  return;
80  }
81 
82  if (m_destiny != nullptr)
83  m_destiny->Process();
84 }
85 
87  if (IsWreckSE()) {
88  DoDestinyDamageState3 ddds;
89  ddds.shield = 0;
90  ddds.armor = 0;
91  ddds.structure = 1.0;
92  return ddds.Encode();
93  }
94  DoDestinyDamageState ddds;
95  MakeDamageState(ddds);
96  return ddds.Encode();
97 }
98 
99 void SystemEntity::MakeDamageState(DoDestinyDamageState &into) {
100  into.shield = 1;
101  into.recharge = 110000;
102  into.armor = 1;
103  into.structure = 1;
104  into.timestamp = GetFileTimeNow();
105 }
106 
108  _log(SE__SLIMITEM, "MakeSlimItem for SE %s(%u)", GetName(), m_self->itemID());
109  PyDict *slim = new PyDict();
110  slim->SetItemString("typeID", new PyInt(m_self->typeID()));
111  slim->SetItemString("ownerID", new PyInt(m_ownerID));
112  slim->SetItemString("itemID", new PyLong(m_self->itemID()));
113  return slim;
114 }
115 
117 {
118  using namespace Destiny;
119 
120  BallHeader head = BallHeader();
121  head.entityID = m_self->itemID();
122  head.mode = Ball::Mode::RIGID;
123  head.radius = m_radius;
124  head.posX = x();
125  head.posY = y();
126  head.posZ = z();
128  into.Append( head );
130  main.formationID = 0xFF;
131  into.Append( main );
132  _log(SE__DESTINY, "SE::EncodeDestiny(): %s - id:%li, mode:%u, flags:0x%X", GetName(), head.entityID, head.mode, head.flags);
133 }
134 
135 void SystemEntity::Killed(Damage& fatal_blow)
136 {
137  if (m_targMgr != nullptr) {
138  // loop thru list of all modules targeting this entity and let them know it has been killed.
139  m_targMgr->Destroyed();
140  // remove TargMgr here to avoid redundant calls upon object deletion
142  }
143  Delete();
144 }
145 
147 {
148  if (m_targMgr != nullptr)
149  m_targMgr->ClearFromTargets(); //OnTarget(nullptr, TargMgr::Mode::Clear, TargMgr::Msg::Deleted);
150  if (m_system != nullptr)
151  m_system->RemoveEntity(this);
152  if (!IsContainerSE())
153  m_self->Delete();
154 }
155 
157  if (other->m_bubble == nullptr)
158  return 1000000.0;
159  return GetPosition().distance(other->GetPosition());
160 }
161 
162 void SystemEntity::SendDamageStateChanged() { //working 24Apr15
163  DamageDetails dmgState;
165  dmgState.recharge = m_self->GetAttribute(AttrShieldRechargeRate).get_double();
166  dmgState.timestamp = GetFileTimeNow();
168  dmgState.structure = (1.0 - (m_self->GetAttribute(AttrDamage).get_double() / m_self->GetAttribute(AttrHP).get_double()));
169  OnDamageStateChange dmgChange;
170  dmgChange.entityID = m_self->itemID();
171  dmgChange.state = dmgState.Encode();
172  PyTuple *up = dmgChange.Encode();
173  if (m_targMgr != nullptr)
174  m_targMgr->QueueUpdate(&up);
175  PySafeDecRef(up);
176  _log(DAMAGE__MESSAGE, "%s(%u): DamageUpdate - S:%f A:%f H:%f.", \
177  GetName(), m_self->itemID(), dmgState.shield, dmgState.armor, dmgState.structure);
178 }
179 
180 void SystemEntity::DropLoot(WreckContainerRef wreckRef, uint32 groupID, uint32 owner) {
181  /* allan 27Nov14 */
182  std::vector<LootList> lootList;
183  sDataMgr.GetLoot(groupID, lootList);
184  if (lootList.empty())
185  return;
186 
187  uint32 quantity(0);
188  std::vector<LootList>::iterator cur = lootList.begin();
189  while (cur != lootList.end()) {
190  if (cur->minDrop == cur->maxDrop) {
191  quantity = cur->minDrop;
192  } else {
193  quantity = (uint32)(MakeRandomInt(cur->minDrop, cur->maxDrop));
194  }
195  if (quantity < 1)
196  quantity = 1;
197 
198  ItemData iLoot(cur->itemID, owner, wreckRef->itemID(), flagNone, quantity);
199  wreckRef->AddItem(sItemFactory.SpawnItem(iLoot));
200  ++cur;
201  }
202 }
203 
206 
207  //New Status = ((10 - Old Status) * Sec Incr) + Old Status
208  double oldSec = pChar->GetSecurityRating();
209  EvilNumber maxGain = 0;
210  if (iRef->HasAttribute(AttrEntitySecurityMaxGain, maxGain))
211  if (oldSec > maxGain.get_double())
212  return;
213  float killBonus = iRef->GetAttribute(AttrEntitySecurityStatusKillBonus).get_float();
214  double secAward = (((10 - oldSec) * killBonus) + oldSec) / 100;
215  secAward *= (1 + (0.05f * (pChar->GetSkillLevel(EvESkill::FastTalk, true)))); // 5% increase
216  if (killBonus and secAward) {
217  secAward *= sConfig.rates.secRate;
218  sLog.Magenta("SE::AwardSecurityStatus()"," %s(%u): killBonus: %f. oldSec: %f. secAward: %f.",
219  GetName(), iRef->itemID(), killBonus, oldSec, secAward);
220  pChar->secStatusChange( secAward );
221  std::string msg = "Status Change for killing";
222  if (iRef->HasPilot()) {
223  msg += iRef->GetPilot()->GetName();
224  msg += " in ";
225  msg += m_system->GetNameStr();
226  sStandingMgr.UpdateStandings(iRef->itemID(), pChar->itemID(), Standings::CombatShipKill, secAward, msg);
227  } else {
228  msg += " pirates in ";
229  msg += m_system->GetNameStr();
230  sStandingMgr.UpdateStandings(corpCONCORD, pChar->itemID(), Standings::LawEnforcement, secAward, msg);
231  // decrease standings with faction of this npc kill
232  sStandingMgr.UpdateStandings(iRef->ownerID(), pChar->itemID(), Standings::CombatShipKill, -secAward, msg);
233  }
234  }
235 
244 }
245 
247 {
248  m_warID = 0;
249  m_allyID = 0;
250  m_corpID = 0;
251  m_fleetID = 0;
252  m_ownerID = 1;
253  m_self->ChangeOwner(1); // update this to use system owner? not sure. logs show this as "1" for all non-player items
255 }
256 
257 
258 /* Static / Non-Mobile / Non-Destructable / Celestial Objects - Suns, Planets, Moons, Belts, Gates, Stations */
260 : SystemEntity(self, services, system)
261 {
262 }
263 
265  return true;
266 }
267 
269  _log(SE__SLIMITEM, "MakeSlimItem for SSE %s(%u)", GetName(), m_self->itemID());
270  PyDict *slim = new PyDict();
271  slim->SetItemString("itemID", new PyLong(m_self->itemID()));
272  slim->SetItemString("typeID", new PyInt(m_self->typeID()));
273  slim->SetItemString("name", new PyString(m_self->itemName()));
274  slim->SetItemString("nameID", PyStatic.NewNone());
275  slim->SetItemString("ownerID", PyStatic.NewOne());
276  return slim;
277 }
278 
280  using namespace Destiny;
281  BallHeader head = BallHeader();
282  head.entityID = m_self->itemID();
283  head.mode = Ball::Mode::RIGID;
284  head.posX = x();
285  head.posY = y();
286  head.posZ = z();
287  head.radius = m_radius;
289  into.Append( head );
291  main.formationID = 0xFF;
292  into.Append( main );
293  _log(SE__DESTINY, "SSE::EncodeDestiny(): %s - id:%li, mode:%u, flags:0x%X, radius:%.1f", GetName(), head.entityID, head.mode, head.flags, head.radius);
294 }
295 
297 : StaticSystemEntity(self, services, system)
298 {
299 }
300 
303  return false;
304 
305  if (m_bubble == nullptr)
306  sBubbleMgr.Add(this);
307 
309  _log(DESTINY__BUBBLE_DEBUG, "BeltSE::LoadExtras() - IsBelt set to true for bubble %u.", m_bubble->GetID() );
310  return true;
311 }
312 
314 : StaticSystemEntity(self, services, system),
315 m_sbuSE(nullptr)
316 {
317 }
318 
321  return false;
322 
323  if (m_bubble == nullptr)
324  sBubbleMgr.Add(this);
325 
326  m_bubble->SetGate(true);
327  _log(DESTINY__BUBBLE_DEBUG, "StargateSE::LoadExtras() - IsGate set to true for bubble %u.", m_bubble->GetID() );
329  if (m_jumps != nullptr)
330  return true;
331 
332  return false;
333 }
334 
336  _log(SE__SLIMITEM, "MakeSlimItem for StargateSE %s(%u)", GetName(), m_self->itemID());
342  PyDict *slim = new PyDict();
343  //slim->SetItemString("dunRotation", rotation);
344  slim->SetItemString("typeID", new PyInt(m_self->typeID()));
346  // NOTE: maybe not...logs show this is "1" for all items.
347  slim->SetItemString("ownerID", PyStatic.NewOne());
348  slim->SetItemString("itemID", new PyLong(m_self->itemID()));
349  slim->SetItemString("name", new PyString(m_self->itemName()));
350  slim->SetItemString("nameID", PyStatic.NewNone());
351  if (m_jumps != nullptr)
352  slim->SetItemString("jumps", m_jumps->Clone());
353  return slim;
354 }
355 
356 
357 /* Non-Static / Non-Mobile / Non-Destructable / Celestial Objects - Containers, DeadSpace, ForceFields, ScanProbes */
359 : SystemEntity(self, services, system)
360 {
361  m_keyType = 0;
362 }
363 
365  _log(SE__SLIMITEM, "MakeSlimItem for ISE %s(%u)", GetName(), m_self->itemID());
366  PyDict *slim = new PyDict();
367  slim->SetItemString("itemID", new PyLong(m_self->itemID()));
368  slim->SetItemString("typeID", new PyInt(m_self->typeID()));
369  slim->SetItemString("ownerID", new PyInt(m_ownerID));
371  // this is incomplete........
372  slim->SetItemString("dunSkillLevel", PyStatic.NewNone()); //?
373  slim->SetItemString("dunSkillTypeID", PyStatic.NewNone()); //?
374  slim->SetItemString("dunObjectID", new PyInt(160449)); //? 902139
375  slim->SetItemString("dunToGateID", new PyInt(160484)); //? 902140
376  slim->SetItemString("dunCloaked", new PyBool(0)); //?
377  slim->SetItemString("dunScenarioID", new PyInt(23)); //? 3347
378  slim->SetItemString("dunSpawnID", new PyInt(1572)); //?
379  slim->SetItemString("dunAmount", new PyFloat(0.0)); //?
380  PyList* classList = new PyList();
381  classList->AddItem( new PyInt(324));
382  classList->AddItem( new PyInt(420));
383  classList->AddItem( new PyInt(541));
384  classList->AddItem( new PyInt(834));
385  classList->AddItem( new PyInt(25));
386  classList->AddItem( new PyInt(830));
387  slim->SetItemString("dunShipClasses", classList); //?
388  PyList* dirList = new PyList();
389  dirList->AddItem(new PyInt(5)); //234
390  dirList->AddItem(new PyInt(-1));
391  dirList->AddItem(PyStatic.NewZero());
392  slim->SetItemString("dunDirection", dirList);
393  slim->SetItemString("dunKeyLock", PyStatic.NewNone()); //?
394  slim->SetItemString("dunWipeNPC", new PyBool(0)); //?
395  slim->SetItemString("dunKeyQuantity", PyStatic.NewOne()); //?
396  slim->SetItemString("dunKeyTypeID", new PyInt(m_keyType)); //Training Complex Passkey group Acceleration_Gate_Keys
397  slim->SetItemString("dunOpenUntil", new PyInt(Win32TimeNow()+EvE::Time::Hour)); //?
398  slim->SetItemString("dunRoomName", new PyString("Lobby")); //?
399  slim->SetItemString("dunMusicUrl", new PyString("res:/Sound/Music/Ambient031combat.ogg"));
400  }
411  return slim;
412 }
413 
415 {
416  using namespace Destiny;
417  BallHeader head = BallHeader();
418  head.entityID = m_self->itemID();
419  head.mode = Ball::Mode::RIGID;
420  head.radius = m_radius;
421  head.posX = x();
422  head.posY = y();
423  head.posZ = z();
424  head.flags = 0;
425  into.Append( head );
427  main.formationID = 0xFF;
428  into.Append( main );
429 
430  _log(SE__DESTINY, "ISE::EncodeDestiny(): %s - id:%li, mode:%u, flags:0x%X", GetName(), head.entityID, head.mode, head.flags);
431 }
432 
433 void ItemSystemEntity::MakeDamageState(DoDestinyDamageState &into) {
436  } else {
439  into.timestamp = GetFileTimeNow();
441  into.structure = 1.0 - (m_self->GetAttribute(AttrDamage).get_double() / m_self->GetAttribute(AttrHP).get_double());
442  }
443 }
444 
446 : ItemSystemEntity(self, services, system)
447 {
448  m_warID = data.factionID;
449  m_allyID = data.allianceID;
450  m_corpID = data.corporationID;
451  m_ownerID = data.ownerID;
452 }
453 
455 {
456  using namespace Destiny;
457  BallHeader head = BallHeader();
458  head.entityID = m_self->itemID();
460  head.radius = m_radius;
461  head.posX = x();
462  head.posY = y();
463  head.posZ = z();
464  head.flags = 0 /*(m_harmonic > EVEPOS::Harmonic::Offline ? Ball::Flag::IsMassive : 0)*/; // leave this as 0 to disable client-side bump checks for now
465  into.Append( head );
466  MassSector mass = MassSector();
467  mass.mass = 10000000000; // as seen in packets
468  mass.cloak = 0;
469  mass.harmonic = m_harmonic;
470  mass.corporationID = m_corpID;
471  mass.allianceID = (IsAlliance(m_allyID) ? m_allyID : -1);
472  into.Append( mass );
473  if (head.mode == Ball::Mode::FIELD) {
475  main.formationID = 0xFF;
476  into.Append( main );
477  } else if (head.mode == Ball::Mode::STOP) {
479  main.formationID = 0xFF;
480  into.Append( main );
481  }
482 
483  _log(SE__DESTINY, "FSE::EncodeDestiny(): %s - id:%li, mode:%u, flags:0x%X", GetName(), head.entityID, head.mode, head.flags);
484 }
485 
487 {
489 }
490 
491 
492 /* Non-Static / Non-Mobile / Destructible / Celestial Objects - POS Structures, Outposts, Deployables, empty Ships, Asteroids */
494 : SystemEntity(self, services, system),
495 m_invul(false)
496 {
497  m_targMgr = new TargetManager(this);
498  m_destiny = new DestinyManager(this);
499 
500  assert(m_targMgr != nullptr);
501  assert(m_destiny != nullptr);
502 }
503 
505 {
506  if (m_targMgr != nullptr)
507  if (!sConsole.IsShutdown()) {
509  m_targMgr->ClearAllTargets(false);
510  //m_targMgr->OnTarget(nullptr, TargMgr::Mode::Clear, TargMgr::Msg::Destroyed);
511  }
512 
515 }
516 
518 {
519  using namespace Destiny;
520  BallHeader head = BallHeader();
521  head.entityID = m_self->itemID();
522  head.mode = Ball::Mode::RIGID;
523  head.radius = m_radius;
524  head.posX = x();
525  head.posY = y();
526  head.posZ = z();
528  into.Append( head );
530  main.formationID = 0xFF;
531  into.Append( main );
532 
533  _log(SE__DESTINY, "OSE::EncodeDestiny(): %s - id:%li, mode:%u, flags:0x%X", GetName(), head.entityID, head.mode, head.flags);
534 }
535 
537  _log(SE__SLIMITEM, "MakeSlimItem for OSE %s(%u)", GetName(), m_self->itemID());
538  PyDict *slim = new PyDict();
539  slim->SetItemString("itemID", new PyLong(m_self->itemID()));
540  slim->SetItemString("typeID", new PyInt(GetTypeID()));
541  slim->SetItemString("ownerID", new PyInt(m_ownerID));
542  slim->SetItemString("categoryID", new PyInt(m_self->categoryID()));
543  slim->SetItemString("groupID", new PyInt(m_self->groupID()));
544  slim->SetItemString("name", new PyString(m_self->itemName()));
545  slim->SetItemString("corpID", IsCorp(m_corpID) ? new PyInt(m_corpID) : PyStatic.NewNone());
546  slim->SetItemString("allianceID", IsAlliance(m_allyID) ? new PyInt(m_allyID) : PyStatic.NewNone());
547  slim->SetItemString("warFactionID", IsFaction(m_warID) ? new PyInt(m_warID) : PyStatic.NewNone());
548  return slim;
549 }
550 
551 void ObjectSystemEntity::MakeDamageState(DoDestinyDamageState &into) {
554  into.timestamp = GetFileTimeNow();
556  into.structure = 1.0 - (m_self->GetAttribute(AttrDamage).get_double() / m_self->GetAttribute(AttrHP).get_double());
557 }
558 
560 {
562  DamageDetails dmgState;
564  dmgState.recharge = m_self->GetAttribute(AttrShieldRechargeRate).get_double();
565  dmgState.timestamp = GetFileTimeNow();
567  dmgState.structure = 1.0 - m_self->GetAttribute(AttrDamage).get_double() / m_self->GetAttribute(AttrHP).get_double();
568  OnDamageStateChange dmgChange;
569  dmgChange.entityID = m_self->itemID();
570  dmgChange.state = dmgState.Encode();
571  PyTuple *up = dmgChange.Encode();
572  //source->QueueDestinyUpdate(&up);
573 }
574 
576 {
577  // do we need to make wreck items here?
578  // do these structures have loot? probably so eventually
579 
581  if (IsCOSE()) {
582  if (GetCOSE()->GetPlanetID() > 0) {
583  SystemEntity* pSE = m_system->GetSE(GetCOSE()->GetPlanetID());
584  pSE->GetPlanetSE()->SetCustomsOffice(nullptr);
585  }
586  }
587 }
588 
590 : ObjectSystemEntity(self, services, system)
591 {
592  m_warID = data.factionID;
593  m_allyID = data.allianceID;
594  m_corpID = data.corporationID;
595  m_ownerID = data.ownerID;
596 }
597 
598 
599 /* Non-Static / Mobile / Destructible / Celestial Objects - PC's, NPC's, Drones, Ships, Missiles, Wrecks */
601 : SystemEntity(self, services, system),
602 m_invul(false),
603 m_frozen(false)
604 {
605  m_targMgr = new TargetManager(this);
606  m_destiny = new DestinyManager(this);
607 
608  assert(m_targMgr != nullptr);
609  assert(m_destiny != nullptr);
610 }
611 
613 {
614  if (m_targMgr != nullptr)
615  if (!sConsole.IsShutdown()) {
617  m_targMgr->ClearAllTargets(false);
618  //m_targMgr->OnTarget(nullptr, TargMgr::Mode::Clear, TargMgr::Msg::Destroyed);
619  }
620 
623 }
624 
626  if (IsNPCSE())
628 
629  _log(SE__SLIMITEM, "MakeSlimItem for DSE %s(%u)", GetName(), m_self->itemID());
630  PyDict *slim = new PyDict();
631  slim->SetItemString("itemID", new PyLong(m_self->itemID()));
632  slim->SetItemString("typeID", new PyInt(m_self->typeID()));
633  slim->SetItemString("ownerID", new PyInt(m_ownerID));
634  //slim->SetItemString("categoryID", new PyInt(m_self->categoryID()));
635  //slim->SetItemString("groupID", new PyInt(m_self->groupID()));
636  slim->SetItemString("name", new PyString(m_self->itemName()));
637  slim->SetItemString("corpID", IsCorp(m_corpID) ? new PyInt(m_corpID) : PyStatic.NewNone());
638  slim->SetItemString("allianceID", IsAlliance(m_allyID) ? new PyInt(m_allyID) : PyStatic.NewNone());
639  slim->SetItemString("warFactionID", IsFaction(m_warID) ? new PyInt(m_warID) : PyStatic.NewNone());
640  return (slim);
641 }
642 
644 {
645  using namespace Destiny;
646  BallHeader head = BallHeader();
647  head.entityID = m_self->itemID();
648  head.mode = Ball::Mode::STOP;
649  head.radius = m_radius;
650  head.posX = x();
651  head.posY = y();
652  head.posZ = z();
653  head.flags = Ball::Flag::IsFree;
654  into.Append( head );
655  MassSector mass = MassSector();
656  mass.mass = m_destiny->GetMass();
657  mass.cloak = (m_destiny->IsCloaked() ? 1 : 0);
658  mass.harmonic = m_harmonic;
659  mass.corporationID = m_corpID;
660  mass.allianceID = (IsAlliance(m_allyID) ? m_allyID : -1);
661  into.Append( mass );
662  DataSector data = DataSector();
663  data.inertia = m_destiny->GetInertia();
665  data.velX = m_destiny->GetVelocity().x;
666  data.velY = m_destiny->GetVelocity().y;
667  data.velZ = m_destiny->GetVelocity().z;
669  into.Append( data );
671  main.formationID = 0xFF;
672  into.Append( main );
673 
674  _log(SE__DESTINY, "DSE::EncodeDestiny(): %s - id:%li, mode:%u, flags:0x%X", GetName(), head.entityID, head.mode, head.flags);
675 }
676 
677 void DynamicSystemEntity::MakeDamageState(DoDestinyDamageState &into) {
680  into.timestamp = GetFileTimeNow();
682  into.structure = 1.0 - (m_self->GetAttribute(AttrDamage).get_double() / m_self->GetAttribute(AttrHP).get_double());
683 }
684 
686 {
689  DamageDetails dmgState;
691  dmgState.recharge = m_self->GetAttribute(AttrShieldRechargeRate).get_double();
692  dmgState.timestamp = GetFileTimeNow();
694  dmgState.structure = 1.0 - m_self->GetAttribute(AttrDamage).get_double() / m_self->GetAttribute(AttrHP).get_double();
695  OnDamageStateChange dmgChange;
696  dmgChange.entityID = m_self->itemID();
697  dmgChange.state = dmgState.Encode();
698  PyTuple *up = dmgChange.Encode();
699  //source->QueueDestinyUpdate(&up);
700 }
701 
703 {
704  // this will use a map{charID/BountyData} in system manager for using a bounty timer.
706  bounty *= sConfig.rates.npcBountyMultiply;
707  if (bounty < 1)
708  return;
709 
710  // add data to StatisticMgr
711  sStatMgr.Add(Stat::npcBounties, bounty);
712 
713  std::string reason = "Bounty for killing a pirate in ";
714  reason += pClient->GetSystemName();
715 
716  BountyData data = BountyData();
717  data.fromID = m_self->itemID();
718  data.toID = pClient->GetCharacterID();
722  data.reason = reason;
723 
724  // handle distribution to fleets
725  if (pClient->InFleet()) {
726  // get fleet members onGrid and distrubute bounty
727  std::vector< uint32 > members;
728  sFltSvc.GetFleetMembersOnGrid(pClient, members);
729  // split bounty between members
730  bounty /= members.size();
731  // send bounty to members
732  if (sConfig.server.BountyPayoutDelayed and sConfig.server.FleetShareDelayed) {
733  for (auto cur :members)
734  m_system->AddBounty(cur, data);
735  } else {
736  reason += " (FleetShare) ";
737  reason += " by ";
738  reason += pClient->GetName();
739  data.reason = reason;
740  for (auto cur :members)
742  }
743  } else {
744  data.amount = bounty;
745  if (sConfig.server.BountyPayoutDelayed) {
746  m_system->AddBounty(pClient->GetCharacterID(), data);
747  } else {
749  }
750  }
751 }
void Append(const T &value)
Appends a single value to buffer.
Definition: Buffer.h:437
#define sConfig
A macro for easier access to the singleton.
void QueueUpdate(PyTuple **up) const
virtual void Process()
#define sStatMgr
Definition: StatisticMgr.h:68
SystemEntity * GetSE(uint32 entityID) const
float GetSecurityRating() const
Definition: Character.h:289
uint16 fromKey
StaticSystemEntity(InventoryItemRef self, PyServiceMgr &services, SystemManager *system)
#define _log(type, fmt,...)
Definition: logsys.h:124
#define sConsole
Python string.
Definition: PyRep.h:430
DestinyManager * m_destiny
Definition: SystemEntity.h:265
virtual bool IsNPCSE()
Definition: SystemEntity.h:186
virtual void EncodeDestiny(Buffer &into)
void ClearAllTargets(bool notify=true)
virtual void Killed(Damage &fatal_blow)
Python's dictionary.
Definition: PyRep.h:719
uint32 m_ownerID
Definition: SystemEntity.h:283
bool HasAttribute(const uint16 attrID) const
uint32 ownerID() const
Definition: InventoryItem.h:99
virtual void AddItem(InventoryItemRef iRef)
virtual PlanetSE * GetPlanetSE()
Definition: SystemEntity.h:101
virtual PyRep * Clone() const =0
Clones object.
void SetCustomsOffice(CustomsSE *pSE)
Definition: Planet.h:67
virtual ~ObjectSystemEntity()
virtual void EncodeDestiny(Buffer &into)
double y()
Definition: SystemEntity.h:214
static PyObject * ListJumps(uint32)
Definition: SystemDB.cpp:41
Python floating point number.
Definition: PyRep.h:292
const GVector & GetVelocity() const
SystemBubble * m_bubble
Definition: SystemEntity.h:262
int32 GetCharacterID() const
Definition: Client.h:113
const std::string & GetNameStr() const
Definition: SystemManager.h:83
virtual CustomsSE * GetCOSE()
Definition: SystemEntity.h:128
virtual PyDict * MakeSlimItem()
#define sStandingMgr
Definition: StandingMgr.h:52
this is a class that kinda mimics how python polymorph's numbers.
Definition: EvilNumber.h:59
const char * name()
virtual bool LoadExtras()
Python tuple.
Definition: PyRep.h:567
GaFloat x
Definition: GaTypes.h:207
int32 m_harmonic
Definition: SystemEntity.h:276
const GPoint & GetPosition() const
Definition: SystemEntity.h:211
void AddItem(PyRep *i)
Definition: PyRep.h:701
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
Definition: SafeMem.h:83
virtual void Delete()
uint16 groupID() const
virtual void Killed(Damage &fatal_blow)
TargetManager * m_targMgr
Definition: SystemEntity.h:264
virtual PyDict * MakeSlimItem()
Python boolean.
Definition: PyRep.h:323
virtual PyDict * MakeSlimItem()
float GetSpeedFraction()
#define sFltSvc
Definition: FleetService.h:147
uint32 m_fleetID
Definition: SystemEntity.h:282
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
virtual PyDict * MakeSlimItem()
virtual bool IsCOSE()
Definition: SystemEntity.h:164
InventoryItemRef m_self
Definition: SystemEntity.h:269
virtual void EncodeDestiny(Buffer &into)
Generic class for buffers.
Definition: Buffer.h:40
bool InFleet()
Definition: Client.h:142
void SetGate(uint32 gateID)
uint32 m_corpID
Definition: SystemEntity.h:281
void ClearFromTargets()
PyTuple * MakeDamageState()
virtual ~DynamicSystemEntity()
void AddBounty(uint32 charID, BountyData &data)
PyRep * m_jumps
Definition: SystemEntity.h:364
virtual void EncodeDestiny(Buffer &into)
virtual bool IsContainerSE()
Definition: SystemEntity.h:157
uint16 GetID()
Definition: SystemBubble.h:91
void RemoveEntity(SystemEntity *pSE)
Definition: Damage.h:33
void SetBelt(InventoryItemRef itemRef)
static void TranserFunds(uint32 fromID, uint32 toID, double amount, std::string reason="", uint8 entryTypeID=Journal::EntryType::Undefined, uint32 referenceID=0, uint16 fromKey=Account::KeyType::Cash, uint16 toKey=Account::KeyType::Cash, Client *pClient=nullptr)
Python integer.
Definition: PyRep.h:231
double GetMaxVelocity()
SystemManager * m_system
Definition: SystemEntity.h:263
virtual void UpdateDamage()
Definition: SystemEntity.h:250
double GetInertia()
double z()
Definition: SystemEntity.h:215
BeltSE(InventoryItemRef self, PyServiceMgr &services, SystemManager *system)
#define PyStatic
Definition: PyRep.h:1209
X * get() const
Definition: RefPtr.h:213
SystemEntity(InventoryItemRef self, PyServiceMgr &services, SystemManager *system)
const char * GetName() const
Definition: Client.h:94
void ChangeOwner(uint32 new_owner, bool notify=false)
int64 Win32TimeNow()
Definition: utils_time.cpp:70
const char * GetName() const
Definition: SystemEntity.h:210
virtual PyDict * MakeSlimItem()
double x()
Definition: SystemEntity.h:213
Definition: Client.h:66
unsigned __int32 uint32
Definition: eve-compat.h:50
virtual void UpdateDamage()
virtual bool IsWreckSE()
Definition: SystemEntity.h:188
uint32 corporationID
virtual void EncodeDestiny(Buffer &into)
#define IsCorp(itemID)
Definition: EVE_Defines.h:234
virtual void EncodeDestiny(Buffer &into)
std::string reason
void AwardBounty(Client *pClient)
GaFloat y
Definition: GaTypes.h:207
double GetFileTimeNow()
Definition: utils_time.cpp:84
int64 MakeRandomInt(int64 low, int64 high)
Generates random integer from interval [low; high].
Definition: misc.cpp:109
const std::string & itemName() const
int main(int argc, char *argv[])
virtual PyDict * MakeSlimItem()
void SendDamageStateChanged()
void DropLoot(WreckContainerRef wreckRef, uint32 groupID, uint32 owner)
EvilNumber GetAttribute(const uint16 attrID) const
virtual void UpdateDamage()
#define IsFaction(itemID)
Definition: EVE_Defines.h:250
double get_double()
Definition: EvilNumber.cpp:191
void AwardSecurityStatus(InventoryItemRef iRef, Character *pChar)
int8 GetSkillLevel(uint16 skillTypeID, bool zeroForNotInjected=true) const
Definition: Character.cpp:575
virtual void Delete()
void secStatusChange(float amount)
Definition: Character.h:294
virtual bool LoadExtras()
#define PySafeDecRef(op)
Definition: PyRep.h:61
#define sItemFactory
Definition: ItemFactory.h:165
#define IsAlliance(itemID)
Definition: EVE_Defines.h:244
float get_float()
Definition: EvilNumber.cpp:184
DynamicSystemEntity(InventoryItemRef self, PyServiceMgr &services, SystemManager *system)
GaExpInl GaFloat distance(const GaVec3 &oth) const
Definition: GaTypes.h:158
StargateSE(InventoryItemRef self, PyServiceMgr &services, SystemManager *system)
uint16 GetTypeID()
Definition: SystemEntity.h:203
virtual bool LoadExtras()
std::string GetSystemName() const
Definition: Client.h:155
#define sBubbleMgr
ItemSystemEntity(InventoryItemRef self, PyServiceMgr &services, SystemManager *system)
virtual void Abandon()
uint16 typeID() const
uint8 categoryID() const
virtual bool HasPilot()
double m_radius
Definition: SystemEntity.h:273
Python list.
Definition: PyRep.h:639
GaFloat z
Definition: GaTypes.h:207
ObjectSystemEntity(InventoryItemRef self, PyServiceMgr &services, SystemManager *system)
uint32 itemID() const
Definition: InventoryItem.h:98
virtual Client * GetPilot()
virtual PyDict * MakeSlimItem()
Python long integer.
Definition: PyRep.h:261
double DistanceTo2(const SystemEntity *other)
#define sDataMgr
FieldSE(InventoryItemRef self, PyServiceMgr &services, SystemManager *system, const FactionData &data)
DeployableSE(InventoryItemRef self, PyServiceMgr &services, SystemManager *system, const FactionData &data)