#include "MW4Headers.hpp" #include "AI_RadioSquad.hpp" #include "ai.hpp" using namespace MW4AI; using namespace MW4AI::Squad; using namespace MechWarrior4; const Stuff::Scalar isshot_propagation_delay = 2.0f; RadioSquad::RadioSquad() { } RadioSquad::~RadioSquad() { } ID RadioSquad::GetID() const { return (GROUPAI_RADIOSQUAD); } void RadioSquad::Update(MechWarrior4::Group& group, MechWarrior4::CombatAI& combat_ai) { UpdateIsShotCommunications(group); } void RadioSquad::NotifyShot(MechWarrior4::Group& group, Adept::ObjectID id) { is_shot_notifier n(id,gos_GetElapsedTime() + isshot_propagation_delay); is_shot_notifier_list::iterator found = m_IsShotNotifiers.find(n.first); if ((found == m_IsShotNotifiers.end()) || ((*found).second > n.second)) { if (found != m_IsShotNotifiers.end()) { m_IsShotNotifiers.erase(found); } m_IsShotNotifiers.insert(n); } } void RadioSquad::NotifyShotFired(MechWarrior4::Group& group, const Stuff::Line3D& line, MechWarrior4::MWObject& at_who, MechWarrior4::MWObject& shooter) { } void RadioSquad::UpdateIsShotCommunications(const Group& group) { {for (is_shot_notifier_list::iterator i = m_IsShotNotifiers.begin(); i != m_IsShotNotifiers.end(); ++i) { if ((*i).second < gos_GetElapsedTime()) { {for (Group::element_list::const_iterator i_group = group.GetElements().begin(); i_group != group.GetElements().end(); ++i_group) { Adept::Entity* entity = group.IDToEntity(*i_group); if ((entity != 0) && (entity->IsDerivedFrom(MWObject::DefaultData) == true)) { MWObject* mwobject = Cast_Object(MWObject*,entity); if (mwobject->GetAI() != 0) { mwobject->GetAI()->NotifyShot((*i).first,false); } } }} m_IsShotNotifiers.erase(i); UpdateIsShotCommunications(group); return; } }} } void RadioSquad::NotifyMemberAdded(MechWarrior4::Group& group, MechWarrior4::MWObject& who) { } void RadioSquad::NotifyMemberRemoved(MechWarrior4::Group& group, MechWarrior4::MWObject& who) { } void RadioSquad::SetEntityToIgnore(Adept::ObjectID objectid) { }