]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamec/w_crylink.c
fixed repeating sound with weapons stay
[divverent/nexuiz.git] / data / qcsrc / server / gamec / w_crylink.c
1 void() crylink_ready_01;
2 void() crylink_fire1_01;
3 void() crylink_fire2_01;
4 void() crylink_deselect_01;
5 void() crylink_select_01;
6
7 .float gravity;
8 const vector proj_color = '1 1 1';
9
10 float() crylink_check =
11 {
12         if (self.ammo_cells >= cvar("g_balance_crylink_primary_ammo"))
13                 return TRUE;
14         return FALSE;
15 };
16
17 float() crylink_check2 =
18 {
19         if (self.ammo_cells >= cvar("g_balance_crylink_secondary_ammo"))
20                 return TRUE;
21         return FALSE;
22 };
23
24 void(float req) w_crylink =
25 {
26         if (req == WR_IDLE)
27                 crylink_ready_01();
28         else if (req == WR_FIRE1)
29                 weapon_prepareattack(crylink_check, crylink_check, crylink_fire1_01, cvar("g_balance_crylink_primary_refire"));
30         else if (req == WR_FIRE2)
31                 weapon_prepareattack(crylink_check2, crylink_check2, crylink_fire2_01, cvar("g_balance_crylink_secondary_refire"));
32         else if (req == WR_RAISE)
33                 crylink_select_01();
34         else if (req == WR_UPDATECOUNTS)
35                 self.currentammo = self.ammo_cells;
36         else if (req == WR_DROP)
37                 crylink_deselect_01();
38         else if (req == WR_SETUP)
39                 weapon_setup(WEP_CRYLINK, "w_crylink.zym", IT_CELLS);
40         else if (req == WR_CHECKAMMO)
41                 weapon_hasammo = crylink_check() + crylink_check2();
42 };
43
44 .entity realowner;
45 void W_Crylink_Touch (void)
46 {
47         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
48         {
49                 remove(self);
50                 return;
51         }
52         RadiusDamage (self, self.realowner, cvar("g_balance_crylink_primary_damage"), cvar("g_balance_crylink_primary_edgedamage"), cvar("g_balance_crylink_primary_radius"), world, cvar("g_balance_crylink_primary_force"), IT_CRYLINK);
53         //te_smallflash(self.origin);
54         if (other.takedamage == DAMAGE_AIM)
55         {
56                 remove (self);
57                 return;
58         }
59         self.owner = world;
60         self.touch = SUB_Null;
61         setmodel (self, "models/plasma.mdl");
62         setsize (self, '0 0 0', '0 0 0');
63         self.gravity = 0;
64         self.glow_size = 0;
65         self.glow_color = 0;
66         self.think = SUB_Remove;
67         self.movetype = MOVETYPE_NONE;
68         self.effects = EF_FULLBRIGHT | EF_LOWPRECISION;
69         SUB_SetFade(self, time, 1);
70         //remove (self);
71 }
72
73 void W_Crylink_Touch2 (void)
74 {
75         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
76         {
77                 remove(self);
78                 return;
79         }
80         RadiusDamage (self, self.realowner, cvar("g_balance_crylink_secondary_damage"), cvar("g_balance_crylink_secondary_edgedamage"), cvar("g_balance_crylink_secondary_radius"), world, cvar("g_balance_crylink_secondary_force"), IT_CRYLINK);
81         //te_smallflash(self.origin);
82         if (other.takedamage == DAMAGE_AIM)
83         {
84                 remove (self);
85                 return;
86         }
87         self.owner = world;
88         self.touch = SUB_Null;
89         setmodel (self, "models/plasma.mdl");
90         setsize (self, '0 0 0', '0 0 0');
91         self.gravity = 0;
92         self.glow_size = 0;
93         self.glow_color = 0;
94         self.think = SUB_Remove;
95         self.movetype = MOVETYPE_NONE;
96         self.effects = EF_FULLBRIGHT | EF_LOWPRECISION;
97         SUB_SetFade(self, time, 1);
98         //remove (self);
99 }
100
101 void W_Crylink_Attack (void)
102 {
103         local float counter, shots;
104         local vector org;
105         local entity proj;
106
107         local vector trueaim;
108         trueaim = W_TrueAim();
109
110         sound (self, CHAN_WEAPON, "weapons/crylink_fire.ogg", 1, ATTN_NORM);
111         if (self.items & IT_STRENGTH)
112                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
113
114         if (cvar("g_use_ammunition"))
115                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
116         self.punchangle_x = -2;
117
118         org = W_MuzzleOrigin (self, '24 7 -8');
119         te_smallflash(org);
120
121         shots = cvar("g_balance_crylink_primary_shots");
122         while (counter < shots)
123         {
124                 proj = spawn ();
125                 proj.realowner = proj.owner = self;
126                 proj.classname = "spike";
127
128                 proj.movetype = MOVETYPE_BOUNCE;
129                 proj.solid = SOLID_BBOX;
130                 proj.gravity = 0.001;
131
132                 setmodel (proj, "models/plasmatrail.mdl");
133                 setsize (proj, '0 0 0', '0 0 0');
134                 setorigin (proj, org);
135
136                 proj.velocity = (normalize(trueaim - org) + randomvec() * cvar("g_balance_crylink_primary_spread")) * cvar("g_balance_crylink_primary_speed");
137                 proj.touch = W_Crylink_Touch;
138                 proj.think = SUB_Remove;
139                 proj.nextthink = time + cvar("g_balance_crylink_primary_lifetime");
140
141                 proj.angles = vectoangles (proj.velocity);
142
143                 //proj.glow_size = 20;
144
145                 proj.effects = EF_NOSHADOW | EF_FULLBRIGHT | EF_LOWPRECISION;
146                 proj.colormod = proj_color;
147                 counter = counter + 1;
148         }
149 }
150
151 void W_Crylink_Attack2 (void)
152 {
153         local float counter, shots;
154         local vector org;
155         local entity proj;
156
157         local vector trueaim;
158         trueaim = W_TrueAim();
159
160         sound (self, CHAN_WEAPON, "weapons/crylink_fire.ogg", 1, ATTN_NORM);
161         if (self.items & IT_STRENGTH)
162                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
163
164         if (cvar("g_use_ammunition"))
165                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_secondary_ammo");
166         self.punchangle_x = -2;
167
168         org = W_MuzzleOrigin (self, '20 7 -8');
169         te_smallflash(org);
170
171         shots = cvar("g_balance_crylink_secondary_shots");
172         while (counter < shots)
173         {
174                 proj = spawn ();
175                 proj.realowner = proj.owner = self;
176                 proj.classname = "spike";
177
178                 proj.movetype = MOVETYPE_BOUNCE;
179                 proj.solid = SOLID_BBOX;
180                 proj.gravity = 0.001;
181
182                 setmodel (proj, "models/plasmatrail.mdl");
183                 setsize (proj, '0 0 0', '0 0 0');
184                 setorigin (proj, org);
185
186                 proj.velocity = (normalize(trueaim - org) + ((counter / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread")) * cvar("g_balance_crylink_secondary_speed");
187                 proj.touch = W_Crylink_Touch2;
188                 proj.think = SUB_Remove;
189                 proj.nextthink = time + cvar("g_balance_crylink_secondary_lifetime");
190
191                 proj.angles = vectoangles (proj.velocity);
192
193                 //proj.glow_size = 20;
194
195                 proj.effects = EF_NOSHADOW | EF_FULLBRIGHT | EF_LOWPRECISION;
196                 proj.colormod = proj_color;
197                 counter = counter + 1;
198         }
199 }
200
201
202 // weapon frames
203 void()  crylink_ready_01 =      {weapon_thinkf(WFRAME_IDLE, 0.1, crylink_ready_01); self.weaponentity.state = WS_READY;};
204 void()  crylink_select_01 =     {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
205 void()  crylink_deselect_01 =   {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
206 void()  crylink_fire1_01 =
207 {
208         weapon_doattack(crylink_check, crylink_check, W_Crylink_Attack);
209         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), crylink_ready_01);
210 };
211 void()  crylink_fire2_01 =
212 {
213         weapon_doattack(crylink_check2, crylink_check2, W_Crylink_Attack2);
214         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_crylink_secondary_animtime"), crylink_ready_01);
215 };
216
217 /*
218 // experimental lightning gun
219 void W_Crylink_Attack3 (void)
220 {
221         local vector org, dir;
222
223         local vector trueaim;
224         trueaim = W_TrueAim();
225
226         sound (self, CHAN_WEAPON, "weapons/crylink_fire.ogg", 1, ATTN_NORM);
227         if (self.items & IT_STRENGTH) {
228                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
229         }
230
231         if (cvar("g_use_ammunition"))
232                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
233         //self.punchangle_x = -2;
234         org = self.origin + self.view_ofs + v_forward * 10 + v_right * 5 + v_up * -14;
235
236         // use traceline_hitcorpse to make sure it can hit gibs and corpses too
237         dir = normalize(trueaim - org);
238         traceline_hitcorpse(self, org, org + dir * 1000, FALSE, self);
239
240         te_smallflash(org);
241         te_plasmaburn(trace_endpos);
242         te_lightning2(self, org, trace_endpos);
243
244         if (trace_fraction < 1)
245                 Damage(trace_ent, self, self, cvar("g_balance_crylink_primary_damage"), IT_CRYLINK, trace_endpos, '0 0 0');
246 }
247 void()  crylink_fire1_01 =
248 {
249         weapon_doattack(crylink_check, crylink_check, W_Crylink_Attack3);
250         if (self.button0)
251                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), crylink_fire1_01);
252         else
253                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), crylink_ready_01);
254 };
255 */
256