\hypertarget{classDefenseSquadTask}{\section{\-Defense\-Squad\-Task \-Class \-Reference}
\label{classDefenseSquadTask}\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}}
}


{\ttfamily \#include $<$\-Defense\-Squad.\-h$>$}



\-Inheritance diagram for \-Defense\-Squad\-Task\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=550pt]{classDefenseSquadTask__inherit__graph}
\end{center}
\end{figure}


\-Collaboration diagram for \-Defense\-Squad\-Task\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classDefenseSquadTask__coll__graph}
\end{center}
\end{figure}
\subsection*{\-Public \-Member \-Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classDefenseSquadTask_a179779e7da4fb08f171f707bf338aad3}{\-Defense\-Squad\-Task} (\hyperlink{BuildOrder_8h_a542f03dc7d3ea96b4a75927437d0fd4a}{\-Army\-Behaviour} behaviour)
\item 
virtual int \hyperlink{classDefenseSquadTask_af49bdc50795d90470280709317614d09}{get\-End\-Time} () const 
\item 
virtual int \hyperlink{classDefenseSquadTask_af78fabbca72444bc2f813d1c7760fea2}{get\-End\-Time} (\hyperlink{Interface_8h_ab8fbb9e601c27f783b69f16c5a1fd40a}{\-Unit} unit) const 
\item 
virtual int \hyperlink{classDefenseSquadTask_a9cc7e95df4baada379a70ad88fbc7381}{get\-Priority} (\hyperlink{Interface_8h_ab8fbb9e601c27f783b69f16c5a1fd40a}{\-Unit} unit) const 
\item 
virtual \hyperlink{Interface_8h_a7ae5d695cf6b7c013c5ad30d124278e0}{\-Position} \hyperlink{classDefenseSquadTask_ac10d321e0ac8b20871894481c0a91042}{get\-Start\-Location} (\hyperlink{Interface_8h_ab8fbb9e601c27f783b69f16c5a1fd40a}{\-Unit} unit) const 
\item 
virtual \hyperlink{Interface_8h_a7ae5d695cf6b7c013c5ad30d124278e0}{\-Position} \hyperlink{classDefenseSquadTask_ab69c783a5436d22b4df17f7a7b1ae5c0}{get\-End\-Location} (\hyperlink{Interface_8h_ab8fbb9e601c27f783b69f16c5a1fd40a}{\-Unit} unit) const 
\item 
virtual bool \hyperlink{classDefenseSquadTask_adaff896d559a581e312808f1299a084f}{pre\-Update} ()
\item 
virtual bool \hyperlink{classDefenseSquadTask_a614bbed5ff82714af0b85f5932a662cd}{update} ()
\item 
virtual bool \hyperlink{classDefenseSquadTask_afedd613defc8ccdc29d132302cde9a0b}{waiting\-For\-Unit} (\hyperlink{Interface_8h_ab8fbb9e601c27f783b69f16c5a1fd40a}{\-Unit} unit) const 
\item 
virtual void \hyperlink{classDefenseSquadTask_ad10b6dc6a5ef1833dce851adde1c85a2}{give\-Unit} (\hyperlink{Interface_8h_ab8fbb9e601c27f783b69f16c5a1fd40a}{\-Unit} unit)
\item 
virtual void \hyperlink{classDefenseSquadTask_a3f2b21c77a1c661a356d6968b0ec9554}{return\-Unit} (\hyperlink{Interface_8h_ab8fbb9e601c27f783b69f16c5a1fd40a}{\-Unit} unit)
\item 
virtual bool \hyperlink{classDefenseSquadTask_a67785d820c1cba04cf8514f596dc42d9}{morph} (\hyperlink{Interface_8h_ab8fbb9e601c27f783b69f16c5a1fd40a}{\-Unit} unit, \hyperlink{classBWAPI_1_1UnitType}{\-B\-W\-A\-P\-I\-::\-Unit\-Type} previous\-Type)
\item 
virtual \hyperlink{classUnitGroup}{\-Unit\-Group} \hyperlink{classDefenseSquadTask_a4cc09d607edf378ba167c47de266ef34}{get\-Finished\-Units} ()
\item 
virtual std\-::string \hyperlink{classDefenseSquadTask_ad9f3e2e3689e5f0fff294084fc3a7b5e}{get\-Task\-Name} () const 
\item 
virtual std\-::string \hyperlink{classDefenseSquadTask_a4422976b38a2ea8297765d9f3eebf22c}{get\-Output\-Name} () const 
\item 
unsigned int \hyperlink{classDefenseSquadTask_ae89a0d220d399c4b1b9197f7be24250a}{control\-Size} ()
\item 
virtual void \hyperlink{classDefenseSquadTask_a92f17e779b2fc4e3b4f125d30c4cf6b3}{update\-Requirements} ()
\item 
void \hyperlink{classDefenseSquadTask_a73d356bd72ecfdad65290d3fff04e1bd}{set\-Goal} (\hyperlink{classGoal}{\-Goal} goal)
\end{DoxyCompactItemize}
\subsection*{\-Private \-Attributes}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classUnitGroup}{\-Unit\-Group} \hyperlink{classDefenseSquadTask_a1eab0e3c3df092c473f119e680a6f3c4}{m\-Units}
\item 
std\-::map$<$ \hyperlink{Interface_8h_ab8fbb9e601c27f783b69f16c5a1fd40a}{\-Unit}, \hyperlink{classBehaviour}{\-Behaviour} $>$ \hyperlink{classDefenseSquadTask_a81b7f750ca19e716558205a2e2827622}{m\-Unit\-Behaviours}
\item 
int \hyperlink{classDefenseSquadTask_aaf22aa4de103692dc0161cea8f719939}{m\-Needed\-Workers}
\item 
bool \hyperlink{classDefenseSquadTask_a8fc4ea86d5cdb994ac8b768da8ad2b31}{m\-Needs\-Anti\-Air}
\item 
bool \hyperlink{classDefenseSquadTask_a1244a97a32c66bba8a10af74a0fefd3b}{m\-Needs\-Anti\-Ground}
\item 
\hyperlink{classUnitGroup}{\-Unit\-Group} \hyperlink{classDefenseSquadTask_ac8c5095873bed27c64194449a3bfbcd1}{m\-Worker\-Defenders}
\item 
\hyperlink{Interface_8h_ab8fbb9e601c27f783b69f16c5a1fd40a}{\-Unit} \hyperlink{classDefenseSquadTask_a9706aff6952022cdd3ab7d9b883e874a}{m\-Observer}
\item 
\hyperlink{classGoal}{\-Goal} \hyperlink{classDefenseSquadTask_a9ef107b1b32cae456cc1ce58a1a8dc29}{m\-Defense\-Goal}
\end{DoxyCompactItemize}


