Пример #1
0
void RangedManager::kiteTarget(BWAPI::Unit * rangedUnit, BWAPI::Unit * target)
{
	
	double range(rangedUnit->getType().groundWeapon().maxRange());
	if (rangedUnit->getType() == BWAPI::UnitTypes::Protoss_Dragoon && BWAPI::Broodwar->self()->getUpgradeLevel(BWAPI::UpgradeTypes::Singularity_Charge))
	{
		range = 6*32;
	}

	// determine whether the target can be kited
	if (range <= target->getType().groundWeapon().maxRange())
	{

		//LurkerUnBurrow(rangedUnit);
		// if we can't kite it, there's no point
		smartAttackUnit(rangedUnit, target);
		return;
	}

	double		minDist(64);
	bool		kite(true);
	double		dist(rangedUnit->getDistance(target));
	double		speed(rangedUnit->getType().topSpeed());

	double	timeToEnter = std::max(0.0,(dist - range) / speed);
	if ((timeToEnter >= rangedUnit->getGroundWeaponCooldown()) && (dist >= minDist))
	{
		kite = false;
	}

	if (target->getType().isBuilding() && target->getType() != BWAPI::UnitTypes::Terran_Bunker)
	{
		kite = false;
	}

	if (rangedUnit->isSelected())
	{
		BWAPI::Broodwar->drawCircleMap(rangedUnit->getPosition().x(), rangedUnit->getPosition().y(), 
			(int)range, BWAPI::Colors::Cyan);
	}

	// if we can't shoot, run away
	if (kite)
	{
		BWAPI::Position fleePosition(rangedUnit->getPosition() - target->getPosition() + rangedUnit->getPosition());

		BWAPI::Broodwar->drawLineMap(rangedUnit->getPosition().x(), rangedUnit->getPosition().y(), 
			fleePosition.x(), fleePosition.y(), BWAPI::Colors::Cyan);

		//LurkerUnBurrow(rangedUnit);
		smartMove(rangedUnit, fleePosition);
	}
	// otherwise shoot
	else
	{
		//LurkerBurrow(rangedUnit);
		smartAttackUnit(rangedUnit, target);
	}
}
void BattlecruiserManagerExt::kiteTarget(BWAPI::Unit * selectedUnit, BWAPI::Unit * target)
{
	// Battlecruiser do not kite
	int selectedUnitWeaponCooldown;
	double selectedUnitRange;
	if (target->getType().isFlyer())
	{
		selectedUnitRange = selectedUnit->getType().airWeapon().maxRange();
		selectedUnitWeaponCooldown = selectedUnit->getAirWeaponCooldown();
	}
	else
	{
		selectedUnitRange = selectedUnit->getType().groundWeapon().maxRange();
		selectedUnitWeaponCooldown = selectedUnit->getGroundWeaponCooldown();
	}

	double targetRange = getTargetWeaponRange(selectedUnit, target);

	if (target->getType() == BWAPI::UnitTypes::Protoss_Photon_Cannon
		&& (selectedUnit->getEnergy() > 150))
	{
		useYamatoGun(selectedUnit, target);
	} 
	else
	{
		smartAttackUnit(selectedUnit, target);
	}

	//useYamatoGun(selectedUnit, target);
	//smartAttackMove(selectedUnit, target->getPosition());

}
Пример #3
0
void DragoonManager::executeMicro(const UnitVector & targets, BWAPI::Position regroup) 
{
	const UnitVector & dragoons = getUnits();

	// figure out targets
	UnitVector dragoonTargets;
	for (size_t i(0); i<targets.size(); i++) 
	{
		// conditions for targeting
		if (targets[i]->isVisible()) 
		{
			dragoonTargets.push_back(targets[i]);
		}
	}

	// for each zealot
	BOOST_FOREACH(BWAPI::Unit * dragoon, dragoons)
	{
		if (DRAW_UALBERTABOT_DEBUG) BWAPI::Broodwar->drawLineMap(dragoon->getPosition().x(), dragoon->getPosition().y(), 
			dragoon->getTargetPosition().x(), dragoon->getTargetPosition().y(), BWAPI::Colors::White);

		// regroup if we have to regroup and we're not near an enemy
		if (order.type == order.Attack && regroup != BWAPI::Position(0,0))// && !unitNearEnemy(dragoon))
		{
			if (DRAW_UALBERTABOT_DEBUG) BWAPI::Broodwar->drawCircleMap(dragoon->getPosition().x(), dragoon->getPosition().y(), 3, BWAPI::Colors::Orange, true);

			// if the zealot is outside the regroup area
			if (dragoon->getDistance(regroup) > 100)
			{
				// regroup it
				smartMove(dragoon, regroup);
			}
			else
			{
				smartAttackMove(dragoon, dragoon->getPosition());
			}
		}
		// otherwise this unit is not regrouping
		else
		{
			// if the order is to attack or defend
			if (order.type == order.Attack || order.type == order.Defend) {

				// if there are targets
				if (!dragoonTargets.empty())
				{
					// find the best target for this zealot
					BWAPI::Unit * target = getTarget(dragoon, dragoonTargets);
					// attack it
					smartAttackUnit(dragoon, target);
				}
				// if there are no targets
				else
				{
					// if we're not near the order position
					if (dragoon->getDistance(order.position) > 100)
					{
						// move to it
						smartAttackMove(dragoon, order.position);
					}
				}
			}
		}
	}
}