1 /*
2 ===========================================================================
3 Copyright (C) 2000 - 2013, Raven Software, Inc.
4 Copyright (C) 2001 - 2013, Activision, Inc.
5 Copyright (C) 2013 - 2015, OpenJK contributors
6 
7 This file is part of the OpenJK source code.
8 
9 OpenJK is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License version 2 as
11 published by the Free Software Foundation.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, see <http://www.gnu.org/licenses/>.
20 ===========================================================================
21 */
22 
23 // Bryar Pistol Weapon Effects
24 #include "cg_local.h"
25 #include "cg_media.h"
26 #include "FxScheduler.h"
27 
28 /*
29 -------------------------
30 
31 	MAIN FIRE
32 
33 -------------------------
34 FX_BryarProjectileThink
35 -------------------------
36 */
FX_BryarProjectileThink(centity_t * cent,const struct weaponInfo_s * weapon)37 void FX_BryarProjectileThink(  centity_t *cent, const struct weaponInfo_s *weapon )
38 {
39 	vec3_t forward;
40 
41 	if ( VectorNormalize2( cent->gent->s.pos.trDelta, forward ) == 0.0f )
42 	{
43 		if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
44 		{
45 			forward[2] = 1.0f;
46 		}
47 	}
48 
49 	// hack the scale of the forward vector if we were just fired or bounced...this will shorten up the tail for a split second so tails don't clip so harshly
50 	int dif = cg.time - cent->gent->s.pos.trTime;
51 
52 	if ( dif < 75 )
53 	{
54 		if ( dif < 0 )
55 		{
56 			dif = 0;
57 		}
58 
59 		float scale = ( dif / 75.0f ) * 0.95f + 0.05f;
60 
61 		VectorScale( forward, scale, forward );
62 	}
63 
64 	if ( cent->gent && cent->gent->owner && cent->gent->owner->s.number > 0 )
65 	{
66 		theFxScheduler.PlayEffect( "bryar/NPCshot", cent->lerpOrigin, forward );
67 	}
68 	else
69 	{
70 		theFxScheduler.PlayEffect( cgs.effects.bryarShotEffect, cent->lerpOrigin, forward );
71 	}
72 }
73 
74 /*
75 -------------------------
76 FX_BryarHitWall
77 -------------------------
78 */
FX_BryarHitWall(vec3_t origin,vec3_t normal)79 void FX_BryarHitWall( vec3_t origin, vec3_t normal )
80 {
81 	theFxScheduler.PlayEffect( cgs.effects.bryarWallImpactEffect, origin, normal );
82 }
83 
84 /*
85 -------------------------
86 FX_BryarHitPlayer
87 -------------------------
88 */
FX_BryarHitPlayer(vec3_t origin,vec3_t normal,qboolean humanoid)89 void FX_BryarHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
90 {
91 	theFxScheduler.PlayEffect( cgs.effects.bryarFleshImpactEffect, origin, normal );
92 }
93 
94 
95 /*
96 -------------------------
97 
98 	ALT FIRE
99 
100 -------------------------
101 FX_BryarAltProjectileThink
102 -------------------------
103 */
FX_BryarAltProjectileThink(centity_t * cent,const struct weaponInfo_s * weapon)104 void FX_BryarAltProjectileThink(  centity_t *cent, const struct weaponInfo_s *weapon )
105 {
106 	vec3_t forward;
107 
108 	if ( VectorNormalize2( cent->gent->s.pos.trDelta, forward ) == 0.0f )
109 	{
110 		if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
111 		{
112 			forward[2] = 1.0f;
113 		}
114 	}
115 
116 	// hack the scale of the forward vector if we were just fired or bounced...this will shorten up the tail for a split second so tails don't clip so harshly
117 	int dif = cg.time - cent->gent->s.pos.trTime;
118 
119 	if ( dif < 75 )
120 	{
121 		if ( dif < 0 )
122 		{
123 			dif = 0;
124 		}
125 
126 		float scale = ( dif / 75.0f ) * 0.95f + 0.05f;
127 
128 		VectorScale( forward, scale, forward );
129 	}
130 
131 	// see if we have some sort of extra charge going on
132 	for ( int t = 1; t < cent->gent->count; t++ )
133 	{
134 		// just add ourselves over, and over, and over when we are charged
135 		theFxScheduler.PlayEffect( cgs.effects.bryarPowerupShotEffect, cent->lerpOrigin, forward );
136 	}
137 
138 	theFxScheduler.PlayEffect( cgs.effects.bryarShotEffect, cent->lerpOrigin, forward );
139 }
140 
141 /*
142 -------------------------
143 FX_BryarAltHitWall
144 -------------------------
145 */
FX_BryarAltHitWall(vec3_t origin,vec3_t normal,int power)146 void FX_BryarAltHitWall( vec3_t origin, vec3_t normal, int power )
147 {
148 	switch( power )
149 	{
150 	case 4:
151 	case 5:
152 		theFxScheduler.PlayEffect( cgs.effects.bryarWallImpactEffect3, origin, normal );
153 		break;
154 
155 	case 2:
156 	case 3:
157 		theFxScheduler.PlayEffect( cgs.effects.bryarWallImpactEffect2, origin, normal );
158 		break;
159 
160 	default:
161 		theFxScheduler.PlayEffect( cgs.effects.bryarWallImpactEffect, origin, normal );
162 		break;
163 	}
164 }
165 
166 /*
167 -------------------------
168 FX_BryarAltHitPlayer
169 -------------------------
170 */
FX_BryarAltHitPlayer(vec3_t origin,vec3_t normal,qboolean humanoid)171 void FX_BryarAltHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
172 {
173 	theFxScheduler.PlayEffect( cgs.effects.bryarFleshImpactEffect, origin, normal );
174 }
175