\subsection{\-Detailed \-Description}


\-Definition at line 8 of file \-Defense\-Squad.\-h.



\subsection{\-Constructor \& \-Destructor \-Documentation}
\hypertarget{classDefenseSquadTask_a179779e7da4fb08f171f707bf338aad3}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}}
\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{\-Defense\-Squad\-Task}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Defense\-Squad\-Task\-::\-Defense\-Squad\-Task} (
\begin{DoxyParamCaption}
\item[{{\bf \-Army\-Behaviour}}]{behaviour}
\end{DoxyParamCaption}
)}}\label{classDefenseSquadTask_a179779e7da4fb08f171f707bf338aad3}


\-Definition at line 9 of file \-Defense\-Squad.\-cpp.


\begin{DoxyCode}
        : BaseSquadTask(behaviour)
        , mNeededWorkers(0)
        , mDefenseGoal()
{
}
\end{DoxyCode}


\subsection{\-Member \-Function \-Documentation}
\hypertarget{classDefenseSquadTask_ae89a0d220d399c4b1b9197f7be24250a}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!control\-Size@{control\-Size}}
\index{control\-Size@{control\-Size}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{control\-Size}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int {\bf \-Defense\-Squad\-Task\-::control\-Size} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline, virtual\mbox{]}}}}\label{classDefenseSquadTask_ae89a0d220d399c4b1b9197f7be24250a}


\-Implements \hyperlink{classBaseSquadTask_a7c1d1bcd0976b361720ddbea1adc533e}{\-Base\-Squad\-Task}.



\-Definition at line 33 of file \-Defense\-Squad.\-h.



\-References m\-Units, and \-Unit\-Group\-::size().


\begin{DoxyCode}
{ return mUnits.size(); }
\end{DoxyCode}


\-Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classDefenseSquadTask_ae89a0d220d399c4b1b9197f7be24250a_cgraph}
\end{center}
\end{figure}


\hypertarget{classDefenseSquadTask_ab69c783a5436d22b4df17f7a7b1ae5c0}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!get\-End\-Location@{get\-End\-Location}}
\index{get\-End\-Location@{get\-End\-Location}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{get\-End\-Location}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Position} {\bf \-Defense\-Squad\-Task\-::get\-End\-Location} (
\begin{DoxyParamCaption}
\item[{{\bf \-Unit}}]{unit}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}\label{classDefenseSquadTask_ab69c783a5436d22b4df17f7a7b1ae5c0}


\-Implements \hyperlink{classBaseSquadTask_ae17b3c1f46cee12cb569e3e52ed6ee23}{\-Base\-Squad\-Task}.



\-Definition at line 67 of file \-Defense\-Squad.\-cpp.


\begin{DoxyCode}
{
        return unit->getPosition();
}
\end{DoxyCode}
\hypertarget{classDefenseSquadTask_af49bdc50795d90470280709317614d09}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!get\-End\-Time@{get\-End\-Time}}
\index{get\-End\-Time@{get\-End\-Time}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{get\-End\-Time}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf \-Defense\-Squad\-Task\-::get\-End\-Time} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}\label{classDefenseSquadTask_af49bdc50795d90470280709317614d09}


\-Implements \hyperlink{classBaseSquadTask_add66e3f4b4afb54fc0a08d55fd19c2db}{\-Base\-Squad\-Task}.



