]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/w_arc.qc
e34aa660927bb04ded273432d807f5d9515b2d24
[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 */ "arc",
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                         // arc currently has no secondary attack
645                         return FALSE;
646                         //return ((!WEP_CVAR(arc, burst_ammo)) || (self.WEP_AMMO(ARC) > 0));
647                 }
648                 case WR_CONFIG:
649                 {
650                         ARC_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
651                         return TRUE;
652                 }
653                 case WR_KILLMESSAGE:
654                 {
655                         return WEAPON_ARC_MURDER;
656                 }
657         }
658         return FALSE;
659 }
660 #endif
661 #ifdef CSQC
662 void Draw_ArcBeam_callback(vector start, vector hit, vector end)
663 {
664         entity beam = Draw_ArcBeam_callback_entity;
665         vector transformed_view_org;
666         transformed_view_org = WarpZone_TransformOrigin(WarpZone_trace_transform, view_origin);
667
668         // Thickdir shall be perpendicular to the beam and to the view-to-beam direction (WEAPONTODO: WHY)
669         // WEAPONTODO: Wouldn't it be better to be perpendicular to the beam and to the view FORWARD direction?
670         vector thickdir = normalize(cross(normalize(start - hit), transformed_view_org - start));
671
672         vector hitorigin;
673
674         // draw segment
675         #if 0
676         if(trace_fraction != 1)
677         {
678                 // calculate our own hit origin as trace_endpos tends to jump around annoyingly (to player origin?)
679                 hitorigin = start + (Draw_ArcBeam_callback_new_dir * Draw_ArcBeam_callback_segmentdist * trace_fraction);
680                 hitorigin = WarpZone_TransformOrigin(WarpZone_trace_transform, hitorigin);
681         }
682         else
683         {
684                 hitorigin = hit;
685         }
686         #else
687         hitorigin = hit;
688         #endif
689
690         // decide upon thickness
691         float thickness = beam.beam_thickness;
692
693         // draw primary beam render
694         vector top    = hitorigin + (thickdir * thickness);
695         vector bottom = hitorigin - (thickdir * thickness);
696         
697         vector last_top = WarpZone_TransformOrigin(WarpZone_trace_transform, Draw_ArcBeam_callback_last_top);
698         vector last_bottom = WarpZone_TransformOrigin(WarpZone_trace_transform, Draw_ArcBeam_callback_last_bottom);
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                 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                 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 = WarpZone_UnTransformOrigin(WarpZone_trace_transform, top);
739         Draw_ArcBeam_callback_last_bottom = WarpZone_UnTransformOrigin(WarpZone_trace_transform, bottom);
740 }
741
742 void Reset_ArcBeam(void)
743 {
744         entity e;
745         for (e = world; (e = findfloat(e, beam_usevieworigin, 1)); ) {
746                 e.beam_initialized = FALSE;
747         }
748         for (e = world; (e = findfloat(e, beam_usevieworigin, 2)); ) {
749                 e.beam_initialized = FALSE;
750         }
751 }
752
753 void Draw_ArcBeam(void)
754 {
755         if(!self.beam_usevieworigin)
756         {
757                 InterpolateOrigin_Do();
758         }
759
760         // origin = beam starting origin
761         // v_angle = wanted/aim direction
762         // angles = current direction of beam
763
764         vector start_pos;
765         vector wantdir; //= view_forward;
766         vector beamdir; //= self.beam_dir;
767
768         float segments;
769         if(self.beam_usevieworigin)
770         {
771                 // WEAPONTODO:
772                 // Currently we have to replicate nearly the same method of figuring
773                 // out the shotdir that the server does... Ideally in the future we
774                 // should be able to acquire this from a generalized function built
775                 // into a weapon system for client code. 
776
777                 // find where we are aiming
778                 makevectors(warpzone_save_view_angles);
779                 vector forward = v_forward;
780                 vector right = v_right;
781                 vector up = v_up;
782
783                 // decide upon start position
784                 if(self.beam_usevieworigin == 2)
785                         { start_pos = warpzone_save_view_origin; }
786                 else
787                         { start_pos = self.origin; }
788
789                 // trace forward with an estimation
790                 WarpZone_TraceLine(
791                         start_pos,
792                         start_pos + forward * self.beam_range,
793                         MOVE_NOMONSTERS,
794                         self
795                 );
796
797                 // untransform in case our trace went through a warpzone
798                 vector end_pos = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
799
800                 // un-adjust trueaim if shotend is too close
801                 if(vlen(end_pos - start_pos) < g_trueaim_minrange)
802                         end_pos = start_pos + (forward * g_trueaim_minrange);
803
804                 // move shot origin to the actual gun muzzle origin
805                 vector origin_offset =
806                           right * -self.beam_shotorigin_y 
807                         + up * self.beam_shotorigin_z;
808
809                 start_pos = start_pos + origin_offset;
810
811                 // Move it also forward, but only as far as possible without hitting anything. Don't poke into walls!
812                 traceline(start_pos, start_pos + forward * self.beam_shotorigin_x, MOVE_NORMAL, self);
813                 start_pos = trace_endpos;
814
815                 // calculate the aim direction now
816                 wantdir = normalize(end_pos - start_pos);
817
818                 if(!self.beam_initialized)
819                 {
820                         self.beam_dir = wantdir;
821                         self.beam_initialized = TRUE;
822                 }
823
824                 if(self.beam_dir != wantdir)
825                 {
826                         // calculate how much we're going to move the end of the beam to the want position
827                         // WEAPONTODO (server and client):
828                         // blendfactor never actually becomes 0 in this situation, which is a problem
829                         // regarding precision... this means that self.beam_dir and w_shotdir approach
830                         // eachother, however they never actually become the same value with this method.
831                         // Perhaps we should do some form of rounding/snapping?
832                         float angle = vlen(wantdir - self.beam_dir) * RAD2DEG;
833                         if(angle && (angle > self.beam_maxangle))
834                         {
835                                 // if the angle is greater than maxangle, force the blendfactor to make this the maximum factor
836                                 float blendfactor = bound(
837                                         0,
838                                         (1 - (self.beam_returnspeed * frametime)),
839                                         min(self.beam_maxangle / angle, 1)
840                                 );
841                                 self.beam_dir = normalize((wantdir * (1 - blendfactor)) + (self.beam_dir * blendfactor));
842                         }
843                         else
844                         {
845                                 // the radius is not too far yet, no worries :D
846                                 float blendfactor = bound(
847                                         0,
848                                         (1 - (self.beam_returnspeed * frametime)),
849                                         1
850                                 );
851                                 self.beam_dir = normalize((wantdir * (1 - blendfactor)) + (self.beam_dir * blendfactor));
852                         }
853
854                         // calculate how many segments are needed
855                         float max_allowed_segments;
856
857                         if(self.beam_distancepersegment)
858                         {
859                                 max_allowed_segments = min(
860                                         ARC_MAX_SEGMENTS,
861                                         1 + (vlen(wantdir / self.beam_distancepersegment))
862                                 );
863                         }
864                         else { max_allowed_segments = ARC_MAX_SEGMENTS; }
865
866                         if(self.beam_degreespersegment)
867                         {
868                                 segments = bound(
869                                         1, 
870                                         (
871                                                 min(
872                                                         angle,
873                                                         self.beam_maxangle
874                                                 )
875                                                 /
876                                                 self.beam_degreespersegment
877                                         ),
878                                         max_allowed_segments
879                                 );
880                         }
881                         else { segments = 1; }
882                 }
883                 else { segments = 1; }
884
885                 // set the beam direction which the rest of the code will refer to
886                 beamdir = self.beam_dir;
887
888                 // finally, set self.angles to the proper direction so that muzzle attachment points in proper direction
889                 self.angles = fixedvectoangles2(forward, up); // TODO(Samual): is this == warpzone_save_view_angles?
890         }
891         else
892         {
893                 // set the values from the provided info from the networked entity
894                 start_pos = self.origin;
895                 wantdir = self.v_angle;
896                 beamdir = self.angles;
897
898                 if(beamdir != wantdir)
899                 {
900                         float angle = vlen(wantdir - beamdir) * RAD2DEG;
901
902                         // calculate how many segments are needed
903                         float max_allowed_segments;
904
905                         if(self.beam_distancepersegment)
906                         {
907                                 max_allowed_segments = min(
908                                         ARC_MAX_SEGMENTS,
909                                         1 + (vlen(wantdir / self.beam_distancepersegment))
910                                 );
911                         }
912                         else { max_allowed_segments = ARC_MAX_SEGMENTS; }
913
914                         if(self.beam_degreespersegment)
915                         {
916                                 segments = bound(
917                                         1, 
918                                         (
919                                                 min(
920                                                         angle,
921                                                         self.beam_maxangle
922                                                 )
923                                                 /
924                                                 self.beam_degreespersegment
925                                         ),
926                                         max_allowed_segments
927                                 );
928                         }
929                         else { segments = 1; }
930                 }
931                 else { segments = 1; }
932         }
933
934         setorigin(self, start_pos);
935         self.beam_muzzleentity.angles_z = random() * 360; // WEAPONTODO: use avelocity instead?
936
937         vector beam_endpos = (start_pos + (beamdir * self.beam_range));
938         vector beam_controlpoint = start_pos + wantdir * (self.beam_range * (1 - self.beam_tightness));
939
940         Draw_ArcBeam_callback_entity = self;
941         Draw_ArcBeam_callback_last_thickness = 0;
942         Draw_ArcBeam_callback_last_top = start_pos;
943         Draw_ArcBeam_callback_last_bottom = start_pos;
944
945         vector last_origin = start_pos;
946         vector original_start_pos = start_pos;
947
948         float i;
949         for(i = 1; i <= segments; ++i)
950         {
951                 // WEAPONTODO (client):
952                 // In order to do nice fading and pointing on the starting segment, we must always
953                 // have that drawn as a separate triangle... However, that is difficult to do when
954                 // keeping in mind the above problems and also optimizing the amount of segments
955                 // drawn on screen at any given time. (Automatic beam quality scaling, essentially)
956
957                 vector new_origin = bezier_quadratic_getpoint(
958                         start_pos,
959                         beam_controlpoint,
960                         beam_endpos,
961                         i / segments);
962
963                 WarpZone_TraceBox_ThroughZone(
964                         last_origin,
965                         '0 0 0',
966                         '0 0 0',
967                         new_origin,
968                         MOVE_NORMAL,
969                         world,
970                         world,
971                         Draw_ArcBeam_callback
972                 );
973
974                 // Do all the transforms for warpzones right now, as we already "are" in the post-trace
975                 // system (if we hit a player, that's always BEHIND the last passed wz).
976                 last_origin = trace_endpos;
977                 start_pos = WarpZone_TransformOrigin(WarpZone_trace_transform, start_pos);
978                 beam_controlpoint = WarpZone_TransformOrigin(WarpZone_trace_transform, beam_controlpoint);
979                 beam_endpos = WarpZone_TransformOrigin(WarpZone_trace_transform, beam_endpos);
980                 beamdir = WarpZone_TransformVelocity(WarpZone_trace_transform, beamdir);
981                 Draw_ArcBeam_callback_last_top = WarpZone_TransformOrigin(WarpZone_trace_transform, Draw_ArcBeam_callback_last_top);
982                 Draw_ArcBeam_callback_last_bottom = WarpZone_TransformOrigin(WarpZone_trace_transform, Draw_ArcBeam_callback_last_bottom);
983
984                 if(trace_fraction < 1) { break; }
985         }
986
987         // visual effects for startpoint and endpoint
988         if(self.beam_hiteffect)
989         {
990                 // FIXME we really should do this on the server so it actually
991                 // matches gameplay. What this client side stuff is doing is no
992                 // more than guesswork.
993                 pointparticles(
994                         self.beam_hiteffect,
995                         last_origin,
996                         beamdir * -1,
997                         frametime * 2
998                 );
999         }
1000         if(self.beam_hitlight[0])
1001         {
1002                 adddynamiclight(
1003                         last_origin,
1004                         self.beam_hitlight[0],
1005                         vec3(
1006                                 self.beam_hitlight[1],
1007                                 self.beam_hitlight[2],
1008                                 self.beam_hitlight[3]
1009                         )
1010                 );
1011         }
1012         if(self.beam_muzzleeffect)
1013         {
1014                 pointparticles(
1015                         self.beam_muzzleeffect,
1016                         original_start_pos + wantdir * 20,
1017                         wantdir * 1000,
1018                         frametime * 0.1
1019                 );
1020         }
1021         if(self.beam_muzzlelight[0])
1022         {
1023                 adddynamiclight(
1024                         original_start_pos + wantdir * 20,
1025                         self.beam_muzzlelight[0],
1026                         vec3(
1027                                 self.beam_muzzlelight[1],
1028                                 self.beam_muzzlelight[2],
1029                                 self.beam_muzzlelight[3]
1030                         )
1031                 );
1032         }
1033
1034         // cleanup
1035         Draw_ArcBeam_callback_entity = world;
1036         Draw_ArcBeam_callback_last_thickness = 0;
1037         Draw_ArcBeam_callback_last_top = '0 0 0';
1038         Draw_ArcBeam_callback_last_bottom = '0 0 0';
1039 }
1040
1041 void Remove_ArcBeam(void)
1042 {
1043         remove(self.beam_muzzleentity);
1044         sound(self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTEN_NORM);
1045 }
1046
1047 void Ent_ReadArcBeam(float isnew)
1048 {
1049         float sf = ReadByte();
1050         entity flash;
1051
1052         if(isnew)
1053         {
1054                 // calculate shot origin offset from gun alignment
1055                 float gunalign = autocvar_cl_gunalign;
1056                 if(gunalign != 1 && gunalign != 2 && gunalign != 4)
1057                         gunalign = 3; // default value
1058                 --gunalign;
1059
1060                 self.beam_shotorigin = arc_shotorigin[gunalign];
1061
1062                 // set other main attributes of the beam
1063                 self.draw = Draw_ArcBeam;
1064                 self.entremove = Remove_ArcBeam;
1065                 sound(self, CH_SHOTS_SINGLE, "weapons/lgbeam_fly.wav", VOL_BASE, ATTEN_NORM);
1066
1067                 flash = spawn();
1068                 flash.owner = self;
1069                 flash.effects = EF_ADDITIVE | EF_FULLBRIGHT;
1070                 flash.drawmask = MASK_NORMAL;
1071                 flash.solid = SOLID_NOT;
1072                 flash.avelocity_z = 5000;
1073                 setattachment(flash, self, "");
1074                 setorigin(flash, '0 0 0');
1075
1076                 self.beam_muzzleentity = flash;
1077         }
1078         else
1079         {
1080                 flash = self.beam_muzzleentity;
1081         }
1082
1083         if(sf & ARC_SF_SETTINGS) // settings information
1084         {
1085                 self.beam_degreespersegment = ReadShort();
1086                 self.beam_distancepersegment = ReadShort();
1087                 self.beam_maxangle = ReadShort();
1088                 self.beam_range = ReadCoord();
1089                 self.beam_returnspeed = ReadShort();
1090                 self.beam_tightness = (ReadByte() / 10);
1091
1092                 if(ReadByte())
1093                 {
1094                         if(autocvar_chase_active)
1095                                 { self.beam_usevieworigin = 1; }
1096                         else // use view origin
1097                                 { self.beam_usevieworigin = 2; }
1098                 }
1099                 else
1100                 {
1101                         self.beam_usevieworigin = 0;
1102                 }
1103         }
1104
1105         if(!self.beam_usevieworigin)
1106         {
1107                 // self.iflags = IFLAG_ORIGIN | IFLAG_ANGLES | IFLAG_V_ANGLE; // why doesn't this work?
1108                 self.iflags = IFLAG_ORIGIN;
1109
1110                 InterpolateOrigin_Undo();
1111         }
1112
1113         if(sf & ARC_SF_START) // starting location
1114         {
1115                 self.origin_x = ReadCoord();
1116                 self.origin_y = ReadCoord();
1117                 self.origin_z = ReadCoord();
1118         }
1119         else if(self.beam_usevieworigin) // infer the location from player location
1120         {
1121                 if(self.beam_usevieworigin == 2)
1122                 {
1123                         // use view origin
1124                         self.origin = view_origin;
1125                 }
1126                 else
1127                 {
1128                         // use player origin so that third person display still works
1129                         self.origin = getplayerorigin(player_localnum) + ('0 0 1' * getstati(STAT_VIEWHEIGHT));
1130                 }
1131         }
1132
1133         setorigin(self, self.origin);
1134
1135         if(sf & ARC_SF_WANTDIR) // want/aim direction
1136         {
1137                 self.v_angle_x = ReadCoord();
1138                 self.v_angle_y = ReadCoord();
1139                 self.v_angle_z = ReadCoord();
1140         }
1141
1142         if(sf & ARC_SF_BEAMDIR) // beam direction
1143         {
1144                 self.angles_x = ReadCoord();
1145                 self.angles_y = ReadCoord();
1146                 self.angles_z = ReadCoord();
1147         }
1148
1149         if(sf & ARC_SF_BEAMTYPE) // beam type
1150         {
1151                 self.beam_type = ReadByte();
1152                 switch(self.beam_type)
1153                 {
1154                         case ARC_BT_MISS:
1155                         {
1156                                 self.beam_color = '-1 -1 1';
1157                                 self.beam_alpha = 0.5;
1158                                 self.beam_thickness = 8;
1159                                 self.beam_traileffect = FALSE;
1160                                 self.beam_hiteffect = particleeffectnum("electro_lightning");
1161                                 self.beam_hitlight[0] = 0;
1162                                 self.beam_hitlight[1] = 1;
1163                                 self.beam_hitlight[2] = 1;
1164                                 self.beam_hitlight[3] = 1;
1165                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1166                                 self.beam_muzzlelight[0] = 0;
1167                                 self.beam_muzzlelight[1] = 1;
1168                                 self.beam_muzzlelight[2] = 1;
1169                                 self.beam_muzzlelight[3] = 1;
1170                                 self.beam_image = "particles/lgbeam";
1171                                 setmodel(flash, "models/flash.md3");
1172                                 flash.alpha = self.beam_alpha;
1173                                 flash.colormod = self.beam_color;
1174                                 flash.scale = 0.5;
1175                                 break;
1176                         }
1177                         case ARC_BT_WALL: // grenadelauncher_muzzleflash healray_muzzleflash
1178                         {
1179                                 self.beam_color = '0.5 0.5 1';
1180                                 self.beam_alpha = 0.5;
1181                                 self.beam_thickness = 8;
1182                                 self.beam_traileffect = FALSE;
1183                                 self.beam_hiteffect = particleeffectnum("electro_lightning");
1184                                 self.beam_hitlight[0] = 0;
1185                                 self.beam_hitlight[1] = 1;
1186                                 self.beam_hitlight[2] = 1;
1187                                 self.beam_hitlight[3] = 1;
1188                                 self.beam_muzzleeffect = FALSE; // particleeffectnum("grenadelauncher_muzzleflash");
1189                                 self.beam_muzzlelight[0] = 0;
1190                                 self.beam_muzzlelight[1] = 1;
1191                                 self.beam_muzzlelight[2] = 1;
1192                                 self.beam_muzzlelight[3] = 1;
1193                                 self.beam_image = "particles/lgbeam";
1194                                 setmodel(flash, "models/flash.md3");
1195                                 flash.alpha = self.beam_alpha;
1196                                 flash.colormod = self.beam_color;
1197                                 flash.scale = 0.5;
1198                                 break;
1199                         }
1200                         case ARC_BT_HEAL:
1201                         {
1202                                 self.beam_color = '0 1 0';
1203                                 self.beam_alpha = 0.5;
1204                                 self.beam_thickness = 8;
1205                                 self.beam_traileffect = FALSE;
1206                                 self.beam_hiteffect = particleeffectnum("healray_impact"); 
1207                                 self.beam_hitlight[0] = 0;
1208                                 self.beam_hitlight[1] = 1;
1209                                 self.beam_hitlight[2] = 1;
1210                                 self.beam_hitlight[3] = 1;
1211                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1212                                 self.beam_muzzlelight[0] = 0;
1213                                 self.beam_muzzlelight[1] = 1;
1214                                 self.beam_muzzlelight[2] = 1;
1215                                 self.beam_muzzlelight[3] = 1;
1216                                 self.beam_image = "particles/lgbeam";
1217                                 setmodel(flash, "models/flash.md3");
1218                                 flash.alpha = self.beam_alpha;
1219                                 flash.colormod = self.beam_color;
1220                                 flash.scale = 0.5;
1221                                 break;
1222                         }
1223                         case ARC_BT_HIT:
1224                         {
1225                                 self.beam_color = '1 0 1';
1226                                 self.beam_alpha = 0.5;
1227                                 self.beam_thickness = 8;
1228                                 self.beam_traileffect = FALSE;
1229                                 self.beam_hiteffect = particleeffectnum("electro_lightning"); 
1230                                 self.beam_hitlight[0] = 20;
1231                                 self.beam_hitlight[1] = 1;
1232                                 self.beam_hitlight[2] = 0;
1233                                 self.beam_hitlight[3] = 0;
1234                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1235                                 self.beam_muzzlelight[0] = 50;
1236                                 self.beam_muzzlelight[1] = 1;
1237                                 self.beam_muzzlelight[2] = 0;
1238                                 self.beam_muzzlelight[3] = 0;
1239                                 self.beam_image = "particles/lgbeam";
1240                                 setmodel(flash, "models/flash.md3");
1241                                 flash.alpha = self.beam_alpha;
1242                                 flash.colormod = self.beam_color;
1243                                 flash.scale = 0.5;
1244                                 break;
1245                         }
1246                         case ARC_BT_BURST_MISS:
1247                         {
1248                                 self.beam_color = '-1 -1 1';
1249                                 self.beam_alpha = 0.5;
1250                                 self.beam_thickness = 14;
1251                                 self.beam_traileffect = FALSE;
1252                                 self.beam_hiteffect = particleeffectnum("electro_lightning"); 
1253                                 self.beam_hitlight[0] = 0;
1254                                 self.beam_hitlight[1] = 1;
1255                                 self.beam_hitlight[2] = 1;
1256                                 self.beam_hitlight[3] = 1;
1257                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1258                                 self.beam_muzzlelight[0] = 0;
1259                                 self.beam_muzzlelight[1] = 1;
1260                                 self.beam_muzzlelight[2] = 1;
1261                                 self.beam_muzzlelight[3] = 1;
1262                                 self.beam_image = "particles/lgbeam";
1263                                 setmodel(flash, "models/flash.md3");
1264                                 flash.alpha = self.beam_alpha;
1265                                 flash.colormod = self.beam_color;
1266                                 flash.scale = 0.5;
1267                                 break;
1268                         }
1269                         case ARC_BT_BURST_WALL:
1270                         {
1271                                 self.beam_color = '0.5 0.5 1';
1272                                 self.beam_alpha = 0.5;
1273                                 self.beam_thickness = 14;
1274                                 self.beam_traileffect = FALSE;
1275                                 self.beam_hiteffect = particleeffectnum("electro_lightning"); 
1276                                 self.beam_hitlight[0] = 0;
1277                                 self.beam_hitlight[1] = 1;
1278                                 self.beam_hitlight[2] = 1;
1279                                 self.beam_hitlight[3] = 1;
1280                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1281                                 self.beam_muzzlelight[0] = 0;
1282                                 self.beam_muzzlelight[1] = 1;
1283                                 self.beam_muzzlelight[2] = 1;
1284                                 self.beam_muzzlelight[3] = 1;
1285                                 self.beam_image = "particles/lgbeam";
1286                                 setmodel(flash, "models/flash.md3");
1287                                 flash.alpha = self.beam_alpha;
1288                                 flash.colormod = self.beam_color;
1289                                 flash.scale = 0.5;
1290                                 break;
1291                         }
1292                         case ARC_BT_BURST_HEAL:
1293                         {
1294                                 self.beam_color = '0 1 0';
1295                                 self.beam_alpha = 0.5;
1296                                 self.beam_thickness = 14;
1297                                 self.beam_traileffect = FALSE;
1298                                 self.beam_hiteffect = particleeffectnum("electro_lightning"); 
1299                                 self.beam_hitlight[0] = 0;
1300                                 self.beam_hitlight[1] = 1;
1301                                 self.beam_hitlight[2] = 1;
1302                                 self.beam_hitlight[3] = 1;
1303                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1304                                 self.beam_muzzlelight[0] = 0;
1305                                 self.beam_muzzlelight[1] = 1;
1306                                 self.beam_muzzlelight[2] = 1;
1307                                 self.beam_muzzlelight[3] = 1;
1308                                 self.beam_image = "particles/lgbeam";
1309                                 setmodel(flash, "models/flash.md3");
1310                                 flash.alpha = self.beam_alpha;
1311                                 flash.colormod = self.beam_color;
1312                                 flash.scale = 0.5;
1313                                 break;
1314                         }
1315                         case ARC_BT_BURST_HIT:
1316                         {
1317                                 self.beam_color = '1 0 1';
1318                                 self.beam_alpha = 0.5;
1319                                 self.beam_thickness = 14;
1320                                 self.beam_traileffect = FALSE;
1321                                 self.beam_hiteffect = particleeffectnum("electro_lightning"); 
1322                                 self.beam_hitlight[0] = 0;
1323                                 self.beam_hitlight[1] = 1;
1324                                 self.beam_hitlight[2] = 1;
1325                                 self.beam_hitlight[3] = 1;
1326                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1327                                 self.beam_muzzlelight[0] = 0;
1328                                 self.beam_muzzlelight[1] = 1;
1329                                 self.beam_muzzlelight[2] = 1;
1330                                 self.beam_muzzlelight[3] = 1;
1331                                 self.beam_image = "particles/lgbeam";
1332                                 setmodel(flash, "models/flash.md3");
1333                                 flash.alpha = self.beam_alpha;
1334                                 flash.colormod = self.beam_color;
1335                                 flash.scale = 0.5;
1336                                 break;
1337                         }
1338
1339                         // shouldn't be possible, but lets make it colorful if it does :D
1340                         default:
1341                         {
1342                                 self.beam_color = randomvec();
1343                                 self.beam_alpha = 1;
1344                                 self.beam_thickness = 8;
1345                                 self.beam_traileffect = FALSE;
1346                                 self.beam_hiteffect = FALSE; 
1347                                 self.beam_hitlight[0] = 0;
1348                                 self.beam_hitlight[1] = 1;
1349                                 self.beam_hitlight[2] = 1;
1350                                 self.beam_hitlight[3] = 1;
1351                                 self.beam_muzzleeffect = FALSE; //particleeffectnum("nex_muzzleflash");
1352                                 self.beam_muzzlelight[0] = 0;
1353                                 self.beam_muzzlelight[1] = 1;
1354                                 self.beam_muzzlelight[2] = 1;
1355                                 self.beam_muzzlelight[3] = 1;
1356                                 self.beam_image = "particles/lgbeam";
1357                                 setmodel(flash, "models/flash.md3");
1358                                 flash.alpha = self.beam_alpha;
1359                                 flash.colormod = self.beam_color;
1360                                 flash.scale = 0.5;
1361                                 break;
1362                         }
1363                 }
1364         }
1365
1366         if(!self.beam_usevieworigin)
1367         {
1368                 InterpolateOrigin_Note();
1369         }
1370 }
1371
1372 float W_Arc(float req)
1373 {
1374         switch(req)
1375         {
1376                 case WR_IMPACTEFFECT:
1377                 {
1378                         // todo
1379                         return TRUE;
1380                 }
1381                 case WR_INIT:
1382                 {
1383                         precache_sound("weapons/lgbeam_fly.wav");
1384                         return TRUE;
1385                 }
1386                 case WR_ZOOMRETICLE:
1387                 {
1388                         // no weapon specific image for this weapon
1389                         return FALSE;
1390                 }
1391         }
1392         return FALSE;
1393 }
1394 #endif
1395 #endif