]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/vehicles/vehicle/spiderbot.qc
Merge branch 'DefaultUser/gametype_votescreen' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / vehicle / spiderbot.qc
1 #include "spiderbot.qh"
2
3 #ifdef IMPLEMENTATION
4
5 const int SBRM_FIRST = 1;
6 const int SBRM_VOLLY = 1;
7 const int SBRM_GUIDE = 2;
8 const int SBRM_ARTILLERY = 3;
9 const int SBRM_LAST = 3;
10
11 #ifdef SVQC
12 bool autocvar_g_vehicle_spiderbot = true;
13
14 float autocvar_g_vehicle_spiderbot_respawntime = 45;
15
16 float autocvar_g_vehicle_spiderbot_speed_stop = 50;
17 float autocvar_g_vehicle_spiderbot_speed_strafe = 400;
18 float autocvar_g_vehicle_spiderbot_speed_walk = 500;
19 float autocvar_g_vehicle_spiderbot_speed_run = 700;
20 float autocvar_g_vehicle_spiderbot_turnspeed = 90;
21 float autocvar_g_vehicle_spiderbot_turnspeed_strafe = 300;
22 float autocvar_g_vehicle_spiderbot_movement_inertia = 0.15;
23
24 float autocvar_g_vehicle_spiderbot_springlength = 150;
25 float autocvar_g_vehicle_spiderbot_springup = 20;
26 float autocvar_g_vehicle_spiderbot_springblend = 0.1;
27 float autocvar_g_vehicle_spiderbot_tiltlimit = 90;
28
29 float autocvar_g_vehicle_spiderbot_head_pitchlimit_down = -20;
30 float autocvar_g_vehicle_spiderbot_head_pitchlimit_up = 30;
31 float autocvar_g_vehicle_spiderbot_head_turnlimit = 90;
32 float autocvar_g_vehicle_spiderbot_head_turnspeed = 110;
33
34 int autocvar_g_vehicle_spiderbot_health = 800;
35 float autocvar_g_vehicle_spiderbot_health_regen = 10;
36 float autocvar_g_vehicle_spiderbot_health_regen_pause = 5;
37
38 int autocvar_g_vehicle_spiderbot_shield = 200;
39 float autocvar_g_vehicle_spiderbot_shield_regen = 25;
40 float autocvar_g_vehicle_spiderbot_shield_regen_pause = 0.35;
41
42 // 'minspeed_for_pain speedchange_to_pain_factor max_damage'
43 vector autocvar_g_vehicle_spiderbot_bouncepain = '0 0 0';
44
45 .float jump_delay;
46 bool spiderbot_frame(entity this, float dt)
47 {
48         entity vehic = this.vehicle;
49         return = true;
50
51         if(intermission_running)
52         {
53                 vehic.velocity = '0 0 0';
54                 vehic.avelocity = '0 0 0';
55                 return;
56         }
57
58         vehicles_frame(vehic, this);
59
60         PHYS_INPUT_BUTTON_ZOOM(this) = false;
61         PHYS_INPUT_BUTTON_CROUCH(this) = false;
62         PS(this).m_switchweapon = WEP_Null;
63         this.vehicle_weapon2mode = vehic.vehicle_weapon2mode;
64
65
66 #if 1 // 0 to enable per-gun impact aux crosshairs
67         // Avarage gun impact point's -> aux cross
68         vector ad = gettaginfo(vehic.tur_head, gettagindex(vehic.tur_head, "tag_hardpoint01"));
69         vector vf = v_forward;
70         ad += gettaginfo(vehic.tur_head, gettagindex(vehic.tur_head, "tag_hardpoint02"));
71         vf += v_forward;
72         ad = ad * 0.5;
73         v_forward = vf * 0.5;
74         traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, vehic);
75         UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 0);
76 #else
77         vector ad = gettaginfo(vehic.gun1, gettagindex(vehic.gun1, "barrels"));
78         traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, vehic);
79         UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 0);
80         vector vf = ad;
81         ad = gettaginfo(vehic.gun2, gettagindex(vehic.gun2, "barrels"));
82         traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, vehic);
83         UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 1);
84         ad = 0.5 * (ad + vf);
85 #endif
86
87         crosshair_trace(this);
88         ad = vectoangles(normalize(trace_endpos - ad));
89         ad = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(vehic.angles), AnglesTransform_FromAngles(ad))) - vehic.tur_head.angles;
90         ad = AnglesTransform_Normalize(ad, true);
91         //UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload2) + ('0 1 0' * (1 - this.vehicle_reload2)), 2);
92
93         // Rotate head
94         float ftmp = autocvar_g_vehicle_spiderbot_head_turnspeed * PHYS_INPUT_FRAMETIME;
95         ad_y = bound(-ftmp, ad_y, ftmp);
96         vehic.tur_head.angles_y = bound(autocvar_g_vehicle_spiderbot_head_turnlimit * -1, vehic.tur_head.angles_y + ad_y, autocvar_g_vehicle_spiderbot_head_turnlimit);
97
98         // Pitch head
99         ad_x = bound(ftmp * -1, ad_x, ftmp);
100         vehic.tur_head.angles_x = bound(autocvar_g_vehicle_spiderbot_head_pitchlimit_down, vehic.tur_head.angles_x + ad_x, autocvar_g_vehicle_spiderbot_head_pitchlimit_up);
101
102
103         //fixedmakevectors(vehic.angles);
104         makevectors(vehic.angles + '-2 0 0' * vehic.angles_x);
105
106         movelib_groundalign4point(vehic, autocvar_g_vehicle_spiderbot_springlength, autocvar_g_vehicle_spiderbot_springup, autocvar_g_vehicle_spiderbot_springblend, autocvar_g_vehicle_spiderbot_tiltlimit);
107
108         if(IS_ONGROUND(vehic))
109                 vehic.jump_delay = time; // reset now so movement can begin
110
111         //if(IS_ONGROUND(vehic))
112         {
113                 if(IS_ONGROUND(vehic))
114                 if(vehic.frame == 4 && vehic.tur_head.wait != 0)
115                 {
116                         sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_LAND, VOL_VEHICLEENGINE, ATTEN_NORM);
117                         vehic.frame = 5;
118                 }
119
120                 if (!PHYS_INPUT_BUTTON_JUMP(this))
121                         PHYS_INPUT_BUTTON_JUMP(vehic) = false;
122
123                 if((IS_ONGROUND(vehic)) && PHYS_INPUT_BUTTON_JUMP(this) && !PHYS_INPUT_BUTTON_JUMP(vehic) && vehic.tur_head.wait < time)
124                 {
125                         sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_JUMP, VOL_VEHICLEENGINE, ATTEN_NORM);
126                         //dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
127                         vehic.delay = 0;
128
129                         vehic.tur_head.wait = time + 2;
130                         vehic.jump_delay = time + 2;
131                         PHYS_INPUT_BUTTON_JUMP(vehic) = true; // set spider's jump
132                         //PHYS_INPUT_BUTTON_JUMP(this) = false;
133
134                         vector movefix = '0 0 0';
135                         if(this.movement_x > 0) movefix_x = 1;
136                         if(this.movement_x < 0) movefix_x = -1;
137                         if(this.movement_y > 0) movefix_y = 1;
138                         if(this.movement_y < 0) movefix_y = -1;
139
140                         vector rt = movefix_y * v_right;
141                         vector sd = movefix_x * v_forward;
142                         if(movefix_y == 0 && movefix_x == 0)
143                                 sd = v_forward; // always do forward
144
145                         UNSET_ONGROUND(vehic);
146
147                         vehic.velocity = sd * 700 + rt * 600 + v_up * 600;
148                         vehic.frame = 4;
149                 }
150                 else if(time >= vehic.jump_delay)
151                 {
152                         if(!this.movement)
153                         {
154                                 if(IS_ONGROUND(vehic))
155                                 {
156                                         if(vehic.sound_nexttime < time || vehic.delay != 3)
157                                         {
158                                                 vehic.delay = 3;
159                                                 vehic.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_idle.wav");
160                                                 //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n");
161                                                 sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_IDLE, VOL_VEHICLEENGINE, ATTEN_NORM);
162                                         }
163                                         movelib_brake_simple(vehic, autocvar_g_vehicle_spiderbot_speed_stop);
164                                         vehic.frame = 5;
165                                 }
166                         }
167                         else
168                         {
169                                 // Turn Body
170                                 if(this.movement_x == 0 && this.movement_y != 0)
171                                         ftmp = autocvar_g_vehicle_spiderbot_turnspeed_strafe * PHYS_INPUT_FRAMETIME;
172                                 else
173                                         ftmp = autocvar_g_vehicle_spiderbot_turnspeed * PHYS_INPUT_FRAMETIME;
174
175                                 ftmp = bound(-ftmp, vehic.tur_head.angles_y, ftmp);
176                                 vehic.angles_y = anglemods(vehic.angles_y + ftmp);
177                                 vehic.tur_head.angles_y -= ftmp;
178
179                                 if(this.movement_x != 0)
180                                 {
181                                         if(this.movement_x > 0)
182                                         {
183                                                 this.movement_x = 1;
184                                                 if(IS_ONGROUND(vehic))
185                                                         vehic.frame = 0;
186                                         }
187                                         else if(this.movement_x < 0)
188                                         {
189                                                 this.movement_x = -1;
190                                                 if(IS_ONGROUND(vehic))
191                                                         vehic.frame = 1;
192                                         }
193                                         this.movement_y = 0;
194                                         float oldvelz = vehic.velocity_z;
195                                         movelib_move_simple(vehic, normalize(v_forward * this.movement_x),((PHYS_INPUT_BUTTON_JUMP(this)) ? autocvar_g_vehicle_spiderbot_speed_run : autocvar_g_vehicle_spiderbot_speed_walk),autocvar_g_vehicle_spiderbot_movement_inertia);
196                                         vehic.velocity_z = oldvelz;
197                                         float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1);
198                                         if(vehic.velocity_z <= 20) // not while jumping
199                                                 vehic.velocity_z -= g * PHYS_INPUT_FRAMETIME * autocvar_sv_gravity;
200                                         if(IS_ONGROUND(vehic))
201                                         if(vehic.sound_nexttime < time || vehic.delay != 1)
202                                         {
203                                                 vehic.delay = 1;
204                                                 vehic.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_walk.wav");
205                                                 sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_WALK, VOL_VEHICLEENGINE, ATTEN_NORM);
206                                                 //dprint("spiderbot_walk:", ftos(soundlength("vehicles/spiderbot_walk.wav")), "\n");
207                                         }
208                                 }
209                                 else if(this.movement_y != 0)
210                                 {
211                                         if(this.movement_y < 0)
212                                         {
213                                                 this.movement_y = -1;
214                                                 if(IS_ONGROUND(vehic))
215                                                         vehic.frame = 2;
216                                         }
217                                         else if(this.movement_y > 0)
218                                         {
219                                                 this.movement_y = 1;
220                                                 if(IS_ONGROUND(vehic))
221                                                         vehic.frame = 3;
222                                         }
223
224                                         float oldvelz = vehic.velocity_z;
225                                         movelib_move_simple(vehic, normalize(v_right * this.movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia);
226                                         vehic.velocity_z = oldvelz;
227                                         float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1);
228                                         if(vehic.velocity_z <= 20) // not while jumping
229                                                 vehic.velocity_z -= g * PHYS_INPUT_FRAMETIME * autocvar_sv_gravity;
230                                         if(IS_ONGROUND(vehic))
231                                         if(vehic.sound_nexttime < time || vehic.delay != 2)
232                                         {
233                                                 vehic.delay = 2;
234                                                 vehic.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_strafe.wav");
235                                                 sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_STRAFE, VOL_VEHICLEENGINE, ATTEN_NORM);
236                                                 //dprint("spiderbot_strafe:", ftos(soundlength("vehicles/spiderbot_strafe.wav")), "\n");
237                                         }
238                                 }
239                         }
240                 }
241         }
242
243         vehic.angles_x = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, vehic.angles_x, autocvar_g_vehicle_spiderbot_tiltlimit);
244         vehic.angles_z = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, vehic.angles_z, autocvar_g_vehicle_spiderbot_tiltlimit);
245
246         if(!forbidWeaponUse(this))
247         if(PHYS_INPUT_BUTTON_ATCK(this))
248         {
249                 vehic.cnt = time;
250                 if(vehic.vehicle_ammo1 >= autocvar_g_vehicle_spiderbot_minigun_ammo_cost && vehic.tur_head.attack_finished_single[0] <= time)
251                 {
252                         entity gun;
253                         vector v;
254                         vehic.misc_bulletcounter += 1;
255
256                         gun = (vehic.misc_bulletcounter % 2) ? vehic.gun1 : vehic.gun2;
257
258                         v = gettaginfo(gun, gettagindex(gun, "barrels"));
259                         v_forward = normalize(v_forward);
260                         v += v_forward * 50;
261
262                         fireBullet(this, v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_solidpenetration,
263                                 autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN.m_id, 0);
264
265                         sound (gun, CH_WEAPON_A, SND_UZI_FIRE, VOL_BASE, ATTEN_NORM);
266                         //trailparticles(this, _particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos);
267                         Send_Effect(EFFECT_SPIDERBOT_MINIGUN_MUZZLEFLASH, v, v_forward * 2500, 1);
268
269                         vehic.vehicle_ammo1 -= autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
270                         vehic.tur_head.attack_finished_single[0] = time + autocvar_g_vehicle_spiderbot_minigun_refire;
271                         this.vehicle_ammo1 = (vehic.vehicle_ammo1 / autocvar_g_vehicle_spiderbot_minigun_ammo_max) * 100;
272                         vehic.gun1.angles_z += 45;
273                         vehic.gun2.angles_z -= 45;
274                         if(vehic.gun1.angles_z >= 360)
275                         {
276                                 vehic.gun1.angles_z = 0;
277                                 vehic.gun2.angles_z = 0;
278                         }
279                 }
280         }
281         else
282                 vehicles_regen(vehic, vehic.cnt, vehicle_ammo1, autocvar_g_vehicle_spiderbot_minigun_ammo_max,
283                                                                                    autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause,
284                                                                                    autocvar_g_vehicle_spiderbot_minigun_ammo_regen, dt, false);
285
286
287         spiderbot_rocket_do(vehic);
288
289         if(vehic.vehicle_flags  & VHF_SHIELDREGEN)
290                 vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_spiderbot_shield, autocvar_g_vehicle_spiderbot_shield_regen_pause, autocvar_g_vehicle_spiderbot_shield_regen, dt, true);
291
292         if(vehic.vehicle_flags  & VHF_HEALTHREGEN)
293                 vehicles_regen(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_spiderbot_health, autocvar_g_vehicle_spiderbot_health_regen_pause, autocvar_g_vehicle_spiderbot_health_regen, dt, false);
294
295         PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false;
296         //this.vehicle_ammo2 = vehic.tur_head.frame;
297         this.vehicle_ammo2 = (9 - vehic.tur_head.frame) / 8 * 100; // Percentage, like ammo1
298
299         if(vehic.gun2.cnt <= time)
300                 this.vehicle_reload2 = 100;
301         else
302                 this.vehicle_reload2 = 100 - ((vehic.gun2.cnt - time) / vehic.attack_finished_single[0]) * 100;
303
304         setorigin(this, vehic.origin + '0 0 1' * vehic.maxs_z);
305         this.velocity = vehic.velocity;
306
307         VEHICLE_UPDATE_PLAYER(this, vehic, health, spiderbot);
308
309         if(vehic.vehicle_flags & VHF_HASSHIELD)
310                 VEHICLE_UPDATE_PLAYER(this, vehic, shield, spiderbot);
311 }
312
313 void spiderbot_exit(entity this, int eject)
314 {
315         vector spot;
316
317         IL_EACH(g_projectiles, it.owner == this.owner && it.classname == "spiderbot_rocket",
318         {
319                 it.realowner = this.owner;
320                 it.owner = NULL;
321         });
322
323         setthink(this, vehicles_think);
324         this.nextthink = time;
325         this.frame = 5;
326         set_movetype(this, MOVETYPE_WALK);
327
328         if(!this.owner)
329                 return;
330
331         makevectors(this.angles);
332         if(eject)
333         {
334                 spot = this.origin + v_forward * 100 + '0 0 64';
335                 spot = vehicles_findgoodexit(this, spot);
336                 setorigin(this.owner , spot);
337                 this.owner.velocity = (v_up + v_forward * 0.25) * 750;
338                 this.owner.oldvelocity = this.owner.velocity;
339         }
340         else
341         {
342                 if(vdist(this.velocity, >, autocvar_g_vehicle_spiderbot_speed_strafe))
343                 {
344                         this.owner.velocity = normalize(this.velocity) * vlen(this.velocity);
345                         this.owner.velocity_z += 200;
346                         spot = this.origin + v_forward * 128 + '0 0 64';
347                         spot = vehicles_findgoodexit(this, spot);
348                 }
349                 else
350                 {
351                         this.owner.velocity = this.velocity * 0.5;
352                         this.owner.velocity_z += 10;
353                         spot = this.origin + v_forward * 256 + '0 0 64';
354                         spot = vehicles_findgoodexit(this, spot);
355                 }
356                 this.owner.oldvelocity = this.owner.velocity;
357                 setorigin(this.owner , spot);
358         }
359
360         antilag_clear(this.owner, CS(this.owner));
361         this.owner = NULL;
362 }
363
364 void spiderbot_headfade(entity this)
365 {
366         setthink(this, spiderbot_headfade);
367         this.nextthink = this.fade_time;
368         this.alpha = 1 - (time - this.fade_time) * this.fade_rate;
369
370         if(this.cnt < time || this.alpha < 0.1)
371         {
372                 if(this.alpha > 0.1)
373                 {
374                         sound (this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
375                         Send_Effect(EFFECT_EXPLOSION_BIG, this.origin + '0 0 100', '0 0 0', 1);
376                 }
377                 delete(this);
378         }
379 }
380
381 void spiderbot_blowup(entity this)
382 {
383         if(this.cnt > time)
384         {
385                 if(random() < 0.1)
386                 {
387                         sound (this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
388                         Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (this.origin + '0 0 100'), '0 0 0', 1);
389                 }
390                 this.nextthink = time + 0.1;
391                 return;
392         }
393
394         entity h, g1, g2, b;
395         b = spawn();
396         h = spawn();
397         g1 = spawn();
398         g2 = spawn();
399
400         setmodel(b, MDL_VEH_SPIDERBOT_BODY);
401         setmodel(h, MDL_VEH_SPIDERBOT_TOP);
402         setmodel(g1, MDL_VEH_SPIDERBOT_GUN);
403         setmodel(g2, MDL_VEH_SPIDERBOT_GUN);
404
405         setorigin(b, this.origin);
406         b.frame = 11;
407         b.angles = this.angles;
408         setsize(b, this.mins, this.maxs);
409
410         vector org = gettaginfo(this, gettagindex(this, "tag_head"));
411         setorigin(h, org);
412         set_movetype(h, MOVETYPE_BOUNCE);
413         h.solid = SOLID_BBOX;
414         h.velocity = v_up * (500 + random() * 500) + randomvec() * 128;
415         h.modelflags = MF_ROCKET;
416         h.effects = EF_FLAME | EF_LOWPRECISION;
417         h.avelocity = randomvec() * 360;
418
419         h.alpha = 1;
420         h.cnt = time + (3.5 * random());
421         h.fade_rate = 1 / min(this.respawntime, 10);
422         h.fade_time = time;
423         setthink(h, spiderbot_headfade);
424         h.nextthink = time;
425
426         org = gettaginfo(this.tur_head, gettagindex(this.tur_head, "tag_hardpoint01"));
427         setorigin(g1, org);
428         set_movetype(g1, MOVETYPE_TOSS);
429         g1.solid = SOLID_CORPSE;
430         g1.velocity = v_forward * 700 + (randomvec() * 32);
431         g1.avelocity = randomvec() * 180;
432
433         org = gettaginfo(this.tur_head, gettagindex(this.tur_head, "tag_hardpoint02"));
434         setorigin(g2, org);
435         set_movetype(g2, MOVETYPE_TOSS);
436         g2.solid = SOLID_CORPSE;
437         g2.velocity = v_forward * 700 + (randomvec() * 32);
438         g2.avelocity = randomvec() * 180;
439
440         h.colormod = b.colormod = g1.colormod = g2.colormod = '-2 -2 -2';
441
442         SUB_SetFade(b,  time + 5, min(this.respawntime, 1));
443         //SUB_SetFade(h,  time, min(this.respawntime, 10));
444         SUB_SetFade(g1, time, min(this.respawntime, 10));
445         SUB_SetFade(g2, time, min(this.respawntime, 10));
446
447         RadiusDamage (this, this.enemy, 250, 15, 250, NULL, NULL, 250, DEATH_VH_SPID_DEATH.m_id, NULL);
448
449         this.alpha = this.tur_head.alpha = this.gun1.alpha = this.gun2.alpha = -1;
450         set_movetype(this, MOVETYPE_NONE);
451         this.deadflag = DEAD_DEAD;
452         this.solid = SOLID_NOT;
453         this.tur_head.effects &= ~EF_FLAME;
454         this.vehicle_hudmodel.viewmodelforclient = this;
455 }
456
457 bool spiderbot_impulse(entity this, int _imp)
458 {
459         switch(_imp)
460         {
461                 case IMP_weapon_group_1.impulse:
462                         this.vehicle.vehicle_weapon2mode = SBRM_VOLLY;
463                         CSQCVehicleSetup(this, 0);
464                         return true;
465                 case IMP_weapon_group_2.impulse:
466                         this.vehicle.vehicle_weapon2mode = SBRM_GUIDE;
467                         CSQCVehicleSetup(this, 0);
468                         return true;
469                 case IMP_weapon_group_3.impulse:
470                         this.vehicle.vehicle_weapon2mode = SBRM_ARTILLERY;
471                         CSQCVehicleSetup(this, 0);
472                         return true;
473
474                 case IMP_weapon_next_byid.impulse:
475                 case IMP_weapon_next_bypriority.impulse:
476                 case IMP_weapon_next_bygroup.impulse:
477                         this.vehicle.vehicle_weapon2mode += 1;
478                         if(this.vehicle.vehicle_weapon2mode > SBRM_LAST)
479                                 this.vehicle.vehicle_weapon2mode = SBRM_FIRST;
480
481                         //centerprint(this, strcat("Rocket mode is ", ftos(this.vehicle.vehicle_weapon2mode)));
482                         CSQCVehicleSetup(this, 0);
483                         return true;
484                 case IMP_weapon_last.impulse:
485                 case IMP_weapon_prev_byid.impulse:
486                 case IMP_weapon_prev_bypriority.impulse:
487                 case IMP_weapon_prev_bygroup.impulse:
488                         this.vehicle.vehicle_weapon2mode -= 1;
489                         if(this.vehicle.vehicle_weapon2mode < SBRM_FIRST)
490                                 this.vehicle.vehicle_weapon2mode = SBRM_LAST;
491
492                         //centerprint(this, strcat("Rocket mode is ", ftos(this.vehicle.vehicle_weapon2mode)));
493                         CSQCVehicleSetup(this, 0);
494                         return true;
495
496                 /*
497                 case IMP_weapon_drop.impulse: // toss gun, could be used to exit?
498                         break;
499                 case IMP_weapon_reload.impulse: // Manual minigun reload?
500                         break;
501                 */
502         }
503         return false;
504 }
505
506 spawnfunc(vehicle_spiderbot)
507 {
508         if(!autocvar_g_vehicle_spiderbot) { delete(this); return; }
509         if(!vehicle_initialize(this, VEH_SPIDERBOT, false)) { delete(this); return; }
510 }
511
512 METHOD(Spiderbot, vr_impact, void(Spiderbot thisveh, entity instance))
513 {
514     if(autocvar_g_vehicle_spiderbot_bouncepain)
515         vehicles_impact(instance, autocvar_g_vehicle_spiderbot_bouncepain_x, autocvar_g_vehicle_spiderbot_bouncepain_y, autocvar_g_vehicle_spiderbot_bouncepain_z);
516 }
517 METHOD(Spiderbot, vr_enter, void(Spiderbot thisveh, entity instance))
518 {
519     instance.vehicle_weapon2mode = SBRM_GUIDE;
520     set_movetype(instance, MOVETYPE_WALK);
521     CSQCVehicleSetup(instance.owner, 0);
522     instance.owner.vehicle_health = (instance.vehicle_health / autocvar_g_vehicle_spiderbot_health) * 100;
523     instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_spiderbot_shield) * 100;
524
525     if(instance.owner.flagcarried)
526     {
527         setattachment(instance.owner.flagcarried, instance.tur_head, "");
528         setorigin(instance.owner.flagcarried, '-20 0 120');
529     }
530 }
531 METHOD(Spiderbot, vr_think, void(Spiderbot thisveh, entity instance))
532 {
533     if(IS_ONGROUND(instance))
534         movelib_brake_simple(instance, autocvar_g_vehicle_spiderbot_speed_stop);
535 }
536 METHOD(Spiderbot, vr_death, void(Spiderbot thisveh, entity instance))
537 {
538     instance.health                             = 0;
539     instance.event_damage               = func_null;
540     instance.takedamage                 = DAMAGE_NO;
541     settouch(instance, func_null);
542     instance.cnt                                = 3.4 + time + random() * 2;
543     setthink(instance, spiderbot_blowup);
544     instance.nextthink                  = time;
545     instance.deadflag                   = DEAD_DYING;
546     instance.frame                              = 5;
547     instance.tur_head.effects  |= EF_FLAME;
548     instance.colormod                   = instance.tur_head.colormod = '-1 -1 -1';
549     instance.frame                              = 10;
550     set_movetype(instance, MOVETYPE_TOSS);
551
552     CSQCModel_UnlinkEntity(instance); // networking the death scene would be a nightmare
553 }
554 METHOD(Spiderbot, vr_spawn, void(Spiderbot thisveh, entity instance))
555 {
556     if(!instance.gun1)
557     {
558         instance.vehicles_impulse = spiderbot_impulse;
559         instance.gun1 = spawn();
560         instance.gun2 = spawn();
561         setmodel(instance.gun1, MDL_VEH_SPIDERBOT_GUN);
562         setmodel(instance.gun2, MDL_VEH_SPIDERBOT_GUN);
563         setattachment(instance.gun1, instance.tur_head, "tag_hardpoint01");
564         setattachment(instance.gun2, instance.tur_head, "tag_hardpoint02");
565         instance.gravity = 2;
566         instance.mass = 5000;
567     }
568
569     instance.frame = 5;
570     instance.tur_head.frame = 1;
571     set_movetype(instance, MOVETYPE_WALK);
572     instance.solid = SOLID_SLIDEBOX;
573     instance.alpha = instance.tur_head.alpha = instance.gun1.alpha = instance.gun2.alpha = 1;
574     instance.tur_head.angles = '0 0 0';
575     instance.vehicle_exit = spiderbot_exit;
576
577     setorigin(instance, instance.pos1 + '0 0 128');
578     instance.angles = instance.pos2;
579     instance.damageforcescale = 0.03;
580     instance.vehicle_health = autocvar_g_vehicle_spiderbot_health;
581     instance.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
582
583     instance.PlayerPhysplug = spiderbot_frame;
584 }
585 METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh, entity instance))
586 {
587     if(autocvar_g_vehicle_spiderbot_shield)
588         instance.vehicle_flags |= VHF_HASSHIELD;
589
590     if(autocvar_g_vehicle_spiderbot_shield_regen)
591         instance.vehicle_flags |= VHF_SHIELDREGEN;
592
593     if(autocvar_g_vehicle_spiderbot_health_regen)
594         instance.vehicle_flags |= VHF_HEALTHREGEN;
595
596     instance.respawntime = autocvar_g_vehicle_spiderbot_respawntime;
597     instance.vehicle_health = autocvar_g_vehicle_spiderbot_health;
598     instance.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
599     instance.max_health = instance.vehicle_health;
600     instance.pushable = true; // spiderbot can use jumppads
601 }
602
603 #endif // SVQC
604 #ifdef CSQC
605 float autocvar_cl_vehicle_spiderbot_cross_alpha = 0.6;
606 float autocvar_cl_vehicle_spiderbot_cross_size = 1;
607
608 METHOD(Spiderbot, vr_hud, void(Spiderbot thisveh))
609 {
610     Vehicles_drawHUD(VEH_SPIDERBOT.m_icon, "vehicle_spider_weapon1", "vehicle_spider_weapon2",
611                      "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
612                      "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color);
613 }
614 METHOD(Spiderbot, vr_crosshair, void(Spiderbot thisveh, entity player))
615 {
616     string crosshair;
617
618     switch(weapon2mode)
619     {
620         case SBRM_VOLLY:     crosshair = vCROSS_BURST; break;
621         case SBRM_GUIDE:     crosshair = vCROSS_GUIDE; break;
622         case SBRM_ARTILLERY: crosshair = vCROSS_RAIN;  break;
623         default:             crosshair = vCROSS_BURST;
624     }
625
626     Vehicles_drawCrosshair(crosshair);
627 }
628 METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh, entity instance))
629 {
630     AuxiliaryXhair[0].axh_image = vCROSS_HINT; // Minigun1
631     AuxiliaryXhair[1].axh_image = vCROSS_HINT; // Minigun2
632 }
633
634 #endif
635 #endif