I second Captain P advice, the way you are doing it right now will involve a lot of code duplication and that will put a lot of burden when maintaining it.
Sometimes in situations like these, it's best to make methods that solve small but repetitive problems. In your case, one small problem is "how do I convert the
value to a C string that would match the animations names" and "how do I handle the standing up/crouched difference".
Then you combine both solutions to get the "final answer" to your original problem which was "how do I get the proper value to use in
". In the end, you have something like this:
* Returns the name of a sequence for this monster based on his stance (standing up or crouched), a specific name and his current weapon's name.
* @param szName The name of the sequence without the stance ("ref_" and "crouch_"), weapon's name ("python"...) and any underscore.
* @return The corresponding sequence name.
const char *CMyMonster::GetSequenceName( const char *szName ) const
static char szResult;
strncpy( szResult, m_fStanding ? "ref_" : "crouch_", sizeof( szResult ) );
strncat( szResult, szName, sizeof( szResult ) );
strncat( szResult, "_", sizeof( szResult ) );
strncat( szResult, GetWeaponIDAsCStr(), sizeof( szResult ) );
* Returns the name of the weapon this monster is currently using as a "C string".
* This is used to select the proper sequence when performing activities.
* @return This monster's current weapon name.
const char *CMyMonster::GetWeaponIDAsCStr() const
if ( pev->weapons & HEVSCI_PYTHON )
else if ( pev->weapons & HEVSCI_SHOTGUN )
else if ( pev->weapons & HEVSCI_MP5 )
else if ( pev->weapons & HEVSCI_CROSSBOW )
else if ( pev->weapons & HEVSCI_RPG )
else if ( pev->weapons & HEVSCI_GAUSS )
Which you can use like this:
void CMyMonster::SetActivity( Activity NewActivity )
int iSequence = ACTIVITY_NOT_AVAILABLE;
void *pModel = GET_MODEL_PTR( ENT( pev ) );
switch ( NewActivity )
iSequence = LookupSequence( GetSequenceName( "aim" ) );
iSequence = LookupActivity( NewActivity );
if ( iSequence <= ACTIVITY_NOT_AVAILABLE )
// Not available try to get default anim
ALERT( at_console, "%s has no sequence for act:%d\n", STRING( pev->classname ), NewActivity );
pev->sequence = 0; // Set to the reset anim (if it's there)
// Set to the desired anim, or default anim if the desired is not present
if ( pev->sequence != iSequence || !m_fSequenceLoops )
pev->frame = 0;
pev->sequence = iSequence; // Set to the reset anim (if it's there)
Assuming your monster is crouched, uses the Python and you want the corresponding
GetSequenceName( "aim" )