mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2024-12-25 14:25:32 +03:00
Redid parts of backup activity system to support weapon act table recursion
This commit is contained in:
parent
670465dc58
commit
f79515fc11
@ -2725,6 +2725,35 @@ bool CBaseCombatCharacter::Weapon_CanUse( CBaseCombatWeapon *pWeapon )
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
static Activity Weapon_BackupActivityFromList( CBaseCombatCharacter *pBCC, acttable_t *pTable, int actCount, Activity activity, bool weaponTranslationWasRequired, CBaseCombatWeapon *pWeapon )
|
||||
{
|
||||
int i = 0;
|
||||
for ( ; i < actCount; i++, pTable++ )
|
||||
{
|
||||
if ( activity == pTable->baseAct )
|
||||
{
|
||||
// Don't pick backup activities we don't actually have an animation for.
|
||||
if (!pBCC->GetModelPtr()->HaveSequenceForActivity(pTable->weaponAct))
|
||||
break;
|
||||
|
||||
return (Activity)pTable->weaponAct;
|
||||
}
|
||||
}
|
||||
|
||||
// We didn't succeed in finding an activity. See if we can recurse
|
||||
acttable_t *pBackupTable = CBaseCombatWeapon::GetDefaultBackupActivityList( pTable - i, actCount );
|
||||
if (pBackupTable)
|
||||
{
|
||||
return Weapon_BackupActivityFromList( pBCC, pBackupTable, actCount, activity, weaponTranslationWasRequired, pWeapon );
|
||||
}
|
||||
|
||||
return activity;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Uses an activity from a different weapon when the activity we were originally looking for does not exist on this character.
|
||||
// This gives NPCs and players the ability to use weapons they are otherwise unable to use.
|
||||
@ -2739,30 +2768,27 @@ Activity CBaseCombatCharacter::Weapon_BackupActivity( Activity activity, bool we
|
||||
if (!pWeapon->SupportsBackupActivity(activity))
|
||||
return activity;
|
||||
|
||||
// Sometimes, a NPC is supposed to use the default activity. Return that if the weapon translation was "not required" and we have an original activity.
|
||||
// Don't do this with players.
|
||||
// UNDONE: Sometimes, a NPC is supposed to use the default activity. Return that if the weapon translation was "not required" and we have an original activity.
|
||||
/*
|
||||
if (!weaponTranslationWasRequired && GetModelPtr()->HaveSequenceForActivity(activity) && !IsPlayer())
|
||||
{
|
||||
return activity;
|
||||
}
|
||||
*/
|
||||
|
||||
acttable_t *pTable = pWeapon->GetBackupActivityList();
|
||||
if (pTable)
|
||||
int actCount = pWeapon->GetBackupActivityListCount();
|
||||
if (!pTable)
|
||||
{
|
||||
// Look for a default list
|
||||
actCount = pWeapon->ActivityListCount();
|
||||
pTable = CBaseCombatWeapon::GetDefaultBackupActivityList( pWeapon->ActivityList(), actCount );
|
||||
}
|
||||
|
||||
if (pTable && GetModelPtr())
|
||||
{
|
||||
int actCount = pWeapon->GetBackupActivityListCount();
|
||||
for ( int i = 0; i < actCount; i++, pTable++ )
|
||||
{
|
||||
if ( activity == pTable->baseAct )
|
||||
{
|
||||
// Don't pick backup activities we don't actually have an animation for.
|
||||
if (GetModelPtr() ? !GetModelPtr()->HaveSequenceForActivity(pTable->weaponAct) : false)
|
||||
{
|
||||
return activity;
|
||||
}
|
||||
|
||||
return (Activity)pTable->weaponAct;
|
||||
}
|
||||
}
|
||||
return Weapon_BackupActivityFromList( this, pTable, actCount, activity, weaponTranslationWasRequired, pWeapon );
|
||||
}
|
||||
|
||||
return activity;
|
||||
|
@ -1802,20 +1802,6 @@ bool CAI_ActBusyBehavior::PlayAnimForActBusy( busyanimparts_t AnimPart )
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Get the busy's move activity
|
||||
//-----------------------------------------------------------------------------
|
||||
Activity CAI_ActBusyBehavior::GetMoveActivityForActBusy()
|
||||
{
|
||||
busyanim_t *pBusyAnim = g_ActBusyAnimDataSystem.GetBusyAnim( m_iCurrentBusyAnim );
|
||||
if ( !pBusyAnim )
|
||||
return m_ForcedActivity;
|
||||
|
||||
return pBusyAnim->bTranslateActivity ? GetOuter()->TranslateActivity( m_ForcedActivity ) : m_ForcedActivity;
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -2044,11 +2030,7 @@ void CAI_ActBusyBehavior::StartTask( const Task_t *pTask )
|
||||
// If we have a forced activity, use that. Otherwise, walk.
|
||||
if ( m_ForcedActivity != ACT_INVALID && m_ForcedActivity != ACT_RESET )
|
||||
{
|
||||
#ifdef MAPBASE
|
||||
GetNavigator()->SetMovementActivity( GetMoveActivityForActBusy() );
|
||||
#else
|
||||
GetNavigator()->SetMovementActivity( m_ForcedActivity );
|
||||
#endif
|
||||
|
||||
// Cover is void once I move
|
||||
Forget( bits_MEMORY_INCOVER );
|
||||
|
@ -167,9 +167,6 @@ private:
|
||||
void NotifyBusyEnding( void );
|
||||
bool HasAnimForActBusy( int iActBusy, busyanimparts_t AnimPart );
|
||||
bool PlayAnimForActBusy( busyanimparts_t AnimPart );
|
||||
#ifdef MAPBASE
|
||||
Activity GetMoveActivityForActBusy();
|
||||
#endif
|
||||
void PlaySoundForActBusy( busyanimparts_t AnimPart );
|
||||
|
||||
private:
|
||||
|
@ -225,6 +225,17 @@ acttable_t CWeapon357::m_acttable[] =
|
||||
|
||||
|
||||
IMPLEMENT_ACTTABLE( CWeapon357 );
|
||||
|
||||
// Allows Weapon_BackupActivity() to access the 357's activity table.
|
||||
acttable_t *Get357Acttable()
|
||||
{
|
||||
return CWeapon357::m_acttable;
|
||||
}
|
||||
|
||||
int Get357ActtableCount()
|
||||
{
|
||||
return ARRAYSIZE(CWeapon357::m_acttable);
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -1100,6 +1100,11 @@ WeaponClass_t CBaseCombatWeapon::WeaponClassify()
|
||||
case ACT_IDLE_ANGRY_PISTOL: return WEPCLASS_HANDGUN;
|
||||
#if EXPANDED_HL2_WEAPON_ACTIVITIES
|
||||
case ACT_IDLE_ANGRY_CROSSBOW: // For now, crossbows are rifles
|
||||
#endif
|
||||
#if EXPANDED_HL2_UNUSED_WEAPON_ACTIVITIES
|
||||
case ACT_IDLE_ANGRY_AR1:
|
||||
case ACT_IDLE_ANGRY_SMG2:
|
||||
case ACT_IDLE_ANGRY_SNIPER_RIFLE:
|
||||
#endif
|
||||
case ACT_IDLE_ANGRY_SMG1:
|
||||
case ACT_IDLE_ANGRY_AR2: return WEPCLASS_RIFLE;
|
||||
@ -1134,6 +1139,18 @@ WeaponClass_t CBaseCombatWeapon::WeaponClassFromString(const char *str)
|
||||
#ifdef HL2_DLL
|
||||
extern acttable_t *GetSMG1Acttable();
|
||||
extern int GetSMG1ActtableCount();
|
||||
|
||||
extern acttable_t *GetAR2Acttable();
|
||||
extern int GetAR2ActtableCount();
|
||||
|
||||
extern acttable_t *GetShotgunActtable();
|
||||
extern int GetShotgunActtableCount();
|
||||
|
||||
extern acttable_t *GetPistolActtable();
|
||||
extern int GetPistolActtableCount();
|
||||
|
||||
extern acttable_t *Get357Acttable();
|
||||
extern int Get357ActtableCount();
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -1154,20 +1171,69 @@ bool CBaseCombatWeapon::SupportsBackupActivity(Activity activity)
|
||||
|
||||
acttable_t *CBaseCombatWeapon::GetBackupActivityList()
|
||||
{
|
||||
#ifdef HL2_DLL
|
||||
return GetSMG1Acttable();
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
int CBaseCombatWeapon::GetBackupActivityListCount()
|
||||
{
|
||||
#ifdef HL2_DLL
|
||||
return GetSMG1ActtableCount();
|
||||
#else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
acttable_t *CBaseCombatWeapon::GetDefaultBackupActivityList( acttable_t *pTable, int &actCount )
|
||||
{
|
||||
#ifdef HL2_DLL
|
||||
// Ensure this isn't already a default backup activity list
|
||||
if (pTable == GetSMG1Acttable() || pTable == GetPistolActtable())
|
||||
return NULL;
|
||||
|
||||
// Use a backup table based on what ACT_IDLE_ANGRY is translated to
|
||||
Activity actTranslated = ACT_INVALID;
|
||||
for ( int i = 0; i < actCount; i++, pTable++ )
|
||||
{
|
||||
if ( pTable->baseAct == ACT_IDLE_ANGRY )
|
||||
{
|
||||
actTranslated = (Activity)pTable->weaponAct;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (actTranslated == ACT_INVALID)
|
||||
return NULL;
|
||||
|
||||
switch (actTranslated)
|
||||
{
|
||||
#if EXPANDED_HL2_WEAPON_ACTIVITIES
|
||||
case ACT_IDLE_ANGRY_REVOLVER:
|
||||
#endif
|
||||
case ACT_IDLE_ANGRY_PISTOL:
|
||||
{
|
||||
actCount = GetPistolActtableCount();
|
||||
return GetPistolActtable();
|
||||
}
|
||||
#if EXPANDED_HL2_WEAPON_ACTIVITIES
|
||||
case ACT_IDLE_ANGRY_CROSSBOW: // For now, crossbows are rifles
|
||||
#endif
|
||||
#if EXPANDED_HL2_UNUSED_WEAPON_ACTIVITIES
|
||||
case ACT_IDLE_ANGRY_AR1:
|
||||
case ACT_IDLE_ANGRY_SMG2:
|
||||
case ACT_IDLE_ANGRY_SNIPER_RIFLE:
|
||||
#endif
|
||||
case ACT_IDLE_ANGRY_SMG1:
|
||||
case ACT_IDLE_ANGRY_AR2:
|
||||
case ACT_IDLE_ANGRY_SHOTGUN:
|
||||
case ACT_IDLE_ANGRY_RPG:
|
||||
{
|
||||
actCount = GetSMG1ActtableCount();
|
||||
return GetSMG1Acttable();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
actCount = 0;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -232,6 +232,7 @@ public:
|
||||
virtual bool SupportsBackupActivity(Activity activity);
|
||||
virtual acttable_t *GetBackupActivityList();
|
||||
virtual int GetBackupActivityListCount();
|
||||
static acttable_t *GetDefaultBackupActivityList( acttable_t *pTable, int &actCount );
|
||||
#endif
|
||||
|
||||
virtual void Equip( CBaseCombatCharacter *pOwner );
|
||||
|
Loading…
Reference in New Issue
Block a user