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