Ejemplo n.º 1
0
bool WraithAgent::checkUseCloak()
{
	TechType cloak = TechTypes::Cloaking_Field;
	if (Broodwar->self()->hasResearched(cloak))
	{
		if (!unit->isCloaked())
		{
			if (unit->getEnergy() >= 25 && !isDetectorWithinRange(unit->getTilePosition(), 192))
			{
				int range = 10 * 32;
				int eCnt = enemyUnitsWithinRange(range);
				if (eCnt > 0)
				{
					unit->useTech(cloak);
					return true;
				}
			}
		}
		//Dont decloak since it is costly to first use cloak and
		//keeping it up is cheap.
		/*if (unit->isCloaked())
		{
			int range = 10 * 32;
			int eCnt = enemyUnitsWithinRange(range);
			if (eCnt == 0)
			{
				unit->decloak();
				return true;
			}
		}*/
	}
	return false;
}
Ejemplo n.º 2
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);
}