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