예제 #1
0
void GhostAgent::computeActions()
{
    int eCnt = enemyGroundAttackingUnitsWithinRange(unit->getTilePosition(), 384) + enemyAirAttackingUnitsWithinRange(unit->getTilePosition(), 384); //384 = range of tank in siege mode

    TechType cloak = TechTypes::Personnel_Cloaking;
    if (Broodwar->self()->hasResearched(cloak))
    {
        if (!unit->isCloaked() && eCnt > 0 && !isDetectorWithinRange(unit->getTilePosition(), 192))
        {
            if (unit->getEnergy() > 25)
            {
                unit->useTech(cloak);
                //Broodwar->printf("[%d] Ghost used cloaking", unitID);
                return;
            }
        }
    }

    TechType lockdown = TechTypes::Lockdown;
    if (Broodwar->self()->hasResearched(lockdown))
    {
        if (unit->getEnergy() >= 100)
        {
            Unit* target = findLockdownTarget();
            if (target != NULL)
            {
                Broodwar->printf("[%d] Used Lockdown on [%d] %s", unitID, target->getID(), target->getType().getName().c_str());
                unit->useTech(lockdown, target);
                return;
            }
        }
    }

    defensive = false;
    NavigationAgent::getInstance()->computeMove(this, goal, defensive);
    TargetingAgent::checkTarget(this);
}
예제 #2
0
int UnitAgent::enemyAttackingUnitsWithinRange(UnitType type)
{
	return enemyGroundAttackingUnitsWithinRange(unit->getTilePosition(), getGroundRange(type)) + enemyAirAttackingUnitsWithinRange(unit->getTilePosition(), getAirRange(type));
}
예제 #3
0
int UnitAgent::enemyAttackingUnitsWithinRange(int maxRange, TilePosition center)
{
	return enemyGroundAttackingUnitsWithinRange(center, maxRange) + enemyAirAttackingUnitsWithinRange(center, maxRange);
}