\-Definition at line 16 of file \-Defense\-Squad.\-cpp.



\-References \-Requirement\-::max\-Time.


\begin{DoxyCode}
{
        return Requirement::maxTime;
}
\end{DoxyCode}
\hypertarget{classDefenseSquadTask_af78fabbca72444bc2f813d1c7760fea2}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!get\-End\-Time@{get\-End\-Time}}
\index{get\-End\-Time@{get\-End\-Time}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{get\-End\-Time}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf \-Defense\-Squad\-Task\-::get\-End\-Time} (
\begin{DoxyParamCaption}
\item[{{\bf \-Unit}}]{unit}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}\label{classDefenseSquadTask_af78fabbca72444bc2f813d1c7760fea2}


\-Implements \hyperlink{classBaseSquadTask_a21afb9ae0447a604bf4ff0a1834dcc3d}{\-Base\-Squad\-Task}.



\-Definition at line 21 of file \-Defense\-Squad.\-cpp.



\-References \-Requirement\-::max\-Time.


\begin{DoxyCode}
{
        return Requirement::maxTime;
}
\end{DoxyCode}
\hypertarget{classDefenseSquadTask_a4cc09d607edf378ba167c47de266ef34}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!get\-Finished\-Units@{get\-Finished\-Units}}
\index{get\-Finished\-Units@{get\-Finished\-Units}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{get\-Finished\-Units}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Unit\-Group} {\bf \-Defense\-Squad\-Task\-::get\-Finished\-Units} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}\label{classDefenseSquadTask_a4cc09d607edf378ba167c47de266ef34}


\-Implements \hyperlink{classBaseSquadTask_aff3584b53267b105829931b3ab326d6d}{\-Base\-Squad\-Task}.



\-Definition at line 126 of file \-Defense\-Squad.\-cpp.



\-References m\-Units.


\begin{DoxyCode}
{
        return mUnits;
}
\end{DoxyCode}
\hypertarget{classDefenseSquadTask_a4422976b38a2ea8297765d9f3eebf22c}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!get\-Output\-Name@{get\-Output\-Name}}
\index{get\-Output\-Name@{get\-Output\-Name}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{get\-Output\-Name}]{\setlength{\rightskip}{0pt plus 5cm}virtual std\-::string {\bf \-Defense\-Squad\-Task\-::get\-Output\-Name} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline, virtual\mbox{]}}}}\label{classDefenseSquadTask_a4422976b38a2ea8297765d9f3eebf22c}


\-Implements \hyperlink{classBaseSquadTask_a1d9d5d0ab94bd3dc78f977fb224fe7a5}{\-Base\-Squad\-Task}.



\-Definition at line 31 of file \-Defense\-Squad.\-h.


\begin{DoxyCode}
{ return ""; }
\end{DoxyCode}
\hypertarget{classDefenseSquadTask_a9cc7e95df4baada379a70ad88fbc7381}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!get\-Priority@{get\-Priority}}
\index{get\-Priority@{get\-Priority}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{get\-Priority}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf \-Defense\-Squad\-Task\-::get\-Priority} (
\begin{DoxyParamCaption}
\item[{{\bf \-Unit}}]{unit}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}\label{classDefenseSquadTask_a9cc7e95df4baada379a70ad88fbc7381}


\-Implements \hyperlink{classBaseSquadTask_ae32a9a20d95ec82c3e31ba1085690731}{\-Base\-Squad\-Task}.



\-Definition at line 26 of file \-Defense\-Squad.\-cpp.



\-References m\-Needed\-Workers, m\-Needs\-Anti\-Air, m\-Needs\-Anti\-Ground, m\-Worker\-Defenders, and \-Unit\-Group\-::size().


\begin{DoxyCode}
{
        if(!unit->getType().isWorker())
        {
                bool isNeeded = false;
                if(mNeedsAntiAir && unit->canAttackAir())
                        isNeeded = true;
                
                if(mNeedsAntiGround && unit->canAttackGround())
                        isNeeded = true;

                if(isNeeded)
                        return 30;
                else
                        return 1;
        }

        int workersToReturn = int(mWorkerDefenders.size()) - mNeededWorkers;
        if(workersToReturn > 0)
        {
                int count = 1;
                for each(Unit worker in mWorkerDefenders)
                {
                        if(worker == unit)
                        {
                                if(count <= workersToReturn)
                                        return 1;
                                break;
                        }
                        ++count;
                }
        }

        return 30;
}
\end{DoxyCode}


\-Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classDefenseSquadTask_a9cc7e95df4baada379a70ad88fbc7381_cgraph}
\end{center}
\end{figure}


\hypertarget{classDefenseSquadTask_ac10d321e0ac8b20871894481c0a91042}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!get\-Start\-Location@{get\-Start\-Location}}
\index{get\-Start\-Location@{get\-Start\-Location}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{get\-Start\-Location}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Position} {\bf \-Defense\-Squad\-Task\-::get\-Start\-Location} (
\begin{DoxyParamCaption}
\item[{{\bf \-Unit}}]{unit}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}\label{classDefenseSquadTask_ac10d321e0ac8b20871894481c0a91042}


