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