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#if defined(SVQC)
5#elif defined(MENUQC)
6 #include "spiderbot.qh"
7#endif
8
9#ifdef GAMEQC
10
11#ifdef SVQC
12
14
17
18// 0: go where player aims, +forward etc relative to aim angles
19// 1: ignore aim for up/down movement. +forward always moved forward, +jump always moves up
24
30
32
37
43
47
51
55
59
60.entity bomb1;
61.entity bomb2;
62
64{
65 float hgt;
66
67 hgt = vehicle_altitude(this, 512);
68 this.velocity = (this.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * PHYS_INPUT_FRAMETIME);
69 this.angles_x *= 0.95;
70 this.angles_z *= 0.95;
71
72 if(hgt < 128 && hgt > 0)
73 this.frame = (hgt / 128) * 25;
74
75 this.bomb1.gun1.avelocity_y = 90 + ((this.frame / 25) * 2000);
76 this.bomb1.gun2.avelocity_y = -this.bomb1.gun1.avelocity_y;
77
78 if(hgt < 16)
79 {
82 this.frame = 0;
83 }
84
85 this.nextthink = time;
86
88}
89
90void raptor_exit(entity this, int eject)
91{
92 entity player = this.owner;
93
94 this.tur_head.exteriormodeltoclient = NULL;
95
96 if(!IS_DEAD(this))
97 {
98 setthink(this, raptor_land);
99 this.nextthink = time;
100 }
101
102 if(!player)
103 return;
104
105 makevectors(this.angles);
106 vector spot;
107 if(eject)
108 {
109 spot = this.origin + v_forward * 100 + '0 0 64';
110 spot = vehicles_findgoodexit(this, player, spot);
111 setorigin(player, spot);
112 player.velocity = (v_up + v_forward * 0.25) * 750;
113 player.oldvelocity = player.velocity;
114 }
115 else
116 {
117 if(vdist(this.velocity, >, 2 * autocvar_sv_maxairspeed))
118 {
119 player.velocity = normalize(this.velocity) * autocvar_sv_maxairspeed * 2;
120 player.velocity_z += 200;
121 spot = this.origin + v_forward * 32 + '0 0 64';
122 spot = vehicles_findgoodexit(this, player, spot);
123 }
124 else
125 {
126 player.velocity = this.velocity * 0.5;
127 player.velocity_z += 10;
128 spot = this.origin - v_forward * 200 + '0 0 64';
129 spot = vehicles_findgoodexit(this, player, spot);
130 }
131 player.oldvelocity = player.velocity;
132 setorigin(player, spot);
133 }
134
135 this.owner = NULL;
136 antilag_clear(player, CS(player));
137}
138
139bool raptor_frame(entity this, float dt)
140{
141 entity vehic = this.vehicle;
142 return = true;
143
144 if(game_stopped)
145 {
146 vehic.solid = SOLID_NOT;
147 vehic.takedamage = DAMAGE_NO;
149 return;
150 }
151
152 vehicles_frame(vehic, this);
153
154 /*
155 ftmp = vlen(vehic.velocity);
156 if(ftmp > autocvar_g_vehicle_raptor_speed_forward)
157 ftmp = 1;
158 else
159 ftmp = ftmp / autocvar_g_vehicle_raptor_speed_forward;
160 */
161
162 if(vehic.sound_nexttime < time)
163 {
164 vehic.sound_nexttime = time + 7.955812;
165 //sound (vehic.tur_head, CH_TRIGGER_SINGLE, SND_VEH_RAPTOR_FLY, 1 - ftmp, ATTEN_NORM );
166 sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_RAPTOR_SPEED, 1, ATTEN_NORM);
167 vehic.wait = 0;
168 }
169 /*
170 else if(fabs(ftmp - vehic.wait) > 0.2)
171 {
172 sound (vehic.tur_head, CH_TRIGGER_SINGLE, SND_Null, 1 - ftmp, ATTEN_NORM );
173 sound (vehic, CH_TRIGGER_SINGLE, SND_Null, ftmp, ATTEN_NORM);
174 vehic.wait = ftmp;
175 }
176 */
177
178 if(IS_DEAD(vehic))
179 {
181 return;
182 }
183 crosshair_trace(this);
184
185 //if(time - vehic.lastteleporttime < 1)
186 //{
187 if(vehic.angles_z > 50 || vehic.angles_z < -50)
188 {
189 if(PHYS_INPUT_BUTTON_JUMP(this))
190 {
191 PHYS_INPUT_BUTTON_CROUCH(this) = true;
192 PHYS_INPUT_BUTTON_JUMP(this) = false;
193 }
194 }
195 //}
196
197 vector vang;
198 vang = vehic.angles;
199 vector df = vectoangles(normalize(trace_endpos - vehic.origin + '0 0 32'));
200 vang_x *= -1;
201 df_x *= -1;
202 if(df_x > 180) df_x -= 360;
203 if(df_x < -180) df_x += 360;
204 if(df_y > 180) df_y -= 360;
205 if(df_y < -180) df_y += 360;
206
207 float ftmp = shortangle_f(this.v_angle_y - vang_y, vang_y);
208 if(ftmp > 180) ftmp -= 360; if(ftmp < -180) ftmp += 360;
209 vehic.avelocity_y = bound(-autocvar_g_vehicle_raptor_turnspeed, ftmp + vehic.avelocity_y * 0.9, autocvar_g_vehicle_raptor_turnspeed);
210
211 // Pitch
212 ftmp = 0;
213 if(CS(this).movement_x > 0 && vang_x < autocvar_g_vehicle_raptor_pitchlimit) ftmp = 5;
214 else if(CS(this).movement_x < 0 && vang_x > -autocvar_g_vehicle_raptor_pitchlimit) ftmp = -20;
215
218 vehic.avelocity_x = bound(-autocvar_g_vehicle_raptor_pitchspeed, ftmp + vehic.avelocity_x * 0.9, autocvar_g_vehicle_raptor_pitchspeed);
219
220 vehic.angles_x = anglemods(vehic.angles_x);
221 vehic.angles_y = anglemods(vehic.angles_y);
222 vehic.angles_z = anglemods(vehic.angles_z);
223
225 makevectors('0 1 0' * vehic.angles_y);
226 else
227 makevectors(this.v_angle);
228
229 df = vehic.velocity * -autocvar_g_vehicle_raptor_friction;
230
231 if(CS(this).movement_x != 0)
232 {
233 if(CS(this).movement_x > 0)
235 else if(CS(this).movement_x < 0)
237 }
238
239 if(CS(this).movement_y != 0)
240 {
241 if(CS(this).movement_y < 0)
243 else if(CS(this).movement_y > 0)
245
246 vehic.angles_z = bound(-30,vehic.angles_z + (CS(this).movement_y / autocvar_g_vehicle_raptor_speed_strafe),30);
247 }
248 else
249 {
250 vehic.angles_z *= 0.95;
251 if(vehic.angles_z >= -1 && vehic.angles_z <= -1)
252 vehic.angles_z = 0;
253 }
254
257 else if (PHYS_INPUT_BUTTON_JUMP(this))
259
260 vehic.velocity += df * dt;
261 this.velocity = CS(this).movement = vehic.velocity;
262 setorigin(this, vehic.origin + '0 0 32');
263 this.oldorigin = this.origin; // negate fall damage
264
265 STAT(VEHICLESTAT_W2MODE, this) = STAT(VEHICLESTAT_W2MODE, vehic);
266
267 vector vf, ad;
268 // Target lock & predict
270 {
271 if(vehic.gun1.lock_time < time || IS_DEAD(vehic.gun1.enemy) || STAT(FROZEN, vehic.gun1.enemy))
272 vehic.gun1.enemy = NULL;
273
274 if(trace_ent)
275 if(trace_ent.move_movetype)
276 if(trace_ent.takedamage)
277 if(!IS_DEAD(trace_ent) && !STAT(FROZEN, trace_ent))
278 {
279 if(teamplay)
280 {
281 if(trace_ent.team != this.team)
282 {
283 vehic.gun1.enemy = trace_ent;
284 vehic.gun1.lock_time = time + 5;
285 }
286 }
287 else
288 {
289 vehic.gun1.enemy = trace_ent;
290 vehic.gun1.lock_time = time + 0.5;
291 }
292 }
293
294 if(vehic.gun1.enemy)
295 {
296 float distance, impact_time;
297
298 vf = real_origin(vehic.gun1.enemy);
299 UpdateAuxiliaryXhair(this, vf, '1 0 0', 1);
300 vector _vel = vehic.gun1.enemy.velocity;
301 if(vehic.gun1.enemy.move_movetype == MOVETYPE_WALK)
302 _vel_z *= 0.1;
303
305 {
306 ad = vf;
307 distance = vlen(ad - this.origin);
308 impact_time = distance / autocvar_g_vehicle_raptor_cannon_speed;
309 ad = vf + _vel * impact_time;
310 trace_endpos = ad;
311 }
312 else
313 trace_endpos = vf;
314 }
315 }
317 {
318
322
323 if(vehic.lock_target != NULL)
325 if(vehic.lock_strength == 1)
326 {
327 float i, distance, impact_time;
328
329 vf = real_origin(vehic.lock_target);
330 ad = vf;
331 for(i = 0; i < 4; ++i)
332 {
333 distance = vlen(ad - vehic.origin);
334 impact_time = distance / autocvar_g_vehicle_raptor_cannon_speed;
335 ad = vf + vehic.lock_target.velocity * impact_time;
336 }
337 trace_endpos = ad;
338 }
339
340 if(vehic.lock_target)
341 {
342 if(vehic.lock_strength == 1)
343 UpdateAuxiliaryXhair(this, real_origin(vehic.lock_target), '1 0 0', 1);
344 else if(vehic.lock_strength > 0.5)
345 UpdateAuxiliaryXhair(this, real_origin(vehic.lock_target), '0 1 0', 1);
346 else if(vehic.lock_strength < 0.5)
347 UpdateAuxiliaryXhair(this, real_origin(vehic.lock_target), '0 0 1', 1);
348 }
349 }
350
351
352 vehicle_aimturret(vehic, trace_endpos, vehic.gun1, "fire1",
355
356 vehicle_aimturret(vehic, trace_endpos, vehic.gun2, "fire1",
359
360 /*
361 ad = ad * 0.5;
362 v_forward = vf * 0.5;
363 traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, vehic);
364 UpdateAuxiliaryXhair(this, trace_endpos, '0 1 0', 0);
365 */
366
367 Weapon wep1 = WEP_RAPTOR;
368 .entity weaponentity = weaponentities[0];
369 if(!weaponLocked(this) && !weaponUseForbidden(this))
370 if(PHYS_INPUT_BUTTON_ATCK(this))
371 if (wep1.wr_checkammo1(wep1, vehic, weaponentity))
372 {
373 wep1.wr_think(wep1, vehic, weaponentity, 1);
374 }
375
376 if(vehic.vehicle_flags & VHF_SHIELDREGEN)
378
379 if(vehic.vehicle_flags & VHF_HEALTHREGEN)
381
382 if(vehic.vehicle_flags & VHF_ENERGYREGEN)
384
385 Weapon wep2a = WEP_RAPTOR_BOMB;
386 if(!weaponLocked(this) && !weaponUseForbidden(this))
387 if(STAT(VEHICLESTAT_W2MODE, vehic) == RSM_BOMB)
388 {
391 {
392 .entity weaponentity = weaponentities[1];
393 wep2a.wr_think(wep2a, vehic, weaponentity, 2);
395 vehic.lip = time;
396 }
397 }
398 else
399 {
400 Weapon wep2b = WEP_RAPTOR_FLARE;
403 {
404 .entity weaponentity = weaponentities[1];
405 wep2b.wr_think(wep2b, vehic, weaponentity, 2);
407 vehic.lip = time;
408 }
409 }
410
411 vehic.bomb1.alpha = vehic.bomb2.alpha = (time - vehic.lip) / (vehic.delay - vehic.lip);
412 this.vehicle_reload2 = bound(0, vehic.bomb1.alpha * 100, 100);
413 this.vehicle_ammo2 = (this.vehicle_reload2 == 100) ? 100 : 0;
414
415 if(vehic.bomb1.cnt < time)
416 {
417 bool incoming = false;
418 IL_EACH(g_projectiles, it.enemy == vehic,
419 {
420 if(it.missile_flags & MIF_GUIDED_TRACKING)
421 if(vdist(vehic.origin - it.origin, <, 2 * autocvar_g_vehicle_raptor_flare_range))
422 {
423 incoming = true;
424 break;
425 }
426 });
427
428 if(incoming)
429 {
430 msg_entity = this;
431 soundto(MSG_ONE, vehic, CH_PAIN_SINGLE, SND(VEH_MISSILE_ALARM), VOL_BASE, ATTEN_NONE, 0);
432 }
433
434 vehic.bomb1.cnt = time + 1;
435 }
436
437
438 VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, raptor, RES_HEALTH);
439 VEHICLE_UPDATE_PLAYER(this, vehic, energy, raptor);
440 if(vehic.vehicle_flags & VHF_HASSHIELD)
441 VEHICLE_UPDATE_PLAYER(this, vehic, shield, raptor);
442
444}
445
446bool raptor_takeoff(entity this, float dt)
447{
448 entity vehic = this.vehicle;
449 return = true;
450
451 vehic.nextthink = time;
453 vehic.nextthink = 0; // will this work?
454
455 if(vehic.sound_nexttime < time)
456 {
457 vehic.sound_nexttime = time + 7.955812; //soundlength("vehicles/raptor_fly.wav");
458 sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_RAPTOR_SPEED, VOL_VEHICLEENGINE, ATTEN_NORM);
459 }
460
461 // Takeoff sequense
462 if(vehic.frame < 25)
463 {
464 vehic.frame += 25 / (autocvar_g_vehicle_raptor_takeofftime / dt);
465 vehic.velocity_z = min(vehic.velocity_z * 1.5, 256);
466 vehic.bomb1.gun1.avelocity_y = 90 + ((vehic.frame / 25) * 25000);
467 vehic.bomb1.gun2.avelocity_y = -vehic.bomb1.gun1.avelocity_y;
469
470 setorigin(this, vehic.origin + '0 0 32');
471 this.oldorigin = this.origin;
472 }
473 else
474 this.PlayerPhysplug = raptor_frame;
475
476 STAT(VEHICLESTAT_W2MODE, this) = STAT(VEHICLESTAT_W2MODE, vehic);
477
478 if(vehic.vehicle_flags & VHF_SHIELDREGEN)
480
481 if(vehic.vehicle_flags & VHF_HEALTHREGEN)
483
484 if(vehic.vehicle_flags & VHF_ENERGYREGEN)
486
487
488 vehic.bomb1.alpha = vehic.bomb2.alpha = (time - vehic.lip) / (vehic.delay - vehic.lip);
489 this.vehicle_reload2 = bound(0, vehic.bomb1.alpha * 100, 100);
490 this.vehicle_ammo2 = (this.vehicle_reload2 == 100) ? 100 : 0;
491
492 VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, raptor, RES_HEALTH);
493 VEHICLE_UPDATE_PLAYER(this, vehic, energy, raptor);
494 if(vehic.vehicle_flags & VHF_HASSHIELD)
495 VEHICLE_UPDATE_PLAYER(this, vehic, shield, raptor);
496
498}
499
501{
502 this.deadflag = DEAD_DEAD;
503 this.vehicle_exit(this, VHEF_NORMAL);
504 RadiusDamage (this, this.enemy, 250, 15, 250, NULL, NULL, 250, DEATH_VH_RAPT_DEATH.m_id, DMG_NOWEP, NULL);
505
506 this.alpha = -1;
508 this.effects = EF_NODRAW;
509 this.colormod = '0 0 0';
510 this.avelocity = '0 0 0';
511 this.velocity = '0 0 0';
512
513 setorigin(this, this.pos1);
514 settouch(this, func_null);
515 this.nextthink = 0;
516}
517
519{
520 if(time >= this.wait)
521 {
522 raptor_blowup(this, NULL);
523 return;
524 }
525
526 if(random() < 0.05)
527 {
528 sound (this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
529 Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (this.origin + '0 0 100'), '0 0 0', 1);
530 }
531 this.nextthink = time;
532
534}
535
536// If we dont do this ever now and then, the raptors rotors
537// stop working, presumably due to angle overflow. cute.
539{
540 this.gun1.angles_y = anglemods(this.gun1.angles_y);
541 this.gun2.angles_y = anglemods(this.gun2.angles_y);
542 this.nextthink = time + 15;
543}
544
545bool raptor_impulse(entity this, int _imp)
546{
547 switch(_imp)
548 {
549 case IMP_weapon_group_1.impulse:
550 STAT(VEHICLESTAT_W2MODE, this.vehicle) = RSM_BOMB;
551 CSQCVehicleSetup(this, 0);
552 return true;
553 case IMP_weapon_group_2.impulse:
554 STAT(VEHICLESTAT_W2MODE, this.vehicle) = RSM_FLARE;
555 CSQCVehicleSetup(this, 0);
556 return true;
557
558 case IMP_weapon_next_byid.impulse:
559 case IMP_weapon_next_bypriority.impulse:
560 case IMP_weapon_next_bygroup.impulse:
561 STAT(VEHICLESTAT_W2MODE, this.vehicle) += 1;
562 if(STAT(VEHICLESTAT_W2MODE, this.vehicle) > RSM_LAST)
563 STAT(VEHICLESTAT_W2MODE, this.vehicle) = RSM_FIRST;
564
565 CSQCVehicleSetup(this, 0);
566 return true;
567 case IMP_weapon_last.impulse:
568 case IMP_weapon_prev_byid.impulse:
569 case IMP_weapon_prev_bypriority.impulse:
570 case IMP_weapon_prev_bygroup.impulse:
571 STAT(VEHICLESTAT_W2MODE, this.vehicle) -= 1;
572 if(STAT(VEHICLESTAT_W2MODE, this.vehicle) < RSM_FIRST)
573 STAT(VEHICLESTAT_W2MODE, this.vehicle) = RSM_LAST;
574
575 CSQCVehicleSetup(this, 0);
576 return true;
577
578 /*
579 case IMP_weapon_drop.impulse: // toss gun, could be used to exit?
580 break;
581 case IMP_weapon_reload.impulse: // Manual minigun reload?
582 break;
583 */
584 }
585 return false;
586}
587
588spawnfunc(vehicle_raptor)
589{
590 if(!autocvar_g_vehicle_raptor) { delete(this); return; }
591 if(!vehicle_initialize(this, VEH_RAPTOR, false)) { delete(this); return; }
592}
593
594METHOD(Raptor, vr_impact, void(Raptor thisveh, entity instance))
595{
597 vehicles_impact(instance, autocvar_g_vehicle_raptor_bouncepain_x, autocvar_g_vehicle_raptor_bouncepain_y, autocvar_g_vehicle_raptor_bouncepain_z);
598}
599METHOD(Raptor, vr_enter, void(Raptor thisveh, entity instance))
600{
601 STAT(VEHICLESTAT_W2MODE, instance) = RSM_BOMB;
602 instance.owner.PlayerPhysplug = raptor_takeoff;
604 instance.solid = SOLID_SLIDEBOX;
605 instance.owner.vehicle_health = (GetResource(instance, RES_HEALTH) / autocvar_g_vehicle_raptor_health) * 100;
606 instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_raptor_shield) * 100;
607 instance.velocity = '0 0 1'; // nudge upwards so takeoff sequence can work
608 instance.tur_head.exteriormodeltoclient = instance.owner;
609
611 instance.lip = time;
612
613 if(instance.owner.flagcarried)
614 setorigin(instance.owner.flagcarried, '-20 0 96');
615
616 CSQCVehicleSetup(instance.owner, 0);
617}
618METHOD(Raptor, vr_death, void(Raptor thisveh, entity instance))
619{
620 SetResourceExplicit(instance, RES_HEALTH, 0);
621 instance.event_damage = func_null;
622 instance.solid = SOLID_CORPSE;
623 instance.takedamage = DAMAGE_NO;
624 instance.deadflag = DEAD_DYING;
625 set_movetype(instance, MOVETYPE_BOUNCE);
626 setthink(instance, raptor_diethink);
627 instance.nextthink = time;
628 instance.wait = time + 5 + (random() * 5);
629
630 Send_Effect(EFFECT_EXPLOSION_MEDIUM, findbetterlocation (instance.origin, 16), '0 0 0', 1);
631
632 instance.velocity_z += 600;
633
634 instance.avelocity = '0 0.5 1' * (random() * 400);
635 instance.avelocity -= '0 0.5 1' * (random() * 400);
636
637 instance.colormod = '-0.5 -0.5 -0.5';
638 settouch(instance, raptor_blowup);
639}
640METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance))
641{
642 if(!instance.gun1)
643 {
644 entity spinner;
645 vector ofs;
646
647 //FIXME: Camera is in a bad place in HUD model.
648 //setorigin(instance.vehicle_viewport, '25 0 5');
649
650 instance.vehicles_impulse = raptor_impulse;
651
652 instance.frame = 0;
653
654 instance.bomb1 = new(raptor_bomb);
655 instance.bomb2 = new(raptor_bomb);
656 instance.gun1 = new(raptor_gun);
657 instance.gun2 = new(raptor_gun);
658
659 setmodel(instance.bomb1, MDL_VEH_RAPTOR_CB_FOLDED);
660 setmodel(instance.bomb2, MDL_VEH_RAPTOR_CB_FOLDED);
661 setmodel(instance.gun1, MDL_VEH_RAPTOR_GUN);
662 setmodel(instance.gun2, MDL_VEH_RAPTOR_GUN);
663 setmodel(instance.tur_head, MDL_VEH_RAPTOR_TAIL);
664
665 setattachment(instance.bomb1, instance, "bombmount_left");
666 setattachment(instance.bomb2, instance, "bombmount_right");
667 setattachment(instance.tur_head, instance,"root");
668
669 // FIXMODEL Guns mounts to angled bones
670 instance.bomb1.angles = instance.angles;
671 instance.angles = '0 0 0';
672 // This messes up gun-aim, so work arround it.
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 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
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 vector where;
782
783 if(!dropmark)
784 {
785 dropmark = new(raptor_dropmark);
786 dropmark.owner = player;
787 dropmark.gravity = 1;
788 dropmark.dphitcontentsmask = DPCONTENTS_SOLID;
789 dropmark.solid = SOLID_CORPSE;
791 }
792
793 float reload2 = STAT(VEHICLESTAT_RELOAD2) * 0.01;
794 if(reload2 == 1)
795 {
796 setorigin(dropmark, pmove_org);
797 dropmark.velocity = pmove_vel;
798 tracetoss(dropmark, player);
799
801
802 setorigin(dropmark, trace_endpos);
803
804 if (!(where.z < 0 || where.x < 0 || where.y < 0 || where.x > vid_conwidth || where.y > vid_conheight))
805 {
806 tmpSize = draw_getimagesize(vCROSS_DROP) * autocvar_cl_vehicles_crosshair_size;
807 where.x -= tmpSize.x * 0.5;
808 where.y -= tmpSize.y * 0.5;
809 where.z = 0;
810 drawpic(where, vCROSS_DROP, tmpSize, '0 1 0', autocvar_crosshair_alpha * 0.9, DRAWFLAG_ADDITIVE);
811 drawpic(where, vCROSS_DROP, tmpSize, '0 1 0', autocvar_crosshair_alpha * 0.6, DRAWFLAG_NORMAL); // Ensure visibility against bright bg
812 }
813 dropmark.cnt = time + 5;
814 }
815 else
816 {
817 if(dropmark.cnt > time)
818 {
819 where = project_3d_to_2d(dropmark.origin);
820
821 if (!(where.z < 0 || where.x < 0 || where.y < 0 || where.x > vid_conwidth || where.y > vid_conheight))
822 {
823 tmpSize = draw_getimagesize(vCROSS_DROP) * autocvar_cl_vehicles_crosshair_size * 1.25;
824 where.x -= tmpSize.x * 0.5;
825 where.y -= tmpSize.y * 0.5;
826 where.z = 0;
827 drawpic(where, vCROSS_DROP, tmpSize, '1 0 0', autocvar_crosshair_alpha * 0.9, DRAWFLAG_ADDITIVE);
828 drawpic(where, vCROSS_DROP, tmpSize, '1 0 0', autocvar_crosshair_alpha * 0.6, DRAWFLAG_NORMAL); // Ensure visibility against bright bg
829 }
830 }
831 }
832 }
833
834 Vehicles_drawCrosshair(crosshair);
835}
836METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance))
837{
838 AuxiliaryXhair[1].axh_image = vCROSS_LOCK;
839}
840
841#endif
842
843#endif
844#ifdef MENUQC
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
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:44
virtual void wr_think()
(SERVER) logic to run every frame
Definition weapon.qh:90
virtual void wr_checkammo1()
(SERVER) checks ammo for weapon primary
Definition weapon.qh:92
#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:154
#define IS_DEAD(s)
Definition player.qh:245
#define PHYS_INPUT_BUTTON_JUMP(s)
Definition player.qh:151
#define PHYS_INPUT_FRAMETIME
Definition player.qh:255
vector v_angle
Definition player.qh:237
float autocvar_sv_maxairspeed
Definition player.qh:52
#define PHYS_INPUT_BUTTON_ATCK(s)
Definition player.qh:150
#define PHYS_INPUT_BUTTON_ATCK2(s)
Definition player.qh:152
float game_stopped
Definition stats.qh:81
vector real_origin(entity ent)
Definition util.qc:148
vector findbetterlocation(vector org, float mindist)
Definition util.qc:117
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:981
#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:124
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:61
void raptor_land(entity this)
Definition raptor.qc:63
float autocvar_g_vehicle_raptor_shield
Definition raptor.qc:52
float autocvar_g_vehicle_raptor_energy
Definition raptor.qc:44
float autocvar_g_vehicle_raptor_cannon_turnspeed
Definition raptor.qc:33
float autocvar_g_vehicle_raptor_cannon_pitchlimit_down
Definition raptor.qc:36
float autocvar_g_vehicle_raptor_bouncestop
Definition raptor.qc:57
float autocvar_g_vehicle_raptor_health
Definition raptor.qc:48
float autocvar_g_vehicle_raptor_turnspeed
Definition raptor.qc:21
float autocvar_g_vehicle_raptor_cannon_locking_releasetime
Definition raptor.qc:40
float autocvar_g_vehicle_raptor_speed_up
Definition raptor.qc:27
float autocvar_g_vehicle_raptor_cannon_predicttarget
Definition raptor.qc:42
float autocvar_g_vehicle_raptor_energy_regen_pause
Definition raptor.qc:46
entity bomb1
Definition raptor.qc:60
float autocvar_g_vehicle_raptor_bouncefactor
Definition raptor.qc:56
void raptor_blowup(entity this, entity toucher)
Definition raptor.qc:500
float autocvar_g_vehicle_raptor_pitchlimit
Definition raptor.qc:23
vector autocvar_g_vehicle_raptor_bouncepain
Definition raptor.qc:58
float autocvar_g_vehicle_raptor_respawntime
Definition raptor.qc:15
bool autocvar_g_vehicle_raptor
Definition raptor.qc:13
bool raptor_takeoff(entity this, float dt)
Definition raptor.qc:446
float autocvar_g_vehicle_raptor_health_regen_pause
Definition raptor.qc:50
int autocvar_g_vehicle_raptor_movestyle
Definition raptor.qc:20
float autocvar_g_vehicle_raptor_cannon_locking_time
Definition raptor.qc:39
bool autocvar_g_vehicle_raptor_swim
Definition raptor.qc:31
float autocvar_g_vehicle_raptor_cannon_turnlimit
Definition raptor.qc:34
float autocvar_g_vehicle_raptor_speed_down
Definition raptor.qc:28
float autocvar_g_vehicle_raptor_shield_regen_pause
Definition raptor.qc:54
void raptor_diethink(entity this)
Definition raptor.qc:518
float autocvar_g_vehicle_raptor_energy_regen
Definition raptor.qc:45
float autocvar_g_vehicle_raptor_shield_regen
Definition raptor.qc:53
float autocvar_g_vehicle_raptor_cannon_locked_time
Definition raptor.qc:41
float autocvar_g_vehicle_raptor_takeofftime
Definition raptor.qc:16
void raptor_rotor_anglefix(entity this)
Definition raptor.qc:538
float autocvar_g_vehicle_raptor_speed_forward
Definition raptor.qc:25
float autocvar_g_vehicle_raptor_cannon_pitchlimit_up
Definition raptor.qc:35
float autocvar_g_vehicle_raptor_friction
Definition raptor.qc:29
float autocvar_g_vehicle_raptor_health_regen
Definition raptor.qc:49
void raptor_exit(entity this, int eject)
Definition raptor.qc:90
bool raptor_impulse(entity this, int _imp)
Definition raptor.qc:545
bool raptor_frame(entity this, float dt)
Definition raptor.qc:139
float autocvar_g_vehicle_raptor_speed_strafe
Definition raptor.qc:26
bool autocvar_g_vehicle_raptor_cannon_locktarget
Definition raptor.qc:38
float autocvar_g_vehicle_raptor_pitchspeed
Definition raptor.qc:22
const int RSM_BOMB
Definition raptor.qh:27
const int RSM_LAST
Definition raptor.qh:29
const int RSM_FIRST
Definition raptor.qh:26
const int RSM_FLARE
Definition raptor.qh:28
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:643
#define PAR(...)
Adds an individually translatable paragraph to PAGE_TEXT without having to deal with strcat and sprin...
Definition string.qh:649
#define PAGE_TEXT_INIT()
Definition string.qh:642
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 energy left on vehicle. If ent is vehicle,...
const float vehicle_reload2
If ent is player this is 0..100 indicating percentage of secondary ammo left. If ent is vehicle,...
const float vehicle_health
const float vehicle_energy
If ent is player this is 0..100 indicating precentage of health left on vehicle. Vehicle's value is t...
#define VEHICLE_UPDATE_PLAYER(ply, vehi, fld, vhname)
const float VOL_VEHICLEENGINE
const int VHEF_NORMAL
#define VEHICLE_UPDATE_PLAYER_RESOURCE(ply, vehi, fld, vhname, res)
entity gun1
entity vehicle
Entity to disply the shild effect on damage.
entity gun2
const float vehicle_ammo2
If ent is player this is 0..100 indicating percentage of primary reload status. If ent is vehicle,...
bool teamplay
Definition teams.qh:59
void crosshair_trace(entity pl)
Definition tracing.qc:549
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8
const int VHF_HASSHIELD
Indicates vehicle.
Definition vehicle.qh:85
const int VHF_HEALTHREGEN
Vehicles shield regenerates.
Definition vehicle.qh:87
const int VHF_ENERGYREGEN
Vehicles health regenerates.
Definition vehicle.qh:88
const int VHF_SHIELDREGEN
Vehicle has shileding.
Definition vehicle.qh:86
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)