|
ProtoBot
|
ScoutingZealot Controls scouting behavior for Zealot and Dragoon units. Combines positioning, threat detection, and movement control to provide safe and consistent map scouting. More...
#include <ScoutingZealot.h>
Public Member Functions | |
| ScoutingZealot (ProtoBotCommander *commander, ScoutingManager *manager) | |
| void | onStart () |
| Initializes the zealot scouting state. | |
| void | onFrame () |
| Main update loop executed every frame. | |
| void | onUnitDestroy (BWAPI::Unit unit) |
| Handles cleanup when the scouting unit is destroyed. | |
| void | setEnemyMain (const BWAPI::TilePosition &tp) |
| Sets the enemy main base location and updates scouting behavior. | |
| void | assign (BWAPI::Unit unit) |
| Assigns a unit as a scouting zealot. | |
| bool | hasScout () const |
| void | setProxyPatroller (bool v) |
| void | drawDebug () const |
| Draws debug information for the scouting unit. | |
Private Types | |
| enum class | State { Idle , WaitEnemyMain , ProxyPatrol , MoveToNatural , HoldEdge , Reposition , Done } |
Private Member Functions | |
| BWAPI::Position | homeRetreatPoint () const |
| void | computeEnemyNatural () |
| Determines the enemy natural expansion location. | |
| BWAPI::Position | pickEdgeOfVisionSpot () |
| Selects a position near the edge of enemy vision at the natural. | |
| BWAPI::Position | pickNaturalChokeSpot () |
| BWAPI::Position | findReachableNearby (const BWAPI::Position &desired) const |
| Finds a reachable nearby position if the desired location is invalid. | |
| BWAPI::Position | pushAwayFromResources (const BWAPI::Position &p, int clearPx) const |
| bool | threatenedNow () const |
| Checks whether the unit is currently threatened. | |
| void | issueMove (const BWAPI::Position &p, bool force=false, int reissueDist=32) |
| Issues movement commands with anti-stuck handling. | |
| void | rebuildProxyPoints () |
| Builds patrol points used for proxy scouting. | |
| bool | isNear (const BWAPI::Position &a, const BWAPI::Position &b, int distPx) const |
| BWAPI::Unit | findPrimaryThreat (int radiusPx) const |
| void | retreatHomeMicro (BWAPI::Unit threat) |
| Executes retreat and kiting behavior toward home base. | |
| BWAPI::Unit | findInWeaponRangeTarget () const |
| int | attackCommitFrames () const |
| bool | tryFireAndCommit (BWAPI::Unit target) |
| Attempts to attack a target and commit to the attack briefly. | |
| bool | isGoodKiteTarget (BWAPI::Unit u, int radiusPx) const |
Static Private Member Functions | |
| static double | groundPathLengthPx (const BWAPI::Position &from, const BWAPI::Position &to) |
| static BWAPI::Position | clampToMapPx (const BWAPI::Position &p, int marginPx=32) |
Private Attributes | |
| State | returnStateAfterReposition = State::HoldEdge |
| ProtoBotCommander * | commanderRef = nullptr |
| ScoutingManager * | manager = nullptr |
| BWAPI::Unit | zealot = nullptr |
| std::optional< BWAPI::TilePosition > | enemyMainTile |
| BWAPI::Position | enemyMainPos = BWAPI::Positions::Invalid |
| BWAPI::TilePosition | enemyNaturalTile = BWAPI::TilePositions::Invalid |
| BWAPI::Position | enemyNaturalPos = BWAPI::Positions::Invalid |
| State | state = State::Idle |
| int | lastMoveIssueFrame = 0 |
| int | lastThreatFrame = -100000 |
| int | lastAttackCmdFrame = -100000 |
| int | lastTargetSelectFrame = -100000 |
| int | proxyRebuildReadyFrame = 0 |
| std::vector< BWAPI::Position > | proxyPoints |
| int | proxyNextIdx = 0 |
| int | proxyNextRebuildFrame = 0 |
| int | proxyNextMoveFrame = 0 |
| BWAPI::Position | proxyCurTarget = BWAPI::Positions::Invalid |
| bool | isProxyPatroller = false |
| std::vector< BWAPI::Position > | cachedProxyPoints |
| bool | proxyPointsBuiltOnce = false |
| BWAPI::Position | cachedPerch = BWAPI::Positions::Invalid |
| int | cachedPerchFrame = -100000 |
| BWAPI::Position | lastIssuedGoal = BWAPI::Positions::Invalid |
| BWAPI::Position | lastPos = BWAPI::Positions::Invalid |
| int | stuckFrames = 0 |
| BWAPI::Unit | lastAttackTarget = nullptr |
Static Private Attributes | |
| static constexpr int | kMoveCooldownFrames = 8 |
| static constexpr int | kEdgeMarginPx = 24 |
| static constexpr int | kThreatRadiusPx = 256 |
| static constexpr int | kRepositionStepPx = 160 |
| static constexpr int | kCalmFramesToReturn = 72 |
| static constexpr int | kDangerClosePx = 96 |
| static constexpr int | kTargetStickFrames = 18 |
| static constexpr int | kProxyRebuildEveryFrames = 24 * 10 |
| static constexpr int | kProxyArriveDist = 96 |
| static constexpr int | kProxyMinBetweenMoves = 12 |
| static constexpr double | kMaxGroundDist = 180 * 32 |
| static constexpr int | kPerchRecalcFrames = 24 |
| static constexpr int | kGoalChangeResetDist = 64 |
ScoutingZealot Controls scouting behavior for Zealot and Dragoon units. Combines positioning, threat detection, and movement control to provide safe and consistent map scouting.
/// Uses a state-driven system to:
Definition at line 23 of file ScoutingZealot.h.
|
strongprivate |
Definition at line 47 of file ScoutingZealot.h.
|
inlineexplicit |
Definition at line 26 of file ScoutingZealot.h.
| void ScoutingZealot::assign | ( | BWAPI::Unit | unit | ) |
Assigns a unit as a scouting zealot.
Initializes behavior based on role:
| unit | Unit to assign as scout |
Definition at line 155 of file ScoutingZealot.cpp.
|
private |
Definition at line 1519 of file ScoutingZealot.cpp.
|
staticprivate |
Definition at line 1021 of file ScoutingZealot.cpp.
|
private |
Determines the enemy natural expansion location.
Selects the closest reachable non-starting base outside of the enemy main area.
Definition at line 448 of file ScoutingZealot.cpp.
| void ScoutingZealot::drawDebug | ( | ) | const |
Draws debug information for the scouting unit.
Displays:
Definition at line 1616 of file ScoutingZealot.cpp.
|
private |
Definition at line 1476 of file ScoutingZealot.cpp.
|
private |
Definition at line 1365 of file ScoutingZealot.cpp.
|
private |
Finds a reachable nearby position if the desired location is invalid.
Searches surrounding positions for a walkable and pathable alternative.
| desired | Desired target position |
Definition at line 742 of file ScoutingZealot.cpp.
|
staticprivate |
Definition at line 861 of file ScoutingZealot.cpp.
|
inline |
Definition at line 37 of file ScoutingZealot.h.
|
private |
Definition at line 433 of file ScoutingZealot.cpp.
|
private |
Definition at line 1586 of file ScoutingZealot.cpp.
|
private |
Definition at line 1028 of file ScoutingZealot.cpp.
|
private |
Issues movement commands with anti-stuck handling.
Includes:
| p | Target position |
| force | Force movement regardless of cooldown |
| reissueDist | Minimum distance to reissue command |
Definition at line 913 of file ScoutingZealot.cpp.
| void ScoutingZealot::onFrame | ( | ) |
Main update loop executed every frame.
Controls state transitions and behavior including:
Definition at line 229 of file ScoutingZealot.cpp.
| void ScoutingZealot::onStart | ( | ) |
Initializes the zealot scouting state.
Sets initial state and tracking values, including home position and movement timers.
Definition at line 136 of file ScoutingZealot.cpp.
| void ScoutingZealot::onUnitDestroy | ( | BWAPI::Unit | unit | ) |
Handles cleanup when the scouting unit is destroyed.
Clears references and marks behavior as complete.
| unit | Destroyed unit |
Definition at line 211 of file ScoutingZealot.cpp.
|
private |
Selects a position near the edge of enemy vision at the natural.
Ensures the unit remains outside the enemy main while maintaining vision of key areas.
Definition at line 494 of file ScoutingZealot.cpp.
|
private |
Definition at line 619 of file ScoutingZealot.cpp.
|
private |
Definition at line 812 of file ScoutingZealot.cpp.
|
private |
Builds patrol points used for proxy scouting.
Generates positions around:
Points are filtered for reachability and spacing.
Definition at line 1045 of file ScoutingZealot.cpp.
|
private |
Executes retreat and kiting behavior toward home base.
Attempts to attack if possible, otherwise moves away from threats while maintaining safe distance.
| threat | Primary threat unit |
Definition at line 1411 of file ScoutingZealot.cpp.
| void ScoutingZealot::setEnemyMain | ( | const BWAPI::TilePosition & | tp | ) |
Sets the enemy main base location and updates scouting behavior.
Computes the enemy natural and transitions the unit to natural-edge scouting unless acting as a proxy patroller.
| tp | Enemy main tile position |
Definition at line 183 of file ScoutingZealot.cpp.
|
inline |
Definition at line 39 of file ScoutingZealot.h.
|
private |
Checks whether the unit is currently threatened.
Considers nearby enemy combat units and attack status.
Definition at line 887 of file ScoutingZealot.cpp.
|
private |
Attempts to attack a target and commit to the attack briefly.
Prevents attack cancellation during weapon windup.
| target | Target unit |
Definition at line 1546 of file ScoutingZealot.cpp.
|
private |
Definition at line 98 of file ScoutingZealot.h.
|
private |
Definition at line 99 of file ScoutingZealot.h.
|
private |
Definition at line 93 of file ScoutingZealot.h.
|
private |
Definition at line 58 of file ScoutingZealot.h.
|
private |
Definition at line 63 of file ScoutingZealot.h.
|
private |
Definition at line 62 of file ScoutingZealot.h.
|
private |
Definition at line 65 of file ScoutingZealot.h.
|
private |
Definition at line 64 of file ScoutingZealot.h.
|
private |
Definition at line 92 of file ScoutingZealot.h.
|
staticconstexprprivate |
Definition at line 73 of file ScoutingZealot.h.
|
staticconstexprprivate |
Definition at line 75 of file ScoutingZealot.h.
|
staticconstexprprivate |
Definition at line 70 of file ScoutingZealot.h.
|
staticconstexprprivate |
Definition at line 107 of file ScoutingZealot.h.
|
staticconstexprprivate |
Definition at line 84 of file ScoutingZealot.h.
|
staticconstexprprivate |
Definition at line 69 of file ScoutingZealot.h.
|
staticconstexprprivate |
Definition at line 106 of file ScoutingZealot.h.
|
staticconstexprprivate |
Definition at line 82 of file ScoutingZealot.h.
|
staticconstexprprivate |
Definition at line 83 of file ScoutingZealot.h.
|
staticconstexprprivate |
Definition at line 81 of file ScoutingZealot.h.
|
staticconstexprprivate |
Definition at line 72 of file ScoutingZealot.h.
|
staticconstexprprivate |
Definition at line 78 of file ScoutingZealot.h.
|
staticconstexprprivate |
Definition at line 71 of file ScoutingZealot.h.
|
private |
Definition at line 76 of file ScoutingZealot.h.
|
private |
Definition at line 130 of file ScoutingZealot.h.
|
private |
Definition at line 101 of file ScoutingZealot.h.
|
private |
Definition at line 68 of file ScoutingZealot.h.
|
private |
Definition at line 103 of file ScoutingZealot.h.
|
private |
Definition at line 77 of file ScoutingZealot.h.
|
private |
Definition at line 74 of file ScoutingZealot.h.
|
private |
Definition at line 59 of file ScoutingZealot.h.
|
private |
Definition at line 91 of file ScoutingZealot.h.
|
private |
Definition at line 88 of file ScoutingZealot.h.
|
private |
Definition at line 90 of file ScoutingZealot.h.
|
private |
Definition at line 89 of file ScoutingZealot.h.
|
private |
Definition at line 87 of file ScoutingZealot.h.
|
private |
Definition at line 94 of file ScoutingZealot.h.
|
private |
Definition at line 85 of file ScoutingZealot.h.
|
private |
Definition at line 57 of file ScoutingZealot.h.
|
private |
Definition at line 67 of file ScoutingZealot.h.
|
private |
Definition at line 104 of file ScoutingZealot.h.
|
private |
Definition at line 60 of file ScoutingZealot.h.