EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MiningLaser Class Reference

#include "MiningLaser.h"

Inheritance diagram for MiningLaser:
Collaboration diagram for MiningLaser:

Public Member Functions

virtual ~MiningLaser ()
 
virtual MiningLaserGetMiningModule ()
 
virtual bool IsMiningLaser () const
 
void CancelOnError ()
 
- Public Member Functions inherited from ActiveModule
virtual ~ActiveModule ()
 
virtual ActiveModuleGetActiveModule ()
 
virtual bool IsActiveModule () const
 
virtual void ApplyDamage ()
 
virtual uint16 GetReloadTime ()
 
virtual uint32 GetTargetID ()
 
SystemEntityGetTargetSE ()
 
 ActiveModule (ModuleItemRef mRef, ShipItemRef sRef)
 
virtual void Process ()
 
virtual void Overload ()
 
virtual void AbortCycle ()
 
virtual void DeOverload ()
 
virtual void Deactivate (std::string effect="")
 
virtual void Activate (uint16 effectID, uint32 targetID=0, int16 repeat=0)
 
virtual void RemoveTarget (SystemEntity *pSE)
 
virtual void Update ()
 
virtual void ReprocessCharge ()
 
void LaunchProbe ()
 
void LaunchMissile ()
 
void LaunchSnowBall ()
 
void ApplyEffect (int8 state, bool active=false)
 
void ShowEffect (bool active=false, bool abort=false)
 
- Public Member Functions inherited from GenericModule
ModuleItemRef GetSelf ()
 
ShipItemRef GetShipRef ()
 
void Repair ()
 
bool HasAttribute (uint32 attrID)
 
void SetAttribute (uint32 attrID, EvilNumber val, bool update=true)
 
void ResetAttribute (uint32 attrID)
 
EvilNumber GetAttribute (uint32 attrID)
 
bool isWarpSafe ()
 
bool isTurretFitted ()
 
bool isLauncherFitted ()
 
virtual PassiveModuleGetPassiveModule ()
 
virtual ProspectorGetProspectModule ()
 
virtual TurretModuleGetTurretModule ()
 
virtual SuperWeaponGetSuperWeapon ()
 
virtual RigModuleGetRigModule ()
 
virtual SubSystemModuleGetSubSystemModule ()
 
virtual CynoModuleGetCynoModule ()
 
virtual bool IsGenericModule () const
 
virtual bool IsPassiveModule () const
 
virtual bool IsProspectModule () const
 
virtual bool IsCynoModule () const
 
virtual bool IsRigModule () const
 
virtual bool IsSubSystemModule () const
 
bool IsLoaded ()
 
bool IsTurretModule ()
 
bool IsLauncherModule ()
 
bool IsOverloaded ()
 
bool IsLinked ()
 
bool IsMaster ()
 
bool IsDamaged ()
 
bool IsActive ()
 
bool IsLoading ()
 
bool isOnline ()
 
bool isLowPower ()
 
bool isHighPower ()
 
bool isMediumPower ()
 
bool isRig ()
 
bool isSubSystem ()
 
uint32 itemID ()
 
uint32 typeID ()
 
uint32 groupID ()
 
EVEItemFlags flag ()
 
void SetChargeRef (InventoryItemRef iRef)
 
void SetModuleState (int8 state)
 
void SetChargeState (int8 state)
 
void SetLinked (bool set=false)
 
void SetLinkMaster (bool set=false)
 
int8 GetModuleState ()
 
int8 GetChargeState ()
 
InventoryItemRef GetLoadedChargeRef ()
 
virtual void ReloadCharge ()
 
virtual void RemoveRig ()
 
virtual void DestroyRig ()
 
virtual bool IsSuccess ()
 
 GenericModule (ModuleItemRef mRef, ShipItemRef sRef)
 
virtual ~GenericModule ()
 
void Online ()
 
void Offline ()
 
void ProcessEffects (int8 state, bool active=false)
 
void Repair (EvilNumber amount)
 
int8 GetModulePowerLevel ()
 

Private Attributes

bool m_rMiner
 
bool m_dcMiner
 
bool m_iMiner
 
bool m_gMiner
 
bool m_IsInitialCycle
 
float m_crystalDmg
 
float m_crystalDmgAmount
 
float m_crystalDmgChance
 
uint16 m_crystalRoidGrp
 
EVEItemFlags m_holdFlag
 

MiningLaser.cpp

mining module class : Allan

Date
: 10 June 2015 -UD/RW 02 April 2017 : 4 August 2017
 MiningLaser (ModuleItemRef mRef, ShipItemRef sRef)
 
virtual void DeactivateCycle (bool abort=false)
 
virtual uint32 DoCycle ()
 
virtual void LoadCharge (InventoryItemRef charge)
 
virtual void UnloadCharge ()
 
virtual bool CanActivate ()
 
float GetMiningVolume ()
 
void Depleted (std::multimap< float, MiningLaser * > &mMap)
 
void AddOreAndDeactivate (uint16 typeID, float amt, bool slave=true)
 
void ProcessCycle (bool abort=false)
 

Additional Inherited Members

- Protected Member Functions inherited from ActiveModule
uint32 GetRemainingCycleTimeMS ()
 