\-Implements \hyperlink{classBaseSquadTask_a2a13fe2d5a0ea4533a6aeed0e49cd513}{\-Base\-Squad\-Task}.



\-Definition at line 62 of file \-Defense\-Squad.\-cpp.


\begin{DoxyCode}
{
        return unit->getPosition();
}
\end{DoxyCode}
\hypertarget{classDefenseSquadTask_ad9f3e2e3689e5f0fff294084fc3a7b5e}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!get\-Task\-Name@{get\-Task\-Name}}
\index{get\-Task\-Name@{get\-Task\-Name}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{get\-Task\-Name}]{\setlength{\rightskip}{0pt plus 5cm}virtual std\-::string {\bf \-Defense\-Squad\-Task\-::get\-Task\-Name} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline, virtual\mbox{]}}}}\label{classDefenseSquadTask_ad9f3e2e3689e5f0fff294084fc3a7b5e}


\-Implements \hyperlink{classBaseSquadTask_a6f0014a8e6cb4c62d0d326911bf8da81}{\-Base\-Squad\-Task}.



\-Definition at line 30 of file \-Defense\-Squad.\-h.


\begin{DoxyCode}
{ return "Defense Squad"; }
\end{DoxyCode}
\hypertarget{classDefenseSquadTask_ad10b6dc6a5ef1833dce851adde1c85a2}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!give\-Unit@{give\-Unit}}
\index{give\-Unit@{give\-Unit}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{give\-Unit}]{\setlength{\rightskip}{0pt plus 5cm}void {\bf \-Defense\-Squad\-Task\-::give\-Unit} (
\begin{DoxyParamCaption}
\item[{{\bf \-Unit}}]{unit}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}\label{classDefenseSquadTask_ad10b6dc6a5ef1833dce851adde1c85a2}


\-Implements \hyperlink{classBaseSquadTask_a2476febd641eada31d338a8e0e3f2d66}{\-Base\-Squad\-Task}.



\-Definition at line 96 of file \-Defense\-Squad.\-cpp.



\-References \-Unit\-Group\-::insert(), m\-Observer, m\-Unit\-Behaviours, m\-Units, m\-Worker\-Defenders, and \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Protoss\-\_\-\-Observer.


\begin{DoxyCode}
{
        if(unit->getType() == BWAPI::UnitTypes::Protoss_Observer)
                mObserver = unit;
        else if(unit->getType().isWorker())
                mWorkerDefenders.insert(unit);

        mUnits.insert(unit);

        mUnitBehaviours[unit] = Behaviour(unit);
}
\end{DoxyCode}


\-Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classDefenseSquadTask_ad10b6dc6a5ef1833dce851adde1c85a2_cgraph}
\end{center}
\end{figure}


\hypertarget{classDefenseSquadTask_a67785d820c1cba04cf8514f596dc42d9}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!morph@{morph}}
\index{morph@{morph}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{morph}]{\setlength{\rightskip}{0pt plus 5cm}bool {\bf \-Defense\-Squad\-Task\-::morph} (
\begin{DoxyParamCaption}
\item[{{\bf \-Unit}}]{unit, }
\item[{{\bf \-B\-W\-A\-P\-I\-::\-Unit\-Type}}]{previous\-Type}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}\label{classDefenseSquadTask_a67785d820c1cba04cf8514f596dc42d9}


\-Implements \hyperlink{classBaseSquadTask_a04e71df2d72163d9ce895460f2944114}{\-Base\-Squad\-Task}.



\-Definition at line 121 of file \-Defense\-Squad.\-cpp.


\begin{DoxyCode}
{
        return false;
}
\end{DoxyCode}
\hypertarget{classDefenseSquadTask_adaff896d559a581e312808f1299a084f}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!pre\-Update@{pre\-Update}}
\index{pre\-Update@{pre\-Update}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{pre\-Update}]{\setlength{\rightskip}{0pt plus 5cm}bool {\bf \-Defense\-Squad\-Task\-::pre\-Update} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}\label{classDefenseSquadTask_adaff896d559a581e312808f1299a084f}


\-Implements \hyperlink{classBaseSquadTask_a28f5ba462879018fd5f9ff515cde1831}{\-Base\-Squad\-Task}.



\-Definition at line 72 of file \-Defense\-Squad.\-cpp.



\-References \-Task\-::has\-Ended(), and update\-Requirements().


\begin{DoxyCode}
{
        updateRequirements();

        return hasEnded();
}
\end{DoxyCode}


\-Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classDefenseSquadTask_adaff896d559a581e312808f1299a084f_cgraph}
\end{center}
\end{figure}


