codemp/cgame/fx_heavyrepeater.c

Go to the documentation of this file.
00001 // Heavy Repeater Weapon
00002 
00003 #include "cg_local.h"
00004 
00005 /*
00006 ---------------------------
00007 FX_RepeaterProjectileThink
00008 ---------------------------
00009 */
00010 
00011 void FX_RepeaterProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
00012 {
00013         vec3_t forward;
00014 
00015         if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
00016         {
00017                 forward[2] = 1.0f;
00018         }
00019 
00020         trap_FX_PlayEffectID( cgs.effects.repeaterProjectileEffect, cent->lerpOrigin, forward, -1, -1 );
00021 }
00022 
00023 /*
00024 ------------------------
00025 FX_RepeaterHitWall
00026 ------------------------
00027 */
00028 
00029 void FX_RepeaterHitWall( vec3_t origin, vec3_t normal )
00030 {
00031         trap_FX_PlayEffectID( cgs.effects.repeaterWallImpactEffect, origin, normal, -1, -1 );
00032 }
00033 
00034 /*
00035 ------------------------
00036 FX_RepeaterHitPlayer
00037 ------------------------
00038 */
00039 
00040 void FX_RepeaterHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
00041 {
00042         trap_FX_PlayEffectID( cgs.effects.repeaterFleshImpactEffect, origin, normal, -1, -1 );
00043 }
00044 
00045 static void CG_DistortionOrb( centity_t *cent )
00046 {
00047         refEntity_t ent;
00048         vec3_t ang;
00049         float scale = 0.5f;
00050         float vLen;
00051 
00052         if (!cg_renderToTextureFX.integer)
00053         {
00054                 return;
00055         }
00056         memset( &ent, 0, sizeof( ent ) );
00057 
00058         VectorCopy( cent->lerpOrigin, ent.origin );
00059 
00060         VectorSubtract(ent.origin, cg.refdef.vieworg, ent.axis[0]);
00061         vLen = VectorLength(ent.axis[0]);
00062         if (VectorNormalize(ent.axis[0]) <= 0.1f)
00063         {       // Entity is right on vieworg.  quit.
00064                 return;
00065         }
00066 
00067 //      VectorCopy(cg.refdef.viewaxis[2], ent.axis[2]);
00068 //      CrossProduct(ent.axis[0], ent.axis[2], ent.axis[1]);
00069         vectoangles(ent.axis[0], ang);
00070         ang[ROLL] = cent->trickAlpha;
00071         cent->trickAlpha += 16; //spin the half-sphere to give a "screwdriver" effect
00072         AnglesToAxis(ang, ent.axis);
00073 
00074         //radius must be a power of 2, and is the actual captured texture size
00075         if (vLen < 128)
00076         {
00077                 ent.radius = 256;
00078         }
00079         else if (vLen < 256)
00080         {
00081                 ent.radius = 128;
00082         }
00083         else if (vLen < 512)
00084         {
00085                 ent.radius = 64;
00086         }
00087         else
00088         {
00089                 ent.radius = 32;
00090         }
00091 
00092         VectorScale(ent.axis[0], scale, ent.axis[0]);
00093         VectorScale(ent.axis[1], scale, ent.axis[1]);
00094         VectorScale(ent.axis[2], -scale, ent.axis[2]);
00095 
00096         ent.hModel = cgs.media.halfShieldModel;
00097         ent.customShader = 0;//cgs.media.halfShieldShader;      
00098 
00099 #if 1
00100         ent.renderfx = (RF_DISTORTION|RF_RGB_TINT);
00101 
00102         //tint the whole thing a shade of blue
00103         ent.shaderRGBA[0] = 200.0f;
00104         ent.shaderRGBA[1] = 200.0f;
00105         ent.shaderRGBA[2] = 255.0f;
00106 #else //no tint
00107         ent.renderfx = RF_DISTORTION;
00108 #endif
00109 
00110         trap_R_AddRefEntityToScene( &ent );
00111 }
00112 
00113 /*
00114 ------------------------------
00115 FX_RepeaterAltProjectileThink
00116 -----------------------------
00117 */
00118 
00119 void FX_RepeaterAltProjectileThink( centity_t *cent, const struct weaponInfo_s *weapon )
00120 {
00121         vec3_t forward;
00122 
00123         if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
00124         {
00125                 forward[2] = 1.0f;
00126         }
00127 
00128         if (cg_repeaterOrb.integer)
00129         {
00130                 CG_DistortionOrb(cent);
00131         }
00132         trap_FX_PlayEffectID( cgs.effects.repeaterAltProjectileEffect, cent->lerpOrigin, forward, -1, -1 );
00133 }
00134 
00135 /*
00136 ------------------------
00137 FX_RepeaterAltHitWall
00138 ------------------------
00139 */
00140 
00141 void FX_RepeaterAltHitWall( vec3_t origin, vec3_t normal )
00142 {
00143         trap_FX_PlayEffectID( cgs.effects.repeaterAltWallImpactEffect, origin, normal, -1, -1 );
00144 }
00145 
00146 /*
00147 ------------------------
00148 FX_RepeaterAltHitPlayer
00149 ------------------------
00150 */
00151 
00152 void FX_RepeaterAltHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
00153 {
00154         trap_FX_PlayEffectID( cgs.effects.repeaterAltWallImpactEffect, origin, normal, -1, -1 );
00155 }