MCPcopy Create free account
hub / github.com/JACoders/OpenJK / CG_AddViewWeapon

Function CG_AddViewWeapon

codeJK2/cgame/cg_weapons.cpp:895–1251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

893extern float CG_ForceSpeedFOV( void );
894
895void CG_AddViewWeapon( playerState_t *ps )
896{
897 refEntity_t hand;
898 refEntity_t gun;
899 refEntity_t flash;
900 vec3_t angles;
901 const weaponInfo_t *weapon;
902 weaponData_t *wData;
903 centity_t *cent;
904 float fovOffset, leanOffset;
905 float cgFov = (cg_fovViewmodel.integer) ? cg_fovViewmodel.integer : cg_fov.integer;
906 int i;
907
908 if (cgFov < 1)
909 cgFov = 1;
910 else if (cgFov > 130)
911 cgFov = 130;
912
913 // no gun if in third person view
914 if ( cg.renderingThirdPerson )
915 return;
916
917 if ( ps->pm_type == PM_INTERMISSION )
918 return;
919
920 cent = &cg_entities[ps->clientNum];
921
922 if ( ps->eFlags & EF_LOCKED_TO_WEAPON )
923 {
924 return;
925 }
926
927 if ( cent->gent && cent->gent->client && cent->gent->client->ps.forcePowersActive&(1<<FP_LIGHTNING) )
928 {//doing the electrocuting
929 vec3_t tAng, fxDir, temp;
930 VectorSet( tAng, cent->pe.torso.pitchAngle, cent->pe.torso.yawAngle, 0 );
931
932 VectorCopy( cent->gent->client->renderInfo.handLPoint, temp );
933 VectorMA( temp, -5, cg.refdef.viewaxis[0], temp );
934 if ( cent->gent->client->ps.forcePowerLevel[FP_LIGHTNING] > FORCE_LEVEL_2 )
935 {//arc
936 vec3_t fxAxis[3];
937 AnglesToAxis( tAng, fxAxis );
938 theFxScheduler.PlayEffect( cgs.effects.forceLightningWide, temp, fxAxis );
939 }
940 else
941 {//line
942 AngleVectors( tAng, fxDir, NULL, NULL );
943 theFxScheduler.PlayEffect( cgs.effects.forceLightning, temp, fxDir );
944 }
945 }
946 // allow the gun to be completely removed
947 if ( !cg_drawGun.integer || cg.zoomMode )
948 {
949 vec3_t origin;
950
951 // special hack for lightning guns...
952 VectorCopy( cg.refdef.vieworg, origin );

Callers 1

CG_DrawActiveFrameFunction · 0.70

Calls 15

VectorSetFunction · 0.85
VectorCopyFunction · 0.85
AnglesToAxisFunction · 0.85
AngleVectorsFunction · 0.85
VectorScaleFunction · 0.85
Q_flrandFunction · 0.85
CG_RegisterWeaponFunction · 0.70
CG_DoMuzzleFlashFunction · 0.70
CG_ForceSpeedFOVFunction · 0.70
cgi_S_AddLoopingSoundFunction · 0.70
CG_MapTorsoToWeaponFrameFunction · 0.70

Tested by

no test coverage detected