\hypertarget{classDefenseSquadTask_a3f2b21c77a1c661a356d6968b0ec9554}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!return\-Unit@{return\-Unit}}
\index{return\-Unit@{return\-Unit}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{return\-Unit}]{\setlength{\rightskip}{0pt plus 5cm}void {\bf \-Defense\-Squad\-Task\-::return\-Unit} (
\begin{DoxyParamCaption}
\item[{{\bf \-Unit}}]{unit}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}\label{classDefenseSquadTask_a3f2b21c77a1c661a356d6968b0ec9554}


\-Implements \hyperlink{classBaseSquadTask_a40abaa603b64db41adda1e7954b71d0b}{\-Base\-Squad\-Task}.



\-Definition at line 108 of file \-Defense\-Squad.\-cpp.



\-References \-Unit\-Group\-::erase(), m\-Observer, m\-Unit\-Behaviours, m\-Units, m\-Worker\-Defenders, and \-Static\-Units\-::nullunit.


\begin{DoxyCode}
{
        mUnits.erase(unit);

        mUnitBehaviours[unit].onDeleted();
        mUnitBehaviours.erase(unit);

        mWorkerDefenders.erase(unit);

        if(unit == mObserver)
                mObserver = StaticUnits::nullunit;
}
\end{DoxyCode}


\-Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classDefenseSquadTask_a3f2b21c77a1c661a356d6968b0ec9554_cgraph}
\end{center}
\end{figure}


\hypertarget{classDefenseSquadTask_a73d356bd72ecfdad65290d3fff04e1bd}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!set\-Goal@{set\-Goal}}
\index{set\-Goal@{set\-Goal}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{set\-Goal}]{\setlength{\rightskip}{0pt plus 5cm}void {\bf \-Defense\-Squad\-Task\-::set\-Goal} (
\begin{DoxyParamCaption}
\item[{{\bf \-Goal}}]{goal}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}\label{classDefenseSquadTask_a73d356bd72ecfdad65290d3fff04e1bd}


\-Definition at line 37 of file \-Defense\-Squad.\-h.



\-References m\-Defense\-Goal.



\-Referenced by \-Squad\-Manager\-Class\-::update().


\begin{DoxyCode}
{ mDefenseGoal = goal; }
\end{DoxyCode}


\-Here is the caller graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classDefenseSquadTask_a73d356bd72ecfdad65290d3fff04e1bd_icgraph}
\end{center}
\end{figure}


\hypertarget{classDefenseSquadTask_a614bbed5ff82714af0b85f5932a662cd}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!update@{update}}
\index{update@{update}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{update}]{\setlength{\rightskip}{0pt plus 5cm}bool {\bf \-Defense\-Squad\-Task\-::update} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}\label{classDefenseSquadTask_a614bbed5ff82714af0b85f5932a662cd}


\-Implements \hyperlink{classBaseSquadTask_a3bbed4ea7b3369947da610102db52d57}{\-Base\-Squad\-Task}.



\-Definition at line 79 of file \-Defense\-Squad.\-cpp.



\-References \-Action\-Type\-Def\-::\-Attack, \-Unit\-Group\-::empty(), \-Goal\-::get\-Action\-Type(), \-Goal\-::get\-Base(), \-Task\-::has\-Ended(), m\-Defense\-Goal, m\-Unit\-Behaviours, m\-Units, and \-B\-W\-A\-P\-I\-::\-Bullet\-Types\-::\-None.


\begin{DoxyCode}
{
        if(mDefenseGoal.getActionType() != ActionType::None)
        {
                Goal enemiesGoal(ActionType::Attack, mDefenseGoal.getBase()->
      getEnemyThreats());
                for(std::map<Unit, Behaviour>::iterator it = mUnitBehaviours.
      begin(); it != mUnitBehaviours.end(); ++it)
                        it->second.update(enemiesGoal, mUnits);
        }

        return hasEnded() && mUnits.empty();
}
\end{DoxyCode}


\-Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classDefenseSquadTask_a614bbed5ff82714af0b85f5932a662cd_cgraph}
\end{center}
\end{figure}


\hypertarget{classDefenseSquadTask_a92f17e779b2fc4e3b4f125d30c4cf6b3}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!update\-Requirements@{update\-Requirements}}
\index{update\-Requirements@{update\-Requirements}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{update\-Requirements}]{\setlength{\rightskip}{0pt plus 5cm}void {\bf \-Defense\-Squad\-Task\-::update\-Requirements} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}\label{classDefenseSquadTask_a92f17e779b2fc4e3b4f125d30c4cf6b3}


\-Reimplemented from \hyperlink{classBaseSquadTask_a22d39149694ddf1c8810e3137e7ccfd8}{\-Base\-Squad\-Task}.



\-Definition at line 131 of file \-Defense\-Squad.\-cpp.



