Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
raptor.qc
Go to the documentation of this file.
1#include "raptor.qh"
2
3#ifdef SVQC
5#endif
6
7#ifdef GAMEQC
8
9#ifdef SVQC
10
12
15
16// 0: go where player aims, +forward etc relative to aim angles
17// 1: ignore aim for up/down movement. +forward always moved forward, +jump always moves up
22
28
30
35
41
45
49
53
57
58.entity bomb1;
59.entity bomb2;
60
62{
63 float hgt = vehicle_altitude(this, 512);
64 this.velocity = (this.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * PHYS_INPUT_FRAMETIME);
65 this.angles.x *= 0.95;
66 this.angles.z *= 0.95;
67
68 if (hgt < 128 && hgt > 0)
69 this.frame = (hgt / 128) * 25;
70
71 this.bomb1.gun1.avelocity.y = 90 + ((this.frame / 25) * 2000);
72 this.bomb1.gun2.avelocity.y = -this.bomb1.gun1.avelocity.y;
73
74 if (hgt < 16)
75 {
78 this.frame = 0;
79 }
80
81 this.nextthink = time;
82
84}
85
86void raptor_exit(entity this, int eject)
87{
88 entity player = this.owner;
89
90 this.tur_head.exteriormodeltoclient = NULL;
91
92 if (!IS_DEAD(this))
93 {
94 setthink(this, raptor_land);
95 this.nextthink = time;
96 }
97
98 if (!player)
99 return;
100
101 makevectors(this.angles);
102 vector spot;
103 if (eject)
104 {
105 spot = this.origin + v_forward * 100 + '0 0 64';
106 spot = vehicles_findgoodexit(this, player, spot);
107 setorigin(player, spot);
108 player.velocity = (v_up + v_forward * 0.25) * 750;
109 player.oldvelocity = player.velocity;
110 }
111 else
112 {
113 if (vdist(this.velocity, >, 2 * autocvar_sv_maxairspeed))
114 {
115 player.velocity = normalize(this.velocity) * autocvar_sv_maxairspeed * 2;
116 player.velocity.z += 200;
117 spot = this.origin + v_forward * 32 + '0 0 64';
118 spot = vehicles_findgoodexit(this, player, spot);
119 }
120 else
121 {
122 player.velocity = this.velocity * 0.5;
123 player.velocity.z += 10;
124 spot = this.origin - v_forward * 200 + '0 0 64';
125 spot = vehicles_findgoodexit(this, player, spot);
126 }
127 player.oldvelocity = player.velocity;
128 setorigin(player, spot);
129 }
130
131 this.owner = NULL;
132 antilag_clear(player, CS(player));
133}
134
135bool raptor_frame(entity this, float dt)
136{
137 entity vehic = this.vehicle;
138 return = true;
139
140 if (game_stopped)
141 {
142 vehic.solid = SOLID_NOT;
143 vehic.takedamage = DAMAGE_NO;
145 return;
146 }
147
148 vehicles_frame(vehic, this);
149
150 /*
151 float ftmp = vlen(vehic.velocity);
152 if (ftmp > autocvar_g_vehicle_raptor_speed_forward)
153 ftmp = 1;
154 else
155 ftmp /= autocvar_g_vehicle_raptor_speed_forward;
156 */
157
158 if (vehic.sound_nexttime < time)
159 {
160 vehic.sound_nexttime = time + 7.955812;
161 //sound(vehic.tur_head, CH_TRIGGER_SINGLE, SND_VEH_RAPTOR_FLY, 1 - ftmp, ATTEN_NORM);
162 sound(vehic, CH_TRIGGER_SINGLE, SND_VEH_RAPTOR_SPEED, 1, ATTEN_NORM);
163 vehic.wait = 0;
164 }
165 /*
166 else if (fabs(ftmp - vehic.wait) > 0.2)
167 {
168 sound(vehic.tur_head, CH_TRIGGER_SINGLE, SND_Null, 1 - ftmp, ATTEN_NORM);
169 sound(vehic, CH_TRIGGER_SINGLE, SND_Null, ftmp, ATTEN_NORM);
170 vehic.wait = ftmp;
171 }
172 */
173
174 if (IS_DEAD(vehic))
175 {
177 return;
178 }
179 crosshair_trace(this);
180
181 //if (time - vehic.lastteleporttime < 1)
182 if ((vehic.angles.z > 50 || vehic.angles.z < -50)
183 && PHYS_INPUT_BUTTON_JUMP(this))
184 {
185 PHYS_INPUT_BUTTON_CROUCH(this) = true;
186 PHYS_INPUT_BUTTON_JUMP(this) = false;
187 }
188
189 vector vang = vehic.angles;
190 vector df = vectoangles(normalize(trace_endpos - vehic.origin + '0 0 32'));
191 vang.x = -vang.x;
192 df.x = -df.x;
193 if (df.x > 180) df.x -= 360;
194 if (df.x < -180) df.x += 360;
195 if (df.y > 180) df.y -= 360;
196 if (df.y < -180) df.y += 360;
197
198 float ftmp = shortangle_f(this.v_angle.y - vang.y, vang.y);
199 if (ftmp > 180) ftmp -= 360;
200 if (ftmp < -180) ftmp += 360;
201 vehic.avelocity.y = bound(-autocvar_g_vehicle_raptor_turnspeed, ftmp + vehic.avelocity.y * 0.9, autocvar_g_vehicle_raptor_turnspeed);
202
203 // Pitch
204 ftmp = 0;
205 if (CS(this).movement.x > 0 && vang.x < autocvar_g_vehicle_raptor_pitchlimit)
206 ftmp = 5;
207 else if (CS(this).movement.x < 0 && vang.x > -autocvar_g_vehicle_raptor_pitchlimit)
208 ftmp = -20;
209
212 vehic.avelocity.x = bound(-autocvar_g_vehicle_raptor_pitchspeed, ftmp + vehic.avelocity.x * 0.9, autocvar_g_vehicle_raptor_pitchspeed);
213
214 vehic.angles.x = anglemods(vehic.angles.x);
215 vehic.angles.y = anglemods(vehic.angles.y);
216 vehic.angles.z = anglemods(vehic.angles.z);
217
219 makevectors('0 1 0' * vehic.angles.y);
220 else
221 makevectors(this.v_angle);
222
223 df = vehic.velocity * -autocvar_g_vehicle_raptor_friction;
224
225 if (CS(this).movement.x != 0)
226 {
227 if (CS(this).movement.x > 0)
229 else if (CS(this).movement.x < 0)
231 }
232
233 if (CS(this).movement.y != 0)
234 {
235 if (CS(this).movement.y < 0)
237 else if (CS(this).movement.y > 0)
239
240 vehic.angles.z = bound(-30, vehic.angles.z + CS(this).movement.y / autocvar_g_vehicle_raptor_speed_strafe, 30);
241 }
242 else
243 {
244 vehic.angles.z *= 0.95;
245 if (vehic.angles.z >= -1 && vehic.angles.z <= -1)
246 vehic.angles.z = 0;
247 }
248
249 if (PHYS_INPUT_BUTTON_CROUCH(this))
251 else if (PHYS_INPUT_BUTTON_JUMP(this))
253
254 vehic.velocity += df * dt;
255 this.velocity = CS(this).movement = vehic.velocity;
256 setorigin(this, vehic.origin + '0 0 32');
257 this.oldorigin = this.origin; // negate fall damage
258
259 STAT(VEHICLESTAT_W2MODE, this) = STAT(VEHICLESTAT_W2MODE, vehic);
260
261 vector vf, ad;
262 // Target lock & predict
264 {
265 if (vehic.gun1.lock_time < time || IS_DEAD(vehic.gun1.enemy) || STAT(FROZEN, vehic.gun1.enemy))
266 vehic.gun1.enemy = NULL;
267
268 if (trace_ent
269 && trace_ent.move_movetype
270 && trace_ent.takedamage
271 && !IS_DEAD(trace_ent) && !STAT(FROZEN, trace_ent))
272 {
273 if (teamplay)
274 {
275 if (trace_ent.team != this.team)
276 {
277 vehic.gun1.enemy = trace_ent;
278 vehic.gun1.lock_time = time + 5;
279 }
280 }
281 else
282 {
283 vehic.gun1.enemy = trace_ent;
284 vehic.gun1.lock_time = time + 0.5;
285 }
286 }
287
288 if (vehic.gun1.enemy)
289 {
290 vf = real_origin(vehic.gun1.enemy);
291 UpdateAuxiliaryXhair(this, vf, '1 0 0', 1);
292 vector _vel = vehic.gun1.enemy.velocity;
293 if (vehic.gun1.enemy.move_movetype == MOVETYPE_WALK)
294 _vel.z *= 0.1;
295
297 {
298 ad = vf;
299 float distance = vlen(ad - this.origin);
300 float impact_time = distance / autocvar_g_vehicle_raptor_cannon_speed;
301 ad = vf + _vel * impact_time;
302 trace_endpos = ad;
303 }
304 else
305 trace_endpos = vf;
306 }
307 }
309 {
310
314
315 if (vehic.lock_target != NULL
317 && vehic.lock_strength == 1)
318 {
319 float distance, impact_time;
320
321 vf = real_origin(vehic.lock_target);
322 ad = vf;
323 for (int i = 0; i < 4; ++i)
324 {
325 distance = vlen(ad - vehic.origin);
326 impact_time = distance / autocvar_g_vehicle_raptor_cannon_speed;
327 ad = vf + vehic.lock_target.velocity * impact_time;
328 }
329 trace_endpos = ad;
330 }
331
332 if (vehic.lock_target)
333 {
334 if (vehic.lock_strength == 1)
335 UpdateAuxiliaryXhair(this, real_origin(vehic.lock_target), '1 0 0', 1);
336 else if (vehic.lock_strength > 0.5)
337 UpdateAuxiliaryXhair(this, real_origin(vehic.lock_target), '0 1 0', 1);
338 else if (vehic.lock_strength < 0.5)
339 UpdateAuxiliaryXhair(this, real_origin(vehic.lock_target), '0 0 1', 1);
340 }
341 }
342
343
344 vehicle_aimturret(vehic, trace_endpos, vehic.gun1, "fire1",
347
348 vehicle_aimturret(vehic, trace_endpos, vehic.gun2, "fire1",
351
352 /*
353 ad *= 0.5;
354 v_forward = vf * 0.5;
355 traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, vehic);
356 UpdateAuxiliaryXhair(this, trace_endpos, '0 1 0', 0);
357 */
358
359 Weapon wep1 = WEP_RAPTOR;
360 .entity weaponentity = weaponentities[0];
361 if (!weaponLocked(this) && !weaponUseForbidden(this)
363 && wep1.wr_checkammo1(wep1, vehic, weaponentity))
364 wep1.wr_think(wep1, vehic, weaponentity, 1);
365
366 if (vehic.vehicle_flags & VHF_SHIELDREGEN)
368
369 if (vehic.vehicle_flags & VHF_HEALTHREGEN)
371
372 if (vehic.vehicle_flags & VHF_ENERGYREGEN)
374
375 Weapon wep2a = WEP_RAPTOR_BOMB;
376 if (!weaponLocked(this) && !weaponUseForbidden(this)
377 && STAT(VEHICLESTAT_W2MODE, vehic) == RSM_BOMB)
378 {
381 {
382 .entity weaponentity = weaponentities[1];
383 wep2a.wr_think(wep2a, vehic, weaponentity, 2);
385 vehic.lip = time;
386 }
387 }
388 else
389 {
390 Weapon wep2b = WEP_RAPTOR_FLARE;
393 {
394 .entity weaponentity = weaponentities[1];
395 wep2b.wr_think(wep2b, vehic, weaponentity, 2);
397 vehic.lip = time;
398 }
399 }
400
401 vehic.bomb1.alpha = vehic.bomb2.alpha = (time - vehic.lip) / (vehic.delay - vehic.lip);
402 this.vehicle_reload2 = bound(0, vehic.bomb1.alpha * 100, 100);
403 this.vehicle_ammo2 = (this.vehicle_reload2 == 100) ? 100 : 0;
404
405 if (vehic.bomb1.cnt < time)
406 {
407 bool incoming = false;
408 IL_EACH(g_projectiles, it.enemy == vehic,
409 {
410 if ((it.missile_flags & MIF_GUIDED_TRACKING)
411 && vdist(vehic.origin - it.origin, <, 2 * autocvar_g_vehicle_raptor_flare_range))
412 {
413 incoming = true;
414 break;
415 }
416 });
417
418 if (incoming)
419 {
420 msg_entity = this;
421 soundto(MSG_ONE, vehic, CH_PAIN_SINGLE, SND(VEH_MISSILE_ALARM), VOL_BASE, ATTEN_NONE, 0);
422 }
423
424 vehic.bomb1.cnt = time + 1;
425 }
426
427 VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, raptor, RES_HEALTH);
428 VEHICLE_UPDATE_PLAYER(this, vehic, energy, raptor);
429 if (vehic.vehicle_flags & VHF_HASSHIELD)
430 VEHICLE_UPDATE_PLAYER(this, vehic, shield, raptor);
431
433}
434
435bool raptor_takeoff(entity this, float dt)
436{
437 entity vehic = this.vehicle;
438 return = true;
439
440 vehic.nextthink = time;
442 vehic.nextthink = 0; // will this work?
443
444 if (vehic.sound_nexttime < time)
445 {
446 vehic.sound_nexttime = time + 7.955812; //soundlength("vehicles/raptor_fly.wav");
447 sound(vehic, CH_TRIGGER_SINGLE, SND_VEH_RAPTOR_SPEED, VOL_VEHICLEENGINE, ATTEN_NORM);
448 }
449
450 // Takeoff sequense
451 if (vehic.frame < 25)
452 {
453 vehic.frame += 25 * dt / autocvar_g_vehicle_raptor_takeofftime;
454 vehic.velocity.z = min(vehic.velocity.z * 1.5, 256);
455 vehic.bomb1.gun1.avelocity.y = 90 + ((vehic.frame / 25) * 25000);
456 vehic.bomb1.gun2.avelocity.y = -vehic.bomb1.gun1.avelocity.y;
458
459 setorigin(this, vehic.origin + '0 0 32');
460 this.oldorigin = this.origin;
461 }
462 else
463 this.PlayerPhysplug = raptor_frame;
464
465 STAT(VEHICLESTAT_W2MODE, this) = STAT(VEHICLESTAT_W2MODE, vehic);
466
467 if (vehic.vehicle_flags & VHF_SHIELDREGEN)
469
470 if (vehic.vehicle_flags & VHF_HEALTHREGEN)
472
473 if (vehic.vehicle_flags & VHF_ENERGYREGEN)
475
476
477 vehic.bomb1.alpha = vehic.bomb2.alpha = (time - vehic.lip) / (vehic.delay - vehic.lip);
478 this.vehicle_reload2 = bound(0, vehic.bomb1.alpha * 100, 100);
479 this.vehicle_ammo2 = (this.vehicle_reload2 == 100) ? 100 : 0;
480
481 VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, raptor, RES_HEALTH);
482 VEHICLE_UPDATE_PLAYER(this, vehic, energy, raptor);
483 if (vehic.vehicle_flags & VHF_HASSHIELD)
484 VEHICLE_UPDATE_PLAYER(this, vehic, shield, raptor);
485
487}
488
490{
491 this.deadflag = DEAD_DEAD;
492 this.vehicle_exit(this, VHEF_NORMAL);
493 RadiusDamage(this, this.enemy,
494 250,
495 15,
496 250,
497 NULL,
498 NULL,
499 250,
500 DEATH_VH_RAPT_DEATH.m_id,
501 DMG_NOWEP,
502 NULL
503 );
504
505 this.alpha = -1;
507 this.effects = EF_NODRAW;
508 this.colormod = '0 0 0';
509 this.avelocity = '0 0 0';
510 this.velocity = '0 0 0';
511
512 setorigin(this, this.pos1);
513 settouch(this, func_null);
514 this.nextthink = 0;
515}
516
518{
519 if (time >= this.wait)
520 {
521 raptor_blowup(this, NULL);
522 return;
523 }
524
525 if (random() < 0.05)
526 {
527 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
528 Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (this.origin + '0 0 100'), '0 0 0', 1);
529 }
530 this.nextthink = time;
531
533}
534
535// If we dont do this ever now and then, the raptors rotors
536// stop working, presumably due to angle overflow. cute.
538{
539 this.gun1.angles.y = anglemods(this.gun1.angles.y);
540 this.gun2.angles.y = anglemods(this.gun2.angles.y);
541 this.nextthink = time + 15;
542}
543
544bool raptor_impulse(entity this, int _imp)
545{
546 switch (_imp)
547 {
548 case IMP_weapon_group_1.impulse:
549 STAT(VEHICLESTAT_W2MODE, this.vehicle) = RSM_BOMB;
550 CSQCVehicleSetup(this, 0);
551 return true;
552 case IMP_weapon_group_2.impulse:
553 STAT(VEHICLESTAT_W2MODE, this.vehicle) = RSM_FLARE;
554 CSQCVehicleSetup(this, 0);
555 return true;
556
557 case IMP_weapon_next_byid.impulse:
558 case IMP_weapon_next_bypriority.impulse:
559 case IMP_weapon_next_bygroup.impulse:
560 ++STAT(VEHICLESTAT_W2MODE, this.vehicle);
561 if (STAT(VEHICLESTAT_W2MODE, this.vehicle) > RSM_LAST)
562 STAT(VEHICLESTAT_W2MODE, this.vehicle) = RSM_FIRST;
563
564 CSQCVehicleSetup(this, 0);
565 return true;
566 case IMP_weapon_last.impulse:
567 case IMP_weapon_prev_byid.impulse:
568 case IMP_weapon_prev_bypriority.impulse:
569 case IMP_weapon_prev_bygroup.impulse:
570 --STAT(VEHICLESTAT_W2MODE, this.vehicle);
571 if (STAT(VEHICLESTAT_W2MODE, this.vehicle) < RSM_FIRST)
572 STAT(VEHICLESTAT_W2MODE, this.vehicle) = RSM_LAST;
573
574 CSQCVehicleSetup(this, 0);
575 return true;
576
577 /*
578 case IMP_weapon_drop.impulse: // toss gun, could be used to exit?
579 break;
580 case IMP_weapon_reload.impulse: // Manual minigun reload?
581 break;
582 */
583 }
584 return false;
585}
586
587spawnfunc(vehicle_raptor)
588{
590 || !vehicle_initialize(this, VEH_RAPTOR, false))
591 {
592 delete(this);
593 return;
594 }
595}
596
597METHOD(Raptor, vr_impact, void(Raptor thisveh, entity instance))
598{
601}
602METHOD(Raptor, vr_enter, void(Raptor thisveh, entity instance))
603{
604 STAT(VEHICLESTAT_W2MODE, instance) = RSM_BOMB;
605 instance.owner.PlayerPhysplug = raptor_takeoff;
607 instance.solid = SOLID_SLIDEBOX;
608 instance.owner.vehicle_health = (GetResource(instance, RES_HEALTH) / autocvar_g_vehicle_raptor_health) * 100;
609 instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_raptor_shield) * 100;
610 instance.velocity = '0 0 1'; // nudge upwards so takeoff sequence can work
611 instance.tur_head.exteriormodeltoclient = instance.owner;
612
614 instance.lip = time;
615
616 if (instance.owner.flagcarried)
617 setorigin(instance.owner.flagcarried, '-20 0 96');
618
619 CSQCVehicleSetup(instance.owner, 0);
620}
621METHOD(Raptor, vr_death, void(Raptor thisveh, entity instance))
622{
623 SetResourceExplicit(instance, RES_HEALTH, 0);
624 instance.event_damage = func_null;
625 instance.solid = SOLID_CORPSE;
626 instance.takedamage = DAMAGE_NO;
627 instance.deadflag = DEAD_DYING;
628 set_movetype(instance, MOVETYPE_BOUNCE);
629 setthink(instance, raptor_diethink);
630 instance.nextthink = time;
631 instance.wait = time + 5 + (random() * 5);
632
633 Send_Effect(EFFECT_EXPLOSION_MEDIUM, findbetterlocation (instance.origin, 16), '0 0 0', 1);
634
635 instance.velocity.z += 600;
636
637 instance.avelocity = '0 0.5 1' * 400 * (random() - random());
638
639 instance.colormod = '-0.5 -0.5 -0.5';
640 settouch(instance, raptor_blowup);
641}
642METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance))
643{
644 if (!instance.gun1)
645 {
646 //FIXME: Camera is in a bad place in HUD model.
647 //setorigin(instance.vehicle_viewport, '25 0 5');
648
649 instance.vehicles_impulse = raptor_impulse;
650
651 instance.frame = 0;
652
653 instance.bomb1 = new(raptor_bomb);
654 instance.bomb2 = new(raptor_bomb);
655 instance.gun1 = new(raptor_gun);
656 instance.gun2 = new(raptor_gun);
657
658 setmodel(instance.bomb1, MDL_VEH_RAPTOR_CB_FOLDED);
659 setmodel(instance.bomb2, MDL_VEH_RAPTOR_CB_FOLDED);
660 setmodel(instance.gun1, MDL_VEH_RAPTOR_GUN);
661 setmodel(instance.gun2, MDL_VEH_RAPTOR_GUN);
662 setmodel(instance.tur_head, MDL_VEH_RAPTOR_TAIL);
663
664 setattachment(instance.bomb1, instance, "bombmount_left");
665 setattachment(instance.bomb2, instance, "bombmount_right");
666 setattachment(instance.tur_head, instance, "root");
667
668 // FIXMODEL Guns mounts to angled bones
669 instance.bomb1.angles = instance.angles;
670 instance.angles = '0 0 0';
671 // This messes up gun-aim, so work arround it.
672 vector ofs;
673 //setattachment(instance.gun1, instance, "gunmount_left");
674 ofs = gettaginfo(instance, gettagindex(instance, "gunmount_left"));
675 ofs -= instance.origin;
676 setattachment(instance.gun1, instance, "");
677 setorigin(instance.gun1, ofs);
678
679 //setattachment(instance.gun2, instance, "gunmount_right");
680 ofs = gettaginfo(instance, gettagindex(instance, "gunmount_right"));
681 ofs -= instance.origin;
682 setattachment(instance.gun2, instance, "");
683 setorigin(instance.gun2, ofs);
684
685 instance.angles = instance.bomb1.angles;
686 instance.bomb1.angles = '0 0 0';
687
688 entity spinner = new(raptor_spinner);
689 spinner.owner = instance;
690 setmodel(spinner, MDL_VEH_RAPTOR_PROP);
691 setattachment(spinner, instance, "engine_left");
693 spinner.avelocity = '0 90 0';
694 instance.bomb1.gun1 = spinner;
695
696 spinner = new(raptor_spinner);
697 spinner.owner = instance;
698 setmodel(spinner, MDL_VEH_RAPTOR_PROP);
699 setattachment(spinner, instance, "engine_right");
701 spinner.avelocity = '0 -90 0';
702 instance.bomb1.gun2 = spinner;
703
704 // Sigh.
705 setthink(instance.bomb1, raptor_rotor_anglefix);
706 instance.bomb1.nextthink = time;
707
708 instance.mass = 1;
709 }
710
711 instance.frame = 0;
713 instance.vehicle_shield = autocvar_g_vehicle_raptor_shield;
714 set_movetype(instance, MOVETYPE_TOSS);
715 instance.solid = SOLID_SLIDEBOX;
716 instance.vehicle_energy = 1;
717
719 instance.dphitcontentsmask |= DPCONTENTS_LIQUIDSMASK;
720
721 instance.PlayerPhysplug = raptor_frame;
722
723 instance.bomb1.gun1.avelocity.y = 90;
724 instance.bomb1.gun2.avelocity.y = -90;
725
726 instance.delay = time;
727
728 instance.bouncefactor = autocvar_g_vehicle_raptor_bouncefactor;
729 instance.bouncestop = autocvar_g_vehicle_raptor_bouncestop;
730 instance.damageforcescale = 0.25;
732 instance.vehicle_shield = autocvar_g_vehicle_raptor_shield;
733}
734METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance))
735{
737 instance.vehicle_flags |= VHF_HASSHIELD;
738
740 instance.vehicle_flags |= VHF_SHIELDREGEN;
741
743 instance.vehicle_flags |= VHF_HEALTHREGEN;
744
746 instance.vehicle_flags |= VHF_ENERGYREGEN;
747
748 instance.vehicle_exit = raptor_exit;
749 instance.respawntime = autocvar_g_vehicle_raptor_respawntime;
751 instance.vehicle_shield = autocvar_g_vehicle_raptor_shield;
752 instance.max_health = GetResource(instance, RES_HEALTH);
753
755 instance.dphitcontentsmask |= DPCONTENTS_LIQUIDSMASK;
756}
757
758#endif // SVQC
759#ifdef CSQC
760
761METHOD(Raptor, vr_hud, void(Raptor thisveh))
762{
763 Vehicles_drawHUD(VEH_RAPTOR.m_icon, "vehicle_raptor_weapon1", "vehicle_raptor_weapon2",
766}
767METHOD(Raptor, vr_crosshair, void(Raptor thisveh, entity player))
768{
769 string crosshair;
770
771 switch (weapon2mode)
772 {
773 case RSM_FLARE: crosshair = vCROSS_RAIN; break;
774 case RSM_BOMB: crosshair = vCROSS_BURST; break;
775 default: crosshair = vCROSS_BURST;
776 }
777
778 vector tmpSize = '0 0 0';
780 {
781 if (!dropmark)
782 {
783 dropmark = new(raptor_dropmark);
784 dropmark.owner = player;
785 dropmark.gravity = 1;
786 dropmark.dphitcontentsmask = DPCONTENTS_SOLID;
787 dropmark.solid = SOLID_CORPSE;
789 }
790
791 vector where;
792 float reload2 = STAT(VEHICLESTAT_RELOAD2) * 0.01;
793 if (reload2 == 1)
794 {
795 setorigin(dropmark, pmove_org);
796 dropmark.velocity = pmove_vel;
797 tracetoss(dropmark, player);
798
800
801 setorigin(dropmark, trace_endpos);
802
803 if (!(where.z < 0 || where.x < 0 || where.y < 0 || where.x > vid_conwidth || where.y > vid_conheight))
804 {
805 tmpSize = draw_getimagesize(vCROSS_DROP) * autocvar_cl_vehicles_crosshair_size;
806 where.x -= tmpSize.x * 0.5;
807 where.y -= tmpSize.y * 0.5;
808 where.z = 0;
809 drawpic(where, vCROSS_DROP, tmpSize, '0 1 0', autocvar_crosshair_alpha * 0.9, DRAWFLAG_ADDITIVE);
810 drawpic(where, vCROSS_DROP, tmpSize, '0 1 0', autocvar_crosshair_alpha * 0.6, DRAWFLAG_NORMAL); // Ensure visibility against bright bg
811 }
812 dropmark.cnt = time + 5;
813 }
814 else
815 {
816 if (dropmark.cnt > time)
817 {
818 where = project_3d_to_2d(dropmark.origin);
819
820 if (!(where.z < 0 || where.x < 0 || where.y < 0 || where.x > vid_conwidth || where.y > vid_conheight))
821 {
822 tmpSize = draw_getimagesize(vCROSS_DROP) * autocvar_cl_vehicles_crosshair_size * 1.25;
823 where.x -= tmpSize.x * 0.5;
824 where.y -= tmpSize.y * 0.5;
825 where.z = 0;
826 drawpic(where, vCROSS_DROP, tmpSize, '1 0 0', autocvar_crosshair_alpha * 0.9, DRAWFLAG_ADDITIVE);
827 drawpic(where, vCROSS_DROP, tmpSize, '1 0 0', autocvar_crosshair_alpha * 0.6, DRAWFLAG_NORMAL); // Ensure visibility against bright bg
828 }
829 }
830 }
831 }
832
833 Vehicles_drawCrosshair(crosshair);
834}
835METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance))
836{
837 AuxiliaryXhair[1].axh_image = vCROSS_LOCK;
838}
839
840#endif // CSQC
841
842#endif // GAMEQC
843#ifdef MENUQC
844#include "spiderbot.qh"
845
846METHOD(Raptor, describe, string(Raptor this))
847{
848 TC(Raptor, this);
850 PAR(_("The %s vehicle is a flying vehicle that takes only one pilot, who can operate both of the weapons."), COLORED_NAME(this));
851 PAR(_("The two weapons have different reticles for them similar to the %s. "
852 "The primary weapon is laser-based, shooting toward the white reticle. "
853 "The secondary weapon drops bombs to the ground, aiming towards the green reticle. "
854 "The white reticle always points to the head of the vehicle, while the green reticle's location is determined by the momentum of the vehicle."), COLORED_NAME(VEH_SPIDERBOT));
855 return PAGE_TEXT;
856}
857
858#endif // MENUQC
ERASEABLE float anglemods(float v)
Definition angle.qc:13
ERASEABLE float shortangle_f(float ang1, float ang2)
Definition angle.qc:29
float frame
primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4)
Definition anim.qh:6
void antilag_clear(entity e, entity store)
Definition antilag.qc:114
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
void Vehicles_drawCrosshair(string crosshair)
void Vehicles_drawHUD(string vehicle, string vehicleWeapon1, string vehicleWeapon2, string iconAmmo1, vector colorAmmo1, string iconAmmo2, vector colorAmmo2)
vector autocvar_hud_progressbar_vehicles_ammo2_color
const string vCROSS_LOCK
vector autocvar_hud_progressbar_vehicles_ammo1_color
float autocvar_cl_vehicles_crosshair_size
Definition cl_vehicles.qh:7
const string vCROSS_BURST
entity dropmark
#define weapon2mode
const string vCROSS_DROP
const string vCROSS_RAIN
entity AuxiliaryXhair[MAX_AXH]
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition weapon.qh:42
virtual void wr_think()
(SERVER) logic to run every frame
Definition weapon.qh:98
virtual void wr_checkammo1()
(SERVER) checks ammo for weapon primary
Definition weapon.qh:100
#define drawpic(position, pic, size, rgb, alpha, flag)
Definition draw.qh:21
vector colormod
Definition powerups.qc:21
float alpha
Definition items.qc:13
float wait
Definition items.qc:17
entity owner
Definition main.qh:87
int spectatee_status
the -1 disables HUD panels before CSQC receives necessary data
Definition main.qh:197
#define COLORED_NAME(this)
Definition color.qh:195
#define setmodel(this, m)
Definition model.qh:26
#define PHYS_INPUT_BUTTON_CROUCH(s)
Definition player.qh:156
vector movement
Definition player.qh:228
#define IS_DEAD(s)
Definition player.qh:244
#define PHYS_INPUT_BUTTON_JUMP(s)
Definition player.qh:153
#define PHYS_INPUT_FRAMETIME
Definition player.qh:254
vector v_angle
Definition player.qh:236
float autocvar_sv_maxairspeed
Definition player.qh:52
#define PHYS_INPUT_BUTTON_ATCK(s)
Definition player.qh:152
#define PHYS_INPUT_BUTTON_ATCK2(s)
Definition player.qh:154
float game_stopped
Definition stats.qh:81
vector real_origin(entity ent)
Definition util.qc:147
vector findbetterlocation(vector org, float mindist)
Definition util.qc:116
float autocvar_crosshair_alpha
Definition crosshair.qh:11
vector v_up
const float DRAWFLAG_NORMAL
const float SOLID_SLIDEBOX
entity trace_ent
vector pmove_vel
float DPCONTENTS_SOLID
const float DRAWFLAG_ADDITIVE
vector avelocity
vector pmove_org
float DPCONTENTS_LIQUIDSMASK
const float SOLID_CORPSE
vector velocity
const float SOLID_NOT
float effects
float time
vector v_right
vector trace_endpos
float nextthink
vector v_forward
vector origin
vector oldorigin
const float EF_NODRAW
#define CSQCMODEL_AUTOUPDATE(e)
float RadiusDamage(entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity cantbe, entity mustbe, float forceintensity, int deathtype,.entity weaponentity, entity directhitentity)
Definition damage.qc:943
#define DMG_NOWEP
Definition damage.qh:104
#define gettagindex
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:120
ent angles
Definition ent_cs.qc:121
#define IL_EACH(this, cond, body)
#define TC(T, sym)
Definition _all.inc:82
noref float vid_conwidth
Definition draw.qh:8
noref float vid_conheight
Definition draw.qh:9
#define STAT(...)
Definition stats.qh:82
float MSG_ONE
Definition menudefs.qc:56
float bound(float min, float value, float max)
float random(void)
float vlen(vector v)
vector vectoangles(vector v)
vector randomvec(void)
float min(float f,...)
vector normalize(vector v)
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_WALK
Definition movetypes.qh:132
const int MOVETYPE_NONE
Definition movetypes.qh:129
const int MOVETYPE_BOUNCEMISSILE
Definition movetypes.qh:140
const int MOVETYPE_NOCLIP
Definition movetypes.qh:137
const int MOVETYPE_TOSS
Definition movetypes.qh:135
const int MOVETYPE_BOUNCE
Definition movetypes.qh:139
var void func_null()
#define METHOD(cname, name, prototype)
Definition oo.qh:269
#define NULL
Definition post.qh:14
#define makevectors
Definition post.qh:21
#define gettaginfo
Definition post.qh:32
float DEAD_DYING
Definition progsdefs.qc:275
entity msg_entity
Definition progsdefs.qc:63
float deadflag
Definition progsdefs.qc:149
float DEAD_DEAD
Definition progsdefs.qc:276
entity bomb2
Definition raptor.qc:59
void raptor_land(entity this)
Definition raptor.qc:61
float autocvar_g_vehicle_raptor_shield
Definition raptor.qc:50
float autocvar_g_vehicle_raptor_energy
Definition raptor.qc:42
float autocvar_g_vehicle_raptor_cannon_turnspeed
Definition raptor.qc:31
float autocvar_g_vehicle_raptor_cannon_pitchlimit_down
Definition raptor.qc:34
float autocvar_g_vehicle_raptor_bouncestop
Definition raptor.qc:55
float autocvar_g_vehicle_raptor_health
Definition raptor.qc:46
float autocvar_g_vehicle_raptor_turnspeed
Definition raptor.qc:19
float autocvar_g_vehicle_raptor_cannon_locking_releasetime
Definition raptor.qc:38
float autocvar_g_vehicle_raptor_speed_up
Definition raptor.qc:25
float autocvar_g_vehicle_raptor_cannon_predicttarget
Definition raptor.qc:40
float autocvar_g_vehicle_raptor_energy_regen_pause
Definition raptor.qc:44
entity bomb1
Definition raptor.qc:58
float autocvar_g_vehicle_raptor_bouncefactor
Definition raptor.qc:54
void raptor_blowup(entity this, entity toucher)
Definition raptor.qc:489
float autocvar_g_vehicle_raptor_pitchlimit
Definition raptor.qc:21
vector autocvar_g_vehicle_raptor_bouncepain
Definition raptor.qc:56
float autocvar_g_vehicle_raptor_respawntime
Definition raptor.qc:13
bool autocvar_g_vehicle_raptor
Definition raptor.qc:11
bool raptor_takeoff(entity this, float dt)
Definition raptor.qc:435
float autocvar_g_vehicle_raptor_health_regen_pause
Definition raptor.qc:48
int autocvar_g_vehicle_raptor_movestyle
Definition raptor.qc:18
float autocvar_g_vehicle_raptor_cannon_locking_time
Definition raptor.qc:37
bool autocvar_g_vehicle_raptor_swim
Definition raptor.qc:29
float autocvar_g_vehicle_raptor_cannon_turnlimit
Definition raptor.qc:32
float autocvar_g_vehicle_raptor_speed_down
Definition raptor.qc:26
float autocvar_g_vehicle_raptor_shield_regen_pause
Definition raptor.qc:52
void raptor_diethink(entity this)
Definition raptor.qc:517
float autocvar_g_vehicle_raptor_energy_regen
Definition raptor.qc:43
float autocvar_g_vehicle_raptor_shield_regen
Definition raptor.qc:51
float autocvar_g_vehicle_raptor_cannon_locked_time
Definition raptor.qc:39
float autocvar_g_vehicle_raptor_takeofftime
Definition raptor.qc:14
void raptor_rotor_anglefix(entity this)
Definition raptor.qc:537
float autocvar_g_vehicle_raptor_speed_forward
Definition raptor.qc:23
float autocvar_g_vehicle_raptor_cannon_pitchlimit_up
Definition raptor.qc:33
float autocvar_g_vehicle_raptor_friction
Definition raptor.qc:27
float autocvar_g_vehicle_raptor_health_regen
Definition raptor.qc:47
void raptor_exit(entity this, int eject)
Definition raptor.qc:86
bool raptor_impulse(entity this, int _imp)
Definition raptor.qc:544
bool raptor_frame(entity this, float dt)
Definition raptor.qc:135
float autocvar_g_vehicle_raptor_speed_strafe
Definition raptor.qc:24
bool autocvar_g_vehicle_raptor_cannon_locktarget
Definition raptor.qc:36
float autocvar_g_vehicle_raptor_pitchspeed
Definition raptor.qc:20
const int RSM_BOMB
Definition raptor.qh:30
const int RSM_LAST
Definition raptor.qh:32
const int RSM_FIRST
Definition raptor.qh:29
const int RSM_FLARE
Definition raptor.qh:31
float autocvar_g_vehicle_raptor_cannon_speed
float autocvar_g_vehicle_raptor_bombs_refire
float autocvar_g_vehicle_raptor_flare_refire
float health
Legacy fields for the resources. To be removed.
Definition resources.qh:9
#define setthink(e, f)
vector
Definition self.qh:92
entity entity toucher
Definition self.qh:72
#define settouch(e, f)
Definition self.qh:73
IntrusiveList g_projectiles
Definition common.qh:58
const int CH_TRIGGER_SINGLE
Definition sound.qh:13
const float VOL_BASE
Definition sound.qh:36
const int CH_PAIN_SINGLE
Definition sound.qh:19
const int CH_SHOTS
Definition sound.qh:14
const float ATTEN_NONE
Definition sound.qh:27
const float ATTEN_NORM
Definition sound.qh:30
#define sound(e, c, s, v, a)
Definition sound.qh:52
void soundto(int _dest, entity e, int chan, string samp, float vol, float _atten, float _pitch)
Definition all.qc:74
#define SND(id)
Definition all.qh:35
#define spawnfunc(id)
Definition spawnfunc.qh:96
ClientState CS(Client this)
Definition state.qh:47
#define PAGE_TEXT
Definition string.qh:642
#define PAR(...)
Adds an individually translatable paragraph to PAGE_TEXT without having to deal with strcat and sprin...
Definition string.qh:648
#define PAGE_TEXT_INIT()
Definition string.qh:641
const int DAMAGE_NO
Definition subs.qh:79
vector pos1
Definition subs.qh:50
entity enemy
Definition sv_ctf.qh:153
entity tur_head
Definition sv_turrets.qh:28
void vehicles_impact(entity this, float _minspeed, float _speedfac, float _maxpain)
bool vehicle_initialize(entity this, Vehicle info, bool nodrop)
void vehicles_regen(entity this, float timer,.float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale)
vector vehicles_findgoodexit(entity this, entity player, vector prefer_spot)
void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, int axh_id)
void vehicles_think(entity this)
void vehicles_regen_resource(entity this, float timer,.float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale, Resource resource)
void CSQCVehicleSetup(entity own, int vehicle_id)
vector vehicle_aimturret(entity _vehic, vector _target, entity _turrret, string _tagname, float _pichlimit_min, float _pichlimit_max, float _rotlimit_min, float _rotlimit_max, float _aimspeed, float dt)
void vehicles_frame(entity this, entity actor)
void vehicles_locktarget(entity this, float incr, float decr, float _lock_time)
const float vehicle_shield
If ent is player this is 0..100 indicating precentage of shield left on vehicle. If ent is vehicle,...
const float vehicle_reload2
If ent is player this is 0..100 indicating percentage of secondary reload status. If ent is vehicle,...
const float vehicle_health
If ent is player this is 0..100 indicating precentage of health left on vehicle. Vehicle's value is t...
const float vehicle_energy
If ent is player this is 0..100 indicating precentage of energy left on vehicle. If ent is vehicle,...
#define VEHICLE_UPDATE_PLAYER(ply, vehi, fld, vhname)
const float VOL_VEHICLEENGINE
const int VHEF_NORMAL
User pressed exit key.
#define VEHICLE_UPDATE_PLAYER_RESOURCE(ply, vehi, fld, vhname, res)
entity gun1
entity vehicle
entity gun2
const float vehicle_ammo2
If ent is player this is 0..100 indicating percentage of secondary ammo left. If ent is vehicle,...
bool teamplay
Definition teams.qh:59
void crosshair_trace(entity pl)
Definition tracing.qc:542
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8
const int VHF_HASSHIELD
Vehicle has shileding.
Definition vehicle.qh:95
const int VHF_HEALTHREGEN
Vehicles health regenerates.
Definition vehicle.qh:97
const int VHF_ENERGYREGEN
Vehicles energy regenerates.
Definition vehicle.qh:98
const int VHF_SHIELDREGEN
Vehicles shield regenerates.
Definition vehicle.qh:96
float vehicle_altitude(entity this, float amax)
Definition vehicles.qc:4
vector project_3d_to_2d(vector vec)
Definition view.qc:373
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17
bool weaponUseForbidden(entity player)
bool weaponLocked(entity player)