void StopTimer ()
 
void Clear ()
 
void ProcessActiveCycle ()
 
void UpdateCharge (uint16 attrID, uint16 testAttrID, uint16 srcAttrID, InventoryItemRef iRef)
 
void UpdateDamage (uint16 attrID, uint16 srcAttrID, InventoryItemRef iRef)
 
void SetSlaveData (ShipSE *pShip)
 
void ConsumeCharge ()
 
void SetTimer (uint32 time)
 
- Protected Member Functions inherited from GenericModule
const char * GetModuleStateName (int8 state)
 
- Protected Attributes inherited from ActiveModule
SystemBubblem_bubble
 
SystemEntitym_targetSE
 
DestinyManagerm_destinyMgr
 
SystemManagerm_sysMgr
 
TargetManagerm_targMgr
 
uint16 m_reloadTime
 
uint16 m_effectID
 
uint32 m_targetID
 
bool m_Stop:1
 
bool m_usesCharge:1
 
bool m_needsCharge:1
 
bool m_needsTarget:1
 
- Protected Attributes inherited from GenericModule
ModuleItemRef m_modRef
 
ShipItemRef m_shipRef
 
InventoryItemRef m_chargeRef
 
int8 m_ModuleState
 
int8 m_ChargeState
 
int16 m_repeat
 
bool m_linkMaster:1
 
bool m_linked:1
 
bool m_isWarpSafe:1
 
bool m_hiPower:1
 
bool m_medPower:1
 
bool m_loPower:1
 
bool m_rigSlot:1
 
bool m_subSystem:1
 
bool m_launcher:1
 
bool m_turret:1
 
bool m_overLoaded:1
 
bool m_chargeLoaded:1
 

Detailed Description

Definition at line 17 of file MiningLaser.h.

Constructor & Destructor Documentation

MiningLaser::MiningLaser ( ModuleItemRef  mRef,
ShipItemRef  sRef 
)

Definition at line 24 of file MiningLaser.cpp.

References _log, AttrDuration, flagCargoHold, EVEDB::invGroups::Frequency_Mining_Laser, EVEDB::invGroups::Gas_Cloud_Harvester, EvilNumber::get_int(), GenericModule::GetAttribute(), InventoryItem::groupID(), m_crystalDmg, m_crystalDmgAmount, m_crystalDmgChance, m_crystalRoidGrp, m_dcMiner, m_gMiner, m_holdFlag, m_iMiner, m_IsInitialCycle, GenericModule::m_modRef, ActiveModule::m_reloadTime, m_rMiner, EVEDB::invGroups::Mining_Laser, InventoryItem::name(), EVEDB::invGroups::Strip_Miner, and InventoryItem::typeID().

25 : ActiveModule(mRef, sRef)
26 {
27  m_IsInitialCycle = true;
28  m_rMiner = m_dcMiner = m_iMiner = m_gMiner = false;
30 
32  m_rMiner = true;
33  } else if ((m_modRef->typeID() == 12108) or (m_modRef->typeID() == 18068) or (m_modRef->typeID() == 24305) or (m_modRef->typeID() == 28748)) {
34  m_dcMiner = true;
35  } else if ((m_modRef->typeID() == 16278) or (m_modRef->typeID() == 22229) or (m_modRef->typeID() == 22589) or (m_modRef->typeID() == 22591)
36  or (m_modRef->typeID() == 22597) or (m_modRef->typeID() == 22599) or (m_modRef->typeID() == 28752)) {
37  /* this includes 'dev testing modules' */
38  m_iMiner = true;
40  m_gMiner = true;
42  m_rMiner = true;
43  m_reloadTime = 8000; // this is not set in ActiveModule c'tor. easier/cheaper to set here.
45  m_rMiner = true;
46  }
47 
49  _log(MINING__TRACE, "MiningLaser Created for %s with %ums Duration.", mRef->name(), GetAttribute(AttrDuration).get_int());
50 }
#define _log(type, fmt,...)
Definition: logsys.h:124
bool m_rMiner
Definition: MiningLaser.h:54
ActiveModule(ModuleItemRef mRef, ShipItemRef sRef)
ModuleItemRef m_modRef
uint16 groupID() const
float m_crystalDmgChance
Definition: MiningLaser.h:59
EVEItemFlags m_holdFlag
Definition: MiningLaser.h:63
uint16 m_reloadTime
Definition: ActiveModule.h:99
int64 get_int()
Definition: EvilNumber.cpp:166
float m_crystalDmg
Definition: MiningLaser.h:57
float m_crystalDmgAmount
Definition: MiningLaser.h:58
bool m_iMiner
Definition: MiningLaser.h:54
bool m_dcMiner
Definition: MiningLaser.h:54
uint16 m_crystalRoidGrp
Definition: MiningLaser.h:61
EvilNumber GetAttribute(uint32 attrID)
Definition: GenericModule.h:53
uint16 typeID() const
bool m_gMiner
Definition: MiningLaser.h:54
bool m_IsInitialCycle
Definition: MiningLaser.h:55

Here is the call graph for this function:

virtual MiningLaser::~MiningLaser ( )
inlinevirtual

Definition at line 21 of file MiningLaser.h.