\-References \-Task\-::add\-Requirement(), \-Requirement\-Group\-::add\-Unit\-Filter\-Requirement(), \-B\-W\-A\-P\-I\-::\-Broodwar, \-Unit\-Filter\-Flags\-::\-Can\-Attack\-Air, \-Unit\-Filter\-Flags\-::\-Can\-Attack\-Ground, \-Task\-::clear\-Requirements(), \-B\-W\-A\-P\-I\-::\-Game\-::draw\-Text\-Map(), \-Goal\-::get\-Action\-Type(), \-Goal\-::get\-Base(), \-Task\-::has\-Ended(), \-Unit\-Filter\-Flags\-::\-Is\-Army\-Unit, \-Unit\-Filter\-Flags\-::\-Is\-Complete, \-Unit\-Filter\-Flags\-::\-Is\-Worker, \-Requirement\-::max\-Time, m\-Defense\-Goal, m\-Needed\-Workers, m\-Needs\-Anti\-Air, m\-Needs\-Anti\-Ground, m\-Observer, m\-Units, m\-Worker\-Defenders, \-B\-W\-A\-P\-I\-::\-Bullet\-Types\-::\-None, \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Protoss\-\_\-\-Observer, \-Unit\-Group\-::size(), \-B\-W\-A\-P\-I\-::\-Position\-::x(), \-B\-W\-A\-P\-I\-::\-Position\-::y(), \-B\-W\-A\-P\-I\-::\-Races\-::\-Zerg, and \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Zerg\-\_\-\-Lurker.



\-Referenced by pre\-Update().


\begin{DoxyCode}
{
        clearRequirements();
        mNeededWorkers = 0;
        mNeedsAntiAir = false;
        mNeedsAntiGround = false;

        // Basic idea is to have a defense goal for each base that will take
       only the amount of units it needs to take out the threat
        // and also take workers if it cannot take out the threat with the
       number of units it has

        // This should make it do important things such as kill the threat
       while the rest of the army in the default squad stay at the choke
        // stopping any other units from entering
        if(!hasEnded() && mDefenseGoal.getActionType() != ActionType::None)
        {
                //TODO: currently picks units based on it getting units with a
       score higher than 100, if its zerg it could get zerglings in which case it wont
       have enough
                // TODO: maybe do some modification based on current units
       health
                int AirThreatScore = 0;
                int GroundThreatScore = 0;
                int GroundThreatCount = 0;
                bool needsDetection = false;
                for each(Unit enemy in mDefenseGoal.getBase()->getEnemyThreats(
      ))
                {
                        if(!needsDetection && (enemy->getType().isCloakable() |
      | enemy->getType().hasPermanentCloak() || enemy->isBurrowed() || enemy->getType(
      ) == BWAPI::UnitTypes::Zerg_Lurker))
                                needsDetection = true;

                        if(enemy->isLifted() || enemy->getType().isFlyer())
                        {
                                if(enemy->canAttackGround())
                                        AirThreatScore += enemy->getType().
      buildScore();
                                else if(enemy->getType().spaceProvided() > 0)
                                {
                                        if(enemy->getPlayer()->getRace() != 
      BWAPI::Races::Zerg)
                                                AirThreatScore += 400;
                                        else if(BWAPI::Broodwar->getFrameCount(
      ) > 24*60*6) //TODO: has the player researched drop?
                                                AirThreatScore += 250;
                                        else
                                                AirThreatScore += 50;
                                }
                                else
                                        AirThreatScore += 50;
                        }
                        else
                        {
                                ++GroundThreatCount;
                                if(enemy->canAttackGround())
                                        GroundThreatScore += enemy->getType().
      buildScore();
                                else
                                        GroundThreatScore += 50;
                        }
                }

                // Temp till defense squad is good enough to use army units and
       not just workers
                if(needsDetection)
                        return;

                if(GroundThreatScore > 0)
                        mNeedsAntiGround = true;
                if(AirThreatScore > 0)
                        mNeedsAntiAir = true;

                int AntiAirScore = 0;
                int AntiGroundScore = 0;
                for each(Unit unit in mUnits)
                {
                        if(unit->getType().isWorker())
                                continue;

                        if(unit->canAttackGround())
                        {
                                --GroundThreatCount;
                                AntiGroundScore += unit->getType().buildScore()
      ;
                        }
                        if(unit->canAttackAir())
                                AntiAirScore += unit->getType().buildScore();
                }

                mNeededWorkers = std::max((GroundThreatScore - AntiGroundScore)
       / 50, 0);
                if(mNeededWorkers == 0 && (GroundThreatScore - AntiGroundScore)
       > 0)
                        mNeededWorkers = 1;

                if(mNeededWorkers < GroundThreatCount)
                        mNeededWorkers = GroundThreatCount;

                int canAttackGroundNeeded = mNeededWorkers / 2;

                if(mNeededWorkers > 14) mNeededWorkers = 0; //If we cannot
       defend with 14 workers, don't try, probably not worth possible losses
                if(mNeededWorkers > 1) mNeededWorkers += 1;
                if(mNeededWorkers > 2) mNeededWorkers += 1;
                if(mNeededWorkers > 14) mNeededWorkers = 14;

                int workersNeeded = std::max(mNeededWorkers - int(
      mWorkerDefenders.size()), 0);

                canAttackGroundNeeded -= (int(mWorkerDefenders.size()) / 2);

                // Get as many as we can for now
                // TODO: maybe check if its our only mining base or do
       something better
                for(int i = 0; i < workersNeeded; ++i)
                {
                        RequirementGroup reqWorkers;
                        reqWorkers.addUnitFilterRequirement(30, 
      Requirement::maxTime, UnitFilter(UnitFilterFlags::type(UnitFilterFlags::IsWorker
       | UnitFilterFlags::IsComplete)), mDefenseGoal.getBase()->getCenterLocation());
                        addRequirement(reqWorkers);
                }

                // Temp till defense squad is good enough to use army units and
       not just workers
                // in the below state can cause the bots army to get too
       seperated and cause the main army to get possibly destroyed engaging a group elsewhere
                return;

                RequirementGroup reqMain;
                if(canAttackGroundNeeded > 0)
                        reqMain.addUnitFilterRequirement(30, 
      Requirement::maxTime, UnitFilter(UnitFilterFlags::type(
      UnitFilterFlags::IsArmyUnit | UnitFilterFlags::CanAttackGround | 
      UnitFilterFlags::IsComplete)), canAttackGroundNeeded, mDefenseGoal.getBase()->
      getCenterLocation());

                int canAttackAirNeeded = std::max((AirThreatScore - 
      AntiAirScore) / 100, 0);
                if(canAttackAirNeeded > 0)
                        reqMain.addUnitFilterRequirement(30, 
      Requirement::maxTime, UnitFilter(UnitFilterFlags::type(
      UnitFilterFlags::IsArmyUnit | UnitFilterFlags::CanAttackAir | 
      UnitFilterFlags::IsComplete)), canAttackAirNeeded, mDefenseGoal.getBase()->
      getCenterLocation());

                if(!mObserver && needsDetection)
                        reqMain.addUnitFilterRequirement(30, 
      Requirement::maxTime, UnitFilter(BWAPI::UnitTypes::Protoss_Observer) && 
      UnitFilter(UnitFilterFlags::IsComplete), mDefenseGoal.getBase()->
      getCenterLocation());

                addRequirement(reqMain);

                Position goalpos = mDefenseGoal.getBase()->getCenterLocation();
                const int x = goalpos.x();
                const int y = goalpos.y();

                BWAPI::Broodwar->drawTextMap(x, y, "canAttackGroundNeeded : %d"
      , canAttackGroundNeeded);
                BWAPI::Broodwar->drawTextMap(x, y+10, "canAttackAirNeeded : %d"
      , canAttackAirNeeded);
                BWAPI::Broodwar->drawTextMap(x, y+20, "workersNeeded : %d", 
      workersNeeded);
                BWAPI::Broodwar->drawTextMap(x, y+30, "workers Have : %d", int(
      mWorkerDefenders.size()));
                BWAPI::Broodwar->drawTextMap(x, y+40, "Units Have : %d", int(
      mUnits.size()));
                if(!mObserver && needsDetection)
                        BWAPI::Broodwar->drawTextMap(x, y+50, "Needs Observer")
      ;
        }
}\end{DoxyCode}


