]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_laser.qc
- experimental CSQC change: get rid of old ONS team radar code, support ons_showmap...
[divverent/nexuiz.git] / data / qcsrc / server / w_laser.qc
1 void(float imp) W_SwitchWeapon;
2
3 void W_Laser_Touch (void)
4 {
5         vector  dir;
6         vector org2;
7         vector normal;
8
9         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
10         {
11                 remove(self);
12                 return;
13         }
14
15         if (other == self.owner)
16                 return;
17
18         normal = trace_plane_normal;
19         dir = normalize (self.owner.origin - self.origin);
20         org2 = findbetterlocation (self.origin, 8);
21
22         pointparticles(particleeffectnum("laser_impact"), org2, normal * 1000, 1);
23
24
25         self.event_damage = SUB_Null;
26         if (self.dmg)
27                 RadiusDamage (self, self.owner, cvar("g_balance_laser_secondary_damage"), cvar("g_balance_laser_secondary_edgedamage"), cvar("g_balance_laser_secondary_radius"), world, cvar("g_balance_laser_secondary_force"), self.projectiledeathtype, other);
28         else
29                 RadiusDamage (self, self.owner, cvar("g_balance_laser_primary_damage"), cvar("g_balance_laser_primary_edgedamage"), cvar("g_balance_laser_primary_radius"), world, cvar("g_balance_laser_primary_force"), self.projectiledeathtype, other);
30         sound (self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
31
32         remove (self);
33 }
34
35 void W_Laser_Attack (float issecondary)
36 {
37         local entity missile;
38
39         W_SetupShot (self, '25 8 -8', FALSE, 3, "weapons/lasergun_fire.wav");
40         pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
41
42         missile = spawn ();
43         missile.owner = self;
44         missile.classname = "laserbolt";
45         missile.dmg = issecondary;
46         missile.bot_dodge = TRUE;
47         if (issecondary)
48                 missile.bot_dodgerating = cvar("g_balance_laser_secondary_damage");
49         else
50                 missile.bot_dodgerating = cvar("g_balance_laser_primary_damage");
51
52         missile.movetype = MOVETYPE_FLY;
53         missile.solid = SOLID_BBOX;
54         missile.projectiledeathtype = WEP_LASER;
55         if(issecondary)
56                 missile.projectiledeathtype |= HITTYPE_SECONDARY;
57
58         setmodel (missile, "models/laser.mdl"); // precision set below
59         setsize (missile, '0 0 0', '0 0 0');
60         setorigin (missile, w_shotorg);
61
62         if (issecondary)
63                 missile.velocity = w_shotdir * cvar("g_balance_laser_secondary_speed");
64         else
65                 missile.velocity = w_shotdir * cvar("g_balance_laser_primary_speed");
66         W_SetupProjectileVelocity(missile);
67         missile.angles = vectoangles (missile.velocity);
68         //missile.glow_color = 250; // 244, 250
69         //missile.glow_size = 120;
70         missile.touch = W_Laser_Touch;
71         missile.think = SUB_Remove;
72         if (issecondary)
73                 missile.nextthink = time + cvar("g_balance_laser_secondary_lifetime");
74         else
75                 missile.nextthink = time + cvar("g_balance_laser_primary_lifetime");
76
77         missile.effects = EF_LOWPRECISION;
78         missile.flags = FL_PROJECTILE;
79 }
80
81 float w_laser(float req)
82 {
83         local float r1;
84         local float r2;
85         if (req == WR_AIM)
86         {
87                 if(cvar("g_balance_laser_secondary"))
88                 {
89                         r1 = cvar("g_balance_laser_primary_damage");
90                         r2 = cvar("g_balance_laser_secondary_damage");
91                         if (random() * (r2 + r1) > r1)
92                                 self.BUTTON_ATCK2 = bot_aim(cvar("g_balance_laser_secondary_speed"), 0, cvar("g_balance_laser_secondary_lifetime"), FALSE);
93                         else
94                                 self.BUTTON_ATCK = bot_aim(cvar("g_balance_laser_primary_speed"), 0, cvar("g_balance_laser_primary_lifetime"), FALSE);
95                 }
96                 else
97                         self.BUTTON_ATCK = bot_aim(cvar("g_balance_laser_primary_speed"), 0, cvar("g_balance_laser_primary_lifetime"), FALSE);
98         }
99         else if (req == WR_THINK)
100         {
101                 if (self.BUTTON_ATCK)
102                 if (weapon_prepareattack(0, cvar("g_balance_laser_primary_refire")))
103                 {
104                         W_Laser_Attack(FALSE);
105                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_laser_primary_animtime"), w_ready);
106                 }
107                 if (self.BUTTON_ATCK2)
108                 {
109                         if(cvar("g_balance_laser_secondary"))
110                         {
111                                 if (weapon_prepareattack(0, cvar("g_balance_laser_secondary_refire")))
112                                 {
113                                         W_Laser_Attack(TRUE);
114                                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_laser_secondary_animtime"), w_ready);
115                                 }
116                         }
117                         else
118                         {
119                                 if (self.BUTTON_ATCK2)
120                                 if (client_hasweapon(self, self.cnt, TRUE, FALSE))
121                                         W_SwitchWeapon (self.cnt);
122                         }
123                 }
124         }
125         else if (req == WR_PRECACHE)
126         {
127                 precache_model ("models/laser.mdl");
128                 precache_model ("models/weapons/v_laser.md3");
129                 precache_model ("models/weapons/w_laser.zym");
130                 precache_sound ("weapons/lasergun_fire.wav");
131                 precache_sound ("weapons/laserimpact.wav");
132         }
133         else if (req == WR_SETUP)
134                 weapon_setup(WEP_LASER);
135         else if (req == WR_CHECKAMMO1)
136                 return TRUE;
137         else if (req == WR_CHECKAMMO2)
138                 return TRUE;
139         else if (req == WR_SUICIDEMESSAGE)
140                 w_deathtypestring = "lasered himself to hell";
141         else if (req == WR_KILLMESSAGE)
142         {
143                 w_deathtypestring = "was lasered to death by"; // unchecked: SPLASH
144         }
145         return TRUE;
146 };