EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ModuleManager.h
Go to the documentation of this file.
1 /*
2  * ModuleManager.cpp
3  *
4  * this class manages all aspects of modules and charges loaded in ships
5  *
6  * Author: Allan
7  * Started: 30Mar16
8  *
9  * loosely based on original evemu code by Aknor Jaden and Luck
10  */
11 
12 
13 #ifndef EVE_SHIP_MODULES_MODULEMANAGER_H
14 #define EVE_SHIP_MODULES_MODULEMANAGER_H
15 
16 
17 #include "PyService.h"
18 
19 class GenericModule;
20 class SystemEntity;
21 
23 {
24 public:
25  ModuleManager(ShipItem* const pShip);
27 
28  // i dont think this can throw
29  bool Initialize();
30  void LoadOnline();
31  bool IsSlotOccupied(EVEItemFlags flag);
33 
34  void CargoFull();
35  void RemoveTarget(SystemEntity* pSE);
36 
37  // verify slot available
38  // will throw if no slots available
40  // verify module isnt group limited
41  // will throw if group is over fitLimited.
43 
44  // returns vector of fitted GenericModule* in specified flag's bank
45  void GetModulesInBank(EVEItemFlags flag, std::vector<GenericModule*>& modVec);
46 
47  bool InstallRig(ModuleItemRef mRef, EVEItemFlags flag);
50  bool AddModule(ModuleItemRef mRef, EVEItemFlags flag);
51  // this will deactivate, offline and remove charges from module
52  void UnfitModule(uint32 itemID);
53  // this will deactivate, offline and remove charges from module
54  void UnfitModule(EVEItemFlags flag);
55  void Online(uint32 itemID);
56  void Offline(uint32 itemID);
57  void Online(EVEItemFlags flag);
58  void Offline(EVEItemFlags flag);
59  void OnlineAll();
60  void OfflineAll();
61  void Activate(int32 itemID, uint16 effectID, int32 targetID, int32 repeat);
62  void Deactivate(uint32 itemID, std::string effectName);
63  void DeactivateAllModules();
64  void Overload(uint32 itemID);
65  void DeOverload(uint32 itemID);
66  void DamageModule(uint32 itemID, float amount);
67  void DamageModule(GenericModule* pMod, float amount);
68  void DamageRandModule();
69  void DamageRandModule(float amount);
70  void RepairModule(uint32 itemID, EvilNumber amount);
71  void RepairModule(GenericModule* pMod, EvilNumber amount);
72  void RepairModules();
73  // this is for repairing modules with nanite paste
74  PyRep* ModuleRepair(uint32 modID);
75  void StopModuleRepair(uint32 modID);
76  // this will move charge item to module and split stack if needed
77  // must NOT throw
78  void LoadCharge(InventoryItemRef chargeRef, EVEItemFlags flag);
79  // this will remove charge item from module and update client
80  // must NOT throw
81  void UnloadCharge(GenericModule* pMod);
82  // unload charge from module by itemID
83  void UnloadModule(uint32 itemID);
84  // unload charge from module by flag
85  void UnloadModule(EVEItemFlags flag);
86  // unload charge from module by module*
87  void UnloadModule(GenericModule* pMod);
88  // this will remove charges from all modules
89  void UnloadAllModules();
90  // this will remove charges from weapons only
91  void UnloadWeapons();
92  void UpdateModules(std::vector<uint32> modVec);
93  void UpdateModules(EVEItemFlags flag);
94  bool VerifySlotExchange(EVEItemFlags slot1, EVEItemFlags slot2);
95  void CharacterLeavingShip();
96  void CharacterBoardingShip();
97  void ShipWarping();
98  void ShipJumping();
99  void Process();
100  void AbortCycle();
101 
104 
105  void GetLoadedCharges(std::map<EVEItemFlags, InventoryItemRef> &charges)
106  { charges = m_charges; }
107 
108  void GetWeapons(std::list<GenericModule*>& weaponList);
109 
110  void GetShipRigs(std::vector< uint32 >& modVec);
111  void GetShipSubSystems(std::vector< uint32 >& modVec);
112  void SortModulesBySlotDec(std::vector< uint32 >& modVec, std::vector< GenericModule* >& pModList);
113  // low, mid, hi, rig, subsys
114  void GetModuleListOfRefsAsc(std::vector<InventoryItemRef>& modVec);
115  // subsys, rig, hi, mid, low
116  void GetModuleListOfRefsDec(std::vector<InventoryItemRef>& modVec);
117  // subsys, rig, low, mid, hi
118  void GetModuleListOfRefsOrdered(std::vector<InventoryItemRef>& modVec);
119  // hi, mid, low, rig, subsys
120  void GetModuleListOfRefsOrderedRev(std::vector<InventoryItemRef>& modVec);
121  void GetModuleListByReqSkill(uint16 skillID, std::vector<InventoryItemRef>& modVec);
122  void SaveModules();
123 
124  void GetActiveModules(uint8 rack, std::vector< GenericModule* >& modVec);
125  void GetActiveModulesHeat(uint8 rack, float &heat);
126  // returns # of active non-ol'd modules for this rack
129 
130  // scan method to check for scanning rigs.
131  // this is set as % with 1.0 being 100%
132  float GetRigScanBonus() { return m_rigScanBonus; }
133 
134  GenericModule* GetModule(EVEItemFlags flag); // faster than GetModule(itemID)
135  GenericModule* GetModule(uint32 itemID); // slower than GetModule(flag)
137 
138 
139  // huge fucking hack to set charge qty in fit window when in space
140  void UpdateChargeQty();
141 
142 private:
143  // adds module ref to map, modifies rof if applicable, sets maps for fit-by-group, adjusts slot count
144  void addModuleRef(EVEItemFlags flag, GenericModule* pMod);
145  // removes module ref from maps and adjusts slot count
146  void deleteModuleRef(EVEItemFlags flag, GenericModule* pMod);
147 
149 
151 
157 
158  // dont like this, but best way to do it...need to set attrib for this, either on char or ship
159  float m_rigScanBonus; // fuzzy logic as %
160 
161  std::map<uint16, uint8> m_modByGroup; // groupID, count
162  std::map<uint8, GenericModule*> m_modules; // slot, module (for all slots)
163  std::map<uint8, GenericModule*> m_systems; // slot, module (for rigs and subsystems)
164  std::map<uint8, GenericModule*> m_fittings; // slot, module (for hi,mid,lo slots)
165  std::map<EVEItemFlags, InventoryItemRef> m_charges; // slot, chargeItem
166 };
167 
168 
169 #endif // EVE_SHIP_MODULES_MODULEMANAGER_H
170 
171 /* {'messageKey': 'ModuleActivatedDeniedForceField', 'dataID': 17881053, 'suppressable': False, 'bodyID': 258630, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 1797}
172  * {'messageKey': 'ModuleActivationDeniedCriminalAssistance', 'dataID': 17875215, 'suppressable': False, 'bodyID': 256427, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 3548}
173  * {'messageKey': 'ModuleAlreadyActive', 'dataID': 17882992, 'suppressable': False, 'bodyID': 259340, 'messageType': 'info', 'urlAudio': '', 'urlIcon': '', 'titleID': 259339, 'messageID': 1224}
174  * {'messageKey': 'ModuleAlreadyBanked', 'dataID': 17878036, 'suppressable': False, 'bodyID': 257477, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 2671}
175  * {'messageKey': 'ModuleAlreadyFitting', 'dataID': 17882995, 'suppressable': False, 'bodyID': 259341, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 1225}
176  * {'messageKey': 'ModuleEffectActive', 'dataID': 17883214, 'suppressable': False, 'bodyID': 259424, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 1226}
177  * {'messageKey': 'ModuleFitFailed', 'dataID': 17883222, 'suppressable': False, 'bodyID': 259427, 'messageType': 'info', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 1228}
178  * u'ModuleFitFailedBody'}(u'The {moduleName} cannot be fitted. {reason}', None, {u'{reason}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'reason'}, u'{moduleName}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'moduleName'}})
179  * {'messageKey': 'ModuleGotDamagedWhileBeingRepaired', 'dataID': 17879486, 'suppressable': False, 'bodyID': 258026, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 2389}
180  * {'messageKey': 'ModuleIsBlocked', 'dataID': 17878649, 'suppressable': False, 'bodyID': 257706, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 2573}
181  * u'ModuleIsBlockedBody'}(u'External factors are preventing your {moduleName} from responding to this command', None, {u'{moduleName}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'moduleName'}})
182  * {'messageKey': 'ModuleJammedOnBadAmmo', 'dataID': 17883225, 'suppressable': False, 'bodyID': 259428, 'messageType': 'info', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 1229}
183  * u'ModuleJammedOnBadAmmoBody'}(u'{[item]module.name} jammed on the {[item]ammo.name} within it, which it does not use.', None, {u'{[item]module.name}': {'conditionalValues': [], 'variableType': 2, 'propertyName': 'name', 'args': 0, 'kwargs': {}, 'variableName': 'module'}, u'{[item]ammo.name}': {'conditionalValues': [], 'variableType': 2, 'propertyName': 'name', 'args': 0, 'kwargs': {}, 'variableName': 'ammo'}})
184  * {'messageKey': 'ModuleNoLongerPresentForCharges', 'dataID': 17882998, 'suppressable': False, 'bodyID': 259342, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 1230}
185  * {'messageKey': 'ModuleNotPowered', 'dataID': 17883231, 'suppressable': False, 'bodyID': 259430, 'messageType': 'info', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 1232}
186  * {'messageKey': 'ModuleReactivationDelayed2', 'dataID': 17879578, 'suppressable': False, 'bodyID': 258059, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 2307}
187  * {'messageKey': 'ModuleRequiresFuel', 'dataID': 17883167, 'suppressable': False, 'bodyID': 259407, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 1235}
188  * {'messageKey': 'ModuleRequiresLowerSystemSecurity', 'dataID': 17883256, 'suppressable': False, 'bodyID': 259439, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 1236}
189  * {'messageKey': 'ModuleRequiresTargetOwnerFleetMembership', 'dataID': 17883161, 'suppressable': False, 'bodyID': 259405, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 1237}
190  * {'messageKey': 'ModuleTooDamagedToRepairGoToStation', 'dataID': 17879349, 'suppressable': False, 'bodyID': 257974, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 2387}
191  * {'messageKey': 'ModuleUnfit', 'dataID': 17883328, 'suppressable': False, 'bodyID': 259464, 'messageType': 'notify', 'urlAudio': 'wise:/msg_ModuleUnfit_play', 'urlIcon': '', 'titleID': None, 'messageID': 1239}
192  * {'messageKey': 'ModulesIncorrectlyFitted', 'dataID': 17878135, 'suppressable': False, 'bodyID': 257513, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 2512}
193  * u'ModulesIncorrectlyFittedBody'}(u'Your modules are incorrectly fitted. Possibly your slot layout has changed and a module is in a slot that is no longer valid. Try unfitting your modules and fit them again.', None, None)
194  * {'messageKey': 'ModulesNotLoadableInSpace', 'dataID': 17883271, 'suppressable': False, 'bodyID': 259444, 'messageType': 'notify', 'urlAudio': '', 'urlIcon': '', 'titleID': None, 'messageID': 1240}
195  * u'ModulesNotLoadableInSpaceBody'}(u'You can only fit or unfit from a ship while in station. An exception to this rule is when employing a device like the {device}.', None, {u'{device}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'device'}})
196  */
Base Python wire object.
Definition: PyRep.h:66
unsigned __int8 uint8
Definition: eve-compat.h:46
void addModuleRef(EVEItemFlags flag, GenericModule *pMod)
void CheckSlotFitLimited(EVEItemFlags flag)
void deleteModuleRef(EVEItemFlags flag, GenericModule *pMod)
void DeOverload(uint32 itemID)
InventoryItemRef GetLoadedChargeOnModule(EVEItemFlags flag)
void UnfitModule(uint32 itemID)
uint8 m_SubSystemSlots
EVEItemFlags
Definition: EVE_Flags.h:13
void UnloadModule(uint32 itemID)
void GetActiveModules(uint8 rack, std::vector< GenericModule * > &modVec)
void CheckGroupFitLimited(EVEItemFlags flag, InventoryItemRef iRef)
void GetShipRigs(std::vector< uint32 > &modVec)
this is a class that kinda mimics how python polymorph's numbers.
Definition: EvilNumber.h:59
void GetLoadedCharges(std::map< EVEItemFlags, InventoryItemRef > &charges)
void UninstallRig(uint32 itemID)
float m_rigScanBonus
void GetModulesInBank(EVEItemFlags flag, std::vector< GenericModule * > &modVec)
signed __int32 int32
Definition: eve-compat.h:49
void GetWeapons(std::list< GenericModule * > &weaponList)
std::map< uint8, GenericModule * > m_fittings
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type()() itemID() copy() materialLevel()()() itemID() itemID Fits selected item to active ship() skillID(level)-gives skillID to specified level." ) COMMAND( online
void GetModuleListOfRefsAsc(std::vector< InventoryItemRef > &modVec)
GenericModule * GetModule(EVEItemFlags flag)
PyRep * ModuleRepair(uint32 modID)
void UpdateModules(std::vector< uint32 > modVec)
bool VerifySlotExchange(EVEItemFlags slot1, EVEItemFlags slot2)
void GetModuleListOfRefsOrderedRev(std::vector< InventoryItemRef > &modVec)
bool InstallRig(ModuleItemRef mRef, EVEItemFlags flag)
void GetModuleListOfRefsOrdered(std::vector< InventoryItemRef > &modVec)
bool InstallSubSystem(ModuleItemRef mRef, EVEItemFlags flag)
std::map< EVEItemFlags, InventoryItemRef > m_charges
void DeactivateAllModules()
void Activate(int32 itemID, uint16 effectID, int32 targetID, int32 repeat)
EVEEffectID
Definition: EVE_Effects.h:16
uint8 GetFittedModuleCountByGroup(uint16 groupID)
void GetShipSubSystems(std::vector< uint32 > &modVec)
void StopModuleRepair(uint32 modID)
unsigned __int32 uint32
Definition: eve-compat.h:50
void DamageRandModule()
void SortModulesBySlotDec(std::vector< uint32 > &modVec, std::vector< GenericModule * > &pModList)
GenericModule * GetRandModule()
void RemoveTarget(SystemEntity *pSE)
void UnloadCharge(GenericModule *pMod)
ShipItem * pShipItem
void GetModuleListByReqSkill(uint16 skillID, std::vector< InventoryItemRef > &modVec)
void Deactivate(uint32 itemID, std::string effectName)
std::map< uint16, uint8 > m_modByGroup
void CharacterLeavingShip()
Definition: Ship.h:46
uint16 GetAvailableSlotInBank(EVEEffectID slotBank)
void Offline(uint32 itemID)
void LoadCharge(InventoryItemRef chargeRef, EVEItemFlags flag)
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 RepairModule(uint32 itemID, EvilNumber amount)
bool AddModule(ModuleItemRef mRef, EVEItemFlags flag)
std::map< uint8, GenericModule * > m_systems
void Online(uint32 itemID)
void GetActiveModulesHeat(uint8 rack, float &heat)
void CharacterBoardingShip()
void Overload(uint32 itemID)
std::map< uint8, GenericModule * > m_modules
bool IsSlotOccupied(EVEItemFlags flag)
ModuleManager(ShipItem *const pShip)
void DamageModule(uint32 itemID, float amount)
unsigned __int16 uint16
Definition: eve-compat.h:48
uint8 GetActiveModulesCount(uint8 rack)
float GetRigScanBonus()
void GetModuleListOfRefsDec(std::vector< InventoryItemRef > &modVec)
Reference-counting-based smart pointer.
Definition: RefPtr.h:133