\-Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classDefenseSquadTask_a92f17e779b2fc4e3b4f125d30c4cf6b3_cgraph}
\end{center}
\end{figure}




\-Here is the caller graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classDefenseSquadTask_a92f17e779b2fc4e3b4f125d30c4cf6b3_icgraph}
\end{center}
\end{figure}


\hypertarget{classDefenseSquadTask_afedd613defc8ccdc29d132302cde9a0b}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!waiting\-For\-Unit@{waiting\-For\-Unit}}
\index{waiting\-For\-Unit@{waiting\-For\-Unit}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{waiting\-For\-Unit}]{\setlength{\rightskip}{0pt plus 5cm}bool {\bf \-Defense\-Squad\-Task\-::waiting\-For\-Unit} (
\begin{DoxyParamCaption}
\item[{{\bf \-Unit}}]{unit}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}\label{classDefenseSquadTask_afedd613defc8ccdc29d132302cde9a0b}


\-Implements \hyperlink{classBaseSquadTask_a6f5969e4520a4fd0db2ce8dd7dc2c4d0}{\-Base\-Squad\-Task}.



\-Definition at line 91 of file \-Defense\-Squad.\-cpp.


\begin{DoxyCode}
{
        return false;
}
\end{DoxyCode}


\subsection{\-Member \-Data \-Documentation}
\hypertarget{classDefenseSquadTask_a9ef107b1b32cae456cc1ce58a1a8dc29}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!m\-Defense\-Goal@{m\-Defense\-Goal}}
\index{m\-Defense\-Goal@{m\-Defense\-Goal}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{m\-Defense\-Goal}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Goal} {\bf \-Defense\-Squad\-Task\-::m\-Defense\-Goal}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classDefenseSquadTask_a9ef107b1b32cae456cc1ce58a1a8dc29}


\-Definition at line 49 of file \-Defense\-Squad.\-h.



\-Referenced by set\-Goal(), update(), and update\-Requirements().