21 { /* do nothing here */ }

Member Function Documentation

void MiningLaser::AddOreAndDeactivate ( uint16  typeID,
float  amt,
bool  slave = true 
)

Definition at line 366 of file MiningLaser.cpp.

References _log, ShipItem::AddItemByFlag(), ActiveModule::DeactivateCycle(), flagNone, ShipItem::GetPilot(), InventoryItem::itemID(), locTemp, m_holdFlag, GenericModule::m_modRef, GenericModule::m_shipRef, InventoryItem::name(), Stat::oreMined, InventoryItem::ownerID(), Client::SendNotifyMsg(), sItemFactory, and sStatMgr.

Referenced by Depleted().

366  {
367 
368  ItemData idata(typeID, m_shipRef->ownerID(), locTemp, flagNone, amt);
369  InventoryItemRef oRef(sItemFactory.SpawnItem( idata ));
370  if (oRef.get() == nullptr) {
371  _log(MINING__ERROR, "AddOreAndDeactivate() - Could not create mined ore for %s(%u)", m_shipRef->name(), m_shipRef->itemID() );
372  return;
373  }
374 
375  if (!m_shipRef->AddItemByFlag(m_holdFlag, oRef))
376  _log(MINING__ERROR, "AddOreAndDeactivate() - Could not add ore to hold for %s(%u)", m_shipRef->name(), m_shipRef->itemID() );
377 
378  // send pilot msg about depletion for this module
379  m_shipRef->GetPilot()->SendNotifyMsg("Your %s deactivates; Its target has been depleted.", m_modRef->name());
380 
381  if (slave)
383 
384  // add data to StatisticMgr
385  sStatMgr.Add(Stat::oreMined, amt);
386 }
#define sStatMgr
Definition: StatisticMgr.h:68
#define _log(type, fmt,...)
Definition: logsys.h:124
uint32 ownerID() const
Definition: InventoryItem.h:99
const char * name()
void SendNotifyMsg(const char *fmt,...)
Definition: Client.cpp:2776
ModuleItemRef m_modRef
ShipItemRef m_shipRef
EVEItemFlags m_holdFlag
Definition: MiningLaser.h:63
virtual Client * GetPilot()
Definition: Ship.h:72
uint32 AddItemByFlag(EVEItemFlags flag, InventoryItemRef iRef, Client *pClient=nullptr)
Definition: Ship.cpp:486
#define sItemFactory
Definition: ItemFactory.h:165
virtual void DeactivateCycle(bool abort=false)
uint32 typeID()
Definition: GenericModule.h:98
uint32 itemID() const
Definition: InventoryItem.h:98

Here is the call graph for this function:

Here is the caller graph for this function:

bool MiningLaser::CanActivate ( )
virtual

Reimplemented from ActiveModule.

Definition at line 78 of file MiningLaser.cpp.

References _log, EVEDB::invCategories::Asteroid, AttrCrystalVolatilityChance, AttrCrystalVolatilityDamage, AttrDamage, AttrGasHoldCapacity, AttrOreHoldCapacity, AttrSpecialisationAsteroidGroup, ActiveModule::CanActivate(), InventoryItem::categoryID(), flagGasHold, flagOreHold, RefPtr< X >::get(), EvilNumber::get_float(), InventoryItem::GetAttribute(), SystemManager::GetBeltMgr(), SystemBubble::GetID(), GetMiningVolume(), SystemEntity::GetName(), ShipItem::GetPilot(), ShipItem::GetRemainingVolumeByFlag(), SystemEntity::GetSelf(), InventoryItem::groupID(), EVEDB::invGroups::Harvestable_Cloud, InventoryItem::HasAttribute(), ShipItem::HasPilot(), EVEDB::invGroups::Ice, GenericModule::m_chargeLoaded, GenericModule::m_chargeRef, m_crystalDmg, m_crystalDmgAmount, m_crystalDmgChance, m_crystalRoidGrp, m_dcMiner, m_gMiner, m_holdFlag, m_iMiner, m_IsInitialCycle, m_rMiner, GenericModule::m_shipRef, ActiveModule::m_targetSE, EVEDB::invGroups::Mercoxit, Client::SendNotifyMsg(), BeltMgr::SetActive(), SystemEntity::SysBubble(), and SystemEntity::SystemMgr().

