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 
25 #include "cg_headers.h"
26 
27 #include "cg_media.h"
28 #include "FxScheduler.h"
29 
30 /*
31 -------------------------
32 
33 	MAIN FIRE
34 
35 -------------------------
36 FX_BryarProjectileThink
37 -------------------------
38 */
FX_BryarProjectileThink(centity_t * cent,const struct weaponInfo_s * weapon)39 void FX_BryarProjectileThink(  centity_t *cent, const struct weaponInfo_s *weapon )
40 {
41 	vec3_t forward;
42 
43 	if ( VectorNormalize2( cent->gent->s.pos.trDelta, forward ) == 0.0f )
44 	{
45 		if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
46 		{
47 			forward[2] = 1.0f;
48 		}
49 	}
50 
51 	// 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
52 	int dif = cg.time - cent->gent->s.pos.trTime;
53 
54 	if ( dif < 75 )
55 	{
56 		if ( dif < 0 )
57 		{
58 			dif = 0;
59 		}
60 
61 		float scale = ( dif / 75.0f ) * 0.95f + 0.05f;
62 
63 		VectorScale( forward, scale, forward );
64 	}
65 
66 	if ( cent->gent && cent->gent->owner && cent->gent->owner->s.number > 0 )
67 	{
68 		theFxScheduler.PlayEffect( "bryar/NPCshot", cent->lerpOrigin, forward );
69 	}
70 	else
71 	{
72 		theFxScheduler.PlayEffect( cgs.effects.bryarShotEffect, cent->lerpOrigin, forward );
73 	}
74 }
75 
76 /*
77 -------------------------
78 FX_BryarHitWall
79 -------------------------
80 */
FX_BryarHitWall(vec3_t origin,vec3_t normal)81 void FX_BryarHitWall( vec3_t origin, vec3_t normal )
82 {
83 	theFxScheduler.PlayEffect( cgs.effects.bryarWallImpactEffect, origin, normal );
84 }
85 
86 /*
87 -------------------------
88 FX_BryarHitPlayer
89 -------------------------
90 */
FX_BryarHitPlayer(vec3_t origin,vec3_t normal,qboolean humanoid)91 void FX_BryarHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
92 {
93 	theFxScheduler.PlayEffect( cgs.effects.bryarFleshImpactEffect, origin, normal );
94 }
95 
96 
97 /*
98 -------------------------
99 
100 	ALT FIRE
101 
102 -------------------------
103 FX_BryarAltProjectileThink
104 -------------------------
105 */
FX_BryarAltProjectileThink(centity_t * cent,const struct weaponInfo_s * weapon)106 void FX_BryarAltProjectileThink(  centity_t *cent, const struct weaponInfo_s *weapon )
107 {
108 	vec3_t forward;
109 
110 	if ( VectorNormalize2( cent->gent->s.pos.trDelta, forward ) == 0.0f )
111 	{
112 		if ( VectorNormalize2( cent->currentState.pos.trDelta, forward ) == 0.0f )
113 		{
114 			forward[2] = 1.0f;
115 		}
116 	}
117 
118 	// 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
119 	int dif = cg.time - cent->gent->s.pos.trTime;
120 
121 	if ( dif < 75 )
122 	{
123 		if ( dif < 0 )
124 		{
125 			dif = 0;
126 		}
127 
128 		float scale = ( dif / 75.0f ) * 0.95f + 0.05f;
129 
130 		VectorScale( forward, scale, forward );
131 	}
132 
133 	// see if we have some sort of extra charge going on
134 	for ( int t = 1; t < cent->gent->count; t++ )
135 	{
136 		// just add ourselves over, and over, and over when we are charged
137 		theFxScheduler.PlayEffect( cgs.effects.bryarPowerupShotEffect, cent->lerpOrigin, forward );
138 	}
139 
140 	theFxScheduler.PlayEffect( cgs.effects.bryarShotEffect, cent->lerpOrigin, forward );
141 }
142 
143 /*
144 -------------------------
145 FX_BryarAltHitWall
146 -------------------------
147 */
FX_BryarAltHitWall(vec3_t origin,vec3_t normal,int power)148 void FX_BryarAltHitWall( vec3_t origin, vec3_t normal, int power )
149 {
150 	switch( power )
151 	{
152 	case 4:
153 	case 5:
154 		theFxScheduler.PlayEffect( cgs.effects.bryarWallImpactEffect3, origin, normal );
155 		break;
156 
157 	case 2:
158 	case 3:
159 		theFxScheduler.PlayEffect( cgs.effects.bryarWallImpactEffect2, origin, normal );
160 		break;
161 
162 	default:
163 		theFxScheduler.PlayEffect( cgs.effects.bryarWallImpactEffect, origin, normal );
164 		break;
165 	}
166 }
167 
168 /*
169 -------------------------
170 FX_BryarAltHitPlayer
171 -------------------------
172 */
FX_BryarAltHitPlayer(vec3_t origin,vec3_t normal,qboolean humanoid)173 void FX_BryarAltHitPlayer( vec3_t origin, vec3_t normal, qboolean humanoid )
174 {
175 	theFxScheduler.PlayEffect( cgs.effects.bryarFleshImpactEffect, origin, normal );
176 }
177