EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CynoModule.cpp
Go to the documentation of this file.
1 
9 #include "system/SystemManager.h"
10 #include "fleet/FleetService.h"
11 #include "pos/Tower.h"
13 
15 : ActiveModule(mRef, sRef),
16 cSE(nullptr),
17 pClient(nullptr),
18 pShipSE(nullptr),
19 m_firstRun(true),
20 m_shipVelocity(0.0f)
21 {
22  if (!m_shipRef->HasPilot())
23  return;
24 
26 
27  // increase scan speed by level of survey skill
28  float cycleTime = GetAttribute(AttrDuration).get_float();
29  cycleTime *= (1 + (0.03f * (pClient->GetChar()->GetSkillLevel(EvESkill::Survey, true))));
30  SetAttribute(AttrDuration, cycleTime);
31 }
32 
33 void CynoModule::Activate(uint16 effectID, uint32 targetID, int16 repeat)
34 {
36 
37  m_firstRun = true;
38  ActiveModule::Activate(effectID, targetID, repeat);
39 
40  // check to see if Activate() was denied.
41  if (m_Stop)
42  return;
43 
44  _log(MODULE__DEBUG, "Cynosural field generator activated by %s in %s", pClient->GetName(), m_sysMgr->GetName());
45 
46  // hack to disable ship movement here
48  pShipSE->DestinyMgr()->SetFrozen(true);
49 }
50 
52 {
54  cSE->Delete();
55  SafeDelete(cSE);
57 
58  // hack to reinstate ship movement here
59  // may have to reset/reapply all fx for ship movement
61  pShipSE->DestinyMgr()->SetFrozen(false);
62 }
63 
65 {
66  if (!pClient->InFleet())
67  throw UserError("CynoMustBeInFleet");
68 
69  if (pShipSE->SysBubble()->HasTower()) {
70  TowerSE* ptSE = pShipSE->SysBubble()->GetTowerSE();
71  if (ptSE->HasForceField())
72  if (pShipSE->GetPosition().distance(ptSE->GetPosition()) < ptSE->GetSOI())
73  throw UserError("NoCynoInPOSShields");
74  }
75 
78  //if (m_sysMgr->HasCynoJammer())
79  // throw UserError("CynosuralGenerationJammed");
80 
81  //Send message if the system is being jammed
82  SovereigntyData sovData = svDataMgr.GetSovereigntyData(pClient->GetLocationID());
83  if (sovData.jammerID != 0) {
84  pClient->SendNotifyMsg("This system is currently being jammed.");
85  return false;
86  }
87 
88  //Make sure player is not in high-sec (configurable)
89  if (!sConfig.world.highSecCyno) {
90  if (pClient->SystemMgr()->GetSecValue() >= 0.5f) {
91  pClient->SendNotifyMsg("This module may not be used in high security space.");
92  return false;
93  }
94  }
95 
96  // all specific checks pass. run generic checks in base class
98 }
99 
101 {
102  // i really dont like this, but cant get it to work anywhere else...
103  uint32 retVal(0);
104  if (retVal = ActiveModule::DoCycle())
105  if (m_firstRun) {
106  m_firstRun = false;
107  CreateCyno();
108  }
109 
110  return retVal;
111 }
112 
114 {
115  // do we already have a cyno field created?
116  if (cSE != nullptr)
117  return;
118 
119  // Create Cyno field here
121  InventoryItemRef cRef = sItemFactory.SpawnItem(cData);
122 
123  _log(MODULE__DEBUG, "Creating Cynosural field");
124 
125  cSE = new ItemSystemEntity(cRef, pClient->services(), m_sysMgr);
126  GPoint location(pShipSE->GetPosition());
127  location.MakeRandomPointOnSphere(1500.0f + cRef->type().radius());
128  cSE->SetPosition(location);
129  cRef->SaveItem();
131 
133 }
134 
135 void CynoModule::SendOnJumpBeaconChange(bool active/*false*/) {
136  //Send ProcessSovStatusChanged Notification
137  _log(MODULE__DEBUG, "Sending OnJumpBeaconChange (active = %s)", active ? "true" : "false");
138 
139  uint32 fieldID(0);
140  if (cSE != nullptr)
141  fieldID = cSE->GetID();
142 
143  PyTuple* data = new PyTuple(4);
144  data->SetItem(0, new PyInt(pClient->GetCharacterID()));
145  data->SetItem(1, new PyInt(m_sysMgr->GetID()));
146  data->SetItem(2, new PyInt(fieldID));
147  data->SetItem(3, new PyBool(active));
148 
149  std::vector<Client *> fleetClients;
150  fleetClients = sFltSvc.GetFleetClients(pClient->GetFleetID());
151  for (auto cur : fleetClients)
152  if (cur != nullptr) {
153  cur->SendNotification("OnJumpBeaconChange", "clientID", &data);
154  _log(MODULE__DEBUG, "OnJumpBeaconChange sent to %s (%u)", cur->GetName(), cur->GetCharID());
155  }
156 }
157 
158 /*
159  * {'messageKey': 'CynoMustBeInFleet', 'dataID': 17879144, 'suppressable': False, 'bodyID': 257897, 'messageType': 'info', 'urlAudio': '', 'urlIcon': '', 'titleID': 257896, 'messageID': 2253}
160  * {'messageKey': 'CynosuralGenerationJammed', 'dataID': 17880043, 'suppressable': False, 'bodyID': 258240, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 2249}
161  * {'messageKey': 'NoActiveBeacon', 'dataID': 17879973, 'suppressable': False, 'bodyID': 258214, 'messageType': 'info', 'urlAudio': '', 'urlIcon': '', 'titleID': 258213, 'messageID': 2211}
162  * {'messageKey': 'NoCynoInPOSShields', 'dataID': 17878872, 'suppressable': False, 'bodyID': 257791, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 2339}
163  *
164  */
165 
166 /*
167  * {'FullPath': u'UI/Messages', 'messageID': 257896, 'label': u'CynoMustBeInFleetTitle'}(u'Cannot start Cynosural Field', None, None)
168  * {'FullPath': u'UI/Messages', 'messageID': 257897, 'label': u'CynoMustBeInFleetBody'}(u'You must be in a fleet to activate your Cynosural Field.', None, None)
169  *
170  * {'FullPath': u'UI/Messages', 'messageID': 258213, 'label': u'NoActiveBeaconTitle'}(u'No Active Beacon', None, None)
171  * {'FullPath': u'UI/Messages', 'messageID': 258214, 'label': u'NoActiveBeaconBody'}(u'You do not have an active Cynosural Field Beacon.', None, None)
172  *
173  * {'FullPath': u'UI/Messages', 'messageID': 258240, 'label': u'CynosuralGenerationJammedBody'}(u'You are unable to generate a cynosural field while there is a jammer present and active somewhere in this solar system.', None, None)
174  *
175  * {'FullPath': u'UI/Messages', 'messageID': 257791, 'label': u'NoCynoInPOSShieldsBody'}(u'You cannot set up a cynosural field within the force field of a Control Tower', None, None)
176  */
#define sConfig
A macro for easier access to the singleton.
void SetPosition(const GPoint &pos)
Definition: SystemEntity.h:212
uint32 GetLocationID() const
Definition: Client.h:151
void AddEntity(SystemEntity *pSE, bool addSignal=true)
virtual bool CanActivate()
Definition: CynoModule.cpp:64
#define _log(type, fmt,...)
Definition: logsys.h:124
PyServiceMgr & services() const
Definition: Client.h:90
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
virtual void Activate(uint16 effectID, uint32 targetID=0, int16 repeat=0)
Definition: CynoModule.cpp:33
virtual bool HasPilot()
Definition: Ship.h:71
int32 GetCharacterID() const
Definition: Client.h:113
SystemManager * m_sysMgr
Definition: ActiveModule.h:80
uint32 GetID() const
Definition: SystemManager.h:80
void SendNotifyMsg(const char *fmt,...)
Definition: Client.cpp:2776
CharacterRef GetChar() const
Definition: Client.h:164
Python tuple.
Definition: PyRep.h:567
Client * pClient
Definition: CynoModule.h:34
void SetAttribute(uint32 attrID, EvilNumber val, bool update=true)
Definition: GenericModule.h:51
uint16 GetSOI()
Definition: Tower.h:90
const GPoint & GetPosition() const
Definition: SystemEntity.h:211
TowerSE * GetTowerSE()
Definition: SystemBubble.h:142
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
Definition: SafeMem.h:83
virtual void Delete()
Python boolean.
Definition: PyRep.h:323
bool m_firstRun
Definition: CynoModule.h:38
#define sFltSvc
Definition: FleetService.h:147
virtual uint32 DoCycle()
Definition: CynoModule.cpp:100
ShipItemRef m_shipRef
Definition: gpoint.h:33
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
bool InFleet()
Definition: Client.h:142
SystemEntity * cSE
Definition: CynoModule.h:36
InventoryItemRef GetSelf()
Definition: SystemEntity.h:202
void SendOnJumpBeaconChange(bool status=false)
Definition: CynoModule.cpp:135
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:610
SystemManager * SystemMgr() const
Definition: Client.h:92
Python integer.
Definition: PyRep.h:231
double GetMaxVelocity()
void CreateCyno()
Definition: CynoModule.cpp:113
float GetSecValue()
void SetAttribute(uint16 attrID, int num, bool notify=true)
uint32 GetID()
Definition: SystemEntity.h:207
uint32 GetFleetID() const
Definition: Client.h:146
const char * GetName() const
Definition: Client.h:94
Python object "ccp_exceptions.UserError".
Definition: PyExceptions.h:121
virtual bool CanActivate()
unsigned __int32 uint32
Definition: eve-compat.h:50
void SetFrozen(bool set=false)
ShipSE * pShipSE
Definition: CynoModule.h:35
float m_shipVelocity
Definition: CynoModule.h:40
CynoModule(ModuleItemRef mRef, ShipItemRef sRef)
Definition: CynoModule.cpp:14
const char * GetName() const
Definition: SystemManager.h:84
ShipSE * GetShipSE()
Definition: Client.h:168
bool HasTower()
Definition: SystemBubble.h:141
virtual Client * GetPilot()
Definition: Ship.h:72
signed __int16 int16
Definition: eve-compat.h:47
int8 GetSkillLevel(uint16 skillTypeID, bool zeroForNotInjected=true) const
Definition: Character.cpp:575
Definition: Tower.h:19
#define sItemFactory
Definition: ItemFactory.h:165
virtual uint32 DoCycle()
float get_float()
Definition: EvilNumber.cpp:184
GaExpInl GaFloat distance(const GaVec3 &oth) const
Definition: GaTypes.h:158
#define svDataMgr
void MakeRandomPointOnSphere(double radius)
Definition: gpoint.h:46
bool HasForceField()
Definition: Tower.h:76
unsigned __int16 uint16
Definition: eve-compat.h:48
EvilNumber GetAttribute(uint32 attrID)
Definition: GenericModule.h:53
virtual void DeactivateCycle(bool abort=false)
virtual void DeactivateCycle(bool abort=false)
Definition: CynoModule.cpp:51
virtual void Activate(uint16 effectID, uint32 targetID=0, int16 repeat=0)