]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_crylink.qc
improve waypointsprites for speccers
[divverent/nexuiz.git] / data / qcsrc / server / w_crylink.qc
1 .float gravity;
2
3 .entity realowner;
4
5 // NO bounce protection, as bounces are limited!
6 void W_Crylink_Touch (void)
7 {
8         float finalhit;
9         float f;
10         PROJECTILE_TOUCH;
11         finalhit = ((self.cnt <= 0) || (other.takedamage != DAMAGE_NO));
12         if(finalhit)
13                 f = 1;
14         else
15                 f = cvar("g_balance_crylink_primary_bouncedamagefactor");
16         if(self.alpha)
17                 f *= self.alpha;
18         RadiusDamage (self, self.realowner, cvar("g_balance_crylink_primary_damage") * f, cvar("g_balance_crylink_primary_edgedamage") * f, cvar("g_balance_crylink_primary_radius"), world, cvar("g_balance_crylink_primary_force") * f, self.projectiledeathtype, other);
19         if (finalhit)
20         {
21                 remove (self);
22                 return;
23         }
24         self.cnt = self.cnt - 1;
25         self.angles = vectoangles(self.velocity);
26         self.owner = world;
27         self.projectiledeathtype |= HITTYPE_BOUNCE;
28         // commented out as it causes a little hitch...
29         //if(proj.cnt == 0)
30         //      CSQCProjectile(proj, TRUE, PROJECTILE_CRYLINK, TRUE);
31 }
32
33 void W_Crylink_Touch2 (void)
34 {
35         float finalhit;
36         float f;
37         PROJECTILE_TOUCH;
38         finalhit = ((self.cnt <= 0) || (other.takedamage != DAMAGE_NO));
39         if(finalhit)
40                 f = 1;
41         else
42                 f = cvar("g_balance_crylink_secondary_bouncedamagefactor");
43         if(self.alpha)
44                 f *= self.alpha;
45         RadiusDamage (self, self.realowner, cvar("g_balance_crylink_secondary_damage") * f, cvar("g_balance_crylink_secondary_edgedamage") * f, cvar("g_balance_crylink_secondary_radius"), world, cvar("g_balance_crylink_secondary_force") * f, self.projectiledeathtype, other);
46         if (finalhit)
47         {
48                 remove (self);
49                 return;
50         }
51         self.cnt = self.cnt - 1;
52         self.angles = vectoangles(self.velocity);
53         self.owner = world;
54         self.projectiledeathtype |= HITTYPE_BOUNCE;
55         // commented out as it causes a little hitch...
56         //if(proj.cnt == 0)
57         //      CSQCProjectile(proj, TRUE, PROJECTILE_CRYLINK, TRUE);
58 }
59
60 void W_Crylink_Attack (void)
61 {
62         local float counter, shots;
63         local entity proj;
64         local vector s;
65         vector forward, right, up;
66
67         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
68                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
69
70         W_SetupShot (self, FALSE, 2, "weapons/crylink_fire.wav");
71         forward = v_forward;
72         right = v_right;
73         up = v_up;
74
75         shots = cvar("g_balance_crylink_primary_shots");
76         pointparticles(particleeffectnum("crylink_muzzleflash"), w_shotorg, w_shotdir * 1000, shots);
77         while (counter < shots)
78         {
79                 proj = spawn ();
80                 proj.realowner = proj.owner = self;
81                 proj.classname = "spike";
82                 proj.bot_dodge = TRUE;
83                 proj.bot_dodgerating = cvar("g_balance_crylink_primary_damage");
84
85                 proj.movetype = MOVETYPE_BOUNCEMISSILE;
86                 proj.solid = SOLID_BBOX;
87                 proj.projectiledeathtype = WEP_CRYLINK;
88                 //proj.gravity = 0.001;
89
90                 setorigin (proj, w_shotorg);
91
92
93                 s = '0 0 0';
94                 if (counter == 0)
95                         s = '0 0 0';
96                 else
97                 {
98                         makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
99                         s_y = v_forward_x;
100                         s_z = v_forward_y;
101                 }
102                 s = s * cvar("g_balance_crylink_primary_spread");
103                 proj.velocity = (w_shotdir + right * s_y + up * s_z) * cvar("g_balance_crylink_primary_speed");
104 //              proj.velocity = (w_shotdir + randomvec() * cvar("g_balance_crylink_primary_spread")) * cvar("g_balance_crylink_primary_speed");
105                 W_SetupProjectileVelocity(proj);
106                 proj.touch = W_Crylink_Touch;
107                 if(counter == 0)
108                         SUB_SetFade(proj, time + cvar("g_balance_crylink_primary_middle_lifetime"), cvar("g_balance_crylink_primary_middle_fadetime"));
109                 else if(counter <= 3)
110                         SUB_SetFade(proj, time + cvar("g_balance_crylink_primary_star_lifetime"), cvar("g_balance_crylink_primary_star_fadetime"));
111                 else
112                         SUB_SetFade(proj, time + cvar("g_balance_crylink_primary_other_lifetime"), cvar("g_balance_crylink_primary_other_fadetime"));
113                 proj.cnt = cvar("g_balance_crylink_primary_bounces");
114                 //proj.scale = 1 + 1 * proj.cnt;
115
116                 proj.angles = vectoangles (proj.velocity);
117
118                 //proj.glow_size = 20;
119
120                 proj.flags = FL_PROJECTILE;
121
122                 CSQCProjectile(proj, TRUE, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), TRUE);
123
124                 counter = counter + 1;
125         }
126 }
127
128 void W_Crylink_Attack2 (void)
129 {
130         local float counter, shots;
131         local entity proj;
132
133         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
134                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_secondary_ammo");
135
136         W_SetupShot (self, FALSE, 2, "weapons/crylink_fire2.wav");
137
138         shots = cvar("g_balance_crylink_secondary_shots");
139         pointparticles(particleeffectnum("crylink_muzzleflash"), w_shotorg, w_shotdir * 1000, shots);
140         while (counter < shots)
141         {
142                 proj = spawn ();
143                 proj.realowner = proj.owner = self;
144                 proj.classname = "spike";
145                 proj.bot_dodge = TRUE;
146                 proj.bot_dodgerating = cvar("g_balance_crylink_secondary_damage");
147
148                 proj.movetype = MOVETYPE_BOUNCEMISSILE;
149                 proj.solid = SOLID_BBOX;
150                 proj.projectiledeathtype = WEP_CRYLINK | HITTYPE_SECONDARY;
151                 //proj.gravity = 0.001;
152
153                 setorigin (proj, w_shotorg);
154
155                 proj.velocity = (w_shotdir + (((counter + 0.5) / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread")) * cvar("g_balance_crylink_secondary_speed");
156                 W_SetupProjectileVelocity(proj);
157                 proj.touch = W_Crylink_Touch2;
158                 if(counter == (shots - 1) / 2)
159                         SUB_SetFade(proj, time + cvar("g_balance_crylink_secondary_middle_lifetime"), cvar("g_balance_crylink_secondary_middle_fadetime"));
160                 else
161                         SUB_SetFade(proj, time + cvar("g_balance_crylink_secondary_line_lifetime"), cvar("g_balance_crylink_secondary_line_fadetime"));
162                 proj.cnt = cvar("g_balance_crylink_secondary_bounces");
163                 //proj.scale = 1 + 1 * proj.cnt;
164
165                 proj.angles = vectoangles (proj.velocity);
166
167                 //proj.glow_size = 20;
168
169                 proj.flags = FL_PROJECTILE;
170
171                 CSQCProjectile(proj, TRUE, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), TRUE);
172
173                 counter = counter + 1;
174         }
175 }
176
177
178 /*
179 // experimental lightning gun
180 void W_Crylink_Attack3 (void)
181 {
182         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
183                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
184         W_SetupShot (self, TRUE, 0, "weapons/crylink_fire.wav");
185
186         traceline_antilag(self, w_shotorg, w_shotorg + w_shotdir * 1000, FALSE, self, self.ping * 0.001);
187
188         pointparticles(particleeffectnum("lightning_muzzleflash", w_shotorg, w_shotdir * 1000, 1);
189         pointparticles(particleeffectnum("lightning_impact", trace_endpos, trace_plane_normal * 1000, 1);
190         trailparticles(world, particleeffectnum("lightning_beam", w_shotorg, trace_endpos);
191
192         if (trace_fraction < 1)
193                 Damage(trace_ent, self, self, cvar("g_balance_crylink_primary_damage"), WEP_CRYLINK | HITTYPE_SECONDARY, trace_endpos, '0 0 0');
194 }
195 */
196
197 void spawnfunc_weapon_crylink (void)
198 {
199         weapon_defaultspawnfunc(WEP_CRYLINK);
200 }
201
202 float w_crylink(float req)
203 {
204         if (req == WR_AIM)
205         {
206                 if (random() > 0.15)
207                         self.BUTTON_ATCK = bot_aim(cvar("g_balance_crylink_primary_speed"), 0, cvar("g_balance_crylink_primary_middle_lifetime"), FALSE);
208                 else
209                         self.BUTTON_ATCK2 = bot_aim(cvar("g_balance_crylink_secondary_speed"), 0, cvar("g_balance_crylink_secondary_middle_lifetime"), FALSE);
210         }
211         else if (req == WR_THINK)
212         {
213                 if (self.BUTTON_ATCK)
214                 if (weapon_prepareattack(0, cvar("g_balance_crylink_primary_refire")))
215                 {
216                         W_Crylink_Attack();
217                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), w_ready);
218                 }
219                 if (self.BUTTON_ATCK2)
220                 if (weapon_prepareattack(1, cvar("g_balance_crylink_secondary_refire")))
221                 {
222                         W_Crylink_Attack2();
223                         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_crylink_secondary_animtime"), w_ready);
224                 }
225         }
226         else if (req == WR_PRECACHE)
227         {
228                 precache_model ("models/weapons/g_crylink.md3");
229                 precache_model ("models/weapons/v_crylink.md3");
230                 precache_model ("models/weapons/h_crylink.dpm");
231                 precache_sound ("weapons/crylink_fire.wav");
232                 precache_sound ("weapons/crylink_fire2.wav");
233         }
234         else if (req == WR_SETUP)
235                 weapon_setup(WEP_CRYLINK);
236         else if (req == WR_CHECKAMMO1)
237                 return self.ammo_cells >= cvar("g_balance_crylink_primary_ammo");
238         else if (req == WR_CHECKAMMO2)
239                 return self.ammo_cells >= cvar("g_balance_crylink_secondary_ammo");
240         else if (req == WR_SUICIDEMESSAGE)
241         {
242                 w_deathtypestring = "succeeded at self-destructing himself with the Crylink";
243         }
244         else if (req == WR_KILLMESSAGE)
245         {
246                 if(w_deathtype & HITTYPE_BOUNCE)
247                         w_deathtypestring = "could not hide from #'s Crylink"; // unchecked: SPLASH (SECONDARY can't be)
248                 else if(w_deathtype & HITTYPE_SPLASH)
249                         w_deathtypestring = "was too close to #'s Crylink"; // unchecked: SECONDARY
250                 else
251                         w_deathtypestring = "took a close look at #'s Crylink"; // unchecked: SECONDARY
252         }
253         return TRUE;
254 };