79 {
80  if (m_targetSE == nullptr){
81  _log(MINING__WARNING, "Activate() - Invalid target: m_targetSE == nullptr");
82  if (m_shipRef->HasPilot())
83  m_shipRef->GetPilot()->SendNotifyMsg("Module Activate: Invalid target - Ref: ServerError 15628");
84  return false;
85  }
86 
87  bool canActivate(false);
88  // verify module vs target for activation. disallow if not compatible. set special ore hold if applicable
89  if (m_rMiner) {
92  canActivate = true;
95  }
96  } else if (m_dcMiner) {
98  canActivate = true;
101  }
102  } else if (m_iMiner) {
104  canActivate = true;
107  }
108  } else if (m_gMiner) {
110  canActivate = true;
113  }
114  }
115 
116  if (canActivate) {
117  // so far, checks have passed and proper hold is set.
118  // check for capacity as final test before allowing mining (ship would know)
119 
120  // should we also test for target volume here? ...it's done on every ProcessCycle() call...
122  _log(MINING__WARNING, "Activate() - Cargo full. Denying Activate() on %s", m_targetSE->GetName());
123  if (m_shipRef->HasPilot())
124  m_shipRef->GetPilot()->SendNotifyMsg("Module Activate: Your Cargo is full. - Ref: ServerError 65125");
125 
126  return false;
127  }
128  }
129 
130  if (canActivate) {
131  m_IsInitialCycle = true;
133 
134  // mining on current target approved. check for and set crystal variables here
135  if (m_chargeLoaded and (m_chargeRef.get() != nullptr) and (m_crystalRoidGrp == 0)) {
140  }
141 
142  return ActiveModule::CanActivate();
143  } else {
144  _log(MINING__WARNING, "Activate() - Invalid target: %s", m_targetSE->GetName());
145  if (m_shipRef->HasPilot())
146  m_shipRef->GetPilot()->SendNotifyMsg("Module Activate: %s is an invalid target - Ref: ServerError 15628", m_targetSE->GetName());
147  }
148 
149  return false;
150 }
#define _log(type, fmt,...)
Definition: logsys.h:124
bool m_rMiner
Definition: MiningLaser.h:54
bool HasAttribute(const uint16 attrID) const
float GetMiningVolume()
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
virtual bool HasPilot()
Definition: Ship.h:71
void SendNotifyMsg(const char *fmt,...)
Definition: Client.cpp:2776
uint16 groupID() const
float m_crystalDmgChance
Definition: MiningLaser.h:59
ShipItemRef m_shipRef
SystemEntity * m_targetSE
Definition: ActiveModule.h:78
EVEItemFlags m_holdFlag
Definition: MiningLaser.h:63
SystemManager * SystemMgr()
Definition: SystemEntity.h:196
InventoryItemRef GetSelf()
Definition: SystemEntity.h:202
InventoryItemRef m_chargeRef
uint16 GetID()
Definition: SystemBubble.h:91
float m_crystalDmg
Definition: MiningLaser.h:57
BeltMgr * GetBeltMgr()
X * get() const
Definition: RefPtr.h:213
float m_crystalDmgAmount
Definition: MiningLaser.h:58
const char * GetName() const
Definition: SystemEntity.h:210
bool m_iMiner
Definition: MiningLaser.h:54
virtual bool CanActivate()
bool m_dcMiner
Definition: MiningLaser.h:54
void SetActive(uint16 bubbleID, bool active=true)
Definition: BeltMgr.cpp:114
virtual Client * GetPilot()
Definition: Ship.h:72
EvilNumber GetAttribute(const uint16 attrID) const
uint16 m_crystalRoidGrp
Definition: MiningLaser.h:61
float get_float()
Definition: EvilNumber.cpp:184
float GetRemainingVolumeByFlag(EVEItemFlags flag) const
Definition: Ship.cpp:338
uint8 categoryID() const
bool m_gMiner
Definition: MiningLaser.h:54
bool m_IsInitialCycle
Definition: MiningLaser.h:55

Here is the call graph for this function:

void MiningLaser::CancelOnError ( )
inline

Definition at line 45 of file MiningLaser.h.

References ActiveModule::DeactivateCycle().

virtual void DeactivateCycle(bool abort=false)

Here is the call graph for this function:

void MiningLaser::DeactivateCycle ( bool  abort = false)
virtual

Reimplemented from ActiveModule.

Definition at line 166 of file MiningLaser.cpp.

References FX::State::Active, ActiveModule::ApplyEffect(), ActiveModule::Clear(), Module::State::Deactivating, flagCargoHold, m_holdFlag, GenericModule::m_ModuleState, Module::State::Online, ProcessCycle(), GenericModule::SetModuleState(), and ActiveModule::ShowEffect().

167 {
169  return;
170 
172  ShowEffect(false, abort);
173 
174  ProcessCycle(abort);
176 
178  Clear();
179 }
EVEItemFlags m_holdFlag
Definition: MiningLaser.h:63
void ShowEffect(bool active=false, bool abort=false)
void ApplyEffect(int8 state, bool active=false)
void ProcessCycle(bool abort=false)
void SetModuleState(int8 state)

Here is the call graph for this function:

void MiningLaser::Depleted ( std::multimap< float, MiningLaser * > &  mMap)
Todo:
check for mining drones here!!!

Definition at line 304 of file MiningLaser.cpp.

References _log, AddOreAndDeactivate(), AttrQuantity, AttrVolume, SystemEntity::GetID(), GetMiningVolume(), SystemEntity::GetSelf(), InventoryItem::itemID(), GenericModule::m_modRef, ActiveModule::m_targetSE, InventoryItem::name(), PyTuple::SetItem(), and PyDict::SetItemString().

Referenced by TargetManager::Depleted().

