Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
sv_vehicles.qc
Go to the documentation of this file.
1#include "sv_vehicles.qh"
2
8#include <server/bot/api.qh>
9#include <server/client.qh>
10#include <server/damage.qh>
11#include <server/items/items.qh>
13#include <server/world.qh>
14
15bool SendAuxiliaryXhair(entity this, entity to, int sf)
16{
17 WriteHeader(MSG_ENTITY, ENT_CLIENT_AUXILIARYXHAIR);
19
21
22 if (sf & 2)
23 WriteVector(MSG_ENTITY, this.origin);
24
25 if (sf & 4)
26 {
27 WriteByte(MSG_ENTITY, rint(this.colormod.x * 255));
28 WriteByte(MSG_ENTITY, rint(this.colormod.y * 255));
29 WriteByte(MSG_ENTITY, rint(this.colormod.z * 255));
30 }
31
32 return true;
33}
34
36{
38 entity axh = e.(AuxiliaryXhair[this.cnt]);
39 return axh.owner == this.owner; // cheaply check if the client's axh owner is the same as our real owner
40}
41
44
45void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, int axh_id)
46{
47 if (!IS_REAL_CLIENT(own))
48 return;
49
50 axh_id = bound(0, axh_id, MAX_AXH);
51 entity axh = own.(AuxiliaryXhair[axh_id]);
52
53 if (axh == NULL || wasfreed(axh)) // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist? Mario: because of sloppy code like this)
54 {
55 axh = new(auxiliary_xhair);
56 axh.cnt = axh_id;
57 //axh.drawonlytoclient = own; // not spectatable
59 axh.owner = own;
60 Net_LinkEntity(axh, false, 0, SendAuxiliaryXhair);
61 }
62
63 if (loc != axh.axh_prevorigin)
64 {
65 setorigin(axh, loc);
66 axh.SendFlags |= 2;
67 }
68
69 if (clr != axh.axh_prevcolors)
70 {
71 axh.colormod = clr;
72 axh.SendFlags |= 4;
73 }
74
75 own.(AuxiliaryXhair[axh_id]) = axh; // set it anyway...?
76}
77
78void CSQCVehicleSetup(entity own, int vehicle_id)
79{
80 if (!IS_REAL_CLIENT(own))
81 return;
82
83 msg_entity = own;
84
85 WriteHeader(MSG_ONE, TE_CSQC_VEHICLESETUP);
86 WriteByte(MSG_ONE, vehicle_id);
87
88 if (vehicle_id == 0 || vehicle_id == HUD_NORMAL)
89 for (int i = 0; i < MAX_AXH; ++i)
90 {
91 entity axh = own.(AuxiliaryXhair[i]);
92 own.(AuxiliaryXhair[i]) = NULL;
93
94 if (axh.owner == own && axh != NULL && !wasfreed(axh))
95 delete(axh);
96 }
97}
98
99void vehicles_locktarget(entity this, float incr, float decr, float _lock_time)
100{
101 if (this.lock_target && IS_DEAD(this.lock_target))
102 {
103 this.lock_target = NULL;
104 this.lock_strength = 0;
105 this.lock_time = 0;
106 }
107
108 if (this.lock_time > time)
109 {
110 if (this.lock_target
111 && this.lock_soundtime < time)
112 {
113 this.lock_soundtime = time + 0.5;
114 play2(this.owner, "vehicles/locked.wav");
115 }
116
117 return;
118 }
119
120 if (trace_ent != NULL)
121 if (SAME_TEAM(trace_ent, this)
124 || (trace_ent.alpha <= 0.5 && trace_ent.alpha != 0)) // invisible
125 trace_ent = NULL;
126
127 if (this.lock_target == NULL && trace_ent != NULL)
128 this.lock_target = trace_ent;
129
130 if (this.lock_target && trace_ent == this.lock_target)
131 {
132 if (this.lock_strength != 1 && this.lock_strength + incr >= 1)
133 {
134 play2(this.owner, "vehicles/lock.wav");
135 this.lock_soundtime = time + 0.8;
136 }
137 else if (this.lock_strength != 1 && this.lock_soundtime < time)
138 {
139 play2(this.owner, "vehicles/locking.wav");
140 this.lock_soundtime = time + 0.3;
141 }
142 }
143
144 // Have a locking target
145 // Trace hit current target
146 if (trace_ent == this.lock_target && trace_ent != NULL)
147 {
148 this.lock_strength = min(this.lock_strength + incr, 1);
149 if (this.lock_strength == 1)
150 this.lock_time = time + _lock_time;
151 }
152 else
153 {
154 if (trace_ent)
155 this.lock_strength = max(this.lock_strength - decr * 2, 0);
156 else
157 this.lock_strength = max(this.lock_strength - decr, 0);
158
159 if (this.lock_strength == 0)
160 this.lock_target = NULL;
161 }
162}
163
164// projectile handling
165void vehicles_projectile_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
166{
167 // Ignore damage from oterh projectiles from my owner (dont mess up volly's)
168 if (inflictor.owner == this.owner)
169 return;
170
171 TakeResource(this, RES_HEALTH, damage);
172 this.velocity += force;
173 if (GetResource(this, RES_HEALTH) < 1)
174 {
175 this.takedamage = DAMAGE_NO;
176 this.event_damage = func_null;
177 setthink(this, adaptor_think2use);
178 this.nextthink = time;
179 }
180}
181
183{
184 if (this.owner && toucher != NULL)
185 {
186 if (toucher == this.owner.vehicle)
187 return;
188
189 if (toucher == this.owner.vehicle.tur_head)
190 return;
191 }
192
194
195 this.event_damage = func_null;
196 RadiusDamage(this, this.realowner,
197 this.shot_dmg,
198 0,
199 this.shot_radius,
200 this,
201 NULL,
202 this.shot_force,
204 DMG_NOWEP,
205 toucher
206 );
207
208 delete(this);
209}
210
215
217{
218 vehicles_projectile_explode(this, trigger);
219}
220
222 vector _org, vector _vel,
223 float _dmg, float _radi, float _force, float _size,
224 int _deahtype, float _projtype, float _health,
225 bool _cull, bool _clianim, entity _owner)
226{
227 TC(Sound, _mzlsound);
228 entity proj = new(vehicles_projectile);
229
231 setorigin(proj, _org);
232
233 proj.shot_dmg = _dmg;
234 proj.shot_radius = _radi;
235 proj.shot_force = _force;
236 proj.projectiledeathtype = _deahtype;
237 proj.solid = SOLID_BBOX;
239 proj.flags = FL_PROJECTILE;
240 IL_PUSH(g_projectiles, proj);
241 IL_PUSH(g_bot_dodge, proj);
242 proj.bot_dodge = true;
243 proj.bot_dodgerating = _dmg;
244 proj.velocity = _vel;
247 proj.owner = this;
248 proj.realowner = _owner;
249 setthink(proj, SUB_Remove);
250 proj.nextthink = time + 30;
251
252 if (_health)
253 {
254 proj.takedamage = DAMAGE_AIM;
255 proj.event_damage = vehicles_projectile_damage;
256 SetResourceExplicit(proj, RES_HEALTH, _health);
257 }
258 else
259 proj.flags |= FL_NOTARGET;
260
261 if (_mzlsound != SND_Null)
262 sound(this, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTEN_NORM);
263
264 if (_mzlfx != EFFECT_Null)
265 Send_Effect(_mzlfx, proj.origin, proj.velocity, 1);
266
267 setsize(proj, '-1 -1 -1' * _size, '1 1 1' * _size);
268
269 CSQCProjectile(proj, _clianim, _projtype, _cull);
270
271 return proj;
272}
273
275{
276 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
277 Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (this.origin + '0 0 100'), '0 0 0', 1);
278 Send_Effect(EFFECT_EXPLOSION_SMALL, this.wp00.origin + '0 0 64', '0 0 0', 1);
279 delete(this);
280}
281
286
288{
289 this.alpha -= 0.1;
290 if (this.cnt >= time)
291 delete(this);
292 else
293 this.nextthink = time + 0.1;
294}
295
296entity vehicle_tossgib(entity this, entity _template, vector _vel, string _tag, bool _burn, bool _explode, float _maxtime, vector _rot)
297{
298 entity _gib = new(vehicle_gib);
299 _setmodel(_gib, _template.model);
300 vector org = gettaginfo(this, gettagindex(this, _tag));
301 setorigin(_gib, org);
302 _gib.velocity = _vel;
304 _gib.solid = SOLID_CORPSE;
305 _gib.colormod = '-0.5 -0.5 -0.5';
306 _gib.effects = EF_LOWPRECISION;
307 _gib.avelocity = _rot;
308
309 if (_burn)
310 _gib.effects |= EF_FLAME;
311
312 if (_explode)
313 {
315 _gib.nextthink = time + random() * _explode;
317 }
318 else
319 {
320 _gib.cnt = time + _maxtime;
322 _gib.nextthink = time + _maxtime - 1;
323 _gib.alpha = 1;
324 }
325 return _gib;
326}
327
329 int _hud,
330 Model _hud_model,
331 bool(entity, float) _framefunc,
332 void(entity, bool) _exitfunc, float(entity, entity) _enterfunc)
333{
334 if (!(_owner.vehicle_flags & VHF_MULTISLOT))
335 _owner.vehicle_flags |= VHF_MULTISLOT;
336
337 _slot.PlayerPhysplug = _framefunc;
338 _slot.vehicle_exit = _exitfunc;
339 _slot.vehicle_enter = _enterfunc;
340 STAT(HUD, _slot) = _hud;
341 _slot.vehicle_flags = VHF_PLAYERSLOT;
342 _slot.vehicle_viewport = new(vehicle_viewport);
343 _slot.vehicle_hudmodel = new(vehicle_hudmodel);
344 _slot.vehicle_hudmodel.viewmodelforclient = _slot;
346
347 setmodel(_slot.vehicle_hudmodel, _hud_model);
348 setmodel(_slot.vehicle_viewport, MDL_Null);
349
350 setattachment(_slot.vehicle_hudmodel, _slot, "");
351 setattachment(_slot.vehicle_viewport, _slot.vehicle_hudmodel, "");
352
353 return true;
354}
355
356vector vehicle_aimturret(entity _vehic, vector _target, entity _turrret, string _tagname,
357 float _pichlimit_min, float _pichlimit_max,
358 float _rotlimit_min, float _rotlimit_max, float _aimspeed, float dt)
359{
360 vector vtag = gettaginfo(_turrret, gettagindex(_turrret, _tagname));
361 vector vtmp = vectoangles(normalize(_target - vtag));
363 vtmp = AnglesTransform_Normalize(vtmp, true);
364 float ftmp = _aimspeed * dt;
365 vtmp.y = bound(-ftmp, vtmp.y, ftmp);
366 vtmp.x = bound(-ftmp, vtmp.x, ftmp);
367 _turrret.angles.y = bound(_rotlimit_min, _turrret.angles.y + vtmp.y, _rotlimit_max);
368 _turrret.angles.x = bound(_pichlimit_min, _turrret.angles.x + vtmp.x, _pichlimit_max);
369 return vtag;
370}
371
373{
374 const vector cmod = '0 0 0';
375 int cmap;
376 if (this.team && teamplay)
377 cmap = 1024 + (this.team - 1) * 17;
378 else if (player)
379 cmap = player.colormap;
380 else
381 cmap = 1024;
382 int eff = 0;
384 eff |= EF_NODEPTHTEST;
386 eff |= EF_FULLBRIGHT;
387
388 // Find all ents attacked to main model and setup effects, colormod etc.
390 {
391 if (it == this.vehicle_shieldent)
392 continue;
393
394 it.effects = eff;
395 it.colormod = cmod;
396 it.colormap = cmap;
397 it.alpha = 1;
398 });
399
400 // Also check head tags
402 {
403 if (it == this.vehicle_shieldent)
404 continue;
405
406 it.effects = eff;
407 it.colormod = cmod;
408 it.colormap = cmap;
409 it.alpha = 1;
410 });
411
412 this.vehicle_hudmodel.effects = this.effects = eff; // | EF_LOWPRECISION;
413 this.vehicle_hudmodel.colormod = this.colormod = cmod;
414 this.vehicle_hudmodel.colormap = this.colormap = cmap;
416
417 this.alpha = 1;
418 this.avelocity = '0 0 0';
419 this.velocity = '0 0 0';
420 this.effects = eff;
421
422 Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid);
423 info.vr_setcolors(info, this);
424}
425
427{
428 // Remove "return helper" entities, if any.
429 IL_EACH(g_vehicle_returners, it.wp00 == veh,
430 {
431 it.classname = "";
432 setthink(it, SUB_Remove);
433 it.nextthink = time + 0.1;
434 IL_REMOVE(g_vehicle_returners, it);
435
436 if (it.waypointsprite_attached)
437 WaypointSprite_Kill(it.waypointsprite_attached);
438 });
439}
440
441void vehicles_spawn(entity this);
443{
444 Send_Effect(EFFECT_TELEPORT, this.wp00.origin + '0 0 64', '0 0 0', 1);
445
447 this.wp00.nextthink = time;
448
451
452 delete(this);
453}
454
456{
459
460 delete(this);
461}
462
464{
465 entity ent = this;
466
467 if (ent.cnt)
468 {
470 ent.nextthink = ent.cnt;
471 }
472 else
473 {
475 ent.nextthink = time + 1;
476
477 ent = spawn();
478 ent.team = this.wp00.team;
479 ent.wp00 = this.wp00;
480 setorigin(ent, this.wp00.pos1);
481
482 ent.nextthink = time + 5;
484 }
485
486 vector rgb = (teamplay && ent.team)
487 ? Team_ColorRGB(ent.team)
488 : '1 1 1';
489 entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, ent, '0 0 64', NULL, 0, ent, waypointsprite_attached, true, RADARICON_Vehicle);
490 wp.wp_extra = ent.wp00.vehicleid;
491 wp.colormod = rgb;
492 if (ent.waypointsprite_attached)
493 {
494 WaypointSprite_UpdateRule(ent.waypointsprite_attached, ent.wp00.team, SPRITERULE_DEFAULT);
495 if (this == NULL)
496 WaypointSprite_UpdateBuildFinished(ent.waypointsprite_attached, ent.nextthink);
497 WaypointSprite_Ping(ent.waypointsprite_attached);
498 }
499}
500
502{
504
505 entity ret = new(vehicle_return);
507 ret.wp00 = veh;
508 ret.team = veh.team;
510
511 if (IS_DEAD(veh))
512 {
513 ret.cnt = time + veh.respawntime;
514 ret.nextthink = min(time + veh.respawntime, time + veh.respawntime - 5);
515 }
516 else
517 ret.nextthink = min(time + veh.respawntime, time + veh.respawntime - 1);
518
519 setorigin(ret, veh.pos1 + '0 0 96');
520}
521
522void vehicle_use(entity this, entity actor, entity trigger)
523{
524 LOG_DEBUG("vehicle ", this.netname, " used by ", actor.classname);
525
526 this.tur_head.team = actor.team;
527
528 if (this.tur_head.team == 0)
529 this.active = ACTIVE_NOT;
530 else
531 this.active = ACTIVE_ACTIVE;
532
533 if (this.active == ACTIVE_ACTIVE && !IS_DEAD(this) && !game_stopped)
534 {
535 LOG_DEBUG("Respawning vehicle: ", this.netname);
536 if (this.effects & EF_NODRAW)
537 {
539 this.nextthink = time + 3;
540 }
541 else
542 {
543 vehicles_setreturn(this);
544 vehicles_reset_colors(this, actor);
545 }
546 }
547}
548
549void vehicles_regen(entity this, float timer, .float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale)
550{
551 if (this.(regen_field) < field_max
552 && timer + rpause < time)
553 {
554 if (_healthscale)
555 regen *= GetResource(this, RES_HEALTH) / this.max_health;
556
557 this.(regen_field) = min(this.(regen_field) + regen * delta_time, field_max);
558
559 if (this.owner)
560 this.owner.(regen_field) = (this.(regen_field) / field_max) * 100;
561 }
562}
563
564void vehicles_regen_resource(entity this, float timer, .float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale, Resource resource)
565{
566 float resource_amount = GetResource(this, resource);
567
568 if (resource_amount < field_max
569 && timer + rpause < time)
570 {
571 if (_healthscale)
572 regen *= resource_amount / this.max_health;
573
574 SetResource(this, resource, min(resource_amount + regen * delta_time, field_max));
575
576 if (this.owner)
577 this.owner.(regen_field) = (GetResource(this, resource) / field_max) * 100;
578 }
579}
580
582{
583 this.alpha -= 0.1;
584 if (this.alpha <= 0)
585 {
586 // setmodel(this, MDL_Null);
587 this.alpha = -1;
588 this.effects |= EF_NODRAW;
589 }
590 else
591 this.nextthink = time + 0.1;
592}
593
595{
596 int myhealth = (this.owner)
597 ? this.owner.vehicle_health
598 : ((GetResource(this, RES_HEALTH) / this.max_health) * 100);
599
600 if (myhealth <= 50
601 && this.pain_frame < time)
602 {
603 float _ftmp = myhealth / 50;
604 this.pain_frame = time + max(0.1, 0.1 + (random() * 0.5 * _ftmp));
605 Send_Effect(EFFECT_SMOKE_SMALL, (this.origin + (randomvec() * 80)), '0 0 0', 1);
606
607 if (this.vehicle_flags & VHF_DMGSHAKE)
608 this.velocity += randomvec() * 30;
609
610 if (this.vehicle_flags & VHF_DMGROLL)
611 {
613 this.tur_head.angles += randomvec();
614 else
615 this.angles += randomvec();
616 }
617 }
618}
619
620void vehicles_frame(entity this, entity actor)
621{
622 vehicles_painframe(this);
623}
624
625void vehicles_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
626{
627 this.dmg_time = time;
628
629 // WEAPONTODO
630 if (DEATH_ISWEAPON(deathtype, WEP_VORTEX)) damage *= autocvar_g_vehicles_vortex_damagerate;
631 else if (DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN)) damage *= autocvar_g_vehicles_machinegun_damagerate;
632 else if (DEATH_ISWEAPON(deathtype, WEP_RIFLE)) damage *= autocvar_g_vehicles_rifle_damagerate;
633 else if (DEATH_ISWEAPON(deathtype, WEP_VAPORIZER)) damage *= autocvar_g_vehicles_vaporizer_damagerate;
634 else if (DEATH_ISWEAPON(deathtype, WEP_SEEKER)) damage *= autocvar_g_vehicles_tag_damagerate;
635 else if (DEATH_WEAPONOF(deathtype) != WEP_Null) damage *= autocvar_g_vehicles_weapon_damagerate;
636
637 this.enemy = attacker;
638
639 this.pain_finished = time;
640
641 if ((this.vehicle_flags & VHF_HASSHIELD) && this.vehicle_shield > 0)
642 {
643 if (wasfreed(this.vehicle_shieldent) || this.vehicle_shieldent == NULL)
644 {
646 this.vehicle_shieldent.effects = EF_LOWPRECISION;
647
648 setmodel(this.vehicle_shieldent, MDL_VEH_SHIELD);
649 setattachment(this.vehicle_shieldent, this, "");
650 setorigin(this.vehicle_shieldent, real_origin(this) - this.origin);
651 this.vehicle_shieldent.scale = 256 / vlen(this.maxs - this.mins);
653 }
654
655 this.vehicle_shieldent.colormod = '1 1 1';
656 this.vehicle_shieldent.alpha = 0.45;
657 this.vehicle_shieldent.angles = vectoangles(normalize(hitloc - (this.origin + this.vehicle_shieldent.origin))) - this.angles;
658 this.vehicle_shieldent.nextthink = time;
659 this.vehicle_shieldent.effects &= ~EF_NODRAW;
660
661 this.vehicle_shield -= damage;
662
663 if (this.vehicle_shield < 0)
664 {
665 TakeResource(this, RES_HEALTH, fabs(this.vehicle_shield));
666 this.vehicle_shieldent.colormod = '2 0 0';
667 this.vehicle_shield = 0;
668 this.vehicle_shieldent.alpha = 0.75;
669
670 if (sound_allowed(MSG_BROADCAST, attacker))
671 spamsound(this, CH_PAIN, SND_ONS_HIT2, VOL_BASE, ATTEN_NORM); // FIXME: PLACEHOLDER
672 }
673 else
674 if (sound_allowed(MSG_BROADCAST, attacker))
675 spamsound(this, CH_PAIN, SND_ONS_ELECTRICITY_EXPLODE, VOL_BASE, ATTEN_NORM); // FIXME: PLACEHOLDER
676 }
677 else
678 {
679 TakeResource(this, RES_HEALTH, damage);
680
681 if (sound_allowed(MSG_BROADCAST, attacker))
682 spamsound(this, CH_PAIN, SND_ONS_HIT2, VOL_BASE, ATTEN_NORM); // FIXME: PLACEHOLDER
683 }
684
686 this.velocity += force * this.damageforcescale;
687 else
688 this.velocity += force;
689
690 if (GetResource(this, RES_HEALTH) <= 0)
691 {
692 if (this.owner)
693 {
694 if (this.vehicle_flags & VHF_DEATHEJECT)
696 else
698 }
699
700 antilag_clear(this, this);
701
702 Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid);
703 info.vr_death(info, this);
704 vehicles_setreturn(this);
705 }
706}
707
708bool vehicles_heal(entity targ, entity inflictor, float amount, float limit)
709{
710 float true_limit = (limit != RES_LIMIT_NONE) ? limit : targ.max_health;
711 if (GetResource(targ, RES_HEALTH) <= 0
712 || GetResource(targ, RES_HEALTH) >= true_limit)
713 return false;
714
715 GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
716 if (targ.owner)
717 targ.owner.vehicle_health = (GetResource(targ, RES_HEALTH) / targ.max_health) * 100;
718 return true;
719}
720
722{
723 if (IS_PLAYER(e) && time >= e.vehicle_enter_delay)
724 return true;
725 if (IS_MONSTER(e))
726 return true;
727
728 return false;
729}
730
731void vehicles_impact(entity this, float _minspeed, float _speedfac, float _maxpain)
732{
734 return;
735
736 if (this.play_time < time
737 && vdist(this.velocity - this.oldvelocity, >, _minspeed))
738 {
739 Damage(this, NULL, NULL,
740 min(_speedfac * vlen(this.velocity - this.oldvelocity), _maxpain),
741 DEATH_FALL.m_id,
742 DMG_NOWEP,
743 this.origin,
744 '0 0 0'
745 );
746 this.play_time = time + 0.25;
747 }
748}
749
750// vehicle enter/exit handling
752{
753 // TODO: we actually want the player's size here
754 tracebox(this.origin + '0 0 32', PL_MIN_CONST, PL_MAX_CONST, prefer_spot, MOVE_NORMAL, player);
756 return prefer_spot;
757
758 float mysize = 1.5 * vlen(this.maxs - this.mins);
759 vector v;
760 vector v2 = 0.5 * (this.absmin + this.absmax);
761 for (int i = 0; i < autocvar_g_vehicles_exit_attempts; ++i)
762 {
763 v = randomvec();
764 v.z = 0;
765 v = v2 + normalize(v) * mysize;
766 tracebox(v2, PL_MIN_CONST, PL_MAX_CONST, v, MOVE_NORMAL, player);
768 return v;
769 }
770
771 return this.origin;
772}
773
775void vehicles_exit(entity vehic, bool eject)
776{
777 entity player = vehic.owner;
778
780 {
781 LOG_TRACE("^1vehicles_exit already running! this is not good...");
782 return;
783 }
784
786
787 if (vehic.vehicle_flags & VHF_PLAYERSLOT)
788 {
789 vehic.vehicle_exit(vehic, eject);
790 vehicles_exit_running = false;
791 return;
792 }
793
794 if (player)
795 {
796 if (IS_REAL_CLIENT(player))
797 {
798 msg_entity = player;
800 WriteEntity(MSG_ONE, player);
801
802 // NOTE: engine networked
805 WriteAngle(MSG_ONE, vehic.angles.y);
807 }
808
809 player.takedamage = DAMAGE_AIM;
810 player.solid = SOLID_SLIDEBOX;
812 player.effects &= ~EF_NODRAW;
813 player.teleportable = TELEPORT_NORMAL;
814 player.alpha = default_player_alpha;
815 player.PlayerPhysplug = func_null;
816 player.vehicle = NULL;
817 player.view_ofs = STAT(PL_VIEW_OFS, player);
818 player.event_damage = PlayerDamage;
819 STAT(HUD, player) = HUD_NORMAL;
820 for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
821 {
822 .entity weaponentity = weaponentities[slot];
823 player.(weaponentity).m_switchweapon = vehic.(weaponentity).m_switchweapon;
824 delete(vehic.(weaponentity)); // no longer needed
825 }
826 player.last_vehiclecheck = time + 3;
827 player.vehicle_enter_delay = time + 2;
828 setsize(player, STAT(PL_MIN, player), STAT(PL_MAX, player));
829
831
832 Kill_Notification(NOTIF_ONE, player, MSG_CENTER, CPID_VEHICLES);
833 Kill_Notification(NOTIF_ONE, player, MSG_CENTER, CPID_VEHICLES_OTHER); // kill all vehicle notifications when exiting a vehicle?
834 }
835
836 vehic.flags |= FL_NOTARGET;
837
838 if (!IS_DEAD(vehic))
839 vehic.avelocity = '0 0 0';
840
841 vehic.tur_head.nodrawtoclient = NULL;
842
843 if (!teamplay)
844 vehic.team = 0;
845
846 WaypointSprite_Kill(vehic.wps_intruder);
847
848 MUTATOR_CALLHOOK(VehicleExit, player, vehic);
849
850 vehic.team = vehic.tur_head.team;
851
852 if (vehic.old_vehicle_flags & VHF_SHIELDREGEN)
853 vehic.vehicle_flags |= VHF_SHIELDREGEN;
854 vehic.old_vehicle_flags = 0;
855
856 sound(vehic, CH_TRIGGER_SINGLE, SND_Null, 1, ATTEN_NORM);
857 vehic.vehicle_hudmodel.viewmodelforclient = vehic;
858 vehic.phase = time + 1;
859
860 vehic.vehicle_exit(vehic, eject);
861
862 vehicles_setreturn(vehic);
864 vehic.owner = NULL;
865
866 CSQCMODEL_AUTOINIT(vehic);
867
868 if (player)
869 player.oldorigin = player.origin; // player's location is set by the exit functions, so we need to do this after everything
870
871 vehicles_exit_running = false;
872}
873
875{
876 if (MUTATOR_CALLHOOK(VehicleTouch, this, toucher))
877 return;
878
879 // Vehicle currently in use
880 if (this.owner)
881 {
882 if (toucher != NULL
883 && this.origin.z + this.maxs.z > toucher.origin.z
885 && !weaponLocked(this.owner))
886 {
888 Damage(toucher, this, this.owner,
890 DEATH_VH_CRUSH.m_id,
891 DMG_NOWEP,
892 '0 0 0',
894 );
895
896 return; // Dont do selfdamage when hitting "soft targets".
897 }
898
899 if (this.play_time < time)
900 {
901 Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid);
902 info.vr_impact(info, this);
903 }
904
905 return;
906 }
907
908 if (!autocvar_g_vehicles_enter)
909 vehicles_enter(toucher, this);
910}
911
913{
914 if (!this.vehicle)
915 return false;
916 if (IS_DEAD(this.vehicle))
917 return false;
918 bool(entity, int) f = this.vehicle.vehicles_impulse;
919 if (f && f(this, imp))
920 return true;
921
922 switch (imp)
923 {
924 case IMP_weapon_drop.impulse:
925 stuffcmd(this, "\ntoggle cl_eventchase_vehicle\nset _vehicles_shownchasemessage 1\n");
926 return true;
927 }
928 return false;
929}
930
932{
933 // Remove this when bots know how to use vehicles
935 return;
936
937 // TODO: mutator hook to prevent entering vehicles
938 if (!IS_PLAYER(pl)
939 || veh.phase >= time
940 || pl.vehicle_enter_delay >= time
941 || STAT(FROZEN, pl) || StatusEffects_active(STATUSEFFECT_Frozen, pl)
942 || IS_DEAD(pl)
943 || pl.vehicle)
944 return;
945
946 Vehicle info = veh.vehicledef; //REGISTRY_GET(Vehicles, veh.vehicleid);
947
948 if (autocvar_g_vehicles_enter // vehicle's touch function should handle this if entering via use key is disabled (TODO)
949 && (veh.vehicle_flags & VHF_MULTISLOT)
950 && veh.owner && SAME_TEAM(pl, veh))
951 {
952 // we don't need a return value or anything here
953 // if successful the owner check below will prevent anything weird
954 info.vr_gunner_enter(info, veh, pl);
955 }
956
957 if (veh.owner)
958 return; // got here and didn't enter the gunner, return
959
960 if (teamplay && veh.team)
961 if (DIFF_TEAM(pl, veh))
962 if (autocvar_g_vehicles_steal)
963 {
964 FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, veh), Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_VEHICLE_STEAL));
965
966 Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_VEHICLE_STEAL_SELF);
967
968 veh.vehicle_shield = 0;
969 veh.old_vehicle_flags = veh.vehicle_flags; // make a backup just so we're not permanently crippling this vehicle
970 veh.vehicle_flags &= ~VHF_SHIELDREGEN;
971
972 if (autocvar_g_vehicles_steal_show_waypoint)
973 {
974 entity wp = WaypointSprite_Spawn(WP_VehicleIntruder, 0, 0, pl, '0 0 68', NULL, veh.team, veh, wps_intruder, true, RADARICON_DANGER);
975 wp.colormod = Team_ColorRGB(pl.team);
976 }
977 }
978 else
979 return;
980
982
983 veh.vehicle_ammo1 = 0;
984 veh.vehicle_ammo2 = 0;
985 veh.vehicle_reload1 = 0;
986 veh.vehicle_reload2 = 0;
987 veh.vehicle_energy = 0;
988
989 veh.owner = pl;
990 pl.vehicle = veh;
991
992 // .viewmodelforclient works better.
993 //veh.vehicle_hudmodel.drawonlytoclient = veh.owner;
994
995 veh.vehicle_hudmodel.viewmodelforclient = pl;
996
997 UNSET_DUCKED(pl);
998 pl.view_ofs = STAT(PL_VIEW_OFS, pl);
999 setsize(pl, STAT(PL_MIN, pl), STAT(PL_MAX, pl));
1000
1001 veh.event_damage = vehicles_damage;
1002 veh.event_heal = vehicles_heal;
1003 veh.nextthink = 0;
1004 pl.items &= ~IT_USING_JETPACK;
1005 pl.angles = veh.angles;
1006 pl.takedamage = DAMAGE_NO;
1007 pl.solid = SOLID_NOT;
1008 pl.disableclientprediction = 1; // physics is no longer run, so this won't be reset
1010 pl.teleportable = false;
1011 pl.alpha = -1;
1012 pl.event_damage = func_null;
1013 pl.view_ofs = '0 0 0';
1014 veh.colormap = pl.colormap;
1015 if (veh.tur_head)
1016 veh.tur_head.colormap = pl.colormap;
1017 for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
1018 {
1019 .entity weaponentity = weaponentities[slot];
1020 veh.(weaponentity) = new(temp_wepent);
1021 veh.(weaponentity).m_switchweapon = pl.(weaponentity).m_switchweapon;
1022 }
1023 STAT(HUD, pl) = veh.vehicleid;
1024 pl.PlayerPhysplug = veh.PlayerPhysplug;
1025
1026 pl.vehicle_ammo1 = veh.vehicle_ammo1;
1027 pl.vehicle_ammo2 = veh.vehicle_ammo2;
1028 pl.vehicle_reload1 = veh.vehicle_reload1;
1029 pl.vehicle_reload2 = veh.vehicle_reload2;
1030 pl.vehicle_energy = veh.vehicle_energy;
1031
1032 // Cant do this, hides attached objects too.
1033 //veh.exteriormodeltoclient = veh.owner;
1034 //veh.tur_head.exteriormodeltoclient = veh.owner;
1035
1036 UNSET_ONGROUND(pl);
1037 UNSET_ONGROUND(veh);
1038
1039 veh.team = pl.team;
1040 veh.flags -= FL_NOTARGET;
1041
1042 vehicles_reset_colors(veh, pl);
1043
1044 if (IS_REAL_CLIENT(pl))
1045 {
1046 Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_VEHICLE_ENTER);
1047
1048 msg_entity = pl;
1050 WriteEntity(MSG_ONE, veh.vehicle_viewport);
1051
1052 // NOTE: engine networked
1054 if (veh.tur_head)
1055 {
1056 WriteAngle(MSG_ONE, veh.tur_head.angles.x + veh.angles.x); // tilt
1057 WriteAngle(MSG_ONE, veh.tur_head.angles.y + veh.angles.y); // yaw
1058 WriteAngle(MSG_ONE, 0); // roll
1059 }
1060 else
1061 {
1062 WriteAngle(MSG_ONE, -veh.angles.x); // tilt
1063 WriteAngle(MSG_ONE, veh.angles.y); // yaw
1064 WriteAngle(MSG_ONE, 0); // roll
1065 }
1066 }
1067
1069
1070 CSQCVehicleSetup(pl, veh.vehicleid);
1071
1072 MUTATOR_CALLHOOK(VehicleEnter, pl, veh);
1073
1075 info.vr_enter(info, veh);
1076
1077 antilag_clear(pl, CS(pl));
1078}
1079
1081{
1083
1084 if (this.owner)
1085 STAT(VEHICLESTAT_W2MODE, this.owner) = STAT(VEHICLESTAT_W2MODE, this);
1086
1087 Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid);
1088 info.vr_think(info, this);
1089
1090 vehicles_painframe(this);
1091
1093}
1094
1096{
1097 if (this.owner)
1099
1101
1102 if (this.active != ACTIVE_NOT)
1103 vehicles_spawn(this);
1104}
1105
1106// initialization
1108{
1109 LOG_DEBUG("Spawning vehicle: ", this.classname);
1110
1111 // disown & reset
1112 this.vehicle_hudmodel.viewmodelforclient = this;
1113
1114 this.owner = NULL;
1115 settouch(this, vehicles_touch);
1116 this.event_damage = vehicles_damage;
1117 this.event_heal = vehicles_heal;
1118 this.reset = vehicles_reset;
1119 this.iscreature = true;
1120 this.teleportable = false; // no teleporting for vehicles, too buggy
1121 this.damagedbycontents = true;
1123 this.solid = SOLID_SLIDEBOX;
1124 this.takedamage = DAMAGE_AIM;
1125 this.deadflag = DEAD_NO;
1126 if (!this.bot_attack)
1127 IL_PUSH(g_bot_targets, this);
1128 this.bot_attack = true;
1129 this.flags = FL_NOTARGET;
1130 this.avelocity = '0 0 0';
1131 this.velocity = '0 0 0';
1132 setthink(this, vehicles_think);
1133 this.nextthink = time;
1134
1135 // Reset locking
1136 this.lock_strength = 0;
1137 this.lock_target = NULL;
1138 this.misc_bulletcounter = 0;
1139
1140 // Return to spawn
1141 this.angles = this.pos2;
1142 setorigin(this, this.pos1);
1143 // Show it
1144 Send_Effect(EFFECT_TELEPORT, this.origin + '0 0 64', '0 0 0', 1);
1145
1146 if (this.vehicle_controller)
1147 this.team = this.vehicle_controller.team;
1148
1150 {
1151 for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
1152 {
1153 .entity weaponentity = weaponentities[slot];
1154 if (it.(weaponentity).hook.aiment == this)
1155 RemoveHook(it.(weaponentity).hook);
1156 }
1157 });
1158
1159
1160 Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid);
1161 info.vr_spawn(info, this);
1162
1164
1165 CSQCMODEL_AUTOINIT(this);
1166}
1167
1168bool vehicle_initialize(entity this, Vehicle info, bool nodrop)
1169{
1171 return false;
1172 if (!info.vehicleid)
1173 return false;
1174
1175 if (!this.tur_head)
1176 info.vr_precache(info);
1177
1178 if (this.targetname && this.targetname != "")
1179 {
1181 if (!this.vehicle_controller)
1182 {
1183 LOG_DEBUG("^1WARNING: ^7Vehicle with invalid .targetname");
1184 this.active = ACTIVE_ACTIVE;
1185 }
1186 else
1187 {
1188 this.team = this.vehicle_controller.team;
1189 this.use = vehicle_use;
1190
1191 if (teamplay)
1192 {
1193 if (this.vehicle_controller.team == 0)
1194 this.active = ACTIVE_NOT;
1195 else
1196 this.active = ACTIVE_ACTIVE;
1197 }
1198 }
1199 }
1200 else
1201 this.active = ACTIVE_ACTIVE;
1202
1203 if (this.team && (!teamplay || !autocvar_g_vehicles_teams))
1204 this.team = 0;
1205
1206 if (this.mdl == "" || !this.mdl)
1207 _setmodel(this, info.model);
1208 else
1209 _setmodel(this, this.mdl);
1210
1212
1215 this.tur_head = new(tur_head);
1216 this.tur_head.owner = this;
1217 this.takedamage = DAMAGE_NO;
1218 this.bot_attack = true;
1219 IL_PUSH(g_bot_targets, this);
1220 this.iscreature = true;
1221 this.teleportable = false; // no teleporting for vehicles, too buggy
1222 this.damagedbycontents = true;
1224 this.vehicleid = info.vehicleid;
1225 this.vehicledef = info;
1226 this.PlayerPhysplug = info.PlayerPhysplug;
1227 this.event_damage = func_null;
1228 this.event_heal = func_null;
1229 settouch(this, vehicles_touch);
1230 setthink(this, vehicles_spawn);
1231 this.nextthink = time;
1232 this.effects = EF_NODRAW;
1234
1237
1239 this.effects |= EF_NODEPTHTEST;
1240
1242 this.effects |= EF_FULLBRIGHT;
1243
1244 _setmodel(this.vehicle_hudmodel, info.hud_model);
1245 setmodel(this.vehicle_viewport, MDL_Null);
1246
1247 if (info.head_model != "")
1248 {
1249 _setmodel(this.tur_head, info.head_model);
1250 setattachment(this.tur_head, this, info.tag_head);
1251 setattachment(this.vehicle_hudmodel, this.tur_head, info.tag_hud);
1252 setattachment(this.vehicle_viewport, this.vehicle_hudmodel, info.tag_view);
1253 }
1254 else
1255 {
1256 setattachment(this.tur_head, this, "");
1257 setattachment(this.vehicle_hudmodel, this, info.tag_hud);
1258 setattachment(this.vehicle_viewport, this.vehicle_hudmodel, info.tag_view);
1259 }
1260
1261 setsize(this, info.m_mins, info.m_maxs);
1262
1263 info.vr_setup(info, this);
1264
1265 if (!nodrop)
1266 {
1267 setorigin(this, this.origin);
1268 tracebox(this.origin + '0 0 100', info.m_mins, info.m_maxs, this.origin - '0 0 10000', MOVE_WORLDONLY, this);
1269 setorigin(this, trace_endpos);
1270 }
1271
1272 this.pos1 = this.origin;
1273 this.pos2 = this.angles;
1274 this.tur_head.team = this.team;
1275
1276 if (this.active == ACTIVE_NOT)
1277 this.nextthink = 0; // wait until activated
1280 else
1281 this.nextthink = time + game_starttime;
1282
1283 if (MUTATOR_CALLHOOK(VehicleInit, this))
1284 return false;
1285
1286 return true;
1287}
vector AnglesTransform_ToAngles(vector v)
vector AnglesTransform_LeftDivide(vector from_transform, vector to_transform)
vector AnglesTransform_Normalize(vector t, float minimize_roll)
vector AnglesTransform_FromAngles(vector v)
void antilag_clear(entity e, entity store)
Definition antilag.qc:114
float bot_attack
Definition api.qh:38
IntrusiveList g_bot_targets
Definition api.qh:149
IntrusiveList g_bot_dodge
Definition api.qh:150
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float max_health
float pain_finished
void SetResource(entity e, Resource res_type, float amount)
Sets the current amount of resource the given entity will have.
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
void TakeResource(entity receiver, Resource res_type, float amount)
Takes an entity some resource.
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
const int MAX_AXH
Definition model.qh:3
virtual void vr_gunner_enter()
(SERVER) called when a player enters this vehicle while occupied
Definition vehicle.qh:77
string hud_model
cockpit model
Definition vehicle.qh:25
string head_model
full name of tur_head model
Definition vehicle.qh:23
vector m_mins
vehicle hitbox size
Definition vehicle.qh:43
string model
full name of model
Definition vehicle.qh:19
virtual void vr_precache()
(BOTH) precaches models/sounds used by this vehicle
Definition vehicle.qh:67
virtual void vr_impact()
(SERVER) called when a vehicle hits something
Definition vehicle.qh:81
virtual void vr_think()
(SERVER) logic to run every frame
Definition vehicle.qh:71
virtual void vr_enter()
(SERVER) called when a player enters this vehicle
Definition vehicle.qh:75
virtual void vr_setup()
(BOTH) setup vehicle data
Definition vehicle.qh:65
virtual void vr_death()
(SERVER) called when vehicle dies
Definition vehicle.qh:73
vector m_maxs
vehicle hitbox size
Definition vehicle.qh:45
int vehicleid
Definition vehicle.qh:8
virtual void vr_setcolors()
(SERVER) called when a vehicle's colors are being reset, so modules can be updated
Definition vehicle.qh:83
string netname
Definition powerups.qc:20
float cnt
Definition powerups.qc:24
vector colormod
Definition powerups.qc:21
float alpha
Definition items.qc:13
entity owner
Definition main.qh:87
int team
Definition main.qh:188
const int IT_USING_JETPACK
Definition item.qh:27
string mdl
Definition item.qh:89
#define setmodel(this, m)
Definition model.qh:26
#define IS_DEAD(s)
Definition player.qh:244
#define UNSET_DUCKED(s)
Definition player.qh:214
#define IS_PLAYER(s)
Definition player.qh:242
float game_starttime
Definition stats.qh:82
float game_stopped
Definition stats.qh:81
vector real_origin(entity ent)
Definition util.qc:147
const vector PL_MIN_CONST
Definition constants.qh:56
const int FL_PROJECTILE
Definition constants.qh:85
const int FL_NOTARGET
Definition constants.qh:76
const int HUD_NORMAL
Definition constants.qh:47
const vector PL_MAX_CONST
Definition constants.qh:55
string classname
float flags
const float SOLID_SLIDEBOX
entity trace_ent
float DPCONTENTS_SOLID
vector avelocity
const float MOVE_NORMAL
vector mins
const float SOLID_CORPSE
vector velocity
const float EF_ADDITIVE
float DPCONTENTS_BODY
const float SOLID_BBOX
const float EF_FULLBRIGHT
const float SOLID_NOT
float effects
float DPCONTENTS_PLAYERCLIP
float time
vector trace_endpos
float trace_startsolid
vector maxs
const float EF_FLAME
float nextthink
float MOVE_WORLDONLY
float trace_dphitq3surfaceflags
float colormap
vector absmax
const float EF_NODEPTHTEST
const float EF_SELECTABLE
vector origin
float trace_fraction
vector absmin
float trace_allsolid
float Q3SURFACEFLAG_NOIMPACT
const float EF_NOSHADOW
const float EF_NODRAW
float dphitcontentsmask
#define spawn
#define use
entity tag_entity
const int EF_TELEPORT_BIT
const int EF_DOUBLESIDED
#define CSQCMODEL_AUTOUPDATE(e)
#define CSQCMODEL_AUTOINIT(e)
void CSQCProjectile(entity e, float clientanimate, int type, float docull)
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition damage.qc:493
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
float damagedbycontents
Definition damage.qh:45
IntrusiveList g_damagedbycontents
Definition damage.qh:143
#define DMG_NOWEP
Definition damage.qh:104
float damageforcescale
#define DEATH_ISWEAPON(t, w)
Definition all.qh:46
#define DEATH_WEAPONOF(t)
Definition all.qh:45
void SUB_Remove(entity this)
Remove entity.
Definition defer.qh:13
const int ACTIVE_NOT
Definition defs.qh:36
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
float EF_NOGUNBOB
float EF_LOWPRECISION
#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
solid
Definition ent_cs.qc:165
float timer
Definition hud.qh:125
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define IL_EACH(this, cond, body)
#define FOREACH_ENTITY_ENT(fld, match, body)
Definition iter.qh:179
#define TC(T, sym)
Definition _all.inc:82
#define bool
Definition _all.inc:24
const int MSG_ENTITY
Definition net.qh:156
#define WriteHeader(to, id)
Definition net.qh:265
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
Definition net.qh:167
#define STAT(...)
Definition stats.qh:82
#define LOG_TRACE(...)
Definition log.qh:76
#define LOG_DEBUG(...)
Definition log.qh:80
float MSG_ONE
Definition menudefs.qc:56
float bound(float min, float value, float max)
entity find(entity start,.string field, string match)
float random(void)
float vlen(vector v)
vector vectoangles(vector v)
void WriteEntity(entity data, float dest, float desto)
vector randomvec(void)
float min(float f,...)
float rint(float f)
vector normalize(vector v)
void WriteByte(float data, float dest, float desto)
float fabs(float f)
void WriteAngle(float data, float dest, float desto)
float MSG_BROADCAST
Definition menudefs.qc:55
float max(float f,...)
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_WALK
Definition movetypes.qh:132
const int MOVETYPE_FLYMISSILE
Definition movetypes.qh:138
#define UNSET_ONGROUND(s)
Definition movetypes.qh:18
const int MOVETYPE_NOCLIP
Definition movetypes.qh:137
const int MOVETYPE_TOSS
Definition movetypes.qh:135
var void func_null()
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573
void Kill_Notification(NOTIF broadcast, entity client, MSG net_type, CPID net_cpid)
Definition all.qc:1537
#define NULL
Definition post.qh:14
#define gettaginfo
Definition post.qh:32
entity msg_entity
Definition progsdefs.qc:63
float DEAD_NO
Definition progsdefs.qc:274
float deadflag
Definition progsdefs.qc:149
#define stuffcmd(cl,...)
Definition progsdefs.qh:23
const int RES_LIMIT_NONE
Definition resources.qh:60
#define setthink(e, f)
vector
Definition self.qh:92
#define setcefc(e, f)
vector org
Definition self.qh:92
entity entity toucher
Definition self.qh:72
#define settouch(e, f)
Definition self.qh:73
bool autocvar_g_fullbrightplayers
Definition client.qh:17
bool autocvar_g_playerclip_collisions
Definition client.qh:18
bool autocvar_g_nodepthtestplayers
Definition client.qh:34
void RemoveHook(entity this)
Definition hook.qc:48
void RemoveGrapplingHooks(entity pl)
Definition hook.qc:30
int int int imp
Definition impulse.qc:90
float respawntime
Definition items.qh:31
vector oldvelocity
Definition main.qh:42
bool iscreature
Definition main.qh:46
void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition player.qc:234
int projectiledeathtype
Definition common.qh:21
#define PROJECTILE_TOUCH(e, t)
Definition common.qh:28
IntrusiveList g_projectiles
Definition common.qh:58
#define PROJECTILE_MAKETRIGGER(e)
Definition common.qh:34
float misc_bulletcounter
Definition common.qh:19
const int CH_PAIN
Definition sound.qh:18
const int CH_TRIGGER_SINGLE
Definition sound.qh:13
const float VOL_BASE
Definition sound.qh:36
const int CH_SHOTS
Definition sound.qh:14
const int CH_WEAPON_A
Definition sound.qh:7
const float ATTEN_NORM
Definition sound.qh:30
#define sound(e, c, s, v, a)
Definition sound.qh:52
void play2(entity e, string filename)
Definition all.qc:116
float spamsound(entity e, int chan, Sound samp, float vol, float _atten)
use this one if you might be causing spam (e.g.
Definition all.qc:124
bool sound_allowed(int to, entity e)
Definition all.qc:9
ClientState CS(Client this)
Definition state.qh:47
bool StatusEffects_active(StatusEffect this, entity actor)
const int DAMAGE_NO
Definition subs.qh:79
vector pos2
Definition subs.qh:50
vector pos1
Definition subs.qh:50
const int DAMAGE_AIM
Definition subs.qh:81
float takedamage
Definition subs.qh:78
entity enemy
Definition sv_ctf.qh:153
void CSQCModel_UnlinkEntity(entity e)
Definition sv_model.qc:139
void GiveResourceWithLimit(entity receiver, Resource res_type, float amount, float limit)
Gives an entity some resource but not more than a limit.
entity tur_head
Definition sv_turrets.qh:28
void vehicles_enter(entity pl, entity veh)
void vehicles_impact(entity this, float _minspeed, float _speedfac, float _maxpain)
void vehicles_showwp_goaway(entity this)
void vehicles_reset_colors(entity this, entity player)
bool vehicle_initialize(entity this, Vehicle info, bool nodrop)
void vehicles_setreturn(entity veh)
void vehicles_touch(entity this, entity toucher)
entity vehicles_projectile(entity this, entity _mzlfx, Sound _mzlsound, vector _org, vector _vel, float _dmg, float _radi, float _force, float _size, int _deahtype, float _projtype, float _health, bool _cull, bool _clianim, entity _owner)
void vehicles_exit(entity vehic, bool eject)
void vehicle_use(entity this, entity actor, entity trigger)
void vehicles_regen(entity this, float timer,.float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale)
void vehicles_reset(entity this)
vector vehicles_findgoodexit(entity this, entity player, vector prefer_spot)
void shieldhit_think(entity this)
vector axh_prevorigin
bool vehicle_addplayerslot(entity _owner, entity _slot, int _hud, Model _hud_model, bool(entity, float) _framefunc, void(entity, bool) _exitfunc, float(entity, entity) _enterfunc)
void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, int axh_id)
void vehicles_projectile_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
bool AuxiliaryXhair_customize(entity this, entity client)
bool vehicle_impulse(entity this, int imp)
void vehicles_projectile_explode(entity this, entity toucher)
bool SendAuxiliaryXhair(entity this, entity to, int sf)
bool vehicles_heal(entity targ, entity inflictor, float amount, float limit)
int old_vehicle_flags
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 vehicles_painframe(entity this)
void vehicles_gib_explode(entity this)
void vehicles_spawn(entity this)
void CSQCVehicleSetup(entity own, int vehicle_id)
void vehicles_return(entity this)
bool vehicles_crushable(entity e)
void vehicles_projectile_explode_think(entity this)
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_gib_touch(entity this, entity toucher)
void vehicles_clearreturn(entity veh)
void vehicles_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
void vehicles_showwp(entity this)
void vehicles_projectile_explode_use(entity this, entity actor, entity trigger)
void vehicles_frame(entity this, entity actor)
void vehicles_gib_think(entity this)
vector axh_prevcolors
entity vehicle_tossgib(entity this, entity _template, vector _vel, string _tag, bool _burn, bool _explode, float _maxtime, vector _rot)
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,...
float dmg_time
const float SVC_SETVIEWANGLES
float autocvar_g_vehicles_delayspawn_jitter
float autocvar_g_vehicles_vaporizer_damagerate
entity vehicle_viewport
const float SVC_SETVIEWPORT
float pain_frame
const int VHEF_EJECT
User pressed exit key 3 times fast (not implemented) or vehicle is dying.
bool autocvar_g_vehicles_delayspawn
float vehicles_exit_running
const int VHEF_RELEASE
Release ownership, client possibly allready dissconnected / went spec / changed team / used "kill" (n...
bool autocvar_g_vehicles
Definition sv_vehicles.qh:8
float autocvar_g_vehicles_weapon_damagerate
entity vehicle_controller
float autocvar_g_vehicles_crush_force
float autocvar_g_vehicles_crush_minspeed
float lock_time
entity vehicle
float autocvar_g_vehicles_allow_bots
float autocvar_g_vehicles_machinegun_damagerate
int vehicle_flags
float autocvar_g_vehicles_tag_damagerate
int autocvar_g_vehicles_exit_attempts
float autocvar_g_vehicles_thinkrate
float lock_strength
float autocvar_g_vehicles_rifle_damagerate
entity vehicle_hudmodel
IntrusiveList g_vehicle_returners
float autocvar_g_vehicles_vortex_damagerate
float play_time
entity vehicle_shieldent
Entity to disply the shild effect on damage.
entity wps_intruder
entity lock_target
float autocvar_g_vehicles_crush_dmg
float lock_soundtime
#define SAME_TEAM(a, b)
Definition teams.qh:241
vector Team_ColorRGB(int teamid)
Definition teams.qh:76
bool teamplay
Definition teams.qh:59
#define DIFF_TEAM(a, b)
Definition teams.qh:242
const int TELEPORT_NORMAL
float teleportable
entity realowner
string targetname
Definition triggers.qh:56
string target
Definition triggers.qh:55
#define IS_TURRET(v)
Definition utils.qh:25
#define IS_REAL_CLIENT(v)
Definition utils.qh:17
#define IS_MONSTER(v)
Definition utils.qh:23
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:52
#define IS_VEHICLE(v)
Definition utils.qh:24
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition utils.qh:15
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8
entity wp00
const int VHF_PLAYERSLOT
This ent is a player slot on a multi-person vehicle.
Definition vehicle.qh:107
const int VHF_HASSHIELD
Vehicle has shileding.
Definition vehicle.qh:95
const int VHF_MULTISLOT
Vehicle has multiple player slots.
Definition vehicle.qh:106
entity vehicledef
Definition vehicle.qh:111
const int VHF_DMGSHAKE
Add random velocity each frame if health < 50%.
Definition vehicle.qh:103
const int VHF_DMGHEADROLL
Add random head angles each frame if health < 50%.
Definition vehicle.qh:105
const int VHF_ISVEHICLE
Indicates vehicle.
Definition vehicle.qh:94
const int VHF_SHIELDREGEN
Vehicles shield regenerates.
Definition vehicle.qh:96
const int VHF_DEATHEJECT
Vehicle ejects pilot upon fatal damage.
Definition vehicle.qh:99
const int VHF_DMGROLL
Add random angles each frame if health < 50%.
Definition vehicle.qh:104
float myhealth
Definition view.qc:644
void WaypointSprite_Kill(entity wp)
void WaypointSprite_Ping(entity e)
entity WaypointSprite_Spawn(entity spr, float _lifetime, float maxdistance, entity ref, vector ofs, entity showto, float t, entity own,.entity ownfield, float hideable, entity icon)
entity WaypointSprite_getviewentity(entity e)
void WaypointSprite_UpdateBuildFinished(entity e, float f)
void WaypointSprite_UpdateRule(entity e, float t, float r)
const int SPRITERULE_DEFAULT
entity waypointsprite_attached
const int MAX_WEAPONSLOTS
Definition weapon.qh:16
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17
bool weaponLocked(entity player)
Weapon m_switchweapon
Definition wepent.qh:25
float default_player_alpha
Definition world.qh:72