]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/w_crylink.qc
Merge remote branch 'refs/remotes/origin/terencehill/numbered_bots'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_crylink.qc
1 #ifdef REGISTER_WEAPON
2 REGISTER_WEAPON(CRYLINK, w_crylink, IT_CELLS, 6, WEP_FLAG_NORMAL | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "crylink", "crylink", "Crylink");
3 #else
4 .float gravity;
5
6 .entity realowner;
7
8 // NO bounce protection, as bounces are limited!
9 void W_Crylink_Touch (void)
10 {
11         float finalhit;
12         float f;
13         PROJECTILE_TOUCH;
14         finalhit = ((self.cnt <= 0) || (other.takedamage != DAMAGE_NO));
15         if(finalhit)
16                 f = 1;
17         else
18                 f = cvar("g_balance_crylink_primary_bouncedamagefactor");
19         if(self.alpha)
20                 f *= self.alpha;
21         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);
22         if (finalhit)
23         {
24                 remove (self);
25                 return;
26         }
27         self.cnt = self.cnt - 1;
28         self.angles = vectoangles(self.velocity);
29         self.owner = world;
30         self.projectiledeathtype |= HITTYPE_BOUNCE;
31         // commented out as it causes a little hitch...
32         //if(proj.cnt == 0)
33         //      CSQCProjectile(proj, TRUE, PROJECTILE_CRYLINK, TRUE);
34 }
35
36 void W_Crylink_Touch2 (void)
37 {
38         float finalhit;
39         float f;
40         PROJECTILE_TOUCH;
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         // commented out as it causes a little hitch...
59         //if(proj.cnt == 0)
60         //      CSQCProjectile(proj, TRUE, PROJECTILE_CRYLINK, TRUE);
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, FALSE, 2, "weapons/crylink_fire.wav", (cvar("g_balance_crylink_primary_damage")*cvar("g_balance_crylink_primary_shots")));
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                 PROJECTILE_MAKETRIGGER(proj);
90                 proj.projectiledeathtype = WEP_CRYLINK;
91                 //proj.gravity = 0.001;
92
93                 setorigin (proj, w_shotorg);
94                 setsize(proj, '0 0 0', '0 0 0');
95
96
97                 s = '0 0 0';
98                 if (counter == 0)
99                         s = '0 0 0';
100                 else
101                 {
102                         makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
103                         s_y = v_forward_x;
104                         s_z = v_forward_y;
105                 }
106                 s = s * cvar("g_balance_crylink_primary_spread") * g_weaponspreadfactor;
107                 W_SetupProjectileVelocityEx(proj, w_shotdir + right * s_y + up * s_z, v_up, cvar("g_balance_crylink_primary_speed"), 0, 0, 0);
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.flags = FL_PROJECTILE;
123
124                 CSQCProjectile(proj, TRUE, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), TRUE);
125
126                 counter = counter + 1;
127         }
128 }
129
130 void W_Crylink_Attack2 (void)
131 {
132         local float counter, shots;
133         local entity proj;
134
135         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
136                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_secondary_ammo");
137
138         W_SetupShot (self, FALSE, 2, "weapons/crylink_fire2.wav", (cvar("g_balance_crylink_secondary_damage")*cvar("g_balance_crylink_secondary_shots")));
139
140         shots = cvar("g_balance_crylink_secondary_shots");
141         pointparticles(particleeffectnum("crylink_muzzleflash"), w_shotorg, w_shotdir * 1000, shots);
142         while (counter < shots)
143         {
144                 proj = spawn ();
145                 proj.realowner = proj.owner = self;
146                 proj.classname = "spike";
147                 proj.bot_dodge = TRUE;
148                 proj.bot_dodgerating = cvar("g_balance_crylink_secondary_damage");
149
150                 proj.movetype = MOVETYPE_BOUNCEMISSILE;
151                 PROJECTILE_MAKETRIGGER(proj);
152                 proj.projectiledeathtype = WEP_CRYLINK | HITTYPE_SECONDARY;
153                 //proj.gravity = 0.001;
154
155                 setorigin (proj, w_shotorg);
156                 setsize(proj, '0 0 0', '0 0 0');
157
158                 W_SetupProjectileVelocityEx(proj, (w_shotdir + (((counter + 0.5) / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread") * g_weaponspreadfactor), v_up, cvar("g_balance_crylink_secondary_speed"), 0, 0, 0);
159                 proj.touch = W_Crylink_Touch2;
160                 if(counter == (shots - 1) / 2)
161                         SUB_SetFade(proj, time + cvar("g_balance_crylink_secondary_middle_lifetime"), cvar("g_balance_crylink_secondary_middle_fadetime"));
162                 else
163                         SUB_SetFade(proj, time + cvar("g_balance_crylink_secondary_line_lifetime"), cvar("g_balance_crylink_secondary_line_fadetime"));
164                 proj.cnt = cvar("g_balance_crylink_secondary_bounces");
165                 //proj.scale = 1 + 1 * proj.cnt;
166
167                 proj.angles = vectoangles (proj.velocity);
168
169                 //proj.glow_size = 20;
170
171                 proj.flags = FL_PROJECTILE;
172
173                 CSQCProjectile(proj, TRUE, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), TRUE);
174
175                 counter = counter + 1;
176         }
177 }
178
179 void spawnfunc_weapon_crylink (void)
180 {
181         weapon_defaultspawnfunc(WEP_CRYLINK);
182 }
183
184 float w_crylink(float req)
185 {
186         if (req == WR_AIM)
187         {
188                 if (random() > 0.15)
189                         self.BUTTON_ATCK = bot_aim(cvar("g_balance_crylink_primary_speed"), 0, cvar("g_balance_crylink_primary_middle_lifetime"), FALSE);
190                 else
191                         self.BUTTON_ATCK2 = bot_aim(cvar("g_balance_crylink_secondary_speed"), 0, cvar("g_balance_crylink_secondary_middle_lifetime"), FALSE);
192         }
193         else if (req == WR_THINK)
194         {
195                 if (self.BUTTON_ATCK)
196                 if (weapon_prepareattack(0, cvar("g_balance_crylink_primary_refire")))
197                 {
198                         W_Crylink_Attack();
199                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), w_ready);
200                 }
201                 if (self.BUTTON_ATCK2 && cvar("g_balance_crylink_secondary"))
202                 if (weapon_prepareattack(1, cvar("g_balance_crylink_secondary_refire")))
203                 {
204                         W_Crylink_Attack2();
205                         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_crylink_secondary_animtime"), w_ready);
206                 }
207         }
208         else if (req == WR_PRECACHE)
209         {
210                 precache_model ("models/weapons/g_crylink.md3");
211                 precache_model ("models/weapons/v_crylink.md3");
212                 precache_model ("models/weapons/h_crylink.iqm");
213                 precache_sound ("weapons/crylink_fire.wav");
214                 precache_sound ("weapons/crylink_fire2.wav");
215         }
216         else if (req == WR_SETUP)
217                 weapon_setup(WEP_CRYLINK);
218         else if (req == WR_CHECKAMMO1)
219                 return self.ammo_cells >= cvar("g_balance_crylink_primary_ammo");
220         else if (req == WR_CHECKAMMO2)
221                 return self.ammo_cells >= cvar("g_balance_crylink_secondary_ammo");
222         else if (req == WR_SUICIDEMESSAGE)
223         {
224                 w_deathtypestring = "succeeded at self-destructing themself with the Crylink";
225         }
226         else if (req == WR_KILLMESSAGE)
227         {
228                 if(w_deathtype & HITTYPE_BOUNCE)
229                         w_deathtypestring = "could not hide from #'s Crylink"; // unchecked: SPLASH (SECONDARY can't be)
230                 else if(w_deathtype & HITTYPE_SPLASH)
231                         w_deathtypestring = "was too close to #'s Crylink"; // unchecked: SECONDARY
232                 else
233                         w_deathtypestring = "took a close look at #'s Crylink"; // unchecked: SECONDARY
234         }
235         return TRUE;
236 };
237 #endif