diff options
author | Tim Angus <tim@ngus.net> | 2009-10-03 11:37:35 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:15:11 +0000 |
commit | bac576514472b4f1d70a53078182d29e93c34d59 (patch) | |
tree | acb6f0056003701d26d9d1ed3fb48bb195187be3 /src/game | |
parent | bcc79996c4c254a528e7b00f260d8ebd09e2a820 (diff) |
* First person weapon animation
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/bg_misc.c | 29 | ||||
-rw-r--r-- | src/game/bg_pmove.c | 74 | ||||
-rw-r--r-- | src/game/bg_public.h | 26 |
3 files changed, 98 insertions, 31 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 275f5b41..64924aaa 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -1735,8 +1735,7 @@ classAttributes_t bg_classList[ ] = LEVEL0_HEALTH, //int health; 0.0f, //float fallDamage; LEVEL0_REGEN, //int regenRate; - SCA_WALLCLIMBER|SCA_NOWEAPONDRIFT| - SCA_FOVWARPS|SCA_ALIENSENSE, //int abilities; + SCA_WALLCLIMBER|SCA_FOVWARPS|SCA_ALIENSENSE, //int abilities; WP_ALEVEL0, //weapon_t startWeapon 0.0f, //float buildDist; 140, //int fov; @@ -1778,8 +1777,7 @@ classAttributes_t bg_classList[ ] = LEVEL1_HEALTH, //int health; 0.0f, //float fallDamage; LEVEL1_REGEN, //int regenRate; - SCA_NOWEAPONDRIFT| - SCA_FOVWARPS|SCA_WALLCLIMBER|SCA_ALIENSENSE, //int abilities; + SCA_FOVWARPS|SCA_WALLCLIMBER|SCA_ALIENSENSE, //int abilities; WP_ALEVEL1, //weapon_t startWeapon 0.0f, //float buildDist; 120, //int fov; @@ -1821,8 +1819,7 @@ classAttributes_t bg_classList[ ] = LEVEL1_UPG_HEALTH, //int health; 0.0f, //float fallDamage; LEVEL1_UPG_REGEN, //int regenRate; - SCA_NOWEAPONDRIFT|SCA_FOVWARPS| - SCA_WALLCLIMBER|SCA_ALIENSENSE, //int abilities; + SCA_FOVWARPS|SCA_WALLCLIMBER|SCA_ALIENSENSE, //int abilities; WP_ALEVEL1_UPG, //weapon_t startWeapon 0.0f, //float buildDist; 120, //int fov; @@ -1862,8 +1859,7 @@ classAttributes_t bg_classList[ ] = LEVEL2_HEALTH, //int health; 0.0f, //float fallDamage; LEVEL2_REGEN, //int regenRate; - SCA_NOWEAPONDRIFT|SCA_WALLJUMPER| - SCA_FOVWARPS|SCA_ALIENSENSE, //int abilities; + SCA_WALLJUMPER|SCA_FOVWARPS|SCA_ALIENSENSE, //int abilities; WP_ALEVEL2, //weapon_t startWeapon 0.0f, //float buildDist; 90, //int fov; @@ -1903,8 +1899,7 @@ classAttributes_t bg_classList[ ] = LEVEL2_UPG_HEALTH, //int health; 0.0f, //float fallDamage; LEVEL2_UPG_REGEN, //int regenRate; - SCA_NOWEAPONDRIFT|SCA_WALLJUMPER| - SCA_FOVWARPS|SCA_ALIENSENSE, //int abilities; + SCA_WALLJUMPER|SCA_FOVWARPS|SCA_ALIENSENSE, //int abilities; WP_ALEVEL2_UPG, //weapon_t startWeapon 0.0f, //float buildDist; 90, //int fov; @@ -1945,8 +1940,7 @@ classAttributes_t bg_classList[ ] = LEVEL3_HEALTH, //int health; 0.0f, //float fallDamage; LEVEL3_REGEN, //int regenRate; - SCA_NOWEAPONDRIFT| - SCA_FOVWARPS|SCA_ALIENSENSE, //int abilities; + SCA_FOVWARPS|SCA_ALIENSENSE, //int abilities; WP_ALEVEL3, //weapon_t startWeapon 0.0f, //float buildDist; 110, //int fov; @@ -1987,8 +1981,7 @@ classAttributes_t bg_classList[ ] = LEVEL3_UPG_HEALTH, //int health; 0.0f, //float fallDamage; LEVEL3_UPG_REGEN, //int regenRate; - SCA_NOWEAPONDRIFT| - SCA_FOVWARPS|SCA_ALIENSENSE, //int abilities; + SCA_FOVWARPS|SCA_ALIENSENSE, //int abilities; WP_ALEVEL3_UPG, //weapon_t startWeapon 0.0f, //float buildDist; 110, //int fov; @@ -2030,8 +2023,7 @@ classAttributes_t bg_classList[ ] = LEVEL4_HEALTH, //int health; 0.0f, //float fallDamage; LEVEL4_REGEN, //int regenRate; - SCA_NOWEAPONDRIFT| - SCA_FOVWARPS|SCA_ALIENSENSE, //int abilities; + SCA_FOVWARPS|SCA_ALIENSENSE, //int abilities; WP_ALEVEL4, //weapon_t startWeapon 0.0f, //float buildDist; 90, //int fov; @@ -2070,8 +2062,7 @@ classAttributes_t bg_classList[ ] = 100, //int health; 1.0f, //float fallDamage; 0, //int regenRate; - SCA_TAKESFALLDAMAGE| - SCA_CANUSELADDERS, //int abilities; + SCA_TAKESFALLDAMAGE|SCA_CANUSELADDERS, //int abilities; WP_NONE, //special-cased in g_client.c //weapon_t startWeapon 110.0f, //float buildDist; 90, //int fov; @@ -4953,6 +4944,7 @@ void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean s->time2 = ps->movementDir; s->legsAnim = ps->legsAnim; s->torsoAnim = ps->torsoAnim; + s->weaponAnim = ps->weaponAnim; s->clientNum = ps->clientNum; // ET_PLAYER looks here instead of at number // so corpses can also reference the proper config s->eFlags = ps->eFlags; @@ -5062,6 +5054,7 @@ void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s s->time2 = ps->movementDir; s->legsAnim = ps->legsAnim; s->torsoAnim = ps->torsoAnim; + s->weaponAnim = ps->weaponAnim; s->clientNum = ps->clientNum; // ET_PLAYER looks here instead of at number // so corpses can also reference the proper config s->eFlags = ps->eFlags; diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index d0f0a1c6..5179c24c 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -103,6 +103,20 @@ void PM_StartTorsoAnim( int anim ) /* =================== +PM_StartWeaponAnim +=================== +*/ +static void PM_StartWeaponAnim( int anim ) +{ + if( pm->ps->pm_type >= PM_DEAD ) + return; + + pm->ps->weaponAnim = ( ( pm->ps->torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) + | anim; +} + +/* +=================== PM_StartLegsAnim =================== */ @@ -170,6 +184,19 @@ static void PM_ContinueTorsoAnim( int anim ) /* =================== +PM_ContinueWeaponAnim +=================== +*/ +static void PM_ContinueWeaponAnim( int anim ) +{ + if( ( pm->ps->weaponAnim & ~ANIM_TOGGLEBIT ) == anim ) + return; + + PM_StartWeaponAnim( anim ); +} + +/* +=================== PM_ForceLegsAnim =================== */ @@ -2716,7 +2743,10 @@ static void PM_BeginWeaponChange( int weapon ) pm->ps->stats[ STAT_BUILDABLE ] = BA_NONE; if( !( pm->ps->persistant[ PERS_STATE ] & PS_NONSEGMODEL ) ) + { PM_StartTorsoAnim( TORSO_DROP ); + PM_StartWeaponAnim( WANIM_DROP ); + } } @@ -2741,7 +2771,10 @@ static void PM_FinishWeaponChange( void ) pm->ps->weaponTime += 250; if( !( pm->ps->persistant[ PERS_STATE ] & PS_NONSEGMODEL ) ) + { PM_StartTorsoAnim( TORSO_RAISE ); + PM_StartWeaponAnim( WANIM_RAISE ); + } } @@ -2753,15 +2786,17 @@ PM_TorsoAnimation */ static void PM_TorsoAnimation( void ) { - if( pm->ps->persistant[ PERS_STATE ] & PS_NONSEGMODEL ) - return; - if( pm->ps->weaponstate == WEAPON_READY ) { - if( pm->ps->weapon == WP_BLASTER ) - PM_ContinueTorsoAnim( TORSO_STAND2 ); - else - PM_ContinueTorsoAnim( TORSO_STAND ); + if( !( pm->ps->persistant[ PERS_STATE ] & PS_NONSEGMODEL ) ) + { + if( pm->ps->weapon == WP_BLASTER ) + PM_ContinueTorsoAnim( TORSO_STAND2 ); + else + PM_ContinueTorsoAnim( TORSO_STAND ); + } + + PM_ContinueWeaponAnim( WANIM_IDLE ); } } @@ -2969,6 +3004,8 @@ static void PM_Weapon( void ) PM_ContinueTorsoAnim( TORSO_STAND ); } + PM_ContinueWeaponAnim( WANIM_IDLE ); + return; } @@ -3010,7 +3047,6 @@ static void PM_Weapon( void ) //allow some time for the weapon to be raised pm->ps->weaponstate = WEAPON_RAISING; - PM_StartTorsoAnim( TORSO_RAISE ); pm->ps->weaponTime += 250; return; } @@ -3023,6 +3059,7 @@ static void PM_Weapon( void ) //drop the weapon PM_StartTorsoAnim( TORSO_DROP ); + PM_StartWeaponAnim( WANIM_RELOAD ); pm->ps->weaponTime += BG_FindReloadTimeForWeapon( pm->ps->weapon ); return; @@ -3207,15 +3244,18 @@ static void PM_Weapon( void ) if( pm->ps->weaponstate == WEAPON_READY ) { PM_StartTorsoAnim( TORSO_ATTACK ); + PM_StartWeaponAnim( WANIM_ATTACK1 ); } break; case WP_BLASTER: PM_StartTorsoAnim( TORSO_ATTACK2 ); + PM_StartWeaponAnim( WANIM_ATTACK1 ); break; default: PM_StartTorsoAnim( TORSO_ATTACK ); + PM_StartWeaponAnim( WANIM_ATTACK1 ); break; } } @@ -3227,20 +3267,38 @@ static void PM_Weapon( void ) int num = abs( pm->ps->commandTime ) % 3; if( num == 0 ) + { PM_ForceLegsAnim( NSPA_ATTACK1 ); + PM_StartWeaponAnim( WANIM_ATTACK1 ); + } else if( num == 1 ) + { PM_ForceLegsAnim( NSPA_ATTACK2 ); + PM_StartWeaponAnim( WANIM_ATTACK2 ); + } else if( num == 2 ) + { PM_ForceLegsAnim( NSPA_ATTACK3 ); + PM_StartWeaponAnim( WANIM_ATTACK3 ); + } } else { if( attack1 ) + { PM_ForceLegsAnim( NSPA_ATTACK1 ); + PM_StartWeaponAnim( WANIM_ATTACK1 ); + } else if( attack2 ) + { PM_ForceLegsAnim( NSPA_ATTACK2 ); + PM_StartWeaponAnim( WANIM_ATTACK2 ); + } else if( attack3 ) + { PM_ForceLegsAnim( NSPA_ATTACK3 ); + PM_StartWeaponAnim( WANIM_ATTACK3 ); + } } pm->ps->torsoTimer = TIMER_ATTACK; diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 1ee8d36a..361d857a 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -225,11 +225,10 @@ typedef enum #define SCA_WALLCLIMBER 0x00000001 #define SCA_TAKESFALLDAMAGE 0x00000002 #define SCA_CANZOOM 0x00000004 -#define SCA_NOWEAPONDRIFT 0x00000008 -#define SCA_FOVWARPS 0x00000010 -#define SCA_ALIENSENSE 0x00000020 -#define SCA_CANUSELADDERS 0x00000040 -#define SCA_WALLJUMPER 0x00000080 +#define SCA_FOVWARPS 0x00000008 +#define SCA_ALIENSENSE 0x00000010 +#define SCA_CANUSELADDERS 0x00000020 +#define SCA_WALLJUMPER 0x00000040 #define SS_WALLCLIMBING 0x00000001 #define SS_WALLCLIMBINGCEILING 0x00000002 @@ -770,6 +769,23 @@ typedef enum MAX_BUILDABLE_ANIMATIONS } buildableAnimNumber_t; +typedef enum +{ + WANIM_NONE, + + WANIM_IDLE, + + WANIM_DROP, + WANIM_RELOAD, + WANIM_RAISE, + + WANIM_ATTACK1, + WANIM_ATTACK2, + WANIM_ATTACK3, + + MAX_WEAPON_ANIMATIONS +} weaponAnimNumber_t; + typedef struct animation_s { int firstFrame; |