304  {
305  /* instead of calculations and timers from previous iteration, this method will determine how many modules are activated
306  * on newly-depleted rock, get total cycle volume, and then divide rock contents between modules, weighted by modules cycle volume.
307  */
308  // NOTE: this will be called for EACH active module on rock, with first timer to hit being the 'master' module.
309 
310  // determine % of remaining ore for each module active on this rock
311  float total = GetMiningVolume(), percent = 0.0f;
312  for (auto cur : mMap)
313  total += cur.first;
314 
317  InventoryItemRef roidRef(m_targetSE->GetSelf());
318  float oreVolume(roidRef->GetAttribute(AttrVolume).get_float());
319  if (oreVolume <= 0) {
320  _log(MINING__ERROR, "%s(%u) - Depleted() - oreVolume is <0 for %s(%u)", m_modRef->name(), m_modRef->itemID(), roidRef->name(), m_targetSE->GetID() );
321 
322  // send error and deactivate all active modules here
323  for (auto cur : mMap) {
324  cur.second->GetShipRef()->GetPilot()->SendNotifyMsg("Your %s deactivates because there was a processing error. Ref: ServerError 03123.", \
325  cur.second->GetSelf()->name());
326  cur.second->CancelOnError();
327  }
328  return;
329  }
330 
331  float roidQuantity(roidRef->GetAttribute(AttrQuantity).get_float());
332  double oreAmount(0);
333 
334  for (auto cur : mMap) {
335  if ((cur.first < oreVolume) or (cur.first < 0.1)) {
336  _log(MINING__ERROR, "%s(%u) - Depleted() - Mining Laser could not extract ore from %s(%u)", \
337  cur.second->GetSelf()->name(), cur.second->GetSelf()->itemID(), roidRef->name(), m_targetSE->GetID() );
338  cur.second->GetShipRef()->GetPilot()->SendNotifyMsg("Your %s deactivates because there was an error in it's processing. Ref: ServerError 06428.",\
339  cur.second->GetSelf()->name());
340  cur.second->CancelOnError();
341  continue;
342  }
343 
344  // calculate ore for this laser
345  percent = cur.first /total;
346  oreAmount = roidQuantity * percent;
347 
348  // create and add ore to cargo for this laser
349  cur.second->AddOreAndDeactivate(roidRef->typeID(), oreAmount);
350 
351  // inform pilot of asteroid depleted ...no clue if it actually works like this
352  PyTuple* tuple = new PyTuple(2);
353  tuple->SetItem(0, new PyString("MiningItemDepleted"));
354  PyDict* dict = new PyDict();
355  dict->SetItemString("modulename", new PyString(cur.second->GetSelf()->itemName()));
356  tuple->SetItem(1, dict);
357  cur.second->GetShipRef()->GetPilot()->QueueDestinyUpdate(&tuple);
358  }
359 
360  // calculate ore for this laser
361  percent = GetMiningVolume() /total;
362  // create and add ore to cargo for this laser
363  AddOreAndDeactivate(roidRef->typeID(), roidQuantity * percent, false);
364 }
#define _log(type, fmt,...)
Definition: logsys.h:124
Python string.
Definition: PyRep.h:430
Python's dictionary.
Definition: PyRep.h:719
float GetMiningVolume()
const char * name()
Python tuple.
Definition: PyRep.h:567
ModuleItemRef m_modRef
SystemEntity * m_targetSE
Definition: ActiveModule.h:78
InventoryItemRef GetSelf()
Definition: SystemEntity.h:202
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:610
void AddOreAndDeactivate(uint16 typeID, float amt, bool slave=true)
uint32 GetID()
Definition: SystemEntity.h:207
uint32 itemID() const
Definition: InventoryItem.h:98
void SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
Definition: PyRep.h:812

Here is the call graph for this function:

Here is the caller graph for this function:

uint32 MiningLaser::DoCycle ( )
virtual

Reimplemented from ActiveModule.

Definition at line 152 of file MiningLaser.cpp.

References ActiveModule::DoCycle(), m_IsInitialCycle, and ProcessCycle().

152  {
153  /* ore is dumped into hold at end of module's cycle.
154  * however, code processing runs at beginning of cycle, so this needs to 'fake' the ore acquisition to the end of cycle
155  * we accomplish this by doing nothing on first cycle, and call the processing component at beginning of each cycle after that.
156  */
157  if (m_IsInitialCycle) {
158  m_IsInitialCycle = false;
159  } else {
160  ProcessCycle();
161  }
162 
163  return ActiveModule::DoCycle();
164 }
void ProcessCycle(bool abort=false)
virtual uint32 DoCycle()
bool m_IsInitialCycle
Definition: MiningLaser.h:55

Here is the call graph for this function:

virtual MiningLaser* MiningLaser::GetMiningModule ( )
inlinevirtual

Reimplemented from GenericModule.

Definition at line 24 of file MiningLaser.h.

24 { return this; }
float MiningLaser::GetMiningVolume ( )

Definition at line 388 of file MiningLaser.cpp.

References AttrMiningAmount, AttrSpecialtyMiningAmount, EvilNumber::get_float(), GenericModule::GetAttribute(), SystemEntity::GetGroupID(), ShipItem::GetPilot(), Client::GetShipSE(), GenericModule::m_chargeLoaded, m_crystalRoidGrp, GenericModule::m_shipRef, and ActiveModule::m_targetSE.

Referenced by CanActivate(), Depleted(), and ProcessCycle().