\hypertarget{classDefenseSquadTask_aaf22aa4de103692dc0161cea8f719939}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!m\-Needed\-Workers@{m\-Needed\-Workers}}
\index{m\-Needed\-Workers@{m\-Needed\-Workers}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{m\-Needed\-Workers}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf \-Defense\-Squad\-Task\-::m\-Needed\-Workers}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classDefenseSquadTask_aaf22aa4de103692dc0161cea8f719939}


\-Definition at line 43 of file \-Defense\-Squad.\-h.



\-Referenced by get\-Priority(), and update\-Requirements().

\hypertarget{classDefenseSquadTask_a8fc4ea86d5cdb994ac8b768da8ad2b31}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!m\-Needs\-Anti\-Air@{m\-Needs\-Anti\-Air}}
\index{m\-Needs\-Anti\-Air@{m\-Needs\-Anti\-Air}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{m\-Needs\-Anti\-Air}]{\setlength{\rightskip}{0pt plus 5cm}bool {\bf \-Defense\-Squad\-Task\-::m\-Needs\-Anti\-Air}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classDefenseSquadTask_a8fc4ea86d5cdb994ac8b768da8ad2b31}


\-Definition at line 44 of file \-Defense\-Squad.\-h.



\-Referenced by get\-Priority(), and update\-Requirements().

\hypertarget{classDefenseSquadTask_a1244a97a32c66bba8a10af74a0fefd3b}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!m\-Needs\-Anti\-Ground@{m\-Needs\-Anti\-Ground}}
\index{m\-Needs\-Anti\-Ground@{m\-Needs\-Anti\-Ground}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{m\-Needs\-Anti\-Ground}]{\setlength{\rightskip}{0pt plus 5cm}bool {\bf \-Defense\-Squad\-Task\-::m\-Needs\-Anti\-Ground}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classDefenseSquadTask_a1244a97a32c66bba8a10af74a0fefd3b}


\-Definition at line 45 of file \-Defense\-Squad.\-h.



\-Referenced by get\-Priority(), and update\-Requirements().

\hypertarget{classDefenseSquadTask_a9706aff6952022cdd3ab7d9b883e874a}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!m\-Observer@{m\-Observer}}
\index{m\-Observer@{m\-Observer}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{m\-Observer}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Unit} {\bf \-Defense\-Squad\-Task\-::m\-Observer}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classDefenseSquadTask_a9706aff6952022cdd3ab7d9b883e874a}


\-Definition at line 48 of file \-Defense\-Squad.\-h.



\-Referenced by give\-Unit(), return\-Unit(), and update\-Requirements().

\hypertarget{classDefenseSquadTask_a81b7f750ca19e716558205a2e2827622}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!m\-Unit\-Behaviours@{m\-Unit\-Behaviours}}
\index{m\-Unit\-Behaviours@{m\-Unit\-Behaviours}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{m\-Unit\-Behaviours}]{\setlength{\rightskip}{0pt plus 5cm}std\-::map$<${\bf \-Unit}, {\bf \-Behaviour}$>$ {\bf \-Defense\-Squad\-Task\-::m\-Unit\-Behaviours}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classDefenseSquadTask_a81b7f750ca19e716558205a2e2827622}


\-Definition at line 41 of file \-Defense\-Squad.\-h.



\-Referenced by give\-Unit(), return\-Unit(), and update().

\hypertarget{classDefenseSquadTask_a1eab0e3c3df092c473f119e680a6f3c4}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!m\-Units@{m\-Units}}
\index{m\-Units@{m\-Units}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{m\-Units}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Unit\-Group} {\bf \-Defense\-Squad\-Task\-::m\-Units}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classDefenseSquadTask_a1eab0e3c3df092c473f119e680a6f3c4}


\-Definition at line 40 of file \-Defense\-Squad.\-h.



\-Referenced by control\-Size(), get\-Finished\-Units(), give\-Unit(), return\-Unit(), update(), and update\-Requirements().

\hypertarget{classDefenseSquadTask_ac8c5095873bed27c64194449a3bfbcd1}{\index{\-Defense\-Squad\-Task@{\-Defense\-Squad\-Task}!m\-Worker\-Defenders@{m\-Worker\-Defenders}}
\index{m\-Worker\-Defenders@{m\-Worker\-Defenders}!DefenseSquadTask@{\-Defense\-Squad\-Task}}
\subsubsection[{m\-Worker\-Defenders}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Unit\-Group} {\bf \-Defense\-Squad\-Task\-::m\-Worker\-Defenders}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classDefenseSquadTask_ac8c5095873bed27c64194449a3bfbcd1}


\-Definition at line 47 of file \-Defense\-Squad.\-h.



\-Referenced by get\-Priority(), give\-Unit(), return\-Unit(), and update\-Requirements().



\-The documentation for this class was generated from the following files\-:\begin{DoxyCompactItemize}
\item 
\-Skynet/\-Skynet/\hyperlink{DefenseSquad_8h}{\-Defense\-Squad.\-h}\item 
\-Skynet/\-Skynet/\hyperlink{DefenseSquad_8cpp}{\-Defense\-Squad.\-cpp}\end{DoxyCompactItemize}
