70 std::map<SystemEntity*, TargetEntry*>::iterator itr =
m_targets.begin();
72 if ((itr->first ==
nullptr) or (itr->second ==
nullptr)) {
76 switch (itr->second->state) {
82 if (itr->second->timer.Check(
false)) {
83 itr->second->timer.Disable();
85 _log(TARGET__TRACE,
"%s(%u) has finished locking %s(%u)", \
88 itr->first->TargetMgr()->TargetedByLocked(
mySE);
108 m_targetedBy.clear();
114 codelog(TARGET__ERROR,
"StartTargeting() called by pilot-less ship %s(%u) to target %s(%u)", \
121 _log(TARGET__DEBUG,
" %s(%u): Told to target %s(%u), but we are already targeting them. Ignoring request.", \
126 uint8 maxLockedTargets = 1;
129 if (maxCharTargets > 0)
130 if (maxLockedTargets < maxCharTargets)
131 maxLockedTargets = maxCharTargets;
134 if (maxShipTargets > 0)
135 if (maxLockedTargets > maxShipTargets)
136 maxLockedTargets = maxShipTargets;
138 if (
m_targets.size() >= maxLockedTargets) {
139 mySE->
GetPilot()->
SendNotifyMsg(
"Your ship and skills combination can only handle %u targets at a time.", maxLockedTargets);
140 _log(TARGET__DEBUG,
" %s(%u): Told to target %s(%u), but we already have max targets of %u. Ignoring request.", \
172 double targetDistance = rangeToTarget.
length();
175 if (targetDistance > maxTargetRange) {
176 mySE->
GetPilot()->
SendNotifyMsg(
"Your ship and skills combination can only target to %.0f meters. %s is %.0f meters away.", \
177 maxTargetRange, tSE->
GetName(), targetDistance);
178 _log(TARGET__DEBUG,
" %s(%u): Told to target %s(%u), but they are too far away. Ignoring request.", \
192 _log(TARGET__INFO,
"Pilot %s in %s(%u) started targeting %s(%u) (%.2fs lock time)", \
206 _log(TARGET__DEBUG,
" %s(%u): Told to target %s(%u), but we are already targeting them. Ignoring request.", \
211 if (
m_targets.size() >= maxLockedTargets){
212 _log(TARGET__DEBUG,
" %s(%u): Told to target %s(%u), but we already have max targets. Ignoring request.", \
218 _log(TARGET__TRACE,
" %s(%u): Told to target %s(%u), but they are too far away. Begin Approaching.", \
230 _log(TARGET__INFO,
"NPC %s(%u) started targeting %s(%u) (%.2fs lock time)", \
241 std::map<SystemEntity*, TargetEntry*>::iterator itr =
m_targets.find(tSE);
251 _log(TARGET__TRACE,
"RemoveTarget: %s(%u) has removed target %s(%u).", \
265 _log(TARGET__TRACE,
"ClearTarget: %s(%u) has cleared target %s(%u).", \
276 module = cur->second;
289 _log(TARGET__TRACE,
"ClearAllTargets: %s(%u) has cleared all targeting information.",
mySE->
GetName(),
mySE->
GetID());
297 if (cur.first->TargetMgr() !=
nullptr)
298 cur.first->TargetMgr()->TargetedByLost(
mySE);
300 _log(TARGET__TRACE,
"ClearTargets() - %s(%u) has cleared target %s(%u).",
314 std::vector<SystemEntity *> ToNotify;
318 ToNotify.push_back(cur.first);
319 _log(TARGET__TRACE,
"ClearFrom() - %s(%u) has added %s(%u) to delete list.", \
323 m_targetedBy.clear();
325 for (
auto cur : ToNotify)
326 if (cur->TargetMgr() !=
nullptr)
327 cur->TargetMgr()->TargetLost(
mySE);
331 std::map<SystemEntity *, TargetEntry *>::iterator itr =
m_targets.find(tSE);
355 te.targetID = tSE->
GetID();
357 Notify_OnMultiEvent multi;
358 multi.events =
new PyList();
359 multi.events->AddItem(te.Encode());
365 _log(TARGET__TRACE,
"%s(%u) has been locked by %s(%u)", \
372 std::map<SystemEntity *, TargetedByEntry *>::iterator itr =
m_targetedBy.find(pSE);
374 _log(TARGET__DEBUG,
"%s(%u) TargetByLost() - Tried to notify %s(%u) of target lost, but they did not have us targeted.", \
379 _log(TARGET__TRACE,
"%s(%u) is no longer locked by %s(%u)", \
401 _log(TARGET__TRACE,
"%s(%u) - adding target %s(%u).", \
408 te.targetID = tSE->
GetID();
411 OnDamageStateChange odsc;
412 odsc.entityID = tSE->
GetID();
421 _log(TARGET__INFO,
"Cannot add %s(%u) to %s(%u)'s locked list: they're already in there.", \
426 _log(TARGET__TRACE,
"%s(%u) - %s(%u) has started target lock on me.", \
437 te.mode =
"otheradd";
438 te.targetID = tSE->
GetID();
439 Notify_OnMultiEvent multi;
440 multi.events =
new PyList();
441 multi.events->AddItem(te.Encode());
447 _log(TARGET__TRACE,
"%s(%u) - %s(%u) has lost target lock on me.", \
452 te.mode =
"otherlost";
453 te.targetID = tSE->
GetID();
456 Notify_OnMultiEvent multi;
457 multi.events =
new PyList();
458 multi.events->AddItem(te.Encode());
470 Notify_OnMultiEvent multi;
471 multi.events =
new PyList();
472 multi.events->AddItem(te.Encode());
489 std::map<SystemEntity *, TargetEntry *>::iterator itr =
m_targets.begin();
502 std::map<SystemEntity *, TargetEntry *>::const_iterator itr =
m_targets.begin();
514 std::map<SystemEntity*, TargetedByEntry*>::const_iterator itr =
m_targetedBy.begin();
527 std::map<SystemEntity*, TargetEntry*>::const_iterator itr =
m_targets.begin();
529 if (itr->first->GetID() != targetID)
533 _log(TARGET__INFO,
"Found target %u, but it is not locked.", targetID);
536 _log(TARGET__INFO,
"Found target %u: %s (nl? %s)", targetID, itr->first->GetName(), need_locked?
"yes":
"no");
539 _log(TARGET__INFO,
"Unable to find target %u (nl? %s)", targetID, need_locked?
"yes":
"no");
545 _log(TARGET__INFO,
"Adding %s:%s to %s's activeModule list.", \
557 _log(TARGET__INFO,
"Removing the %s on %s from %s's activeModule list.", \
564 _log(TARGET__INFO,
"%s(%u) has been destroyed. %u modules, %u targets, and %u targeters in maps.", \
567 std::string effect =
"TargetDestroyed";
584 module = cur->second;
627 std::multimap<float, MiningLaser*> mMap;
629 std::map<uint32, ActiveModule*>::iterator itr =
m_modules.begin();
631 mMap.emplace(itr->second->GetMiningModule()->GetMiningVolume(), itr->second->GetMiningModule());
654 float time = ( 40000 /(scanRes * std::pow(
asinh(sigRad), 2)));
674 if (distance > 85000)
677 float disMod = distance /10000;
680 time += (disMod * 0.1f);
688 if (cur.first->HasPilot()) {
690 cur.first->GetPilot()->QueueDestinyEvent(event);
697 if (cur.first->HasPilot()) {
699 cur.first->GetPilot()->QueueDestinyUpdate(update);
705 std::ostringstream str;
707 str <<
"Targets: <br>";
708 str <<
" *NONE*<br>";
711 str <<
"Targets: <br>";
714 str <<
" " << cur.first->GetName();
715 str <<
" (" << cur.first->GetID() <<
") <br>";
721 str <<
"Targeted by: <br>";
722 str <<
" *NONE*<br>";
725 str <<
"Targeted by: <br>";
728 str <<
" " << cur.first->GetName();
729 str <<
" (" << cur.first->GetID() <<
") <br>";
734 str <<
"Active Modules: (ship:module)<br>";
741 str <<
" " << cur.second->GetShipRef()->itemName();
742 str <<
":" << cur.second->GetSelf()->itemName() <<
"<br>";
757 _log(TARGET__DUMP,
" No Targets");
760 cur.second->Dump(cur.first);
763 _log(TARGET__DUMP,
" No Targeters");
766 cur.second->Dump(cur.first);
769 _log(TARGET__DUMP,
" Active Modules: (ship:module(moduleID))");
771 _log(TARGET__DUMP,
" *NONE*");
774 _log(TARGET__DUMP,
"\t\t %s: %s(%u)", cur.second->GetShipRef()->name(), cur.second->GetSelf()->name(), cur.second->itemID());
780 _log(TARGET__DUMP,
" Targeting %s(%u): %s - Timer Running with %ums remaining.", \
797 default:
return "Invalid";
811 default:
return "Invalid";
#define sConfig
A macro for easier access to the singleton.
PyList * GetTargets() const
void QueueUpdate(PyTuple **up) const
void SendNotification(const PyAddress &dest, EVENotificationStream ¬i, bool seq=true)
void TargetedAdd(SystemEntity *tSE)
GaExpInl GaFloat length() const
#define _log(type, fmt,...)
virtual Prospector * GetProspectModule()
void ClearAllTargets(bool notify=true)
void ClearTarget(SystemEntity *tSE)
bool HasAttribute(const uint16 attrID) const
static const char * GetModeName(uint8 mode)
TargetManager(SystemEntity *self)
virtual void TargetLost(SystemEntity *who)
const GPoint & position() const
void Depleted(MiningLaser *pMod)
void QueueDestinyEvent(PyTuple **multiEvent)
void Dump(SystemEntity *pSE) const
virtual Client * GetPilot()
virtual StructureSE * GetOutpostSE()
static const char * GetStateName(uint8 state)
void ClearTargets(bool notify=true)
void SendNotifyMsg(const char *fmt,...)
TargetManager * TargetMgr()
CharacterRef GetChar() const
uint32 GetRemainingTime() const
const GPoint & GetPosition() const
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
void TargetLost(SystemEntity *tSE)
void TargetAdded(SystemEntity *tSE)
PyList * GetTargeters() const
#define is_log_enabled(type)
std::map< SystemEntity *, TargetEntry * > m_targets
void TargetedLost(SystemEntity *tSE)
SystemEntity * GetFirstTarget(bool need_locked=false)
DestinyManager * DestinyMgr()
void RemoveTarget(SystemEntity *tSE)
InventoryItemRef GetSelf()
PyTuple * MakeDamageState()
#define codelog(type, fmt,...)
virtual bool IsContainerSE()
virtual bool IsMiningLaser() const
void RemoveTargetModule(ActiveModule *pMod)
SystemEntity * GetTarget(uint32 targetID, bool need_locked=true) const
void EntityRemoved(SystemEntity *pSE)
std::map< SystemEntity *, TargetedByEntry * > m_targetedBy
void AddItemInt(int32 intval)
virtual void AbortCycle()
const char * GetName() const
const char * GetName() const
void QueueDestinyUpdate(PyTuple **update, bool DoPackage=false, bool IsSetState=false)
float TimeToLock(ShipItemRef sRef, SystemEntity *tSE) const
void Depleted(std::multimap< float, MiningLaser * > &mMap)
std::map< uint32, ActiveModule * > m_modules
virtual bool IsAsteroidSE()
std::string TargetList(uint16 &length, uint16 &count)
virtual TowerSE * GetTowerSE()
virtual void TargetedAdd(SystemEntity *who)
virtual bool IsDeployableSE()
void TargetedByLost(SystemEntity *tSE)
EvilNumber GetAttribute(const uint16 attrID) const
int8 GetSkillLevel(uint16 skillTypeID, bool zeroForNotInjected=true) const
void QueueEvent(PyTuple **up) const
virtual bool IsInanimateSE()
GaExpInl GaFloat distance(const GaVec3 &oth) const
void AddTargetModule(ActiveModule *pMod)
virtual void Deactivate(std::string effect="")
virtual TCUSE * GetTCUSE()
virtual bool IsSentrySE()
virtual IHubSE * GetIHubSE()
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 kick all and halt server immediate command list all items in current location s gives list of cargo contents and volumes in all holds list current session values show current ship DNA show current objects in their destiny state
void TargetedByLocked(SystemEntity *tSE)
void Dump(SystemEntity *pSE) const
bool IsTargetedBy(SystemEntity *pSE)
bool StartTargeting(SystemEntity *tSE, ShipItemRef sRef)
virtual bool IsOutpostSE()
void Start(uint32 setTimerTime=0, bool changeResetTimer=true)