389 {
390  float cycleVol(GetAttribute(AttrMiningAmount).get_float());
391  if (m_chargeLoaded)
394 
395  // fleet involvement enhances mining amount using MiningForeman of highest member (3%/lvl)
396  // this should apply to modules/ship when boost activated, but this is easier at this time.
397  // downside is client will have the original, lower cycle amount as this isnt set in module (but should be)
398  ShipSE* pShip(m_shipRef->GetPilot()->GetShipSE());
399  if (pShip != nullptr)
400  if (pShip->IsBoosted())
401  cycleVol *= (1 + (0.03f * pShip->GetMiningBoostAmount())); // 3% increase/level
402 
403  return cycleVol;
404 }
Definition: Ship.h:301
ShipItemRef m_shipRef
SystemEntity * m_targetSE
Definition: ActiveModule.h:78
uint32 GetGroupID()
Definition: SystemEntity.h:204
ShipSE * GetShipSE()
Definition: Client.h:168
virtual Client * GetPilot()
Definition: Ship.h:72
uint16 m_crystalRoidGrp
Definition: MiningLaser.h:61
float get_float()
Definition: EvilNumber.cpp:184
EvilNumber GetAttribute(uint32 attrID)
Definition: GenericModule.h:53

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool MiningLaser::IsMiningLaser ( ) const
inlinevirtual

Reimplemented from GenericModule.

Definition at line 25 of file MiningLaser.h.

25 { return true; }
void MiningLaser::LoadCharge ( InventoryItemRef  charge)
virtual

Reimplemented from ActiveModule.

Definition at line 52 of file MiningLaser.cpp.

References AttrCrystalVolatilityChance, AttrCrystalVolatilityDamage, AttrDamage, AttrSpecialisationAsteroidGroup, RefPtr< X >::get(), EvilNumber::get_float(), InventoryItem::GetAttribute(), ActiveModule::LoadCharge(), GenericModule::m_chargeRef, m_crystalDmg, m_crystalDmgAmount, m_crystalDmgChance, and m_crystalRoidGrp.

53 {
55 
56  if (m_chargeRef.get() == nullptr)
57  return;
58 
63  //AttrUsageDamagePercent
64 }
float m_crystalDmgChance
Definition: MiningLaser.h:59
InventoryItemRef m_chargeRef
float m_crystalDmg
Definition: MiningLaser.h:57
X * get() const
Definition: RefPtr.h:213
float m_crystalDmgAmount
Definition: MiningLaser.h:58
EvilNumber GetAttribute(const uint16 attrID) const
virtual void LoadCharge(InventoryItemRef charge)
uint16 m_crystalRoidGrp
Definition: MiningLaser.h:61
float get_float()
Definition: EvilNumber.cpp:184

Here is the call graph for this function:

void MiningLaser::ProcessCycle ( bool  abort = false)
protected
Todo:
verify for ice and gas

Definition at line 183 of file MiningLaser.cpp.

References _log, AttrDamage, AttrDuration, AttrQuantity, AttrRadius, AttrVolume, ShipItem::CargoFull(), ActiveModule::DeactivateCycle(), InventoryItem::Delete(), SystemEntity::Delete(), TargetManager::Depleted(), flagNone, RefPtr< X >::get(), EvilNumber::get_float(), GenericModule::GetAttribute(), SystemEntity::GetID(), GetMiningVolume(), InventoryItem::GetMyInventory(), ShipItem::GetPilot(), ActiveModule::GetRemainingCycleTimeMS(), ShipItem::GetRemainingVolumeByFlag(), SystemEntity::GetSelf(), Inventory::HasAvailableSpace(), InventoryItem::itemID(), locTemp, GenericModule::m_chargeLoaded, GenericModule::m_chargeRef, m_crystalDmg, m_crystalDmgAmount, m_crystalDmgChance, m_gMiner, m_holdFlag, m_iMiner, GenericModule::m_modRef, GenericModule::m_shipRef, ActiveModule::m_targetSE, MakeRandomFloat(), InventoryItem::name(), Stat::oreMined, InventoryItem::ownerID(), ShipItem::RemoveItem(), ActiveModule::RemoveTarget(), SafeDelete(), sDataMgr, Client::SendNotifyMsg(), InventoryItem::SetAttribute(), sItemFactory, sStatMgr, and SystemEntity::TargetMgr().

Referenced by DeactivateCycle(), and DoCycle().

