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