|
50 | 50 |
|
51 | 51 | #include "GameLogic/AIPathfind.h" |
52 | 52 | #include "GameLogic/GameLogic.h" |
| 53 | +#include "GameLogic/Locomotor.h" |
53 | 54 | #include "GameLogic/Object.h" |
54 | 55 | #include "GameLogic/PartitionManager.h" |
55 | 56 | #include "GameLogic/Weapon.h" |
@@ -1903,6 +1904,23 @@ Bool SpecialAbilityUpdate::isFacing() |
1903 | 1904 | { |
1904 | 1905 | if( !m_facingComplete && m_facingInitiated) |
1905 | 1906 | { |
| 1907 | + Locomotor *loco = ai->getCurLocomotor(); |
| 1908 | + if( loco && loco->getMinTurnSpeed() > 0.0f ) |
| 1909 | + { |
| 1910 | + //This locomotor can't turn in place (e.g. wings); we're moving toward the |
| 1911 | + //target to turn. Consider facing complete once our heading is within tolerance. |
| 1912 | + const SpecialAbilityUpdateModuleData* data = getSpecialAbilityUpdateModuleData(); |
| 1913 | + Real relAngle = ThePartitionManager->getRelativeAngle2D( getObject(), &m_targetPos ); |
| 1914 | + if( fabs( relAngle ) <= data->m_facingAngleTolerance ) |
| 1915 | + { |
| 1916 | + m_facingComplete = true; |
| 1917 | + ai->aiIdle( CMD_FROM_AI ); //stop the short move; ready to launch |
| 1918 | + return false; |
| 1919 | + } |
| 1920 | + //Still turning (while moving). |
| 1921 | + return true; |
| 1922 | + } |
| 1923 | + |
1906 | 1924 | if( ai->isIdle() ) |
1907 | 1925 | { |
1908 | 1926 | //We finished facing the target |
@@ -1969,7 +1987,26 @@ void SpecialAbilityUpdate::startFacing() |
1969 | 1987 | } |
1970 | 1988 | else if( m_targetPos.x || m_targetPos.y || m_targetPos.z ) //It's zero if not used... |
1971 | 1989 | { |
1972 | | - ai->aiFacePosition( &m_targetPos, CMD_FROM_AI ); |
| 1990 | + Locomotor *loco = ai->getCurLocomotor(); |
| 1991 | + if( loco && loco->getMinTurnSpeed() > 0.0f ) |
| 1992 | + { |
| 1993 | + //This locomotor can't turn in place (e.g. wings); facing in place does nothing. |
| 1994 | + const SpecialAbilityUpdateModuleData* data = getSpecialAbilityUpdateModuleData(); |
| 1995 | + if( fabs( ThePartitionManager->getRelativeAngle2D( getObject(), &m_targetPos ) ) <= data->m_facingAngleTolerance ) |
| 1996 | + { |
| 1997 | + //Already pointed at the target -- no need to move. |
| 1998 | + m_facingComplete = true; |
| 1999 | + } |
| 2000 | + else |
| 2001 | + { |
| 2002 | + //Move toward the target so the locomotor turns us; isFacing() stops us once aligned. |
| 2003 | + ai->aiMoveToPosition( &m_targetPos, CMD_FROM_AI ); |
| 2004 | + } |
| 2005 | + } |
| 2006 | + else |
| 2007 | + { |
| 2008 | + ai->aiFacePosition( &m_targetPos, CMD_FROM_AI ); |
| 2009 | + } |
1973 | 2010 | } |
1974 | 2011 | } |
1975 | 2012 |
|
|
0 commit comments