BWAPI
Public Member Functions
ArconZealotKillUnDetected Class Reference

#include <ArconZealotKillUnDetected.h>

Inheritance diagram for ArconZealotKillUnDetected:
Inheritance graph
[legend]
Collaboration diagram for ArconZealotKillUnDetected:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ArconZealotKillUnDetected (Unit unit)
bool update (const Goal &squadGoal, const UnitGroup &squadUnitGroup)

Detailed Description

Definition at line 6 of file ArconZealotKillUnDetected.h.


Constructor & Destructor Documentation

Definition at line 9 of file ArconZealotKillUnDetected.h.


Member Function Documentation

bool ArconZealotKillUnDetected::update ( const Goal squadGoal,
const UnitGroup squadUnitGroup 
) [virtual]

Implements SingleMicroActionBaseClass.

Definition at line 8 of file ArconZealotKillUnDetected.cpp.

References BWAPI::Orders::CompletingArchonsummon, Singleton< T >::Instance(), SingleMicroActionBaseClass::mUnit, BWAPI::UnitTypes::Protoss_Archon, BWAPI::UnitTypes::Protoss_Zealot, and BWAPI::UnitTypes::Zerg_Lurker.

{
        if(mUnit->getOrder() == BWAPI::Orders::CompletingArchonsummon)
                return true;

        const int minDistance = 32*5;

        Unit lurker;
        int lurkerDistance = std::numeric_limits<int>::max();
        for each(Unit unit in UnitTracker::Instance().selectAllEnemy())
        {
                if(unit->exists() && !unit->isDetected() && (unit->isCloaked() || unit->getType().hasPermanentCloak() || (unit->getType() == BWAPI::UnitTypes::Zerg_Lurker && unit->isBurrowed())))
                {
                        int thisDistance = mUnit->getDistance(unit);
                        if(thisDistance < lurkerDistance)
                        {
                                lurkerDistance = thisDistance;
                                lurker = unit;
                        }
                }
        }

        if(!lurker || lurkerDistance > minDistance)
                return false;

        BWAPI::UnitType typeToFind = mUnit->getType() == BWAPI::UnitTypes::Protoss_Archon ? BWAPI::UnitTypes::Protoss_Zealot : BWAPI::UnitTypes::Protoss_Archon;
        Unit other = UnitTracker::Instance().selectAllUnits(typeToFind).getClosestUnit(lurker);

        if(!other)
                return false;

        int otherDistance = other->getDistance(lurker);
        if(otherDistance > minDistance)
                return false;

        if(typeToFind == BWAPI::UnitTypes::Protoss_Archon)
        {
                if(mUnit != UnitTracker::Instance().selectAllUnits(BWAPI::UnitTypes::Protoss_Zealot).getClosestUnit(lurker))
                        return false;

                mUnit->move(lurker->getPosition());
                return true;
        }
        else
        {
                if(otherDistance <= 14)
                {
                        mUnit->attack(other);
                        return true;
                }
                else
                {
                        mUnit->move(other->getPosition());
                        return true;
                }
        }

        return false;
}

Here is the call graph for this function:


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines