From ec4ae7d79d93a3648dc68ba37baa003f04864e92 Mon Sep 17 00:00:00 2001 From: mohabhassan Date: Sun, 30 Jun 2019 23:03:24 +0200 Subject: [PATCH] Actor Improvements p3_3 --- code/game/actor.cpp | 55 ++-- code/game/actor_alarm.cpp | 15 +- code/game/actor_anim.cpp | 6 +- code/game/actor_animcurious.cpp | 3 +- code/game/actor_balcony.cpp | 42 +-- code/game/actor_cover.cpp | 363 ++++++++++++-------------- code/game/actor_curious.cpp | 9 +- code/game/actor_disguise_common.cpp | 21 +- code/game/actor_disguise_officier.cpp | 6 +- code/game/actor_disguise_rover.cpp | 7 +- code/game/actor_disguise_salute.cpp | 3 +- code/game/actor_disguise_sentry.cpp | 7 +- code/game/actor_dog.cpp | 3 +- code/game/actor_killed.cpp | 6 +- code/game/actor_machinegunner.cpp | 9 +- code/game/actor_turret.cpp | 227 ++++++---------- code/game/actor_weaponless.cpp | 13 +- code/game/g_utils.cpp | 12 +- code/game/simpleactor.cpp | 2 +- code/qcommon/q_math.c | 16 +- 20 files changed, 322 insertions(+), 503 deletions(-) diff --git a/code/game/actor.cpp b/code/game/actor.cpp index dbb09c80..5752486a 100644 --- a/code/game/actor.cpp +++ b/code/game/actor.cpp @@ -3089,18 +3089,15 @@ void Actor::UpdateEyeOrigin ) { - Vector eyeTag = vec_zero; // [esp+50h] [ebp-18h] + Vector eyeTag = vec_zero; int currLvlTime = level.inttime; int currTime = m_iEyeUpdateTime; if (currLvlTime > currTime) { - do - currTime += 100; - while (currTime < currLvlTime); - m_iEyeUpdateTime = currTime; + m_iEyeUpdateTime = NextUpdateTime(currTime, 100); GetTag( "eyes bone", &eyeTag, &m_vEyeDir); @@ -3123,12 +3120,12 @@ void Actor::UpdateEyeOrigin if (eyeposition[1] > 10.5) eyeposition[1] = 10.5; - if (eyeposition[0] < 4.5) + if (eyeposition[2] < 4.5) { - eyeposition[0] = 4.5; + eyeposition[2] = 4.5; } - if (eyeposition[0] > 89.5) - eyeposition[0] = 89.5; + if (eyeposition[2] > 89.5) + eyeposition[2] = 89.5; } } @@ -3275,23 +3272,20 @@ void Actor::SetEnemyPos ) { - Vector vEnemyPos; if (m_vLastEnemyPos != vPos) { m_iLastEnemyPosChangeTime = level.inttime; m_vLastEnemyPos = vPos; - vEnemyPos = m_vLastEnemyPos; if (m_Enemy) { mTargetPos += m_Enemy->eyeposition; - vEnemyPos = m_Enemy->eyeposition; } else { mTargetPos.z += 88; } - if (mTargetPos.z - vEnemyPos.z < 128) + if (mTargetPos.z - EyePosition().z < 128) { mTargetPos.z -= 16; } @@ -9929,17 +9923,17 @@ void Actor::FaceMotion ) { - vec3_t dir; Vector delta; - velocity.copyTo(dir); - if (VectorLength2DSquared(dir) > 1) + if (VectorLength2DSquared(velocity) > 1) { + vec3_t dir; + velocity.copyTo(dir); delta = origin - m_vOriginHistory[m_iCurrentHistory]; if (delta.lengthXYSquared() >= 1) { - if (dir[1] *delta[0] + dir[0] * delta[1] > 0) + if (DotProduct2D(velocity, delta) > 0) { delta.copyTo(dir); } @@ -9956,9 +9950,9 @@ void Actor::FaceMotion SetDesiredYawDir(dir); } - else if (IsIdleState(m_ThinkState)) + else if (IsIdleState(m_ThinkState) && m_pLookEntity) { - IdleLook(); + LookAtLookEntity(); } else { @@ -9986,23 +9980,11 @@ void Actor::FaceDirectionDuringMotion if (velocity[0] != 0 || velocity[1] != 0) { - float fMagsSquared = VectorLength2DSquared(vLook) * Square(velocity[1]) + Square(velocity[0]); + float fMagsSquared = VectorLength2DSquared(vLook) * VectorLength2DSquared(velocity); float fDot = DotProduct2D(velocity, vLook); float fDotSquared = Square(fDot); - if (velocity[1] == 0 && velocity[0] == 0) - { - yaw = 0; - } - else - { - yaw = atan2(velocity[1], velocity[0]) * 180 / M_PI; - } - - if (yaw < 0) - { - yaw += 360; - } + yaw = velocity.toYaw(); float fYaw2; if (fMagsSquared * 0.5 < fDotSquared) @@ -10083,8 +10065,8 @@ void Actor::FaceEnemyOrMotion { if (m_Path.CurrentNodeIndex() != m_sCurrentPathNodeIndex) { - float fDot = DotProduct2D(vDelta, m_Path.CurrentDelta()); - m_bFaceEnemy = fDot <= 0 || vDelta.lengthXYSquared() * 4096 >= fDot * fDot; + float fDist = PathDistanceAlongVector(vDelta); + m_bFaceEnemy = fDist <= 0 || vDelta.lengthXYSquared() * Square(64) >= Square(fDist); m_sCurrentPathNodeIndex = m_Path.CurrentNodeIndex(); } @@ -13126,9 +13108,8 @@ void Actor::EventReload_mg42 { if (m_State == 1200) { - m_State = 1201; m_bAnimScriptSet = true; - m_iStateTime = level.inttime; + TransitionState(1201, 0); } else { diff --git a/code/game/actor_alarm.cpp b/code/game/actor_alarm.cpp index d405faab..db33fb0c 100644 --- a/code/game/actor_alarm.cpp +++ b/code/game/actor_alarm.cpp @@ -54,21 +54,18 @@ void Actor::Begin_Alarm if( PathExists() ) { - m_State = 601; - m_iStateTime = level.inttime; + TransitionState(601, 0); } else { - m_State = 600; - m_iStateTime = level.inttime; + TransitionState(600, 0); parm.movefail = true; } } else { SetLeashHome( origin ); - m_State = 600; - m_iStateTime = level.inttime; + TransitionState(600, 0); m_AlarmThread.Execute( this ); } } @@ -93,8 +90,7 @@ void Actor::State_Alarm_StartThread else SetLeashHome( origin ); - m_State = 600; - m_iStateTime = level.inttime; + TransitionState(600, 0); m_AlarmThread.Execute(); } @@ -119,8 +115,7 @@ void Actor::State_Alarm_Move } else { - m_State = 600; - m_iStateTime = level.inttime; + TransitionState(600, 0); parm.movefail = true; Anim_Aim(); diff --git a/code/game/actor_anim.cpp b/code/game/actor_anim.cpp index f3f81f8a..1596ccc0 100644 --- a/code/game/actor_anim.cpp +++ b/code/game/actor_anim.cpp @@ -47,8 +47,7 @@ void Actor::Begin_Anim m_csMood = m_csIdleMood; ClearPath(); m_YawAchieved = true; - m_State = 1000; - m_iStateTime = level.inttime; + TransitionState(1000, 0); } void Actor::Think_Anim @@ -68,8 +67,7 @@ void Actor::Think_Anim m_bAnimScriptSet = false; m_pszDebugState = "initial"; - m_State = 1001; - m_iStateTime = level.inttime; + TransitionState(1001, 0); } else if (m_State == 1001) { diff --git a/code/game/actor_animcurious.cpp b/code/game/actor_animcurious.cpp index 36c13cc4..06f71a11 100644 --- a/code/game/actor_animcurious.cpp +++ b/code/game/actor_animcurious.cpp @@ -78,7 +78,6 @@ void Actor::FinishedAnimation_AnimCurious { if( m_State == 1101 ) { - m_State = 1100; - m_iStateTime = level.inttime; + TransitionState(1100, 0); } } diff --git a/code/game/actor_balcony.cpp b/code/game/actor_balcony.cpp index 19937bf8..b1fc0dbf 100644 --- a/code/game/actor_balcony.cpp +++ b/code/game/actor_balcony.cpp @@ -147,8 +147,7 @@ void Actor::Begin_BalconyAttack ) { - m_State = 200; - m_iStateTime = level.inttime; + TransitionState(200, 0); } void Actor::State_Balcony_PostShoot @@ -159,8 +158,7 @@ void Actor::State_Balcony_PostShoot { if( m_Enemy ) { - m_State = 201; - m_iStateTime = level.inttime; + TransitionState(201, 0); } } @@ -175,8 +173,7 @@ void Actor::State_Balcony_FindEnemy if( CanSeeEnemy( 200 ) ) { - m_State = 201; - m_iStateTime = level.inttime; + TransitionState(201, 0); } } @@ -193,15 +190,13 @@ void Actor::State_Balcony_Target { if( CanSeeEnemy( 0 ) && CanShootEnemy( 0 ) ) { - m_State = 202; + TransitionState(202, 0); } else { ClearPath(); - m_State = 200; + TransitionState(200, 0); } - - m_iStateTime = level.inttime; } } @@ -282,11 +277,9 @@ void Actor::Begin_BalconyKilled PostEvent( EV_Actor_DeathEmbalm, 0.05f ); if( CalcFallPath() ) - m_State = 800; + TransitionState(800, 0); else - m_State = 806; - - m_iStateTime = level.inttime; + TransitionState(806, 0); } void Actor::End_BalconyKilled @@ -343,8 +336,7 @@ void Actor::Think_BalconyKilled NewAnim( animnum, m_iMotionSlot ); SetTime( m_iMotionSlot, m_pFallPath->startTime ); UpdateNormalAnimSlot( m_iMotionSlot ); - m_State = 801; - m_iStateTime = level.inttime; + TransitionState(801, 0); break; case 801: m_bNextForceStart = false; @@ -357,8 +349,7 @@ void Actor::Think_BalconyKilled Anim_FullBody( STRING_DEATH_BALCONY_LOOP, 7 ); break; case 803: - m_State = 804; - m_iStateTime = level.inttime; + TransitionState(804, 0); StopAllAnimating(); case 804: m_pszDebugState = "outtro"; @@ -381,21 +372,18 @@ void Actor::Think_BalconyKilled { if( m_pFallPath->currentPos >= m_pFallPath->length ) { - m_State = 803; - m_iStateTime = level.inttime; + TransitionState(803, 0); } else if (m_pFallPath->currentPos >= m_pFallPath->loop) { - m_State = 802; - m_iStateTime = level.inttime; + TransitionState(802, 0); } } else if( m_State == 802 ) { if (m_pFallPath->currentPos >= m_pFallPath->length) { - m_State = 803; - m_iStateTime = level.inttime; + TransitionState(803, 0); } } } @@ -411,13 +399,11 @@ void Actor::FinishedAnimation_BalconyKilled if( m_State == 804 || m_State == 806 ) { BecomeCorpse(); - m_State = 805; - m_iStateTime = level.inttime; + TransitionState(805, 0); } else if( m_State == 801 ) { - m_State = 802; - m_iStateTime = level.inttime; + TransitionState(802, 0); StopAllAnimating(); } } diff --git a/code/game/actor_cover.cpp b/code/game/actor_cover.cpp index 105604dc..a280896f 100644 --- a/code/game/actor_cover.cpp +++ b/code/game/actor_cover.cpp @@ -52,13 +52,11 @@ void Actor::Begin_Cover if( m_pCoverNode ) { - m_State = 302; - m_iStateTime = level.inttime; + TransitionState(302, 0); return; } - m_State = 300; - m_iStateTime = level.inttime; + TransitionState(300, 0); if( level.inttime < m_iEnemyChangeTime + 200 ) { @@ -67,8 +65,7 @@ void Actor::Begin_Cover if( AttackEntryAnimation() ) { m_bLockThinkState = true; - m_State = 312; - m_iStateTime = level.inttime; + TransitionState(312, 0); } } } @@ -87,8 +84,7 @@ void Actor::End_Cover m_pCoverNode = NULL; } - m_State = -1; - m_iStateTime = level.inttime; + TransitionState(-1, 0); } void Actor::Suspend_Cover @@ -104,8 +100,7 @@ void Actor::Suspend_Cover m_pCoverNode = NULL; } - m_State = 301; - m_iStateTime = level.inttime; + TransitionState(301, 0); } void Actor::State_Cover_NewEnemy @@ -127,10 +122,8 @@ void Actor::State_Cover_NewEnemy { Anim_Aim(); AimAtTargetPos(); - m_State = 307; + TransitionState(307, 0); } - - m_iStateTime = level.inttime; } void Actor::State_Cover_FindCover @@ -152,10 +145,8 @@ void Actor::State_Cover_FindCover } else { - m_State = 307; + TransitionState(307, 0); } - - m_iStateTime = level.inttime; } else { @@ -182,12 +173,23 @@ void Actor::State_Cover_TakeCover { ClearPath(); m_eAnimMode = 1; - m_State = 303; - m_iStateTime = level.inttime; + TransitionState(303, 0); State_Cover_FinishReloading(); } } +static int Cover_HideTime(int iTeam) +{ + if (iTeam == TEAM_AMERICAN) + { + return rand() % 2001 + 2000; + } + else + { + return rand() % 11001 + 4000; + } +} + void Actor::State_Cover_FinishReloading ( void @@ -216,14 +218,7 @@ void Actor::State_Cover_FinishReloading m_sCurrentPathNodeIndex = -1; - if( m_Team == TEAM_AMERICAN ) - { - m_iStateTime = level.inttime + ( rand() % 2001 + 2000 ); - } - else - { - m_iStateTime = level.inttime + ( rand() % 11001 + 4000 ); - } + TransitionState(308, Cover_HideTime(m_Team)); Anim_Aim(); AimAtTargetPos(); @@ -236,8 +231,7 @@ void Actor::State_Cover_FinishReloading m_eNextAnimMode = 1; m_bNextForceStart = false; m_csNextAnimString = m_csSpecialAttack; - m_State = 304; - m_iStateTime = level.inttime; + TransitionState(304, 0); } void Actor::State_Cover_Target @@ -250,8 +244,7 @@ void Actor::State_Cover_Target if( m_eDontFaceWallMode <= 8 ) { - m_State = 305; - m_iStateTime = level.inttime; + TransitionState(305, 0); State_Cover_FindEnemy(); return; } @@ -267,221 +260,202 @@ void Actor::State_Cover_Target SetDesiredYawDir(m_vGrenadeVel); m_eNextAnimMode = 1; m_bNextForceStart = false; - m_State = 310; m_csNextAnimString = m_eGrenadeMode == AI_GREN_TOSS_ROLL ? STRING_ANIM_GRENADETOSS_SCR : STRING_ANIM_GRENADETHROW_SCR; - m_iStateTime = level.inttime; + TransitionState(310, 0); } else if( CanSeeEnemy( 500 ) && CanShootEnemy( 500 ) ) { - m_State = 309; - m_iStateTime = level.inttime; + TransitionState(309, 0); } else { - m_State = 308; - - if (m_Team == TEAM_AMERICAN) - { - m_iStateTime = level.inttime + (rand() % 2001 + 2000); - } - else - { - m_iStateTime = level.inttime + (rand() % 11001 + 4000); - } + TransitionState(308, Cover_HideTime(m_Team)); } } } void Actor::State_Cover_Hide - ( +( void - ) +) { - if( m_Enemy ) + if (m_Enemy) { - SetEnemyPos( origin ); + SetEnemyPos(origin); } - if( !m_pCoverNode ) + if (!m_pCoverNode) { - m_State = 301; - m_iStateTime = level.inttime; + TransitionState(301, 0); State_Cover_FindCover(); return; } - m_csSpecialAttack = m_pCoverNode->GetSpecialAttack( this ); - MPrintf( "special: %d", m_csSpecialAttack ); + m_csSpecialAttack = m_pCoverNode->GetSpecialAttack(this); + MPrintf("special: %d", m_csSpecialAttack); - if( m_csSpecialAttack ) + if (m_csSpecialAttack) { SetDesiredYaw(angles[1]); - SafeSetOrigin( origin ); + SafeSetOrigin(origin); m_eNextAnimMode = 1; m_bNextForceStart = false; - m_State = 304; m_csNextAnimString = m_csSpecialAttack; - m_iStateTime = level.inttime; + TransitionState(304, 0); return; } - bool bCanShoot = CanShootEnemy( 500 ); - if( CanSeeEnemy( 500 ) || bCanShoot ) + bool bCanShoot = CanShootEnemy(500); + if (CanSeeEnemy(500) || bCanShoot) { - if( CanShootEnemy( 500 ) ) + if (CanShootEnemy(500)) { Vector vDelta = m_Enemy->origin - origin; - if( VectorLength2DSquared( vDelta ) * 0.75f <= ( orientation[ 0 ][ 0 ] + orientation[ 0 ][ 1 ] ) * ( orientation[ 0 ][ 0 ] + orientation[ 1 ][ 1 ] ) ) + if (VectorLength2DSquared(vDelta) * 0.75f <= (orientation[0][0] + orientation[0][1]) * (orientation[0][0] + orientation[1][1])) { m_State = 307; } else { - m_State = 309; - } - - m_iStateTime = level.inttime; - State_Cover_Shoot(); - return; - } - - m_pCoverNode->Relinquish(); - m_pCoverNode->MarkTemporarilyBad(); - m_State = 305; - m_iStateTime = level.inttime; - State_Cover_FindEnemy(); - return; - } - - if( m_Team == TEAM_AMERICAN ) - { - if( level.inttime >= m_iLastFaceDecideTime + 1000 ) - { - m_iLastFaceDecideTime = level.inttime; - PathNode *node = PathManager.FindCornerNodeForExactPath( this, m_Enemy, m_fLeash + m_fMaxDistance ); - - if( !node ) - { - m_bHasDesiredLookAngles = false; - Anim_Stand(); - m_PotentialEnemies.FlagBadEnemy( m_Enemy ); - UpdateEnemy( -1 ); + TransitionState(309, 0); + State_Cover_Shoot(); return; } - Vector vDelta = node->m_PathPos - origin; - - if( vDelta[ 0 ] || vDelta[ 1 ] ) - { - SetDesiredYawDir(vDelta); - } + m_pCoverNode->Relinquish(); + m_pCoverNode->MarkTemporarilyBad(); + TransitionState(305, 0); + State_Cover_FindEnemy(); + return; } - Anim_Aim(); - } - else - { - if( level.inttime >= m_iLastFaceDecideTime + 1000 ) + if (m_Team == TEAM_AMERICAN) { - m_iLastFaceDecideTime = level.inttime; - Vector eyepos = EyePosition(); - Vector end = m_vLastEnemyPos + eyepos; - trace_t trace = G_Trace( - eyepos, - vec_zero, - vec_zero, - end, - this, - (CONTENTS_SOLID|CONTENTS_SLIME|CONTENTS_LAVA), - true, - "State_Cover" ); - - PathNode *node = PathManager.FindCornerNodeForWall( origin, m_vLastEnemyPos, this, 0.0f, trace.plane.normal ); - - if( node ) + if (level.inttime >= m_iLastFaceDecideTime + 1000) { + m_iLastFaceDecideTime = level.inttime; + PathNode *node = PathManager.FindCornerNodeForExactPath(this, m_Enemy, m_fLeash + m_fMaxDistance); + + if (!node) + { + m_bHasDesiredLookAngles = false; + Anim_Stand(); + m_PotentialEnemies.FlagBadEnemy(m_Enemy); + UpdateEnemy(-1); + return; + } + Vector vDelta = node->m_PathPos - origin; - if( vDelta[ 0 ] == 0.0f || vDelta[ 1 ] == 0.0f ) + if (vDelta[0] || vDelta[1]) { SetDesiredYawDir(vDelta); } - - m_eDontFaceWallMode = 6; } - else - { - AimAtTargetPos(); - DontFaceWall(); - } - } - if( m_eDontFaceWallMode <= 8 ) - { - Anim_Stand(); + Anim_Aim(); } else { - Anim_Aim(); + if (level.inttime >= m_iLastFaceDecideTime + 1000) + { + m_iLastFaceDecideTime = level.inttime; + Vector eyepos = EyePosition(); + Vector end = m_vLastEnemyPos + eyepos; + trace_t trace = G_Trace( + eyepos, + vec_zero, + vec_zero, + end, + this, + (CONTENTS_SOLID | CONTENTS_SLIME | CONTENTS_LAVA), + true, + "State_Cover"); + + PathNode *node = PathManager.FindCornerNodeForWall(origin, m_vLastEnemyPos, this, 0.0f, trace.plane.normal); + + if (node) + { + Vector vDelta = node->m_PathPos - origin; + + if (vDelta[0] == 0.0f || vDelta[1] == 0.0f) + { + SetDesiredYawDir(vDelta); + } + + m_eDontFaceWallMode = 6; + } + else + { + AimAtTargetPos(); + DontFaceWall(); + } + } + + if (m_eDontFaceWallMode <= 8) + { + Anim_Stand(); + } + else + { + Anim_Aim(); + } } - } - if( level.inttime <= m_iStateTime ) - return; + if (level.inttime <= m_iStateTime) + return; - PathNode *pNode = ( PathNode * )G_FindRandomSimpleTarget( m_pCoverNode->target ); + PathNode *pNode = (PathNode *)G_FindRandomSimpleTarget(m_pCoverNode->target); - m_pCoverNode->Relinquish(); - m_pCoverNode = NULL; + m_pCoverNode->Relinquish(); + m_pCoverNode = NULL; - if( !pNode ) - { - Anim_Stand(); - m_State = 305; - m_iStateTime = level.inttime + ( rand() & 0x7FF ); - return; - } - - assert( pNode->IsSubclassOfPathNode() ); - if( !pNode->IsSubclassOfPathNode() ) - { - return; - } - - if( !pNode->IsClaimedByOther( this ) ) - { - SetPath( pNode, "Actor::State_Cover_Target", 0 ); - - if( PathExists() ) + if (!pNode) { - m_pCoverNode = pNode; - pNode->Claim( this ); - Anim_RunToDanger( 3 ); - m_State = 306; - m_iStateTime = level.inttime; + Anim_Stand(); + TransitionState(305, rand() & 0x7FF); + return; + } + + assert(pNode->IsSubclassOfPathNode()); + if (!pNode->IsSubclassOfPathNode()) + { + return; + } + + if (!pNode->IsClaimedByOther(this)) + { + SetPath(pNode, "Actor::State_Cover_Target", 0); + + if (PathExists()) + { + m_pCoverNode = pNode; + pNode->Claim(this); + Anim_RunToDanger(3); + TransitionState(306, 0); + } } } } void Actor::State_Cover_Shoot - ( +( void - ) +) { - if( m_bNeedReload ) + if (m_bNeedReload) { - Cover_FindCover( true ); + Cover_FindCover(true); - if( m_pCoverNode ) + if (m_pCoverNode) { - Anim_RunToCover( 3 ); - FaceEnemyOrMotion( 0 ); - m_State = 302; - m_iStateTime = level.inttime; + Anim_RunToCover(3); + FaceEnemyOrMotion(0); + TransitionState(302, 0); return; } } @@ -489,11 +463,11 @@ void Actor::State_Cover_Shoot Anim_Shoot(); AimAtTargetPos(); - if( level.inttime > m_iStateTime + 10000 ) + if (level.inttime > m_iStateTime + 10000) { - gi.Cvar_Set( "g_monitornum", va( "%i", entnum ) ); - assert( !"anim/shoot.scr took over 10 seconds" ); - Com_Error( ERR_DROP, "anim/shoot.scr took over 10 seconds, entnum = %i, targetname = %s", entnum, targetname.c_str() ); + gi.Cvar_Set("g_monitornum", va("%i", entnum)); + assert(!"anim/shoot.scr took over 10 seconds"); + Com_Error(ERR_DROP, "anim/shoot.scr took over 10 seconds, entnum = %i, targetname = %s", entnum, targetname.c_str()); } } @@ -517,8 +491,7 @@ void Actor::State_Cover_SpecialAttack assert( m_pCoverNode ); if( !m_pCoverNode ) { - m_State = 305; - m_iStateTime = level.inttime; + TransitionState(305, 0); State_Cover_FindEnemy(); return; } @@ -531,8 +504,7 @@ void Actor::State_Cover_SpecialAttack m_pCoverNode = NULL; } - m_State = 305; - m_iStateTime = level.inttime; + TransitionState(305, 0); State_Cover_FindEnemy(); return; } @@ -543,8 +515,7 @@ void Actor::State_Cover_SpecialAttack if( !m_csSpecialAttack ) { - m_State = 305; - m_iStateTime = level.inttime; + TransitionState(305, 0); State_Cover_FindEnemy(); return; } @@ -573,8 +544,7 @@ __setpath: ShortenPathToAvoidSquadMates(); if( PathExists() && !PathComplete() && PathAvoidsSquadMates() ) { - m_State = 311; - m_iStateTime = level.inttime; + TransitionState(311, 0); } else { @@ -593,8 +563,7 @@ __setpath: { if( m_eDontFaceWallMode > 8 ) { - m_State = 307; - m_iStateTime = level.inttime; + TransitionState(307, 0); } goto __setpath; @@ -618,7 +587,7 @@ void Actor::State_Cover_SearchNode { Anim_Aim(); AimAtTargetPos(); - m_iStateTime = level.inttime; + TransitionState(307, 0); return; } @@ -634,8 +603,7 @@ void Actor::State_Cover_SearchNode if( level.inttime > m_iStateTime + 3000 ) { - m_State = 301; - m_iStateTime = level.inttime; + TransitionState(301, 0); } } } @@ -653,14 +621,12 @@ void Actor::State_Cover_HuntEnemy { if( CanSeeEnemy( 300 ) ) { - m_State = 307; - m_iStateTime = level.inttime; + TransitionState(307, 0); } } else { - m_State = 305; - m_iStateTime = level.inttime + ( rand() & 0x7FF ); + TransitionState(305, rand() & 0x7FF); if( m_pCoverNode ) { @@ -711,16 +677,14 @@ void Actor::Think_Cover { if( m_State == 313 ) { - m_State = 300; - m_iStateTime = level.inttime; + TransitionState(300, 0); } } else { if( m_State != 313 ) { - m_State = 313; - m_iStateTime = level.inttime + ( rand() & 0x7FF ) + 1000; + TransitionState(313, (rand() & 0x7FF) + 1000); } } @@ -807,18 +771,16 @@ void Actor::FinishedAnimation_Cover { if( m_Enemy && !m_Enemy->IsDead() && CanSeeEnemy( 500 ) && CanShootEnemy( 500 ) ) { - m_iStateTime = level.inttime; + TransitionState(309, 0); } else { - m_State = 301; - m_iStateTime = level.inttime; + TransitionState(301, 0); } } else if( m_State == 310 || m_State == 312 ) { - m_State = 301; - m_iStateTime = level.inttime; + TransitionState(301, 0); } } @@ -828,8 +790,7 @@ void Actor::PathnodeClaimRevoked_Cover ) { - m_State = 301; - m_iStateTime = level.inttime; + TransitionState(301, 0); } bool Actor::Cover_IsValid diff --git a/code/game/actor_curious.cpp b/code/game/actor_curious.cpp index ade4e625..464c6b86 100644 --- a/code/game/actor_curious.cpp +++ b/code/game/actor_curious.cpp @@ -90,8 +90,7 @@ void Actor::Begin_Curious m_bScriptGoalValid = false; } } - m_State = 1100; - m_iStateTime = level.inttime; + TransitionState(1100, 0); if (!m_bScriptGoalValid) { @@ -130,9 +129,8 @@ void Actor::Begin_Curious m_csNextAnimString = STRING_ANIM_STANDFLINCH_SCR; m_bNextForceStart = true; - m_State = 1101; m_bLockThinkState = true; - m_iStateTime = level.inttime; + TransitionState(1101, 0); } else if(m_Enemy && m_PotentialEnemies.GetCurrentVisibility() < 0.1) { @@ -146,9 +144,8 @@ void Actor::Begin_Curious m_csNextAnimString = STRING_ANIM_SURPRISE_SCR; m_bNextForceStart = true; - m_State = 1101; m_bLockThinkState = true; - m_iStateTime = level.inttime; + TransitionState(1101, 0); } } diff --git a/code/game/actor_disguise_common.cpp b/code/game/actor_disguise_common.cpp index 63932848..fb3cbbfd 100644 --- a/code/game/actor_disguise_common.cpp +++ b/code/game/actor_disguise_common.cpp @@ -52,8 +52,7 @@ void Actor::State_Disguise_Wait if (m_fMaxDisguiseDistSquared > fDistSquared * 4) { - m_State = 1; - m_iStateTime = level.inttime; + TransitionState(1, 0); } else { @@ -61,8 +60,7 @@ void Actor::State_Disguise_Wait { if (fDistSquared <= 65536) { - m_State = 1; - m_iStateTime = level.inttime; + TransitionState(1, 0); } else { @@ -93,16 +91,14 @@ void Actor::State_Disguise_Papers { if (m_DisguiseAcceptThread.IsSet()) m_DisguiseAcceptThread.Execute(this); - m_State = 2; + TransitionState(2, 0); } - m_iStateTime = level.inttime; } else { if (level.inttime > m_iStateTime + 12000) { - m_State = 3; - m_iStateTime = level.inttime; + TransitionState(3, 0); } else { @@ -110,8 +106,7 @@ void Actor::State_Disguise_Papers if (VectorLength2DSquared(vDelta) > 65536) { - m_State = 4; - m_iStateTime = level.inttime; + TransitionState(4, 0); } } } @@ -130,8 +125,7 @@ void Actor::State_Disguise_Fake_Papers m_bNextForceStart = false; if (m_iEnemyShowPapersTime < m_Enemy->m_ShowPapersTime || level.inttime > m_iStateTime + 12000) { - m_State = 3; - m_iStateTime = level.inttime; + TransitionState(3, 0); } else { @@ -139,8 +133,7 @@ void Actor::State_Disguise_Fake_Papers if (VectorLength2DSquared(vDelta) > 65536) { - m_State = 4; - m_iStateTime = level.inttime; + TransitionState(4, 0); } } diff --git a/code/game/actor_disguise_officier.cpp b/code/game/actor_disguise_officier.cpp index 582d0149..8a043baf 100644 --- a/code/game/actor_disguise_officier.cpp +++ b/code/game/actor_disguise_officier.cpp @@ -67,10 +67,9 @@ void Actor::Begin_DisguiseOfficer m_csNextAnimString = STRING_ANIM_DISGUISE_PAPERS_SCR; m_bNextForceStart = false; - m_State = 1; m_iEnemyShowPapersTime = m_Enemy->m_ShowPapersTime; - m_iStateTime = level.inttime; + TransitionState(1, 0); } else { @@ -131,8 +130,7 @@ void Actor::Think_DisguiseOfficer } if (!EnemyIsDisguised() && !(m_Enemy->IsSubclassOfActor()) && m_State != 3) { - m_State = 3; - m_iStateTime = level.inttime; + TransitionState(3, 0); } if (level.m_bAlarm) { diff --git a/code/game/actor_disguise_rover.cpp b/code/game/actor_disguise_rover.cpp index 800d3028..e8da0078 100644 --- a/code/game/actor_disguise_rover.cpp +++ b/code/game/actor_disguise_rover.cpp @@ -67,10 +67,8 @@ void Actor::Begin_DisguiseRover m_csNextAnimString = STRING_ANIM_DISGUISE_PAPERS_SCR; m_bNextForceStart = false; - m_State = 1; - m_iEnemyShowPapersTime = m_Enemy->m_ShowPapersTime; - m_iStateTime = level.inttime; + TransitionState(1, 0); } else { @@ -135,8 +133,7 @@ void Actor::Think_DisguiseRover if (!EnemyIsDisguised() && !m_Enemy->IsSubclassOfActor() && m_State != 3) { - m_State = 3; - m_iStateTime = level.inttime; + TransitionState(3, 0); } if (level.m_bAlarm) diff --git a/code/game/actor_disguise_salute.cpp b/code/game/actor_disguise_salute.cpp index 25011703..6950105f 100644 --- a/code/game/actor_disguise_salute.cpp +++ b/code/game/actor_disguise_salute.cpp @@ -70,10 +70,9 @@ void Actor::Begin_DisguiseSalute m_csNextAnimString = STRING_ANIM_DISGUISE_SALUTE_SCR; m_bNextForceStart = false; - m_State = 1; m_iEnemyShowPapersTime = m_Enemy->m_ShowPapersTime; - m_iStateTime = level.inttime; + TransitionState(1, 0); } else { diff --git a/code/game/actor_disguise_sentry.cpp b/code/game/actor_disguise_sentry.cpp index 7a67edcb..f29deac2 100644 --- a/code/game/actor_disguise_sentry.cpp +++ b/code/game/actor_disguise_sentry.cpp @@ -69,10 +69,8 @@ void Actor::Begin_DisguiseSentry m_csNextAnimString = STRING_ANIM_DISGUISE_WAIT_SCR; m_bNextForceStart = false; - m_State = 1; - m_iEnemyShowPapersTime = m_Enemy->m_ShowPapersTime; - m_iStateTime = level.inttime; + TransitionState(1, 0); } else { @@ -134,8 +132,7 @@ void Actor::Think_DisguiseSentry } if (!EnemyIsDisguised() && !m_Enemy->IsSubclassOfActor() && m_State != 3) { - m_State = 3; - m_iStateTime = level.inttime; + TransitionState(3, 0); } if (level.m_bAlarm) diff --git a/code/game/actor_dog.cpp b/code/game/actor_dog.cpp index dfec2f11..6fc01ac1 100644 --- a/code/game/actor_dog.cpp +++ b/code/game/actor_dog.cpp @@ -167,8 +167,7 @@ void Actor::Think_Dog_Attack m_bNextForceStart = false; m_eNextAnimMode = 1; m_csNextAnimString = STRING_ANIM_DOG_CURIOUS_SCR; - m_State = 20; - m_iStateTime = level.inttime; + TransitionState(20, 0); CheckForThinkStateTransition(); PostThink(false); diff --git a/code/game/actor_killed.cpp b/code/game/actor_killed.cpp index decf0205..093d956a 100644 --- a/code/game/actor_killed.cpp +++ b/code/game/actor_killed.cpp @@ -59,8 +59,7 @@ void Actor::Begin_Killed PostEvent( e1, 0.05f); - m_State = 700; - m_iStateTime = level.inttime; + TransitionState(700, 0); } void Actor::Think_Killed @@ -92,6 +91,5 @@ void Actor::FinishedAnimation_Killed { BecomeCorpse(); - m_State = 701; - m_iStateTime = level.inttime; + TransitionState(701, 0); } diff --git a/code/game/actor_machinegunner.cpp b/code/game/actor_machinegunner.cpp index d99d3876..d08bd0e7 100644 --- a/code/game/actor_machinegunner.cpp +++ b/code/game/actor_machinegunner.cpp @@ -75,8 +75,7 @@ void Actor::Begin_MachineGunner Holster(); m_pTurret->TurretBeginUsed(this); - m_State = 1200; - m_iStateTime = level.inttime; + TransitionState(1200, 0); } } else @@ -120,8 +119,7 @@ void Actor::BecomeTurretGuy if (CurrentThink() == THINK_IDLE && Turret_DecideToSelectState()) { - m_State = 100; - m_iStateTime = level.inttime; + TransitionState(100, 0); } } @@ -331,8 +329,7 @@ void Actor::FinishedAnimation_MachineGunner { if (!m_bAnimScriptSet && m_State == 1201) { - m_State = 1200; - m_iStateTime = level.inttime; + TransitionState(1200, 0); Unregister(STRING_ANIMDONE); } } diff --git a/code/game/actor_turret.cpp b/code/game/actor_turret.cpp index b317c676..bf5ee179 100644 --- a/code/game/actor_turret.cpp +++ b/code/game/actor_turret.cpp @@ -56,13 +56,11 @@ void Actor::Begin_Turret if (m_Enemy) { - m_State = 110; - m_iStateTime = level.inttime; + TransitionState(110, 0); } else { - m_State = 109; - m_iStateTime = level.inttime + (rand() & 0x7FF) + 250; + TransitionState(109, (rand() & 0x7FF) + 250); } } @@ -77,8 +75,7 @@ void Actor::End_Turret m_pCoverNode->Relinquish(); m_pCoverNode = NULL; } - m_State = -1; - m_iStateTime = level.inttime; + TransitionState(-1, 0); } void Actor::Suspend_Turret @@ -89,8 +86,7 @@ void Actor::Suspend_Turret { if (!m_Enemy) { - m_State = 110; - m_iStateTime = level.inttime; + TransitionState(110, 0); } else { @@ -98,8 +94,7 @@ void Actor::Suspend_Turret { SetEnemyPos(m_Enemy->origin); AimAtEnemyBehavior(); - m_State = 113; - m_iStateTime = level.inttime; + TransitionState(113, 0); } } } @@ -120,10 +115,8 @@ void Actor::Think_Turret if (m_Enemy && m_State == 110) { - if (!m_bTurretNoInitialCover) + if (!m_bTurretNoInitialCover && Turret_TryToBecomeCoverGuy()) { - if (Turret_TryToBecomeCoverGuy()) - { m_pszDebugState = "CoverInstead"; CheckUnregister(); UpdateAngles(); @@ -131,7 +124,6 @@ void Actor::Think_Turret UpdateBoneControllers(); UpdateFootsteps(); return; - } } m_bTurretNoInitialCover = false; @@ -139,10 +131,7 @@ void Actor::Think_Turret if (m_State == 100 && !CanSeeEnemy(0)) { - SetEnemyPos(m_Enemy->origin); - AimAtEnemyBehavior(); - m_State = 113; - m_iStateTime = level.inttime; + Turret_BeginRetarget(); } SetLeashHome(origin); @@ -151,9 +140,8 @@ void Actor::Think_Turret { if (AttackEntryAnimation()) { - m_State = 108; m_bLockThinkState = true; - m_iStateTime = level.inttime; + TransitionState(108, 0); } } } @@ -173,7 +161,8 @@ void Actor::Think_Turret if (!m_Enemy && m_State != 109 && m_State != 104) { m_State = 109; - m_iStateTime = level.inttime + ((rand() + 0xFA) & 0x7FF); + m_iStateTime = level.inttime + ((rand() + 250) & 0x7FF); + TransitionState(109, ((rand() + 250) & 0x7FF)); } if (!m_Enemy) { @@ -197,10 +186,7 @@ void Actor::Think_Turret } if (m_Enemy && m_State == 109) { - Actor::SetEnemyPos(m_Enemy->origin); - AimAtEnemyBehavior(); - m_State = 113; - m_iStateTime = level.inttime; + Turret_BeginRetarget(); } if (Turret_DecideToSelectState()) @@ -221,8 +207,7 @@ void Actor::Think_Turret if (!PathExists() || PathComplete()) { AimAtEnemyBehavior(); - m_State = 103; - m_iStateTime = level.inttime; + TransitionState(103, 0); } else { @@ -272,38 +257,11 @@ void Actor::Think_Turret break; case 115: m_pszDebugState = "Retarget_Path_Exact"; - AimAtEnemyBehavior(); - SetPathWithLeash(m_vLastEnemyPos, NULL, 0); - if (!ShortenPathToAttack(128.0f)) - { - Turret_NextRetarget(); - } - else - { - ShortenPathToAvoidSquadMates(); - if (PathExists()) - { - m_State = 101; - m_iStateTime = level.inttime; - } - else - { - Turret_NextRetarget(); - } - } + State_Turret_Retarget_Path_Exact(); + break; case 116: m_pszDebugState = "Retarget_Path_Near"; - AimAtEnemyBehavior(); - FindPathNearWithLeash(m_vLastEnemyPos, m_fMinDistanceSquared); - if (ShortenPathToAttack(128.0f)) - { - m_State = 101; - m_iStateTime = level.inttime; - } - else - { - Turret_NextRetarget(); - } + State_Turret_Retarget_Path_Near(); break; case 117: m_pszDebugState = "Retarget_Step_Side_Medium"; @@ -365,19 +323,7 @@ void Actor::ReceiveAIEvent_Turret { if (m_Enemy && fDistSquared <= Square(128)) { - auto pCoverNode = m_pCoverNode; - Cover_FindCover(true); - if (m_pCoverNode) - { - m_State = 111; - m_iStateTime = level.inttime; - SetThink(THINKSTATE_ATTACK, THINK_COVER); - } - else if (pCoverNode) - { - m_pCoverNode = pCoverNode; - m_pCoverNode->Claim(this); - } + Turret_TryToBecomeCoverGuy(); } } else @@ -412,15 +358,12 @@ void Actor::PathnodeClaimRevoked_Turret { if (m_Enemy == NULL) { - m_State = 110; + TransitionState(110, 0); } else { - SetEnemyPos(m_Enemy->origin); - AimAtEnemyBehavior(); - m_State = 113; + Turret_BeginRetarget(); } - m_iStateTime = level.inttime; } bool Actor::Turret_IsRetargeting @@ -456,23 +399,22 @@ bool Actor::Turret_DecideToSelectState } void Actor::Turret_SelectState - ( +( void - ) +) { vec2_t vDelta; float fDistSquared; if (!m_Enemy) { - m_State = 109; - m_iStateTime = level.inttime + rand() & 0x7fff + 250; + TransitionState(109, rand() & 0x7FF + 250); return; } VectorSub2D(origin, m_vHome, vDelta); fDistSquared = VectorLength2DSquared(vDelta); - + if (m_State == 104 && fDistSquared > m_fLeashSquared * 0.64 + 64.0) { if (PathExists() && !PathComplete()) @@ -494,11 +436,13 @@ void Actor::Turret_SelectState SetPath(m_vHome, NULL, 0, NULL, 0.0); ShortenPathToAvoidSquadMates(); - if (PathExists() && !PathComplete()) + if (PathExists()) { - m_State = 104; - m_iStateTime = level.inttime; - return; + if (!PathComplete()) + { + TransitionState(104, 0); + return; + } } else { @@ -510,7 +454,7 @@ void Actor::Turret_SelectState } } - VectorSub2D(origin, m_vHome, vDelta); + VectorSub2D(origin, m_Enemy->origin, vDelta); fDistSquared = VectorLength2DSquared(vDelta); if (m_State == 105) @@ -522,8 +466,7 @@ void Actor::Turret_SelectState if (m_fMinDistanceSquared > fDistSquared) { ClearPath(); - m_State = 105; - m_iStateTime = level.inttime; + TransitionState(105, 0); return; } @@ -532,7 +475,7 @@ void Actor::Turret_SelectState bool bSmthing = false; if (m_Team == TEAM_GERMAN) { - if ((m_Enemy->origin-m_vHome).lengthSquared() >= Square(m_fLeash + m_fMaxDistance) && !CanSeeEnemy(200)) + if ((m_Enemy->origin - m_vHome).lengthSquared() >= Square(m_fLeash + m_fMaxDistance) && !CanSeeEnemy(200)) bSmthing = true; } if (bSmthing) @@ -545,29 +488,26 @@ void Actor::Turret_SelectState if (m_State == 106) return; ClearPath(); - m_State = 106; + TransitionState(106, 0); + return; } - m_iStateTime = level.inttime; - return; - } - if (DecideToThrowGrenade(m_Enemy->velocity + m_vLastEnemyPos, &m_vGrenadeVel, &m_eGrenadeMode)) - { - m_bNextForceStart = false; - SetDesiredYawDir(m_vGrenadeVel); + if (DecideToThrowGrenade(m_Enemy->velocity + m_vLastEnemyPos, &m_vGrenadeVel, &m_eGrenadeMode)) + { + m_bNextForceStart = false; + SetDesiredYawDir(m_vGrenadeVel); - m_eNextAnimMode = 1; - m_State = 107; - m_csNextAnimString = (m_eGrenadeMode == AI_GREN_TOSS_ROLL) ? STRING_ANIM_GRENADETOSS_SCR : STRING_ANIM_GRENADETHROW_SCR; - m_iStateTime = level.inttime; - return; - } + m_eNextAnimMode = 1; + m_csNextAnimString = (m_eGrenadeMode == AI_GREN_TOSS_ROLL) ? STRING_ANIM_GRENADETOSS_SCR : STRING_ANIM_GRENADETHROW_SCR; + TransitionState(107, 0); + return; + } - if (m_State != 100 && m_State != 103 && m_State != 112) - { - ClearPath(); - m_State = 100; - m_iStateTime = level.inttime; + if (m_State != 100 && m_State != 103 && m_State != 112) + { + ClearPath(); + TransitionState(100, 0); + } } } @@ -595,8 +535,7 @@ bool Actor::Turret_TryToBecomeCoverGuy Cover_FindCover(true); if (m_pCoverNode) { - m_State = 111; - m_iStateTime = level.inttime; + TransitionState(111, 0); SetThink(THINKSTATE_ATTACK, THINK_COVER); return true; } @@ -620,8 +559,7 @@ void Actor::Turret_BeginRetarget SetEnemyPos(m_Enemy->origin); AimAtEnemyBehavior(); - m_State = 113; - m_iStateTime = level.inttime; + TransitionState(113, 0); } @@ -668,20 +606,17 @@ void Actor::Turret_NextRetarget { if (!CanSeeEnemy(200)) { - m_State = 112; - m_iStateTime = level.inttime; + TransitionState(112, 0); State_Turret_Wait(); return; } m_pszDebugState = "Retarget->Combat"; } - m_State = 100; - m_iStateTime = level.inttime; + TransitionState(100, 0); State_Turret_Combat(); return; } - m_State = 104; - m_iStateTime = level.inttime; + TransitionState(104, 0); SetPath(m_vHome, NULL, 0, NULL, 0.0); ShortenPathToAvoidSquadMates(); if (!PathExists() || PathComplete()) @@ -721,8 +656,7 @@ void Actor::Turret_SideStep && !PathComplete() && PathAvoidsSquadMates()) { - m_State = 101; - m_iStateTime = level.inttime; + TransitionState(101, 0); } else { @@ -774,8 +708,7 @@ void Actor::State_Turret_Combat SetEnemyPos(m_Enemy->origin); AimAtEnemyBehavior(); - m_State = 113; - m_iStateTime = level.inttime; + TransitionState(113, 0); } void Actor::State_Turret_Reacquire @@ -807,8 +740,7 @@ void Actor::State_Turret_Reacquire { m_pszDebugState = "Retarget->Cheat"; SetEnemyPos(m_Enemy->origin); - m_State = 100; - m_iStateTime = level.inttime; + TransitionState(100, 0); State_Turret_Combat(); } } @@ -827,8 +759,7 @@ void Actor::State_Turret_TakeSniperNode else { AimAtEnemyBehavior(); - m_State = 103; - m_iStateTime = level.inttime; + TransitionState(103, 0); } } @@ -952,8 +883,7 @@ void Actor::State_Turret_Charge if (!MovePathWithLeash()) { m_pszDebugState = "charge->leash->combat"; - m_State = 100; - m_iStateTime = level.inttime; + TransitionState(100, 0); State_Turret_Combat(); return; } @@ -996,8 +926,7 @@ void Actor::State_Turret_Wait if (m_pCoverNode) { - m_State = 111; - m_iStateTime = level.inttime; + TransitionState(111, 0); SetThink(THINKSTATE_ATTACK, THINK_COVER); bSmth = true; } @@ -1018,8 +947,7 @@ void Actor::State_Turret_Wait else { m_pszDebugState = "Wait->Combat"; - m_State = 100; - m_iStateTime = level.inttime; + TransitionState(100, 0); State_Turret_Combat(); } } @@ -1077,8 +1005,7 @@ void Actor::State_Turret_Retarget_Sniper_Node { m_pCoverNode = pSniperNode; pSniperNode->Claim(this); - m_State = 102; - m_iStateTime = level.inttime; + TransitionState(102, 0); State_Turret_TakeSniperNode(); } @@ -1100,15 +1027,21 @@ void Actor::State_Turret_Retarget_Path_Exact { AimAtEnemyBehavior(); SetPathWithLeash(m_vLastEnemyPos, NULL, 0); - if (ShortenPathToAttack(128) - && (ShortenPathToAvoidSquadMates(), PathExists())) + if (!ShortenPathToAttack(128.0f)) { - m_State = 101; - m_iStateTime = level.inttime; + Turret_NextRetarget(); } else { - Turret_NextRetarget(); + ShortenPathToAvoidSquadMates(); + if (PathExists()) + { + TransitionState(101, 0); + } + else + { + Turret_NextRetarget(); + } } } @@ -1122,8 +1055,7 @@ void Actor::State_Turret_Retarget_Path_Near FindPathNearWithLeash(m_vLastEnemyPos, m_fMinDistanceSquared); if (ShortenPathToAttack(128)) { - m_State = 101; - m_iStateTime = level.inttime; + TransitionState(101, 0); } else { @@ -1148,8 +1080,7 @@ void Actor::State_Turret_Retarget_Step_Side_Small && !PathComplete() && PathAvoidsSquadMates()) { - m_State = 101; - m_iStateTime = level.inttime; + TransitionState(101, 0); } else { @@ -1174,8 +1105,7 @@ void Actor::State_Turret_Retarget_Step_Side_Medium && !PathComplete() && PathAvoidsSquadMates()) { - m_State = 101; - m_iStateTime = level.inttime; + TransitionState(101, 0); } else { @@ -1200,8 +1130,7 @@ void Actor::State_Turret_Retarget_Step_Side_Large && !PathComplete() && PathAvoidsSquadMates()) { - m_State = 101; - m_iStateTime = level.inttime; + TransitionState(101, 0); } else { @@ -1226,8 +1155,7 @@ void Actor::State_Turret_Retarget_Step_Face_Medium && !PathComplete() && PathAvoidsSquadMates()) { - m_State = 101; - m_iStateTime = level.inttime; + TransitionState(101, 0); } else { @@ -1252,8 +1180,7 @@ void Actor::State_Turret_Retarget_Step_Face_Large && !PathComplete() && PathAvoidsSquadMates()) { - m_State = 101; - m_iStateTime = level.inttime; + TransitionState(101, 0); } else { diff --git a/code/game/actor_weaponless.cpp b/code/game/actor_weaponless.cpp index fb8dcf3a..dd50e414 100644 --- a/code/game/actor_weaponless.cpp +++ b/code/game/actor_weaponless.cpp @@ -55,13 +55,12 @@ void Actor::Begin_Weaponless SetLeashHome(origin); if (AttackEntryAnimation()) { - m_State = 902; m_bLockThinkState = true; - m_iStateTime = level.inttime; + + TransitionState(902, 0); } } - m_State = 900; - m_iStateTime = level.inttime; + TransitionState(900, 0); } void Actor::Suspend_Weaponless @@ -72,8 +71,7 @@ void Actor::Suspend_Weaponless { if (m_State <= 902) { - m_State = 900; - m_iStateTime = level.inttime; + TransitionState(900, 0); } } @@ -137,8 +135,7 @@ void Actor::FinishedAnimation_Weaponless { if (m_State <= 902) { - m_State = 900; - m_iStateTime = level.inttime + 4000; + TransitionState(900, 4000); } } diff --git a/code/game/g_utils.cpp b/code/game/g_utils.cpp index 34dd1223..dbd3252a 100644 --- a/code/game/g_utils.cpp +++ b/code/game/g_utils.cpp @@ -741,13 +741,13 @@ float vectoyaw( const vec3_t vec ) { if (vec[YAW] == 0 && vec[PITCH] == 0) { yaw = 0; } else { - if (vec[PITCH]) { + //if (vec[PITCH]) { yaw = ( atan2( vec[YAW], vec[PITCH]) * 180 / M_PI ); - } else if (vec[YAW] > 0) { - yaw = 90; - } else { - yaw = 270; - } + //} else if (vec[YAW] > 0) { + // yaw = 90; + //} else { + // yaw = 270; + //} if (yaw < 0) { yaw += 360; } diff --git a/code/game/simpleactor.cpp b/code/game/simpleactor.cpp index 975d7090..a963a27d 100644 --- a/code/game/simpleactor.cpp +++ b/code/game/simpleactor.cpp @@ -1799,7 +1799,7 @@ void SimpleActor::ContinueAnimation if (eAnimMode <= 3 && !PathExists()) { - //assert(!DumpCallTrace("ContinueAnimation() called on a pathed animation, but no path exists")); + assert(!DumpCallTrace("ContinueAnimation() called on a pathed animation, but no path exists")); Anim_Stand(); } } diff --git a/code/qcommon/q_math.c b/code/qcommon/q_math.c index 99e21edd..5c51a98d 100644 --- a/code/qcommon/q_math.c +++ b/code/qcommon/q_math.c @@ -680,15 +680,15 @@ void vectoangles( const vec3_t value1, vec3_t angles ) { } } else { - if ( value1[0] ) { + //if ( value1[0] ) { yaw = ( atan2 ( value1[1], value1[0] ) * 180 / M_PI ); - } - else if ( value1[1] > 0 ) { - yaw = 90; - } - else { - yaw = 270; - } + //} + //else if ( value1[1] > 0 ) { + // yaw = 90; + //} + //else { + // yaw = 270; + //} if ( yaw < 0 ) { yaw += 360; }