Skip to content

Commit d1dc3b4

Browse files
committed
Improved limited target angle behavior
1 parent 47fb435 commit d1dc3b4

4 files changed

Lines changed: 11 additions & 10 deletions

File tree

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ class AIUpdateInterface : public UpdateModule, public AICommandInterface
684684
#endif
685685

686686
// this is intended for use ONLY by AIAttackAimAtTargetState.
687-
Bool friend_isAttackAngleValid(Real relAngle) const;
687+
Bool friend_isAttackAngleValid(Real relAngle, Real angleThresh) const;
688688
Real friend_getClosestAttackAngle(Real relAngle) const;
689689

690690
Object* getGoalObject() { return getStateMachine()->getGoalObject(); } ///< return the id of the current state of the machine

GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5103,7 +5103,7 @@ StateReturnType AIAttackAimAtTargetState::update()
51035103
Real relAngle = m_isAttackingObject ?
51045104
ThePartitionManager->getRelativeAngle2D(source, victim) :
51055105
ThePartitionManager->getRelativeAngle2D(source, getMachineGoalPosition());
5106-
if (sourceAI->friend_isAttackAngleValid(relAngle)) {
5106+
if (sourceAI->friend_isAttackAngleValid(relAngle, 0.07f * 2)) { //about 4 degrees threshold
51075107
//DEBUG_LOG((">>> friend_isAttackAngleValid(%f) = True", relAngle * 180.0 / PI));
51085108

51095109
// Workaround for ships TODO: Make this work for everything
@@ -5216,6 +5216,7 @@ StateReturnType AIAttackAimAtTargetState::update()
52165216
{ // Check our preferred angle on how to move.
52175217

52185218
//We ignore AimDelta here.
5219+
//aimDelta = REL_THRESH * 5; // about 10 degrees
52195220
aimDelta = REL_THRESH;
52205221

52215222
Real relAttackAngle = sourceAI->friend_getClosestAttackAngle(relAngle);
@@ -5319,8 +5320,8 @@ StateReturnType AIAttackAimAtTargetState::update()
53195320
}
53205321
}
53215322

5322-
//if (fabs(stdAngleDiff(desiredAngle,relAngle)) < aimDelta /*&& !m_preAttackFrames*/ )
5323-
if (fabs(relAngle) < aimDelta && !hasPreferredAngle /*&& !m_preAttackFrames*/)
5323+
if (fabs(stdAngleDiff(desiredAngle,relAngle)) < aimDelta /*&& !m_preAttackFrames*/ )
5324+
//if (fabs(relAngle) < aimDelta && !hasPreferredAngle /*&& !m_preAttackFrames*/)
53245325
{
53255326
AIUpdateInterface* victimAI = victim ? victim->getAI() : nullptr;
53265327
// add ourself as a targeter BEFORE calling isTemporarilyPreventingAimSuccess().

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4862,7 +4862,7 @@ setTmpValue(now);
48624862

48634863
// ------------------------------------------------------------------------------------------------
48644864
// ------------------------------------------------------------------------------------------------
4865-
Bool AIUpdateInterface::friend_isAttackAngleValid(Real relAngle) const
4865+
Bool AIUpdateInterface::friend_isAttackAngleValid(Real relAngle, Real angleThresh /*= 0*/) const
48664866
{
48674867
const AIUpdateModuleData* data = getAIUpdateModuleData();
48684868
if (data->m_attackAngles.size() <= 0)
@@ -4871,8 +4871,8 @@ Bool AIUpdateInterface::friend_isAttackAngleValid(Real relAngle) const
48714871
relAngle = normalizeAngle2PI(relAngle);
48724872

48734873
for (AttackAngleData angles : data->m_attackAngles) {
4874-
Real minAngle = angles.m_minAngle;
4875-
Real maxAngle = angles.m_maxAngle;
4874+
Real minAngle = angles.m_minAngle - angleThresh;
4875+
Real maxAngle = angles.m_maxAngle + angleThresh;
48764876
Real curAngle = relAngle;
48774877

48784878
if (minAngle > maxAngle) {

GeneralsMD/Code/Main/WinMain.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,9 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
819819
LPSTR lpCmdLine, Int nCmdShow )
820820
{
821821
Int exitcode = 1;
822-
#ifdef _DEBUG
823-
WaitForDebugger(); //in debug build, wait for debugger attachment
824-
#endif
822+
//#ifdef _DEBUG
823+
// WaitForDebugger(); //in debug build, wait for debugger attachment
824+
//#endif
825825

826826
#ifdef RTS_PROFILE
827827
Profile::StartRange("init");

0 commit comments

Comments
 (0)