]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamec/w_crylink.c
Made more bot skills work (now the range from 0 to 1 should); added waypoints
[divverent/nexuiz.git] / data / qcsrc / server / gamec / w_crylink.c
1 void() crylink_ready_01;
2 void() crylink_fire1_01;
3 void() crylink_fire2_01;
4 void() crylink_deselect_01;
5 void() crylink_select_01;
6
7 .float gravity;
8 const vector proj_color = '1 1 1';
9
10 float() crylink_check =
11 {
12         if (self.ammo_cells >= cvar("g_balance_crylink_primary_ammo"))
13                 return TRUE;
14         return FALSE;
15 };
16
17 float() crylink_check2 =
18 {
19         if (self.ammo_cells >= cvar("g_balance_crylink_secondary_ammo"))
20                 return TRUE;
21         return FALSE;
22 };
23
24 void(float req) w_crylink =
25 {
26         if (req == WR_IDLE)
27                 crylink_ready_01();
28         else if (req == WR_AIM)
29                 self.button0 = bot_aim(cvar("g_balance_crylink_primary_speed"), 0, cvar("g_balance_crylink_primary_lifetime"), FALSE);
30         else if (req == WR_FIRE1)
31                 weapon_prepareattack(crylink_check, crylink_check, crylink_fire1_01, cvar("g_balance_crylink_primary_refire"));
32         else if (req == WR_FIRE2)
33                 weapon_prepareattack(crylink_check2, crylink_check2, crylink_fire2_01, cvar("g_balance_crylink_secondary_refire"));
34         else if (req == WR_RAISE)
35                 crylink_select_01();
36         else if (req == WR_UPDATECOUNTS)
37                 self.currentammo = self.ammo_cells;
38         else if (req == WR_DROP)
39                 crylink_deselect_01();
40         else if (req == WR_SETUP)
41                 weapon_setup(WEP_CRYLINK, "w_crylink.zym", IT_CELLS);
42         else if (req == WR_CHECKAMMO)
43                 weapon_hasammo = crylink_check() + crylink_check2();
44 };
45
46 .entity realowner;
47 void W_Crylink_Touch (void)
48 {
49         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
50         {
51                 remove(self);
52                 return;
53         }
54         RadiusDamage (self, self.realowner, cvar("g_balance_crylink_primary_damage"), cvar("g_balance_crylink_primary_edgedamage"), cvar("g_balance_crylink_primary_radius"), world, cvar("g_balance_crylink_primary_force"), IT_CRYLINK);
55         te_gunshotquad(self.origin);
56         remove (self);
57         /*
58         //te_smallflash(self.origin);
59         if (other.takedamage == DAMAGE_AIM)
60         {
61                 remove (self);
62                 return;
63         }
64         self.owner = world;
65         self.touch = SUB_Null;
66         setmodel (self, "models/plasma.mdl");
67         setsize (self, '0 0 0', '0 0 0');
68         self.gravity = 0;
69         self.glow_size = 0;
70         self.glow_color = 0;
71         self.think = SUB_Remove;
72         self.movetype = MOVETYPE_NONE;
73         self.effects = EF_FULLBRIGHT | EF_LOWPRECISION;
74         SUB_SetFade(self, time, 1);
75         //remove (self);
76         */
77 }
78
79 void W_Crylink_Touch2 (void)
80 {
81         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
82         {
83                 remove(self);
84                 return;
85         }
86         RadiusDamage (self, self.realowner, cvar("g_balance_crylink_secondary_damage"), cvar("g_balance_crylink_secondary_edgedamage"), cvar("g_balance_crylink_secondary_radius"), world, cvar("g_balance_crylink_secondary_force"), IT_CRYLINK);
87         te_gunshotquad(self.origin);
88         remove (self);
89         /*
90         //te_smallflash(self.origin);
91         if (other.takedamage == DAMAGE_AIM)
92         {
93                 remove (self);
94                 return;
95         }
96         self.owner = world;
97         self.touch = SUB_Null;
98         setmodel (self, "models/plasma.mdl");
99         setsize (self, '0 0 0', '0 0 0');
100         self.gravity = 0;
101         self.glow_size = 0;
102         self.glow_color = 0;
103         self.think = SUB_Remove;
104         self.movetype = MOVETYPE_NONE;
105         self.effects = EF_FULLBRIGHT | EF_LOWPRECISION;
106         SUB_SetFade(self, time, 1);
107         //remove (self);
108         */
109 }
110
111 void W_Crylink_Attack (void)
112 {
113         local float counter, shots;
114         local vector org;
115         local entity proj;
116
117         local vector trueaim;
118         trueaim = W_TrueAim();
119
120         sound (self, CHAN_WEAPON, "weapons/crylink_fire.ogg", 1, ATTN_NORM);
121         if (self.items & IT_STRENGTH)
122                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
123
124         if (cvar("g_use_ammunition"))
125                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
126         self.punchangle_x = -2;
127
128         org = W_MuzzleOrigin (self, '24 7 -8');
129         te_smallflash(org);
130
131         shots = cvar("g_balance_crylink_primary_shots");
132         while (counter < shots)
133         {
134                 proj = spawn ();
135                 proj.realowner = proj.owner = self;
136                 proj.classname = "spike";
137                 proj.bot_dodge = TRUE;
138                 proj.bot_dodgerating = cvar("g_balance_crylink_primary_damage");
139
140                 proj.movetype = MOVETYPE_BOUNCE;
141                 proj.solid = SOLID_BBOX;
142                 proj.gravity = 0.001;
143
144                 setmodel (proj, "models/plasmatrail.mdl");
145                 setsize (proj, '0 0 0', '0 0 0');
146                 setorigin (proj, org);
147
148                 proj.velocity = (normalize(trueaim - org) + randomvec() * cvar("g_balance_crylink_primary_spread")) * cvar("g_balance_crylink_primary_speed");
149                 proj.touch = W_Crylink_Touch;
150                 proj.think = SUB_Remove;
151                 proj.nextthink = time + cvar("g_balance_crylink_primary_lifetime");
152
153                 proj.angles = vectoangles (proj.velocity);
154
155                 //proj.glow_size = 20;
156
157                 proj.effects = EF_NOSHADOW | EF_FULLBRIGHT | EF_LOWPRECISION;
158                 proj.flags = FL_PROJECTILE;
159                 proj.colormod = proj_color;
160                 counter = counter + 1;
161         }
162 }
163
164 void W_Crylink_Attack2 (void)
165 {
166         local float counter, shots;
167         local vector org;
168         local entity proj;
169
170         local vector trueaim;
171         trueaim = W_TrueAim();
172
173         sound (self, CHAN_WEAPON, "weapons/crylink_fire.ogg", 1, ATTN_NORM);
174         if (self.items & IT_STRENGTH)
175                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
176
177         if (cvar("g_use_ammunition"))
178                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_secondary_ammo");
179         self.punchangle_x = -2;
180
181         org = W_MuzzleOrigin (self, '20 7 -8');
182         te_smallflash(org);
183
184         shots = cvar("g_balance_crylink_secondary_shots");
185         while (counter < shots)
186         {
187                 proj = spawn ();
188                 proj.realowner = proj.owner = self;
189                 proj.classname = "spike";
190                 proj.bot_dodge = TRUE;
191                 proj.bot_dodgerating = cvar("g_balance_crylink_secondary_damage");
192
193                 proj.movetype = MOVETYPE_BOUNCE;
194                 proj.solid = SOLID_BBOX;
195                 proj.gravity = 0.001;
196
197                 setmodel (proj, "models/plasmatrail.mdl");
198                 setsize (proj, '0 0 0', '0 0 0');
199                 setorigin (proj, org);
200
201                 proj.velocity = (normalize(trueaim - org) + ((counter / shots) * 2 - 1) * v_right * cvar("g_balance_crylink_secondary_spread")) * cvar("g_balance_crylink_secondary_speed");
202                 proj.touch = W_Crylink_Touch2;
203                 proj.think = SUB_Remove;
204                 proj.nextthink = time + cvar("g_balance_crylink_secondary_lifetime");
205
206                 proj.angles = vectoangles (proj.velocity);
207
208                 //proj.glow_size = 20;
209
210                 proj.effects = EF_NOSHADOW | EF_FULLBRIGHT | EF_LOWPRECISION;
211                 proj.flags = FL_PROJECTILE;
212                 proj.colormod = proj_color;
213                 counter = counter + 1;
214         }
215 }
216
217
218 // weapon frames
219 void()  crylink_ready_01 =      {weapon_thinkf(WFRAME_IDLE, 0.1, crylink_ready_01); self.weaponentity.state = WS_READY;};
220 void()  crylink_select_01 =     {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
221 void()  crylink_deselect_01 =   {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
222 void()  crylink_fire1_01 =
223 {
224         weapon_doattack(crylink_check, crylink_check, W_Crylink_Attack);
225         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), crylink_ready_01);
226 };
227 void()  crylink_fire2_01 =
228 {
229         weapon_doattack(crylink_check2, crylink_check2, W_Crylink_Attack2);
230         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_crylink_secondary_animtime"), crylink_ready_01);
231 };
232
233 /*
234 // experimental lightning gun
235 void W_Crylink_Attack3 (void)
236 {
237         local vector org, dir;
238
239         local vector trueaim;
240         trueaim = W_TrueAim();
241
242         sound (self, CHAN_WEAPON, "weapons/crylink_fire.ogg", 1, ATTN_NORM);
243         if (self.items & IT_STRENGTH) {
244                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
245         }
246
247         if (cvar("g_use_ammunition"))
248                 self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
249         //self.punchangle_x = -2;
250         org = self.origin + self.view_ofs + v_forward * 10 + v_right * 5 + v_up * -14;
251
252         // use traceline_hitcorpse to make sure it can hit gibs and corpses too
253         dir = normalize(trueaim - org);
254         traceline_hitcorpse(self, org, org + dir * 1000, FALSE, self);
255
256         te_smallflash(org);
257         te_plasmaburn(trace_endpos);
258         te_lightning2(self, org, trace_endpos);
259
260         if (trace_fraction < 1)
261                 Damage(trace_ent, self, self, cvar("g_balance_crylink_primary_damage"), IT_CRYLINK, trace_endpos, '0 0 0');
262 }
263 void()  crylink_fire1_01 =
264 {
265         weapon_doattack(crylink_check, crylink_check, W_Crylink_Attack3);
266         if (self.button0)
267                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), crylink_fire1_01);
268         else
269                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_crylink_primary_animtime"), crylink_ready_01);
270 };
271 */
272