Esempio n. 1
0
void VultureAgent::computeActions()
{
	int eCnt = enemyGroundAttackingUnitsWithinRange(unit->getTilePosition(), 320);
	if (eCnt > 0)
	{
		int framesSinceDrop = Broodwar->getFrameCount() - mineDropFrame;
		if (unit->getSpiderMineCount() > 0 && framesSinceDrop >= 100)
		{
			//Broodwar->printf("[%d] dropped spider mine", unitID);
			unit->useTech(TechTypes::Spider_Mines, unit->getPosition());
			mineDropFrame = Broodwar->getFrameCount();
			return;
		}
	}

	defensive = false;
	if (unit->getAirWeaponCooldown() > 2 || unit->getGroundWeaponCooldown() > 2) defensive = true;
	
	NavigationAgent::getInstance()->computeMove(this, goal, defensive);
	if (!defensive) TargetingAgent::checkTarget(this);
}
Esempio 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);
}
Esempio n. 3
0
int UnitAgent::enemyAttackingUnitsWithinRange(UnitType type)
{
	return enemyGroundAttackingUnitsWithinRange(unit->getTilePosition(), getGroundRange(type)) + enemyAirAttackingUnitsWithinRange(unit->getTilePosition(), getAirRange(type));
}
Esempio n. 4
0
int UnitAgent::enemyAttackingUnitsWithinRange(int maxRange, TilePosition center)
{
	return enemyGroundAttackingUnitsWithinRange(center, maxRange) + enemyAirAttackingUnitsWithinRange(center, maxRange);
}