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