centerprints now are managed independently per line
[divverent/nexuiz.git] / data / qcsrc / server / w_laser.qc
1
2 void W_Laser_Touch (void)
3 {
4         vector  dir;
5         vector org2;
6
7         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
8         {
9                 remove(self);
10                 return;
11         }
12
13         if (other == self.owner)
14                 return;
15
16         dir = normalize (self.owner.origin - self.origin);
17         org2 = findbetterlocation (self.origin, 8);
18
19         te_knightspike(org2);
20
21
22         self.event_damage = SUB_Null;
23         RadiusDamage (self, self.owner, cvar("g_balance_laser_damage"), cvar("g_balance_laser_edgedamage"), cvar("g_balance_laser_radius"), world, cvar("g_balance_laser_force"), IT_LASER);
24         sound (self, CHAN_BODY, "weapons/laserimpact.ogg", 1, ATTN_NORM);
25
26         remove (self);
27 }
28
29 void W_Laser_Attack (void)
30 {
31         local entity missile;
32
33         W_SetupShot (self, '15 8 -8', FALSE, 3, "weapons/lasergun_fire.ogg");
34         //te_customflash(w_shotorg, 160, 0.2, '1 0 0');
35
36         missile = spawn ();
37         missile.owner = self;
38         missile.classname = "laserbolt";
39         missile.bot_dodge = TRUE;
40         missile.bot_dodgerating = cvar("g_balance_laser_damage");
41
42         missile.movetype = MOVETYPE_FLY;
43         missile.solid = SOLID_BBOX;
44
45         setmodel (missile, "models/laser.mdl");
46         setsize (missile, '0 0 0', '0 0 0');
47         setorigin (missile, w_shotorg);
48
49         missile.velocity = w_shotdir * cvar("g_balance_laser_speed");
50         missile.angles = vectoangles (missile.velocity);
51         //missile.glow_color = 250; // 244, 250
52         //missile.glow_size = 120;
53         missile.touch = W_Laser_Touch;
54         missile.think = SUB_Remove;
55         missile.nextthink = time + cvar("g_balance_laser_lifetime");
56
57         missile.effects = EF_NOSHADOW | EF_FULLBRIGHT | EF_FULLBRIGHT | EF_LOWPRECISION;
58         missile.flags = FL_PROJECTILE;
59 }
60
61 float(float req) w_laser =
62 {
63         if (req == WR_AIM)
64                 self.button0 = bot_aim(cvar("g_balance_laser_speed"), 0, cvar("g_balance_laser_lifetime"), FALSE);
65         else if (req == WR_THINK)
66         {
67                 if (self.button0)
68                 if (weapon_prepareattack(0, cvar("g_balance_laser_refire")))
69                 {
70                         W_Laser_Attack();
71                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_laser_animtime"), w_ready);
72                 }
73                 if (self.button3)
74                 if (client_hasweapon(self, self.cnt, TRUE, TRUE))
75                         self.switchweapon = self.cnt;
76         }
77         else if (req == WR_SETUP)
78                 weapon_setup(WEP_LASER, "laser", 0);
79         else if (req == WR_CHECKAMMO1)
80                 return TRUE;
81         else if (req == WR_CHECKAMMO2)
82                 return TRUE;
83         return TRUE;
84 };