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