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