]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/w_arc.qc
Add names for the sendflags bits
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_arc.qc
1 #ifdef REGISTER_WEAPON
2 REGISTER_WEAPON(
3 /* WEP_##id  */ ARC,
4 /* function  */ W_Arc,
5 /* ammotype  */ ammo_cells,
6 /* impulse   */ 3,
7 /* flags     */ WEP_FLAG_NORMAL,
8 /* rating    */ BOT_PICKUP_RATING_HIGH,
9 /* color     */ '1 1 1',
10 /* modelname */ "hlac",
11 /* simplemdl */ "foobar",
12 /* crosshair */ "gfx/crosshairhlac 0.7",
13 /* wepimg    */ "weaponhlac",
14 /* refname   */ "arc",
15 /* wepname   */ _("Arc")
16 );
17
18 #define ARC_SETTINGS(w_cvar,w_prop) ARC_SETTINGS_LIST(w_cvar, w_prop, ARC, arc)
19 #define ARC_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
20         w_cvar(id, sn, NONE, beam_ammo) \
21         w_cvar(id, sn, NONE, beam_animtime) \
22         w_cvar(id, sn, NONE, beam_botaimspeed) \
23         w_cvar(id, sn, NONE, beam_botaimlifetime) \
24         w_cvar(id, sn, NONE, beam_damage) \
25         w_cvar(id, sn, NONE, beam_degreespersegment) \
26         w_cvar(id, sn, NONE, beam_distancepersegment) \
27         w_cvar(id, sn, NONE, beam_falloff_halflifedist) \
28         w_cvar(id, sn, NONE, beam_falloff_maxdist) \
29         w_cvar(id, sn, NONE, beam_falloff_mindist) \
30         w_cvar(id, sn, NONE, beam_force) \
31         w_cvar(id, sn, NONE, beam_healing_amax) \
32         w_cvar(id, sn, NONE, beam_healing_aps) \
33         w_cvar(id, sn, NONE, beam_healing_hmax) \
34         w_cvar(id, sn, NONE, beam_healing_hps) \
35         w_cvar(id, sn, NONE, beam_maxangle) \
36         w_cvar(id, sn, NONE, beam_nonplayerdamage) \
37         w_cvar(id, sn, NONE, beam_range) \
38         w_cvar(id, sn, NONE, beam_refire) \
39         w_cvar(id, sn, NONE, beam_returnspeed) \
40         w_cvar(id, sn, NONE, beam_tightness) \
41         w_cvar(id, sn, NONE, burst_ammo) \
42         w_cvar(id, sn, NONE, burst_damage) \
43         w_cvar(id, sn, NONE, burst_healing_aps) \
44         w_cvar(id, sn, NONE, burst_healing_hps) \
45         w_prop(id, sn, float,  switchdelay_raise, switchdelay_raise) \
46         w_prop(id, sn, float,  switchdelay_drop, switchdelay_drop) \
47         w_prop(id, sn, string, weaponreplace, weaponreplace) \
48         w_prop(id, sn, float,  weaponstart, weaponstart) \
49         w_prop(id, sn, float,  weaponstartoverride, weaponstartoverride) \
50         w_prop(id, sn, float,  weaponthrowable, weaponthrowable)
51
52 #ifndef MENUQC
53 #define ARC_MAX_SEGMENTS 20
54 vector arc_shotorigin[4];
55 .vector beam_start;
56 .vector beam_dir;
57 .vector beam_wantdir;
58 .float beam_type;
59
60 #define ARC_BT_MISS        0
61 #define ARC_BT_WALL        1
62 #define ARC_BT_HEAL        2
63 #define ARC_BT_HIT         3
64 #define ARC_BT_BURST_MISS  10
65 #define ARC_BT_BURST_WALL  11
66 #define ARC_BT_BURST_HEAL  12
67 #define ARC_BT_BURST_HIT   13
68 #define ARC_BT_BURSTMASK   10
69
70 #define ARC_SF_SETTINGS    1
71 #define ARC_SF_START       2
72 #define ARC_SF_WANTDIR     4
73 #define ARC_SF_BEAMDIR     8
74 #define ARC_SF_BEAMTYPE    16
75 #define ARC_SF_LOCALMASK   14
76 #endif
77 #ifdef SVQC
78 ARC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
79 .entity arc_beam;
80 .float BUTTON_ATCK_prev; // for better animation control
81 .float beam_prev;
82 .float beam_initialized;
83 .float beam_bursting;
84 #endif
85 #ifdef CSQC
86 void Ent_ReadArcBeam(float isnew);
87 #endif
88 #else
89 #ifdef SVQC
90 void spawnfunc_weapon_arc(void) { weapon_defaultspawnfunc(WEP_ARC); }
91
92 float W_Arc_Beam_Send(entity to, float sf)
93 {
94         WriteByte(MSG_ENTITY, ENT_CLIENT_ARC_BEAM);
95
96         // Truncate information when this beam is displayed to the owner client
97         // - The owner client has no use for beam start position or directions,
98         //    it always figures this information out for itself with csqc code.
99         // - Spectating the owner also truncates this information.
100         float drawlocal = ((to == self.owner) || ((to.enemy == self.owner) && IS_SPEC(to)));
101         if(drawlocal)
102         {
103                 sf &= ~ARC_SF_LOCALMASK;
104         }
105
106         WriteByte(MSG_ENTITY, sf);
107
108         if(sf & ARC_SF_SETTINGS) // settings information
109         {
110                 WriteShort(MSG_ENTITY, WEP_CVAR(arc, beam_degreespersegment));
111                 WriteShort(MSG_ENTITY, WEP_CVAR(arc, beam_distancepersegment));
112                 WriteShort(MSG_ENTITY, WEP_CVAR(arc, beam_maxangle));
113                 WriteCoord(MSG_ENTITY, WEP_CVAR(arc, beam_range));
114                 WriteShort(MSG_ENTITY, WEP_CVAR(arc, beam_returnspeed));
115                 WriteByte(MSG_ENTITY, WEP_CVAR(arc, beam_tightness) * 10);
116
117                 WriteByte(MSG_ENTITY, drawlocal);
118         }
119         if(sf & ARC_SF_START) // starting location
120         {
121                 WriteCoord(MSG_ENTITY, self.beam_start_x);
122                 WriteCoord(MSG_ENTITY, self.beam_start_y);
123                 WriteCoord(MSG_ENTITY, self.beam_start_z);
124         }
125         if(sf & ARC_SF_WANTDIR) // want/aim direction
126         {
127                 WriteCoord(MSG_ENTITY, self.beam_wantdir_x);
128                 WriteCoord(MSG_ENTITY, self.beam_wantdir_y);
129                 WriteCoord(MSG_ENTITY, self.beam_wantdir_z);
130         }
131         if(sf & ARC_SF_BEAMDIR) // beam direction
132         {
133                 WriteCoord(MSG_ENTITY, self.beam_dir_x);
134                 WriteCoord(MSG_ENTITY, self.beam_dir_y);
135                 WriteCoord(MSG_ENTITY, self.beam_dir_z);
136         }
137         if(sf & ARC_SF_BEAMTYPE) // beam type
138         {
139                 WriteByte(MSG_ENTITY, self.beam_type);
140         }
141
142         return TRUE;
143 }
144
145 void W_Arc_Beam_Think(void)
146 {
147         if(self != self.owner.arc_beam)
148         {
149                 remove(self);
150                 return;
151         }
152
153         if(
154                 (self.owner.WEP_AMMO(ARC) <= 0 && !(self.owner.items & IT_UNLIMITED_WEAPON_AMMO))
155                 ||
156                 self.owner.deadflag != DEAD_NO
157                 ||
158                 (!self.owner.BUTTON_ATCK && !self.beam_bursting)
159                 ||
160                 self.owner.freezetag_frozen
161         )
162         {
163                 #if 0
164                 // is this needed? I thought this is changed to world when removed ANYWAY
165                 if(self == self.owner.arc_beam) { self.owner.arc_beam = world; }
166                 #endif
167                 entity oldself = self;
168                 self = self.owner;
169                 if(!WEP_ACTION(WEP_ARC, WR_CHECKAMMO1) && !WEP_ACTION(WEP_ARC, WR_CHECKAMMO2))
170                 {
171                         // note: this doesn't force the switch
172                         W_SwitchToOtherWeapon(self);
173                 }
174                 self = oldself;
175                 remove(self);
176                 return;
177         }
178
179         float burst = 0;
180         if(self.owner.BUTTON_ATCK2 || self.beam_bursting)
181         {
182                 if(!self.beam_bursting)
183                         self.beam_bursting = TRUE;
184                 burst = ARC_BT_BURSTMASK;
185         }
186
187         // decrease ammo
188         float coefficient = frametime;
189         if(!(self.owner.items & IT_UNLIMITED_WEAPON_AMMO))
190         {
191                 float rootammo;
192                 if(burst)
193                         { rootammo = WEP_CVAR(arc, burst_ammo); }
194                 else
195                         { rootammo = WEP_CVAR(arc, beam_ammo); }
196
197                 if(rootammo)
198                 {
199                         coefficient = min(coefficient, self.owner.WEP_AMMO(ARC) / rootammo);
200                         self.owner.WEP_AMMO(ARC) = max(0, self.owner.WEP_AMMO(ARC) - (rootammo * frametime));
201                 }
202         }
203
204         makevectors(self.owner.v_angle);
205
206         W_SetupShot_Range(
207                 self.owner,
208                 TRUE,
209                 0,
210                 "",
211                 0,
212                 WEP_CVAR(arc, beam_damage) * coefficient,
213                 WEP_CVAR(arc, beam_range)
214         );
215
216         // network information: shot origin and want/aim direction
217         if(self.beam_start != w_shotorg)
218         {
219                 self.SendFlags |= ARC_SF_START;
220                 self.beam_start = w_shotorg;
221         }
222         if(self.beam_wantdir != w_shotdir)
223         {
224                 self.SendFlags |= ARC_SF_WANTDIR;
225                 self.beam_wantdir = w_shotdir;
226         }
227
228         if(!self.beam_initialized)
229         {
230                 self.beam_dir = w_shotdir;
231                 self.beam_initialized = TRUE;
232         }
233
234         // WEAPONTODO: Detect player velocity so that the beam curves when moving too
235         // idea: blend together self.beam_dir with the inverted direction the player is moving in
236         // might have to make some special accomodation so that it only uses view_right and view_up
237
238         // note that if we do this, it'll always be corrected to a maximum angle by beam_maxangle handling
239
240         float segments; 
241         if(self.beam_dir != w_shotdir)
242         {
243                 // calculate how much we're going to move the end of the beam to the want position
244                 // WEAPONTODO (server and client):
245                 // blendfactor never actually becomes 0 in this situation, which is a problem
246                 // regarding precision... this means that self.beam_dir and w_shotdir approach
247                 // eachother, however they never actually become the same value with this method.
248                 // Perhaps we should do some form of rounding/snapping?
249                 float angle = vlen(w_shotdir - self.beam_dir) * RAD2DEG;
250                 if(angle && (angle > WEP_CVAR(arc, beam_maxangle)))
251                 {
252                         // if the angle is greater than maxangle, force the blendfactor to make this the maximum factor
253                         float blendfactor = bound(
254                                 0,
255                                 (1 - (WEP_CVAR(arc, beam_returnspeed) * frametime)),
256                                 min(WEP_CVAR(arc, beam_maxangle) / angle, 1)
257                         );
258                         self.beam_dir = normalize((w_shotdir * (1 - blendfactor)) + (self.beam_dir * blendfactor));
259                 }
260                 else
261                 {
262                         // the radius is not too far yet, no worries :D
263                         float blendfactor = bound(
264                                 0,
265                                 (1 - (WEP_CVAR(arc, beam_returnspeed) * frametime)),
266                                 1
267                         );
268                         self.beam_dir = normalize((w_shotdir * (1 - blendfactor)) + (self.beam_dir * blendfactor));
269                 }
270
271                 // network information: beam direction
272                 self.SendFlags |= ARC_SF_BEAMDIR;
273
274                 // calculate how many segments are needed
275                 float max_allowed_segments;
276
277                 if(WEP_CVAR(arc, beam_distancepersegment))
278                 {
279                         max_allowed_segments = min(
280                                 ARC_MAX_SEGMENTS,
281                                 1 + (vlen(w_shotdir / WEP_CVAR(arc, beam_distancepersegment)))
282                         );
283                 }
284                 else { max_allowed_segments = ARC_MAX_SEGMENTS; }
285
286                 if(WEP_CVAR(arc, beam_degreespersegment))
287                 {
288                         segments = bound(
289                                 1, 
290                                 (
291                                         min(
292                                                 angle,
293                                                 WEP_CVAR(arc, beam_maxangle)
294                                         )
295                                         /
296                                         WEP_CVAR(arc, beam_degreespersegment)
297                                 ),
298                                 max_allowed_segments
299                         );
300                 }
301                 else { segments = 1; }
302         }
303         else { segments = 1; }
304
305         vector beam_endpos_estimate = (w_shotorg + (self.beam_dir * WEP_CVAR(arc, beam_range)));
306
307         float i;
308         float new_beam_type = 0;
309         vector last_origin = w_shotorg;
310         for(i = 1; i <= segments; ++i)
311         {
312                 // WEAPONTODO (server and client):
313                 // Segment blend and distance should probably really be calculated in a better way,
314                 // however I am not sure how to do it properly. There are a few things I have tried,
315                 // but most of them do not work properly due to my lack of understanding regarding
316                 // the mathematics behind them.
317
318                 // Ideally, we should calculate the positions along a perfect curve
319                 // between wantdir and self.beam_dir with an option for depth of arc
320
321                 // Another issue is that (on the client code) we must separate the
322                 // curve into multiple rendered curves when handling warpzones.
323
324                 // I can handle this by detecting it for each segment, however that
325                 // is a fairly inefficient method in comparison to having a curved line
326                 // drawing function similar to Draw_CylindricLine that accepts
327                 // top and bottom origins as input, this way there would be no
328                 // overlapping edges when connecting the curved pieces.
329
330                 // WEAPONTODO (client):
331                 // In order to do nice fading and pointing on the starting segment, we must always
332                 // have that drawn as a separate triangle... However, that is difficult to do when
333                 // keeping in mind the above problems and also optimizing the amount of segments
334                 // drawn on screen at any given time. (Automatic beam quality scaling, essentially)
335
336                 // calculate this on every segment to ensure that we always reach the full length of the attack
337                 float segmentblend = bound(0, (i/segments) + WEP_CVAR(arc, beam_tightness), 1);
338                 float segmentdist = vlen(beam_endpos_estimate - last_origin) * (i/segments);
339
340                 // WEAPONTODO: Apparently, normalize is not the correct function to use here...
341                 // Figure out how this actually should work.
342                 vector new_dir = normalize(
343                         (w_shotdir * (1 - segmentblend))
344                         +
345                         (normalize(beam_endpos_estimate - last_origin) * segmentblend)
346                 );
347                 vector new_origin = last_origin + (new_dir * segmentdist);
348
349                 WarpZone_traceline_antilag(
350                         self.owner,
351                         last_origin,
352                         new_origin,
353                         MOVE_NORMAL,
354                         self.owner,
355                         ANTILAG_LATENCY(self.owner)
356                 );
357
358                 float is_player = (
359                         trace_ent.classname == "player"
360                         ||
361                         trace_ent.classname == "body"
362                         ||
363                         (trace_ent.flags & FL_MONSTER)
364                 );
365
366                 if(trace_ent && trace_ent.takedamage && (is_player || WEP_CVAR(arc, beam_nonplayerdamage)))
367                 {
368                         // calculate our own hit origin as trace_endpos tends to jump around annoyingly (to player origin?)
369                         vector hitorigin = last_origin + (new_dir * segmentdist * trace_fraction);
370
371                         float falloff = ExponentialFalloff(
372                                 WEP_CVAR(arc, beam_falloff_mindist),
373                                 WEP_CVAR(arc, beam_falloff_maxdist),
374                                 WEP_CVAR(arc, beam_falloff_halflifedist),
375                                 vlen(WarpZone_UnTransformOrigin(WarpZone_trace_transform, hitorigin) - w_shotorg)
376                         );
377
378                         if(is_player && SAME_TEAM(self.owner, trace_ent))
379                         {
380                                 float roothealth, rootarmor;
381                                 if(burst)
382                                 {
383                                         roothealth = WEP_CVAR(arc, burst_healing_hps);
384                                         rootarmor = WEP_CVAR(arc, burst_healing_aps);
385                                 }
386                                 else
387                                 {
388                                         roothealth = WEP_CVAR(arc, beam_healing_hps);
389                                         rootarmor = WEP_CVAR(arc, beam_healing_aps);
390                                 }
391
392                                 if(trace_ent.health <= WEP_CVAR(arc, beam_healing_hmax) && roothealth)
393                                 {
394                                         trace_ent.health = min(
395                                                 trace_ent.health + (roothealth * coefficient),
396                                                 WEP_CVAR(arc, beam_healing_hmax)
397                                         );
398                                 }
399                                 if(trace_ent.armorvalue <= WEP_CVAR(arc, beam_healing_amax) && rootarmor)
400                                 {
401                                         trace_ent.armorvalue = min(
402                                                 trace_ent.armorvalue + (rootarmor * coefficient),
403                                                 WEP_CVAR(arc, beam_healing_amax)
404                                         );
405                                 }
406
407                                 // stop rot, set visual effect
408                                 if(roothealth || rootarmor)
409                                 {
410                                         trace_ent.pauserothealth_finished = max(
411                                                 trace_ent.pauserothealth_finished,
412                                                 time + autocvar_g_balance_pause_health_rot
413                                         );
414                                         trace_ent.pauserotarmor_finished = max(
415                                                 trace_ent.pauserotarmor_finished,
416                                                 time + autocvar_g_balance_pause_armor_rot
417                                         );
418                                         new_beam_type = ARC_BT_HEAL;
419                                 }
420                         }
421                         else
422                         {
423                                 float rootdamage;
424                                 if(is_player)
425                                 {
426                                         if(burst)
427                                                 { rootdamage = WEP_CVAR(arc, burst_damage); }
428                                         else
429                                                 { rootdamage = WEP_CVAR(arc, beam_damage); }
430                                 }
431                                 else
432                                         { rootdamage = WEP_CVAR(arc, beam_nonplayerdamage); }
433
434                                 if(accuracy_isgooddamage(self.owner, trace_ent))
435                                 {
436                                         accuracy_add(
437                                                 self.owner,
438                                                 WEP_ARC,
439                                                 0,
440                                                 rootdamage * coefficient * falloff
441                                         );
442                                 }
443
444                                 Damage(
445                                         trace_ent,
446                                         self.owner,
447                                         self.owner,
448                                         rootdamage * coefficient * falloff,
449                                         WEP_ARC,
450                                         hitorigin,
451                                         WEP_CVAR(arc, beam_force) * new_dir * coefficient * falloff
452                                 );
453
454                                 new_beam_type = ARC_BT_HIT;
455                         }
456                         break; 
457                 }
458                 else if(trace_fraction != 1)
459                 {
460                         // we collided with geometry
461                         new_beam_type = ARC_BT_WALL;
462                         break;
463                 }
464                 else
465                 {
466                         last_origin = new_origin;
467                 }
468         }
469
470         // if we're bursting, use burst visual effects
471         new_beam_type += burst;
472
473         // network information: beam type
474         if(new_beam_type != self.beam_type)
475         {
476                 self.SendFlags |= ARC_SF_BEAMTYPE;
477                 self.beam_type = new_beam_type;
478         }
479
480         self.owner.beam_prev = time;
481         self.nextthink = time;
482 }
483
484 void W_Arc_Beam(float burst)
485 {
486         // only play fire sound if 1 sec has passed since player let go the fire button
487         if(time - self.beam_prev > 1)
488         {
489                 sound(self, CH_WEAPON_A, "weapons/lgbeam_fire.wav", VOL_BASE, ATTN_NORM);
490         }
491
492         entity beam = self.arc_beam = spawn();
493         beam.classname = "W_Arc_Beam";
494         beam.solid = SOLID_NOT;
495         beam.think = W_Arc_Beam_Think;
496         beam.owner = self;
497         beam.movetype = MOVETYPE_NONE;
498         beam.bot_dodge = TRUE;
499         beam.bot_dodgerating = WEP_CVAR(arc, beam_damage);
500         beam.beam_bursting = burst;
501         Net_LinkEntity(beam, FALSE, 0, W_Arc_Beam_Send);
502
503         entity oldself = self;
504         self = beam;
505         self.think();
506         self = oldself;
507 }
508
509 float W_Arc(float req)
510 {
511         switch(req)
512         {
513                 case WR_AIM:
514                 {
515                         if(WEP_CVAR(arc, beam_botaimspeed))
516                         {
517                                 self.BUTTON_ATCK = bot_aim(
518                                         WEP_CVAR(arc, beam_botaimspeed),
519                                         0,
520                                         WEP_CVAR(arc, beam_botaimlifetime),
521                                         FALSE
522                                 );
523                         }
524                         else
525                         {
526                                 self.BUTTON_ATCK = bot_aim(
527                                         1000000,
528                                         0,
529                                         0.001,
530                                         FALSE
531                                 );
532                         }
533                         return TRUE;
534                 }
535                 case WR_THINK:
536                 {
537                         #if 0
538                         if(self.arc_beam.beam_heat > threshold)
539                         {
540                                 stop the beam somehow
541                                 play overheat animation
542                         }
543                         #endif
544
545                         if(self.BUTTON_ATCK || self.BUTTON_ATCK2 || self.arc_beam.beam_bursting)
546                         {
547                                 if(self.BUTTON_ATCK_prev)
548                                 {
549                                         #if 0
550                                         if(self.animstate_startframe == self.anim_shoot_x && self.animstate_numframes == self.anim_shoot_y)
551                                                 weapon_thinkf(WFRAME_DONTCHANGE, autocvar_g_balance_arc_primary_animtime, w_ready);
552                                         else
553                                         #endif
554                                                 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
555                                 }
556
557                                 if((!self.arc_beam) || wasfreed(self.arc_beam))
558                                 {
559                                         if(weapon_prepareattack(!!self.BUTTON_ATCK2, 0))
560                                         {
561                                                 W_Arc_Beam(!!self.BUTTON_ATCK2);
562                                                 
563                                                 if(!self.BUTTON_ATCK_prev)
564                                                 {
565                                                         weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
566                                                         self.BUTTON_ATCK_prev = 1;
567                                                 }
568                                         }
569                                 }
570                         } 
571                         else // todo
572                         {
573                                 if(self.BUTTON_ATCK_prev != 0)
574                                 {
575                                         weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
576                                         ATTACK_FINISHED(self) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor();
577                                 }
578                                 self.BUTTON_ATCK_prev = 0;
579                         }
580
581                         #if 0
582                         if(self.BUTTON_ATCK2)
583                         if(weapon_prepareattack(1, autocvar_g_balance_arc_secondary_refire))
584                         {
585                                 W_Arc_Attack2();
586                                 self.arc_count = autocvar_g_balance_arc_secondary_count;
587                                 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_arc_secondary_animtime, w_arc_checkattack);
588                                 self.arc_secondarytime = time + autocvar_g_balance_arc_secondary_refire2 * W_WeaponRateFactor();
589                         }
590                         #endif
591
592                         return TRUE;
593                 }
594                 case WR_INIT:
595                 {
596                         precache_model("models/weapons/g_arc.md3");
597                         precache_model("models/weapons/v_arc.md3");
598                         precache_model("models/weapons/h_arc.iqm");
599                         //precache_sound("weapons/arc_fire.wav");
600                         //precache_sound("weapons/arc_fire2.wav");
601                         //precache_sound("weapons/arc_impact.wav");
602                         if(!arc_shotorigin[0])
603                         {
604                                 arc_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 1);
605                                 arc_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 2);
606                                 arc_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 3);
607                                 arc_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC), FALSE, FALSE, 4);
608                         }
609                         ARC_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
610                         return TRUE;
611                 }
612                 case WR_CHECKAMMO1:
613                 {
614                         return ((!WEP_CVAR(arc, beam_ammo)) || (self.WEP_AMMO(ARC) > 0));
615                 }
616                 case WR_CHECKAMMO2:
617                 {
618                         return ((!WEP_CVAR(arc, burst_ammo)) || (self.WEP_AMMO(ARC) > 0));
619                 }
620                 case WR_CONFIG:
621                 {
622                         ARC_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
623                         return TRUE;
624                 }
625                 case WR_KILLMESSAGE:
626                 {
627                         if(w_deathtype & HITTYPE_SECONDARY)
628                         {
629                                 return WEAPON_ELECTRO_MURDER_ORBS;
630                         }
631                         else
632                         {
633                                 if(w_deathtype & HITTYPE_BOUNCE)
634                                         return WEAPON_ELECTRO_MURDER_COMBO;
635                                 else
636                                         return WEAPON_ELECTRO_MURDER_BOLT;
637                         }
638                 }
639         }
640         return FALSE;
641 }
642 #endif
643 #ifdef CSQC
644
645 .vector beam_color;
646 .float beam_alpha;
647 .float beam_thickness;
648 .float beam_traileffect;
649 .float beam_hiteffect;
650 .float beam_hitlight[4]; // 0: radius, 123: rgb
651 .float beam_muzzleeffect;
652 .float beam_muzzlelight[4]; // 0: radius, 123: rgb
653 .string beam_image;
654
655 .entity beam_muzzleentity;
656
657 .float beam_degreespersegment;
658 .float beam_distancepersegment;
659 .float beam_usevieworigin;
660 .float beam_initialized;
661 .float beam_maxangle;
662 .float beam_range;
663 .float beam_returnspeed;
664 .float beam_tightness;
665 .vector beam_shotorigin;
666 .vector beam_dir;
667
668 entity Draw_ArcBeam_callback_entity;
669 vector Draw_ArcBeam_callback_new_dir;
670 float Draw_ArcBeam_callback_segmentdist;
671 float Draw_ArcBeam_callback_last_thickness;
672 vector Draw_ArcBeam_callback_last_top;
673 vector Draw_ArcBeam_callback_last_bottom;
674
675 void Draw_ArcBeam_callback(vector start, vector hit, vector end)
676 {
677         entity beam = Draw_ArcBeam_callback_entity;
678         vector transformed_view_org;
679         transformed_view_org = WarpZone_TransformOrigin(WarpZone_trace_transform, view_origin);
680
681         vector thickdir = normalize(cross(normalize(start - hit), transformed_view_org - start));
682
683         vector hitorigin;
684
685         // draw segment
686         #if 0
687         if(trace_fraction != 1)
688         {
689                 // calculate our own hit origin as trace_endpos tends to jump around annoyingly (to player origin?)
690                 hitorigin = start + (Draw_ArcBeam_callback_new_dir * Draw_ArcBeam_callback_segmentdist * trace_fraction);
691                 hitorigin = WarpZone_TransformOrigin(WarpZone_trace_transform, hitorigin);
692         }
693         else
694         {
695                 hitorigin = hit;
696         }
697         #else
698         hitorigin = hit;
699         #endif
700
701         // decide upon thickness
702         float thickness = beam.beam_thickness;
703
704         // draw primary beam render
705         vector top    = hitorigin + (thickdir * thickness);
706         vector bottom = hitorigin - (thickdir * thickness);
707         //vector last_top    = start + (thickdir * Draw_ArcBeam_callback_last_thickness);
708         //vector last_bottom = start - (thickdir * Draw_ArcBeam_callback_last_thickness);
709
710         R_BeginPolygon(beam.beam_image, DRAWFLAG_NORMAL); // DRAWFLAG_ADDITIVE
711         R_PolygonVertex(
712                 top,
713                 '0 0.5 0' + ('0 0.5 0' * (thickness / beam.beam_thickness)),
714                 beam.beam_color,
715                 beam.beam_alpha
716         );
717         R_PolygonVertex(
718                 Draw_ArcBeam_callback_last_top,
719                 '0 0.5 0' + ('0 0.5 0' * (Draw_ArcBeam_callback_last_thickness / beam.beam_thickness)),
720                 beam.beam_color,
721                 beam.beam_alpha
722         );
723         R_PolygonVertex(
724                 Draw_ArcBeam_callback_last_bottom,
725                 '0 0.5 0' * (1 - (Draw_ArcBeam_callback_last_thickness / beam.beam_thickness)),
726                 beam.beam_color,
727                 beam.beam_alpha
728         );
729         R_PolygonVertex(
730                 bottom,
731                 '0 0.5 0' * (1 - (thickness / beam.beam_thickness)),
732                 beam.beam_color,
733                 beam.beam_alpha
734         );
735         R_EndPolygon();
736
737         // draw trailing particles
738         // NOTES:
739         //  - Don't use spammy particle counts here, use a FEW small particles around the beam
740         //  - We're not using WarpZone_TrailParticles here because we will handle warpzones ourselves.
741         if(beam.beam_traileffect)
742         {
743                 trailparticles(beam, beam.beam_traileffect, start, hitorigin);
744         }
745
746         // set up for the next 
747         Draw_ArcBeam_callback_last_thickness = thickness;
748         Draw_ArcBeam_callback_last_top = top;
749         Draw_ArcBeam_callback_last_bottom = bottom;
750 }
751
752 void Draw_ArcBeam(void)
753 {
754         if(!self.beam_usevieworigin)
755         {
756                 InterpolateOrigin_Do();
757         }
758
759         // origin = beam starting origin
760         // v_angle = wanted/aim direction
761         // angles = current direction of beam
762
763         vector start_pos;
764         vector wantdir; //= view_forward;
765         vector beamdir; //= self.beam_dir;
766
767         float segments;
768         if(self.beam_usevieworigin)
769         {
770                 // WEAPONTODO:
771                 // Currently we have to replicate nearly the same method of figuring
772                 // out the shotdir that the server does... Ideally in the future we
773                 // should be able to acquire this from a generalized function built
774                 // into a weapon system for client code. 
775
776                 // find where we are aiming
777                 makevectors(view_angles);
778
779                 // decide upon start position
780                 if(self.beam_usevieworigin == 2)
781                         { start_pos = view_origin; }
782                 else
783                         { start_pos = self.origin; }
784
785                 // trace forward with an estimation
786                 WarpZone_TraceLine(
787                         start_pos,
788                         start_pos + view_forward * self.beam_range,
789                         MOVE_NOMONSTERS,
790                         self
791                 );
792
793                 // untransform in case our trace went through a warpzone
794                 vector vf, vr, vu;
795                 vf = view_forward;
796                 vr = view_right;
797                 vu = view_up;
798                 vector shothitpos = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos); // warpzone support
799                 view_forward = vf;
800                 view_right = vr;
801                 view_up = vu;
802
803                 // un-adjust trueaim if shotend is too close
804                 if(vlen(shothitpos - view_origin) < g_trueaim_minrange)
805                         shothitpos = view_origin + (view_forward * g_trueaim_minrange);
806
807                 // move shot origin to the actual gun muzzle origin
808                 vector origin_offset =
809                         view_forward * self.beam_shotorigin_x
810                         + view_right * -self.beam_shotorigin_y 
811                         + view_up * self.beam_shotorigin_z;
812
813                 start_pos = start_pos + origin_offset;
814
815                 // calculate the aim direction now
816                 wantdir = normalize(shothitpos - start_pos);
817
818                 if(!self.beam_initialized)
819                 {
820                         self.beam_dir = wantdir;
821                         self.beam_initialized = TRUE;
822                 }
823
824                 if(self.beam_dir != wantdir)
825                 {
826                         // calculate how much we're going to move the end of the beam to the want position
827                         // WEAPONTODO (server and client):
828                         // blendfactor never actually becomes 0 in this situation, which is a problem
829                         // regarding precision... this means that self.beam_dir and w_shotdir approach
830                         // eachother, however they never actually become the same value with this method.
831                         // Perhaps we should do some form of rounding/snapping?
832                         float angle = vlen(wantdir - self.beam_dir) * RAD2DEG;
833                         if(angle && (angle > self.beam_maxangle))
834                         {
835                                 // if the angle is greater than maxangle, force the blendfactor to make this the maximum factor
836                                 float blendfactor = bound(
837                                         0,
838                                         (1 - (self.beam_returnspeed * frametime)),
839                                         min(self.beam_maxangle / angle, 1)
840                                 );
841                                 self.beam_dir = normalize((wantdir * (1 - blendfactor)) + (self.beam_dir * blendfactor));
842                         }
843                         else
844                         {
845                                 // the radius is not too far yet, no worries :D
846                                 float blendfactor = bound(
847                                         0,
848                                         (1 - (self.beam_returnspeed * frametime)),
849                                         1
850                                 );
851                                 self.beam_dir = normalize((wantdir * (1 - blendfactor)) + (self.beam_dir * blendfactor));
852                         }
853
854                         // calculate how many segments are needed
855                         float max_allowed_segments;
856
857                         if(self.beam_distancepersegment)
858                         {
859                                 max_allowed_segments = min(
860                                         ARC_MAX_SEGMENTS,
861                                         1 + (vlen(wantdir / self.beam_distancepersegment))
862                                 );
863                         }
864                         else { max_allowed_segments = ARC_MAX_SEGMENTS; }
865
866                         if(self.beam_degreespersegment)
867                         {
868                                 segments = bound(
869                                         1, 
870                                         (
871                                                 min(
872                                                         angle,
873                                                         self.beam_maxangle
874                                                 )
875                                                 /
876                                                 self.beam_degreespersegment
877                                         ),
878                                         max_allowed_segments
879                                 );
880                         }
881                         else { segments = 1; }
882                 }
883                 else { segments = 1; }
884
885                 // set the beam direction which the rest of the code will refer to
886                 beamdir = self.beam_dir;
887
888                 // finally, set self.angles to the proper direction so that muzzle attachment points in proper direction
889                 self.angles = fixedvectoangles2(view_forward, view_up);
890         }
891         else
892         {
893                 // set the values from the provided info from the networked entity
894                 start_pos = self.origin;
895                 wantdir = self.v_angle;
896                 beamdir = self.angles;
897
898                 if(beamdir != wantdir)
899                 {
900                         float angle = vlen(wantdir - beamdir) * RAD2DEG;
901
902                         // calculate how many segments are needed
903                         float max_allowed_segments;
904
905                         if(self.beam_distancepersegment)
906                         {
907                                 max_allowed_segments = min(
908                                         ARC_MAX_SEGMENTS,
909                                         1 + (vlen(wantdir / self.beam_distancepersegment))
910                                 );
911                         }
912                         else { max_allowed_segments = ARC_MAX_SEGMENTS; }
913
914                         if(self.beam_degreespersegment)
915                         {
916                                 segments = bound(
917                                         1, 
918                                         (
919                                                 min(
920                                                         angle,
921                                                         self.beam_maxangle
922                                                 )
923                                                 /
924                                                 self.beam_degreespersegment
925                                         ),
926                                         max_allowed_segments
927                                 );
928                         }
929                         else { segments = 1; }
930                 }
931                 else { segments = 1; }
932         }
933
934         setorigin(self, start_pos);
935         self.beam_muzzleentity.angles_z = random() * 360; // WEAPONTODO: use avelocity instead?
936
937         vector beam_endpos_estimate = (start_pos + (beamdir * self.beam_range));
938
939         Draw_ArcBeam_callback_entity = self;
940         Draw_ArcBeam_callback_last_thickness = 0;
941         Draw_ArcBeam_callback_last_top = start_pos;
942         Draw_ArcBeam_callback_last_bottom = start_pos;
943
944         vector last_origin = start_pos;
945
946         float i;
947         for(i = 1; i <= segments; ++i)
948         {
949                 // WEAPONTODO (server and client):
950                 // Segment blend and distance should probably really be calculated in a better way,
951                 // however I am not sure how to do it properly. There are a few things I have tried,
952                 // but most of them do not work properly due to my lack of understanding regarding
953                 // the mathematics behind them.
954
955                 // Ideally, we should calculate the positions along a perfect curve
956                 // between wantdir and self.beam_dir with an option for depth of arc
957
958                 // Another issue is that (on the client code) we must separate the
959                 // curve into multiple rendered curves when handling warpzones.
960
961                 // I can handle this by detecting it for each segment, however that
962                 // is a fairly inefficient method in comparison to having a curved line
963                 // drawing function similar to Draw_CylindricLine that accepts
964                 // top and bottom origins as input, this way there would be no
965                 // overlapping edges when connecting the curved pieces.
966
967                 // WEAPONTODO (client):
968                 // In order to do nice fading and pointing on the starting segment, we must always
969                 // have that drawn as a separate triangle... However, that is difficult to do when
970                 // keeping in mind the above problems and also optimizing the amount of segments
971                 // drawn on screen at any given time. (Automatic beam quality scaling, essentially)
972
973                 // calculate this on every segment to ensure that we always reach the full length of the attack
974                 float segmentblend = bound(0, (i/segments) + self.beam_tightness, 1);
975                 float segmentdist = vlen(beam_endpos_estimate - last_origin) * (i/segments);
976
977                 // WEAPONTODO: Apparently, normalize is not the correct function to use here...
978                 // Figure out how this actually should work.
979                 vector new_dir = normalize(
980                         (wantdir * (1 - segmentblend))
981                         +
982                         (normalize(beam_endpos_estimate - last_origin) * segmentblend)
983                 );
984                 vector new_origin = last_origin + (new_dir * segmentdist);
985
986                 Draw_ArcBeam_callback_segmentdist = segmentdist;
987                 Draw_ArcBeam_callback_new_dir = new_dir;
988
989                 WarpZone_TraceBox_ThroughZone(
990                         last_origin,
991                         '0 0 0',
992                         '0 0 0',
993                         new_origin,
994                         MOVE_NORMAL,
995                         world,
996                         world,
997                         Draw_ArcBeam_callback
998                 );
999
1000                 //printf("segment: %d, warpzone transform: %d\n", i, (WarpZone_trace_transform != world));
1001
1002                 // WEAPONTODO:
1003                 // Figure out some way to detect a collision with geometry with callback...
1004                 // That way we can know when we are done drawing the beam and skip
1005                 // the rest of the segments without breaking warpzone support.
1006
1007                 last_origin = WarpZone_TransformOrigin(WarpZone_trace_transform, new_origin);
1008                 beam_endpos_estimate = WarpZone_TransformOrigin(WarpZone_trace_transform, beam_endpos_estimate);
1009         }
1010
1011         // startpoint and endpoint drawn visual effects
1012         if(self.beam_hiteffect)
1013         {
1014                 pointparticles(
1015                         self.beam_hiteffect,
1016                         last_origin,
1017                         beamdir * -1,
1018                         frametime * 2
1019                 );
1020         }
1021         if(self.beam_hitlight[0])
1022         {
1023                 adddynamiclight(
1024                         last_origin,
1025                         self.beam_hitlight[0],
1026                         vec3(
1027                                 self.beam_hitlight[1],
1028                                 self.beam_hitlight[2],
1029                                 self.beam_hitlight[3]
1030                         )
1031                 );
1032         }
1033         if(self.beam_muzzleeffect)
1034         {
1035                 pointparticles(
1036                         self.beam_muzzleeffect,
1037                         start_pos + wantdir * 20,
1038                         wantdir * 1000,
1039                         frametime * 0.1
1040                 );
1041         }
1042         if(self.beam_muzzlelight[0])
1043         {
1044                 adddynamiclight(
1045                         start_pos + wantdir * 20,
1046                         self.beam_muzzlelight[0],
1047                         vec3(
1048                                 self.beam_muzzlelight[1],
1049                                 self.beam_muzzlelight[2],
1050                                 self.beam_muzzlelight[3]
1051                         )
1052                 );
1053         }
1054
1055         // cleanup
1056         Draw_ArcBeam_callback_entity = world;
1057         Draw_ArcBeam_callback_new_dir = '0 0 0';
1058         Draw_ArcBeam_callback_segmentdist = 0;
1059         Draw_ArcBeam_callback_last_thickness = 0;
1060         Draw_ArcBeam_callback_last_top = '0 0 0';
1061         Draw_ArcBeam_callback_last_bottom = '0 0 0';
1062 }
1063
1064 void Remove_ArcBeam(void)
1065 {
1066         remove(self.beam_muzzleentity);
1067         sound(self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTEN_NORM);
1068 }
1069
1070 void Ent_ReadArcBeam(float isnew)
1071 {
1072         float sf = ReadByte();
1073         entity flash;
1074
1075         if(isnew)
1076         {
1077                 // calculate shot origin offset from gun alignment
1078                 float gunalign = autocvar_cl_gunalign;
1079                 if(gunalign != 1 && gunalign != 2 && gunalign != 4)
1080                         gunalign = 3; // default value
1081                 --gunalign;
1082
1083                 self.beam_shotorigin = arc_shotorigin[gunalign];
1084
1085                 // set other main attributes of the beam
1086                 self.draw = Draw_ArcBeam;
1087                 self.entremove = Remove_ArcBeam;
1088                 sound(self, CH_SHOTS_SINGLE, "weapons/lgbeam_fly.wav", VOL_BASE, ATTEN_NORM);
1089
1090                 flash = spawn();
1091                 flash.owner = self;
1092                 flash.effects = EF_ADDITIVE | EF_FULLBRIGHT;
1093                 flash.drawmask = MASK_NORMAL;
1094                 flash.solid = SOLID_NOT;
1095                 setattachment(flash, self, "");
1096                 setorigin(flash, '0 0 0');
1097
1098                 self.beam_muzzleentity = flash;
1099         }
1100         else
1101         {
1102                 flash = self.beam_muzzleentity;
1103         }
1104
1105         if(sf & ARC_SF_SETTINGS) // settings information
1106         {
1107                 self.beam_degreespersegment = ReadShort();
1108                 self.beam_distancepersegment = ReadShort();
1109                 self.beam_maxangle = ReadShort();
1110                 self.beam_range = ReadCoord();
1111                 self.beam_returnspeed = ReadShort();
1112                 self.beam_tightness = (ReadByte() / 10);
1113
1114                 if(ReadByte())
1115                 {
1116                         if(autocvar_chase_active)
1117                                 { self.beam_usevieworigin = 1; }
1118                         else // use view origin
1119                                 { self.beam_usevieworigin = 2; }
1120                 }
1121                 else
1122                 {
1123                         self.beam_usevieworigin = 0;
1124                 }
1125         }
1126
1127         if(!self.beam_usevieworigin)
1128         {
1129                 // self.iflags = IFLAG_ORIGIN | IFLAG_ANGLES | IFLAG_V_ANGLE; // why doesn't this work?
1130                 self.iflags = IFLAG_ORIGIN;
1131
1132                 InterpolateOrigin_Undo();
1133         }
1134
1135         if(sf & ARC_SF_START) // starting location
1136         {
1137                 self.origin_x = ReadCoord();
1138                 self.origin_y = ReadCoord();
1139                 self.origin_z = ReadCoord();
1140         }
1141         else if(self.beam_usevieworigin) // infer the location from player location
1142         {
1143                 if(self.beam_usevieworigin == 2)
1144                 {
1145                         // use view origin
1146                         self.origin = view_origin;
1147                 }
1148                 else
1149                 {
1150                         // use player origin so that third person display still works
1151                         self.origin = getplayerorigin(player_localnum) + ('0 0 1' * getstati(STAT_VIEWHEIGHT));
1152                 }
1153         }
1154
1155         setorigin(self, self.origin);
1156
1157         if(sf & ARC_SF_WANTDIR) // want/aim direction
1158         {
1159                 self.v_angle_x = ReadCoord();
1160                 self.v_angle_y = ReadCoord();
1161                 self.v_angle_z = ReadCoord();
1162         }
1163
1164         if(sf & ARC_SF_BEAMDIR) // beam direction
1165         {
1166                 self.angles_x = ReadCoord();
1167                 self.angles_y = ReadCoord();
1168                 self.angles_z = ReadCoord();
1169         }
1170
1171         if(sf & ARC_SF_BEAMTYPE) // beam type
1172         {
1173                 self.beam_type = ReadByte();
1174                 switch(self.beam_type)
1175                 {
1176                         case ARC_BT_MISS:
1177                         {
1178                                 self.beam_color = '-1 -1 1';
1179                                 self.beam_alpha = 0.5;
1180                                 self.beam_thickness = 8;
1181                                 self.beam_traileffect = FALSE;
1182                                 self.beam_hiteffect = particleeffectnum("electro_lightning");
1183                                 self.beam_hitlight[0] = 0;
1184                                 self.beam_hitlight[1] = 1;
1185                                 self.beam_hitlight[2] = 1;
1186                                 self.beam_hitlight[3] = 1;
1187                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1188                                 self.beam_muzzlelight[0] = 0;
1189                                 self.beam_muzzlelight[1] = 1;
1190                                 self.beam_muzzlelight[2] = 1;
1191                                 self.beam_muzzlelight[3] = 1;
1192                                 self.beam_image = "particles/lgbeam";
1193                                 setmodel(flash, "models/flash.md3");
1194                                 flash.alpha = self.beam_alpha;
1195                                 flash.colormod = self.beam_color;
1196                                 flash.scale = 0.5;
1197                                 break;
1198                         }
1199                         case ARC_BT_WALL: // grenadelauncher_muzzleflash healray_muzzleflash
1200                         {
1201                                 self.beam_color = '0.5 0.5 1';
1202                                 self.beam_alpha = 0.5;
1203                                 self.beam_thickness = 8;
1204                                 self.beam_traileffect = FALSE;
1205                                 self.beam_hiteffect = particleeffectnum("electro_lightning");
1206                                 self.beam_hitlight[0] = 0;
1207                                 self.beam_hitlight[1] = 1;
1208                                 self.beam_hitlight[2] = 1;
1209                                 self.beam_hitlight[3] = 1;
1210                                 self.beam_muzzleeffect = FALSE; // particleeffectnum("grenadelauncher_muzzleflash");
1211                                 self.beam_muzzlelight[0] = 0;
1212                                 self.beam_muzzlelight[1] = 1;
1213                                 self.beam_muzzlelight[2] = 1;
1214                                 self.beam_muzzlelight[3] = 1;
1215                                 self.beam_image = "particles/lgbeam";
1216                                 setmodel(flash, "models/flash.md3");
1217                                 flash.alpha = self.beam_alpha;
1218                                 flash.colormod = self.beam_color;
1219                                 flash.scale = 0.5;
1220                                 break;
1221                         }
1222                         case ARC_BT_HEAL:
1223                         {
1224                                 self.beam_color = '0 1 0';
1225                                 self.beam_alpha = 0.5;
1226                                 self.beam_thickness = 8;
1227                                 self.beam_traileffect = FALSE;
1228                                 self.beam_hiteffect = particleeffectnum("healray_impact"); 
1229                                 self.beam_hitlight[0] = 0;
1230                                 self.beam_hitlight[1] = 1;
1231                                 self.beam_hitlight[2] = 1;
1232                                 self.beam_hitlight[3] = 1;
1233                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1234                                 self.beam_muzzlelight[0] = 0;
1235                                 self.beam_muzzlelight[1] = 1;
1236                                 self.beam_muzzlelight[2] = 1;
1237                                 self.beam_muzzlelight[3] = 1;
1238                                 self.beam_image = "particles/lgbeam";
1239                                 setmodel(flash, "models/flash.md3");
1240                                 flash.alpha = self.beam_alpha;
1241                                 flash.colormod = self.beam_color;
1242                                 flash.scale = 0.5;
1243                                 break;
1244                         }
1245                         case ARC_BT_HIT:
1246                         {
1247                                 self.beam_color = '1 0 1';
1248                                 self.beam_alpha = 0.5;
1249                                 self.beam_thickness = 8;
1250                                 self.beam_traileffect = particleeffectnum("nex_beam");
1251                                 self.beam_hiteffect = particleeffectnum("electro_lightning"); 
1252                                 self.beam_hitlight[0] = 20;
1253                                 self.beam_hitlight[1] = 1;
1254                                 self.beam_hitlight[2] = 0;
1255                                 self.beam_hitlight[3] = 0;
1256                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1257                                 self.beam_muzzlelight[0] = 50;
1258                                 self.beam_muzzlelight[1] = 1;
1259                                 self.beam_muzzlelight[2] = 0;
1260                                 self.beam_muzzlelight[3] = 0;
1261                                 self.beam_image = "particles/lgbeam";
1262                                 setmodel(flash, "models/flash.md3");
1263                                 flash.alpha = self.beam_alpha;
1264                                 flash.colormod = self.beam_color;
1265                                 flash.scale = 0.5;
1266                                 break;
1267                         }
1268                         case ARC_BT_BURST_MISS:
1269                         {
1270                                 self.beam_color = '-1 -1 1';
1271                                 self.beam_alpha = 0.5;
1272                                 self.beam_thickness = 14;
1273                                 self.beam_traileffect = FALSE;
1274                                 self.beam_hiteffect = particleeffectnum("electro_lightning"); 
1275                                 self.beam_hitlight[0] = 0;
1276                                 self.beam_hitlight[1] = 1;
1277                                 self.beam_hitlight[2] = 1;
1278                                 self.beam_hitlight[3] = 1;
1279                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1280                                 self.beam_muzzlelight[0] = 0;
1281                                 self.beam_muzzlelight[1] = 1;
1282                                 self.beam_muzzlelight[2] = 1;
1283                                 self.beam_muzzlelight[3] = 1;
1284                                 self.beam_image = "particles/lgbeam";
1285                                 setmodel(flash, "models/flash.md3");
1286                                 flash.alpha = self.beam_alpha;
1287                                 flash.colormod = self.beam_color;
1288                                 flash.scale = 0.5;
1289                                 break;
1290                         }
1291                         case ARC_BT_BURST_WALL:
1292                         {
1293                                 self.beam_color = '0.5 0.5 1';
1294                                 self.beam_alpha = 0.5;
1295                                 self.beam_thickness = 14;
1296                                 self.beam_traileffect = FALSE;
1297                                 self.beam_hiteffect = particleeffectnum("electro_lightning"); 
1298                                 self.beam_hitlight[0] = 0;
1299                                 self.beam_hitlight[1] = 1;
1300                                 self.beam_hitlight[2] = 1;
1301                                 self.beam_hitlight[3] = 1;
1302                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1303                                 self.beam_muzzlelight[0] = 0;
1304                                 self.beam_muzzlelight[1] = 1;
1305                                 self.beam_muzzlelight[2] = 1;
1306                                 self.beam_muzzlelight[3] = 1;
1307                                 self.beam_image = "particles/lgbeam";
1308                                 setmodel(flash, "models/flash.md3");
1309                                 flash.alpha = self.beam_alpha;
1310                                 flash.colormod = self.beam_color;
1311                                 flash.scale = 0.5;
1312                                 break;
1313                         }
1314                         case ARC_BT_BURST_HEAL:
1315                         {
1316                                 self.beam_color = '0 1 0';
1317                                 self.beam_alpha = 0.5;
1318                                 self.beam_thickness = 14;
1319                                 self.beam_traileffect = FALSE;
1320                                 self.beam_hiteffect = particleeffectnum("electro_lightning"); 
1321                                 self.beam_hitlight[0] = 0;
1322                                 self.beam_hitlight[1] = 1;
1323                                 self.beam_hitlight[2] = 1;
1324                                 self.beam_hitlight[3] = 1;
1325                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1326                                 self.beam_muzzlelight[0] = 0;
1327                                 self.beam_muzzlelight[1] = 1;
1328                                 self.beam_muzzlelight[2] = 1;
1329                                 self.beam_muzzlelight[3] = 1;
1330                                 self.beam_image = "particles/lgbeam";
1331                                 setmodel(flash, "models/flash.md3");
1332                                 flash.alpha = self.beam_alpha;
1333                                 flash.colormod = self.beam_color;
1334                                 flash.scale = 0.5;
1335                                 break;
1336                         }
1337                         case ARC_BT_BURST_HIT:
1338                         {
1339                                 self.beam_color = '1 0 1';
1340                                 self.beam_alpha = 0.5;
1341                                 self.beam_thickness = 14;
1342                                 self.beam_traileffect = FALSE;
1343                                 self.beam_hiteffect = particleeffectnum("electro_lightning"); 
1344                                 self.beam_hitlight[0] = 0;
1345                                 self.beam_hitlight[1] = 1;
1346                                 self.beam_hitlight[2] = 1;
1347                                 self.beam_hitlight[3] = 1;
1348                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1349                                 self.beam_muzzlelight[0] = 0;
1350                                 self.beam_muzzlelight[1] = 1;
1351                                 self.beam_muzzlelight[2] = 1;
1352                                 self.beam_muzzlelight[3] = 1;
1353                                 self.beam_image = "particles/lgbeam";
1354                                 setmodel(flash, "models/flash.md3");
1355                                 flash.alpha = self.beam_alpha;
1356                                 flash.colormod = self.beam_color;
1357                                 flash.scale = 0.5;
1358                                 break;
1359                         }
1360
1361                         // shouldn't be possible, but lets make it colorful if it does :D
1362                         default:
1363                         {
1364                                 self.beam_color = randomvec();
1365                                 self.beam_alpha = 1;
1366                                 self.beam_thickness = 8;
1367                                 self.beam_traileffect = FALSE;
1368                                 self.beam_hiteffect = FALSE; 
1369                                 self.beam_hitlight[0] = 0;
1370                                 self.beam_hitlight[1] = 1;
1371                                 self.beam_hitlight[2] = 1;
1372                                 self.beam_hitlight[3] = 1;
1373                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1374                                 self.beam_muzzlelight[0] = 0;
1375                                 self.beam_muzzlelight[1] = 1;
1376                                 self.beam_muzzlelight[2] = 1;
1377                                 self.beam_muzzlelight[3] = 1;
1378                                 self.beam_image = "particles/lgbeam";
1379                                 setmodel(flash, "models/flash.md3");
1380                                 flash.alpha = self.beam_alpha;
1381                                 flash.colormod = self.beam_color;
1382                                 flash.scale = 0.5;
1383                                 break;
1384                         }
1385                 }
1386         }
1387
1388         if(!self.beam_usevieworigin)
1389         {
1390                 InterpolateOrigin_Note();
1391         }
1392 }
1393
1394 float W_Arc(float req)
1395 {
1396         switch(req)
1397         {
1398                 case WR_IMPACTEFFECT:
1399                 {
1400                         // todo
1401                         return TRUE;
1402                 }
1403                 case WR_INIT:
1404                 {
1405                         //precache_sound("weapons/arc_impact.wav");
1406                         //precache_sound("weapons/arc_impact_combo.wav");
1407                         return TRUE;
1408                 }
1409                 case WR_ZOOMRETICLE:
1410                 {
1411                         // no weapon specific image for this weapon
1412                         return FALSE;
1413                 }
1414         }
1415         return FALSE;
1416 }
1417 #endif
1418 #endif