184 {
185  float cycleVol(GetMiningVolume());
186 
187  InventoryItemRef roidRef(m_targetSE->GetSelf());
188  // verify gas clouds have volume attr.
189  float oreVolume(roidRef->GetAttribute(AttrVolume).get_float());
190 
191  if ((cycleVol < oreVolume) or (cycleVol <= 0) or (oreVolume <= 0)) {
192  _log(MINING__ERROR, "%s(%u) - Mining Laser could not extract ore from %s(%u)", m_modRef->name(), m_modRef->itemID(), roidRef->name(), m_targetSE->GetID() );
193  m_shipRef->GetPilot()->SendNotifyMsg("Your %s deactivates because there was an error in it's processing. Ref: ServerError 06428.", m_modRef->name());
195  return;
196  }
197 
198  float oreAmount((cycleVol /oreVolume));
199  if (abort) {
200  // adjust amount AND cycle for partial cycle
201  float delta = 1 - (GetRemainingCycleTimeMS() / GetAttribute(AttrDuration).get_float());
202  cycleVol *= delta;
203  oreAmount *= delta;
204  if (m_iMiner or m_gMiner)
205  oreAmount = floor(oreAmount);
206  _log(MINING__DEBUG, "ProcessCycle(abort) - cycleVol:%.2f, oreAmount:%.2f, delta:%.5f", cycleVol, oreAmount, delta);
207  }
208 
209  float roidQuantity(roidRef->GetAttribute(AttrQuantity).get_float());
210  if (oreAmount > roidQuantity)
211  oreAmount = roidQuantity;
212 
213  float remainingCargoVolume(m_shipRef->GetRemainingVolumeByFlag(m_holdFlag));
214  if (remainingCargoVolume < cycleVol) {
215  // cargohold is full. this module will fill to available volume and trash the rest
216  if (remainingCargoVolume > oreVolume) {
217  oreAmount = remainingCargoVolume /oreVolume;
218  } else {
219  oreAmount = 0;
220  }
221  // check for other lasers running, and deactivate them also.
222  // the ship will tell all miners the current hold is full, and they automagically deactivate.
223  // this is a feature.
224  m_shipRef->CargoFull();
225 
226  // explicitly calling base class method here will negate the possibility of running a loop from DeactivateCycle override and overfilling cargo (elusive error)
228  if (!abort) // dont notify client if they deactivated laser
229  m_shipRef->GetPilot()->SendNotifyMsg("Your %s deactivates because your cargohold is full.", m_modRef->name());
230  }
231 
232  _log(MINING__DEBUG, "ProcessCycle(%s) - cycleVol:%.2f, roidQuantity:%.2f, remainingCargoVolume:%.2f/%.2f, oreAmount:%.2f", \
233  (abort?"true":"false"), cycleVol, roidQuantity, remainingCargoVolume, (remainingCargoVolume -cycleVol), oreAmount);
234 
235  if (oreAmount <= 0)
236  return;
237 
238  roidQuantity -= oreAmount;
239  _log(MINING__TRACE, "new roidQuantity %.3f", roidQuantity);
240 
241  if (roidQuantity > 0.0f) {
242  roidRef->SetAttribute(AttrQuantity, roidQuantity);
243  // do not reset ice radius (our huge-ass chunks will probably never expire)
244  if (!m_iMiner) {
245  /* reversing the radius-to-quantity formula, we get radius = exp((quantity + 112404.8) /25000) */
246  double radius = exp((roidQuantity + 112404.8) /25000);
247  // need to update players in bubble of this change. not sure how yet
248  roidRef->SetAttribute(AttrRadius, radius);
249  }
250  } else {
251  //rock is depleted.
252  // this will get all active miners on depleted rock and set mined amount accordingly for each.
253  m_targetSE->TargetMgr()->Depleted(this);
254  SystemEntity* pSE(m_targetSE);
256  // m_targetSE is null after above call returns
257  pSE->Delete();
258  SafeDelete(pSE);
259  return;
260  }
261 
262  // at this point, there is still plenty of ore in rock
263  ItemData idata(roidRef->typeID(), m_shipRef->ownerID(), locTemp, flagNone, oreAmount);
264  InventoryItemRef oRef(sItemFactory.SpawnItem(idata));
265  if (oRef.get() == nullptr) {
266  _log(MINING__ERROR, "Could not create mined ore for %s(%u)", m_shipRef->name(), m_shipRef->itemID() );
267  return;
268  }
269 
270  bool oreError(true);
272  oreError = false;
273  oRef->MergeTypesInCargo(m_shipRef.get(), m_holdFlag);
274  }
275 
276  // add data to StatisticMgr
277  sStatMgr.Add(Stat::oreMined, cycleVol);
278 
279  if (oreError and !abort) {
280  m_shipRef->GetPilot()->SendNotifyMsg("Your %s deactivates as it couldn't add the %s to your %s.", \
281  m_modRef->name(), oRef->name(), sDataMgr.GetFlagName(m_holdFlag));
282  _log(MINING__ERROR, "Could not add ore to hold for %s(%u)", m_shipRef->name(), m_shipRef->itemID() );
284  return;
285  }
286 
287  if (!m_chargeLoaded or (m_chargeRef.get() == nullptr))
288  return;
289 
290  if (MakeRandomFloat(0,1) < m_crystalDmgChance) {
292  if (m_crystalDmg > 0.99f) {
293  m_shipRef->GetPilot()->SendNotifyMsg("Your %s deactivates due to the destruction of it's %s.", \
294  m_modRef->name(), m_chargeRef->name());
295  InventoryItemRef chargeRef(m_chargeRef); // make a copy of charge's item ref, as m_chargeRef = NULL after next call returns
297  chargeRef->Delete();
298  } else {
300  }
301  }
302 }
#define sStatMgr
Definition: StatisticMgr.h:68
#define _log(type, fmt,...)
Definition: logsys.h:124
uint32 ownerID() const
Definition: InventoryItem.h:99
float GetMiningVolume()
void Depleted(MiningLaser *pMod)
bool HasAvailableSpace(EVEItemFlags flag, InventoryItemRef iRef) const
Definition: Inventory.cpp:625
void CargoFull()
Definition: Ship.cpp:1335
virtual void RemoveTarget(SystemEntity *pSE)
double MakeRandomFloat(double low, double high)
Generates random real from interval [low; high].
Definition: misc.cpp:114
uint32 GetRemainingCycleTimeMS()
Definition: ActiveModule.h:94
const char * name()
void SendNotifyMsg(const char *fmt,...)
Definition: Client.cpp:2776
TargetManager * TargetMgr()
Definition: SystemEntity.h:197
ModuleItemRef m_modRef
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
Definition: SafeMem.h:83
float m_crystalDmgChance
Definition: MiningLaser.h:59
ShipItemRef m_shipRef
SystemEntity * m_targetSE
Definition: ActiveModule.h:78
EVEItemFlags m_holdFlag
Definition: MiningLaser.h:63
InventoryItemRef GetSelf()
Definition: SystemEntity.h:202
InventoryItemRef m_chargeRef
float m_crystalDmg
Definition: MiningLaser.h:57
void SetAttribute(uint16 attrID, int num, bool notify=true)
uint32 GetID()
Definition: SystemEntity.h:207
X * get() const
Definition: RefPtr.h:213
float m_crystalDmgAmount
Definition: MiningLaser.h:58
bool m_iMiner
Definition: MiningLaser.h:54
virtual Client * GetPilot()
Definition: Ship.h:72
virtual void RemoveItem(InventoryItemRef iRef)
Definition: Ship.cpp:532
#define sItemFactory
Definition: ItemFactory.h:165
float get_float()
Definition: EvilNumber.cpp:184
float GetRemainingVolumeByFlag(EVEItemFlags flag) const
Definition: Ship.cpp:338
Inventory * GetMyInventory()
Definition: InventoryItem.h:91
EvilNumber GetAttribute(uint32 attrID)
Definition: GenericModule.h:53
virtual void DeactivateCycle(bool abort=false)
bool m_gMiner
Definition: MiningLaser.h:54
uint32 itemID() const
Definition: InventoryItem.h:98
#define sDataMgr

