-
Notifications
You must be signed in to change notification settings - Fork 247
bugfix: Contact weapons are no longer blocked by obstacles #3194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1214,7 +1214,11 @@ Bool outOfWeaponRangePosition( State *thisState, void* userData ) | |
| } | ||
|
|
||
| Bool viewBlocked = false; | ||
| #if RETAIL_COMPATIBLE_CRC | ||
| if (onGround) | ||
| #else | ||
| if (onGround && !weapon->isContactWeapon()) | ||
| #endif | ||
| { | ||
| viewBlocked = TheAI->pathfinder()->isAttackViewBlockedByObstacle(obj, *obj->getPosition(), nullptr, *pos); | ||
| } | ||
|
|
@@ -2654,7 +2658,11 @@ StateReturnType AIAttackApproachTargetState::updateInternal() | |
| if (m_stopIfInRange && weapon && weapon->isWithinAttackRange(source, &m_goalPosition)) | ||
| { | ||
| Bool viewBlocked = false; | ||
| #if RETAIL_COMPATIBLE_CRC | ||
| if ( ai->isDoingGroundMovement() ) | ||
| #else | ||
| if ( ai->isDoingGroundMovement() && !weapon->isContactWeapon() ) | ||
| #endif | ||
|
Comment on lines
+2661
to
+2665
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Contact attacks ignore obstacle los For attack-position commands, contact weapons now skip isAttackViewBlockedByObstacle, so the approach/aim states can succeed and fire based only on distance even when an obstacle blocks the target point. This can enable detonating a contact weapon at an obstacle-blocked position (e.g., through a thin wall/fence) from an adjacent reachable cell, which is broader than “unit intersecting obstacle geometry.” Agent Prompt
|
||
| { | ||
| viewBlocked = TheAI->pathfinder()->isAttackViewBlockedByObstacle(source, *source->getPosition(), nullptr, m_goalPosition); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3399,7 +3399,11 @@ void AIUpdateInterface::privateAttackPosition( const Coord3D *pos, Int maxShotsT | |
| // this fixes an obscure bug with mine-clearing: if you tell someone to clear mines and put the centerpoint | ||
| // inside a building, the dozer/worker will just go thru the building to that spot. ick. so if you find that | ||
| // this clause (below) is problematic, you'll probably have to find another way to fix this mine-clearing bug. (srj) | ||
| #if RETAIL_COMPATIBLE_CRC | ||
| if (weapon && weapon->isContactWeapon() && !isPathAvailable(&localPos)) | ||
| #else | ||
| if (weapon && weapon->isContactWeapon() && !weapon->isWithinAttackRange(getObject(), &localPos) && !isPathAvailable(&localPos)) | ||
| #endif | ||
|
Comment on lines
+3402
to
+3406
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3. Unpathable contact target preserved privateAttackPosition now skips the “find a nearby pathable spot” adjustment for contact weapons if isWithinAttackRange() is true, even when isPathAvailable() is false. Combined with the LOS bypass, this lets a unit execute a contact attack on an explicitly unpathable goal point (e.g., inside blocking geometry) as long as it can get within range outside the obstacle. Agent Prompt
|
||
| { | ||
| FindPositionOptions fpOptions; | ||
| fpOptions.minRadius = 0.0f; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1219,7 +1219,11 @@ Bool outOfWeaponRangePosition( State *thisState, void* userData ) | |
| } | ||
|
|
||
| Bool viewBlocked = false; | ||
| #if RETAIL_COMPATIBLE_CRC | ||
| if (onGround) | ||
| #else | ||
| if (onGround && !weapon->isContactWeapon()) | ||
| #endif | ||
| { | ||
| viewBlocked = TheAI->pathfinder()->isAttackViewBlockedByObstacle(obj, *obj->getPosition(), nullptr, *pos); | ||
| } | ||
|
|
@@ -2740,7 +2744,11 @@ StateReturnType AIAttackApproachTargetState::updateInternal() | |
| if (m_stopIfInRange && weapon && weapon->isWithinAttackRange(source, &m_goalPosition)) | ||
| { | ||
| Bool viewBlocked = false; | ||
| #if RETAIL_COMPATIBLE_CRC | ||
| if ( ai->isDoingGroundMovement() ) | ||
| #else | ||
| if ( ai->isDoingGroundMovement() && !weapon->isContactWeapon() ) | ||
| #endif | ||
| { | ||
| viewBlocked = TheAI->pathfinder()->isAttackViewBlockedByObstacle(source, *source->getPosition(), nullptr, m_goalPosition); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are 8 calls to |
||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.