Here is the call graph for this function:

Here is the caller graph for this function:

void MiningLaser::UnloadCharge ( )
virtual

Reimplemented from ActiveModule.

Definition at line 66 of file MiningLaser.cpp.

References _log, m_crystalDmg, m_crystalDmgAmount, m_crystalDmgChance, m_crystalRoidGrp, GenericModule::m_modRef, InventoryItem::name(), and ActiveModule::UnloadCharge().

67 {
68  _log(MODULE__TRACE, "%s calling ML::UnloadCharge()", m_modRef->name());
69  //AttrUnfitCapCost
70  m_crystalDmg = 0;
71  m_crystalRoidGrp = 0;
74 
76 }
#define _log(type, fmt,...)
Definition: logsys.h:124
const char * name()
ModuleItemRef m_modRef
float m_crystalDmgChance
Definition: MiningLaser.h:59
virtual void UnloadCharge()
float m_crystalDmg
Definition: MiningLaser.h:57
float m_crystalDmgAmount
Definition: MiningLaser.h:58
uint16 m_crystalRoidGrp
Definition: MiningLaser.h:61

Here is the call graph for this function:

Member Data Documentation

float MiningLaser::m_crystalDmg
private

Definition at line 57 of file MiningLaser.h.

Referenced by CanActivate(), LoadCharge(), MiningLaser(), ProcessCycle(), and UnloadCharge().

float MiningLaser::m_crystalDmgAmount
private

Definition at line 58 of file MiningLaser.h.

Referenced by CanActivate(), LoadCharge(), MiningLaser(), ProcessCycle(), and UnloadCharge().

float MiningLaser::m_crystalDmgChance
private

Definition at line 59 of file MiningLaser.h.

Referenced by CanActivate(), LoadCharge(), MiningLaser(), ProcessCycle(), and UnloadCharge().

uint16 MiningLaser::m_crystalRoidGrp
private

Definition at line 61 of file MiningLaser.h.

Referenced by CanActivate(), GetMiningVolume(), LoadCharge(), MiningLaser(), and UnloadCharge().

bool MiningLaser::m_dcMiner
private

Definition at line 54 of file MiningLaser.h.

Referenced by CanActivate(), and MiningLaser().

bool MiningLaser::m_gMiner
private

Definition at line 54 of file MiningLaser.h.

Referenced by CanActivate(), MiningLaser(), and ProcessCycle().

EVEItemFlags MiningLaser::m_holdFlag
private
bool MiningLaser::m_iMiner
private

Definition at line 54 of file MiningLaser.h.

Referenced by CanActivate(), MiningLaser(), and ProcessCycle().

bool MiningLaser::m_IsInitialCycle
private

Definition at line 55 of file MiningLaser.h.

Referenced by CanActivate(), DoCycle(), and MiningLaser().

bool MiningLaser::m_rMiner
private

Definition at line 54 of file MiningLaser.h.

Referenced by CanActivate(), and MiningLaser().


The documentation for this class was generated from the following files: