1 float autocvar_g_vehicles_crush_dmg;
2 float autocvar_g_vehicles_crush_force;
3 float autocvar_g_vehicles_delayspawn;
4 float autocvar_g_vehicles_delayspawn_jitter;
6 void vehicles_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force);
7 void vehicles_return();
10 void vehicles_reset_colors();
11 void vehicles_clearrturn();
12 void vehicles_setreturn();
16 Send additional points of interest to be drawn, to vehicle owner
19 .entity AuxiliaryXhair[MAX_AXH];
21 float SendAuxiliaryXhair(entity to, float sf)
24 WriteByte(MSG_ENTITY, ENT_CLIENT_AUXILIARYXHAIR);
26 WriteByte(MSG_ENTITY, self.cnt);
28 WriteCoord(MSG_ENTITY, self.origin_x);
29 WriteCoord(MSG_ENTITY, self.origin_y);
30 WriteCoord(MSG_ENTITY, self.origin_z);
32 WriteByte(MSG_ENTITY, rint(self.colormod_x * 255));
33 WriteByte(MSG_ENTITY, rint(self.colormod_y * 255));
34 WriteByte(MSG_ENTITY, rint(self.colormod_z * 255));
39 void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, float axh_id)
43 axh_id = bound(0, axh_id, MAX_AXH);
44 axh = own.(AuxiliaryXhair[axh_id]);
46 if(axh == world || wasfreed(axh)) // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
50 axh.drawonlytoclient = own;
52 Net_LinkEntity(axh, FALSE, 0, SendAuxiliaryXhair);
58 own.(AuxiliaryXhair[axh_id]) = axh;
62 // SVC_TEMPENTITY based, horrible with even 50 ping. hm.
63 // WriteByte(MSG_ONE, SVC_TEMPENTITY) uses reliable messagess, never use for thinsg that need continous updates.
64 void SendAuxiliaryXhair2(entity own, vector loc, vector clr, float axh_id)
68 WriteByte(MSG_ONE, SVC_TEMPENTITY);
69 WriteByte(MSG_ONE, TE_CSQC_AUXILIARYXHAIR);
71 WriteByte(MSG_ONE, axh_id);
73 WriteCoord(MSG_ONE, loc_x);
74 WriteCoord(MSG_ONE, loc_y);
75 WriteCoord(MSG_ONE, loc_z);
77 WriteByte(MSG_ONE, rint(clr_x * 255));
78 WriteByte(MSG_ONE, rint(clr_y * 255));
79 WriteByte(MSG_ONE, rint(clr_z * 255));
86 Notifies the client that he enterd a vehicle, and sends
89 only sends vehicle_id atm (wich is a HUD_* constant, ex. HUD_SPIDERBOT)
91 void CSQCVehicleSetup(entity own, float vehicle_id)
95 WriteByte(MSG_ONE, SVC_TEMPENTITY);
96 WriteByte(MSG_ONE, TE_CSQC_VEHICLESETUP);
97 WriteByte(MSG_ONE, vehicle_id);
100 /** vehicles_locktarget
102 Generic target locking.
104 Figure out if what target is "locked" (if any), for missile tracking as such.
106 after calling, "if(self.lock_target != world && self.lock_strength == 1)" mean
107 you have a locked in target.
109 Exspects a crosshair_trace() or equivalent to be
114 .float lock_strength;
116 .float lock_soundtime;
117 void vehicles_locktarget(float incr, float decr, float _lock_time)
119 if(self.lock_target && self.lock_target.deadflag != DEAD_NO)
121 self.lock_target = world;
122 self.lock_strength = 0;
126 if(self.lock_time > time)
129 if(self.lock_soundtime < time)
131 self.lock_soundtime = time + 0.5;
132 play2(self.owner, "vehicles/locked.wav");
138 if(trace_ent != world)
140 if(teamplay && trace_ent.team == self.team)
143 if(trace_ent.deadflag != DEAD_NO)
146 if not (trace_ent.vehicle_flags & VHF_ISVEHICLE || trace_ent.turrcaps_flags & TFL_TURRCAPS_ISTURRET)
150 if(self.lock_target == world && trace_ent != world)
151 self.lock_target = trace_ent;
153 if(self.lock_target && trace_ent == self.lock_target)
155 if(self.lock_strength != 1 && self.lock_strength + incr >= 1)
157 play2(self.owner, "vehicles/lock.wav");
158 self.lock_soundtime = time + 0.8;
160 else if (self.lock_strength != 1 && self.lock_soundtime < time)
162 play2(self.owner, "vehicles/locking.wav");
163 self.lock_soundtime = time + 0.3;
168 // Have a locking target
169 // Trace hit current target
170 if(trace_ent == self.lock_target && trace_ent != world)
172 self.lock_strength = min(self.lock_strength + incr, 1);
173 if(self.lock_strength == 1)
174 self.lock_time = time + _lock_time;
179 self.lock_strength = max(self.lock_strength - decr * 2, 0);
181 self.lock_strength = max(self.lock_strength - decr, 0);
183 if(self.lock_strength == 0)
184 self.lock_target = world;
188 #define VEHICLE_UPDATE_PLAYER(fld,vhname) \
189 self.owner.vehicle_##fld = (self.vehicle_##fld / autocvar_g_vehicle_##vhname##_##fld) * 100
191 #define vehicles_sweap_collision(orig,vel,dt,acm,mult) \
192 traceline(orig, orig + vel * dt, MOVE_NORMAL, self); \
193 if(trace_fraction != 1) \
194 acm += normalize(self.origin - trace_endpos) * (vlen(vel) * mult)
196 // Hover movement support
197 float force_fromtag_power;
198 float force_fromtag_normpower;
199 vector force_fromtag_origin;
200 vector vehicles_force_fromtag_hover(string tag_name, float spring_length, float max_power)
202 force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name));
203 v_forward = normalize(v_forward) * -1;
204 traceline(force_fromtag_origin, force_fromtag_origin - (v_forward * spring_length), MOVE_NORMAL, self);
206 force_fromtag_power = (1 - trace_fraction) * max_power;
207 force_fromtag_normpower = force_fromtag_power / max_power;
209 return v_forward * force_fromtag_power;
212 // Experimental hovermode wich uses attraction/repulstion from surface insted of gravity/repulsion
213 // Can possibly be use to move abt any surface (inclusing walls/celings)
214 vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float max_power)
217 force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name));
218 v_forward = normalize(v_forward) * -1;
219 traceline(force_fromtag_origin, force_fromtag_origin - (v_forward * spring_length), MOVE_NORMAL, self);
221 // TODO - this may NOT be compatible with wall/celing movement, unhardcode 0.25 (engine count multiplier)
222 if(trace_fraction == 1.0)
224 force_fromtag_normpower = -0.25;
228 force_fromtag_power = ((1 - trace_fraction) - trace_fraction) * max_power;
229 force_fromtag_normpower = force_fromtag_power / max_power;
231 return v_forward * force_fromtag_power;
234 // Generic vehile projectile system
235 void vehicles_projectile_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
237 // Ignore damage from oterh projectiles from my owner (dont mess up volly's)
238 if(inflictor.owner == self.owner)
241 self.health -= damage;
242 self.velocity += force;
245 self.takedamage = DAMAGE_NO;
246 self.event_damage = SUB_Null;
247 self.think = self.use;
248 self.nextthink = time;
253 void vehicles_projectile_explode()
255 if(self.owner && other != world)
257 if(other == self.owner.vehicle)
260 if(other == self.owner.vehicle.tur_head)
266 self.event_damage = SUB_Null;
267 RadiusDamage (self, self.realowner, self.shot_dmg, 0, self.shot_radius, self, self.shot_force, self.totalfrags, other);
272 entity vehicles_projectile(string _mzlfx, string _mzlsound,
273 vector _org, vector _vel,
274 float _dmg, float _radi, float _force, float _size,
275 float _deahtype, float _projtype, float _health,
276 float _cull, float _clianim)
282 PROJECTILE_MAKETRIGGER(proj);
283 setorigin(proj, _org);
285 proj.shot_dmg = _dmg;
286 proj.shot_radius = _radi;
287 proj.shot_force = _force;
288 proj.totalfrags = _deahtype;
289 proj.solid = SOLID_BBOX;
290 proj.movetype = MOVETYPE_FLYMISSILE;
291 proj.flags = FL_PROJECTILE;
292 proj.bot_dodge = TRUE;
293 proj.bot_dodgerating = _dmg;
294 proj.velocity = _vel;
295 proj.touch = vehicles_projectile_explode;
296 proj.use = vehicles_projectile_explode;
298 proj.realowner = self.owner;
299 proj.think = SUB_Remove;
300 proj.nextthink = time + 30;
304 proj.takedamage = DAMAGE_AIM;
305 proj.event_damage = vehicles_projectile_damage;
306 proj.health = _health;
309 proj.flags = FL_PROJECTILE | FL_NOTARGET;
312 sound (self, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTN_NORM);
315 pointparticles(particleeffectnum(_mzlfx), proj.origin, proj.velocity, 1);
318 setsize (proj, '-1 -1 -1' * _size, '1 1 1' * _size);
320 CSQCProjectile(proj, _clianim, _projtype, _cull);
324 // End generic vehile projectile system
327 Exetuted for all vehicles on (re)spawn.
328 Sets defaults for newly spawned units.
330 void vehicles_spawn()
332 dprint("Spawning vehicle: ", self.netname, "\n");
335 self.vehicle_hudmodel.viewmodelforclient = self;
338 self.touch = vehicles_touch;
339 self.event_damage = vehicles_damage;
340 self.iscreature = TRUE;
341 self.damagedbycontents = TRUE;
342 self.movetype = MOVETYPE_WALK;
343 self.solid = SOLID_SLIDEBOX;
344 self.takedamage = DAMAGE_AIM;
345 self.deadflag = DEAD_NO;
346 self.bot_attack = TRUE;
347 self.flags = FL_NOTARGET;
348 self.avelocity = '0 0 0';
349 self.velocity = '0 0 0';
352 self.lock_strength = 0;
353 self.lock_target = world;
354 self.misc_bulletcounter = 0;
357 self.angles = self.pos2;
358 setorigin(self, self.pos1 + '0 0 0');
360 pointparticles(particleeffectnum("teleport"), self.origin + '0 0 64', '0 0 0', 1);
362 vehicles_reset_colors();
363 self.vehicle_spawn();
366 // Better way of determening whats crushable needed! (fl_crushable?)
367 float vehicles_crushable(entity e)
369 if(e.classname == "player")
372 if(e.classname == "monster_zombie")
378 void vehilces_impact(float _minspeed, float _speedfac, float _maxpain)
380 if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
383 if(self.play_time < time)
385 float wc = vlen(self.velocity - self.oldvelocity);
386 //dprint("oldvel: ", vtos(self.oldvelocity), "\n");
387 //dprint("vel: ", vtos(self.velocity), "\n");
390 float take = take = min(_speedfac * wc, _maxpain);
391 Damage (self, world, world, take, DEATH_FALL, self.origin, '0 0 0');
392 self.play_time = time + 0.25;
394 //dprint("wc: ", ftos(wc), "\n");
395 //dprint("take: ", ftos(take), "\n");
400 .void() vehicle_impact;
401 void vehicles_touch()
403 // Vehicle currently in use
407 if(vehicles_crushable(other))
409 if(vlen(self.velocity) != 0)
410 Damage(other, self, self.owner, autocvar_g_vehicles_crush_dmg, DEATH_VHCRUSH, '0 0 0', normalize(other.origin - self.origin) * autocvar_g_vehicles_crush_force);
412 return; // Dont do selfdamage when hitting "soft targets".
415 if(self.play_time < time)
416 if(self.vehicle_impact)
417 self.vehicle_impact();
422 if(other.classname != "player")
425 if(other.deadflag != DEAD_NO)
428 if(other.vehicle != world)
431 // Remove this when bots know how to use vehicles.
432 if (clienttype(other) != CLIENTTYPE_REAL)
438 void vehicles_enter()
440 // Remove this when bots know how to use vehicles
441 if (clienttype(other) != CLIENTTYPE_REAL)
444 if(self.phase > time)
449 if(self.team != other.team)
452 RemoveGrapplingHook(other);
454 self.vehicle_ammo1 = 0;
455 self.vehicle_ammo2 = 0;
456 self.vehicle_reload1 = 0;
457 self.vehicle_reload2 = 0;
458 self.vehicle_energy = 0;
461 self.switchweapon = other.switchweapon;
463 // .viewmodelforclient works better.
464 //self.vehicle_hudmodel.drawonlytoclient = self.owner;
466 self.vehicle_hudmodel.viewmodelforclient = self.owner;
468 self.event_damage = vehicles_damage;
470 self.owner.angles = self.angles;
471 self.owner.takedamage = DAMAGE_NO;
472 self.owner.solid = SOLID_NOT;
473 self.owner.movetype = MOVETYPE_NOCLIP;
474 self.owner.alpha = -1;
475 self.owner.vehicle = self;
476 self.owner.event_damage = SUB_Null;
477 self.owner.view_ofs = '0 0 0';
478 self.colormap = self.owner.colormap;
480 self.tur_head.colormap = self.owner.colormap;
482 self.owner.hud = self.hud;
483 self.owner.PlayerPhysplug = self.PlayerPhysplug;
485 self.owner.vehicle_ammo1 = self.vehicle_ammo1;
486 self.owner.vehicle_ammo2 = self.vehicle_ammo2;
487 self.owner.vehicle_reload1 = self.vehicle_reload1;
488 self.owner.vehicle_reload2 = self.vehicle_reload2;
490 // Cant do this, hides attached objects too.
491 //self.exteriormodeltoclient = self.owner;
492 //self.tur_head.exteriormodeltoclient = self.owner;
494 other.flags &~= FL_ONGROUND;
495 self.flags &~= FL_ONGROUND;
497 self.team = self.owner.team;
498 self.flags -= FL_NOTARGET;
501 WriteByte (MSG_ONE, SVC_SETVIEWPORT);
502 WriteEntity(MSG_ONE, self.vehicle_viewport);
504 WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
507 WriteAngle(MSG_ONE, self.tur_head.angles_x + self.angles_x); // tilt
508 WriteAngle(MSG_ONE, self.tur_head.angles_y + self.angles_y); // yaw
509 WriteAngle(MSG_ONE, 0); // roll
513 WriteAngle(MSG_ONE, self.angles_x * -1); // tilt
514 WriteAngle(MSG_ONE, self.angles_y); // yaw
515 WriteAngle(MSG_ONE, 0); // roll
518 vehicles_clearrturn();
520 CSQCVehicleSetup(self.owner, self.hud);
522 MUTATOR_CALLHOOK(VehicleEnter);
524 self.vehicle_enter();
525 antilag_clear(other);
528 /** vehicles_findgoodexit
529 Locates a valid location for the player to exit the vehicle.
530 Will first try prefer_spot, then up 100 random spots arround the vehicle
531 wich are in direct line of sight and empty enougth to hold a players bbox
533 vector vehicles_findgoodexit(vector prefer_spot)
538 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, prefer_spot, MOVE_NORMAL, self.owner);
539 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
542 mysize = vlen(self.maxs - self.mins);
545 v2 = 0.5 * (self.absmin + self.absmax);
546 for(i = 0; i < 100; ++i)
550 v = v2 + normalize(v) * mysize;
551 tracebox(v2, PL_MIN, PL_MAX, v, MOVE_NORMAL, self.owner);
552 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
557 exitspot = (self.origin + '0 0 48') + v_forward * mysize;
558 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
559 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
562 exitspot = (self.origin + '0 0 48') - v_forward * mysize;
563 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
564 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
567 exitspot = (self.origin + '0 0 48') + v_right * mysize;
568 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
569 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
572 exitspot = (self.origin + '0 0 48') - v_right * mysize;
573 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
574 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
582 Standarrd vehicle release fucntion.
583 custom code goes in self.vehicle_exit
585 void vehicles_exit(float eject)
588 if(self.flags & FL_CLIENT)
594 self.flags |= FL_NOTARGET;
598 msg_entity = self.owner;
599 WriteByte (MSG_ONE, SVC_SETVIEWPORT);
600 WriteEntity( MSG_ONE, self.owner);
602 WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
603 WriteAngle(MSG_ONE, 0); // pich
604 WriteAngle(MSG_ONE, self.angles_y); // yaw
605 WriteAngle(MSG_ONE, 0); // roll
607 setsize(self.owner, PL_MIN,PL_MAX);
609 self.owner.takedamage = DAMAGE_AIM;
610 self.owner.solid = SOLID_SLIDEBOX;
611 self.owner.movetype = MOVETYPE_WALK;
612 self.owner.effects &~= EF_NODRAW;
613 self.owner.alpha = 1;
614 self.owner.PlayerPhysplug = SUB_Null;
615 self.owner.vehicle = world;
616 self.owner.view_ofs = PL_VIEW_OFS;
617 self.owner.event_damage = PlayerDamage;
618 self.owner.hud = HUD_NORMAL;
619 self.owner.switchweapon = self.switchweapon;
620 //self.owner.BUTTON_USE = 0;
622 CSQCVehicleSetup(self.owner, HUD_NORMAL);
625 if(self.deadflag == DEAD_NO)
626 self.avelocity = '0 0 0';
628 self.vehicle_hudmodel.viewmodelforclient = self;
629 self.tur_head.nodrawtoclient = world;
630 vehicles_setreturn();
632 self.phase = time + 1;
637 self.team = self.tur_head.team;
639 MUTATOR_CALLHOOK(VehicleExit);
641 sound (self, CH_TRIGGER_SINGLE, "misc/null.wav", 1, ATTN_NORM);
642 self.vehicle_exit(eject);
644 vehicles_reset_colors();
651 void vehicles_regen(.float timer, .float regen_field, float field_max, float rpause, float regen, float delta_time)
653 if(self.regen_field < field_max)
654 if(self.timer + rpause < time)
656 self.regen_field = min(self.regen_field + regen * delta_time, field_max);
659 self.owner.regen_field = (self.regen_field / field_max) * 100;
663 void shieldhit_think()
668 //setmodel(self, "");
673 self.nextthink = time + 0.1;
677 void vehicles_painframe()
679 if(self.owner.vehicle_health <= 50)
680 if(self.pain_frame < time)
683 _ftmp = self.owner.vehicle_health / 50;
684 self.pain_frame = time + 0.1 + (random() * 0.5 * _ftmp);
685 pointparticles(particleeffectnum("smoke_small"), (self.origin + (randomvec() * 80)), '0 0 0', 1);
687 if(self.vehicle_flags & VHF_DMGSHAKE)
688 self.velocity += randomvec() * 30;
690 if(self.vehicle_flags & VHF_DMGROLL)
691 if(self.vehicle_flags & VHF_DMGHEADROLL)
692 self.tur_head.angles += randomvec();
694 self.angles += randomvec();
699 void vehicles_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
701 self.dmg_time = time;
703 if((self.vehicle_flags & VHF_HASSHIELD) && (self.vehicle_shield > 0))
705 if (wasfreed(self.vehicle_shieldent) || self.vehicle_shieldent == world)
707 self.vehicle_shieldent = spawn();
708 self.vehicle_shieldent.effects = EF_LOWPRECISION;
710 setmodel(self.vehicle_shieldent, "models/vhshield.md3");
711 setattachment(self.vehicle_shieldent, self, "");
712 setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
713 self.vehicle_shieldent.scale = 256 / vlen(self.maxs - self.mins);
714 self.vehicle_shieldent.think = shieldhit_think;
717 self.vehicle_shieldent.colormod = '1 1 1';
718 self.vehicle_shieldent.alpha = 0.45;
719 self.vehicle_shieldent.angles = vectoangles(normalize(hitloc - (self.origin + self.vehicle_shieldent.origin))) - self.angles;
720 self.vehicle_shieldent.nextthink = time;
722 self.vehicle_shield -= damage;
724 if(self.vehicle_shield < 0)
726 self.vehicle_health -= fabs(self.vehicle_shield);
727 self.vehicle_shieldent.colormod = '2 0 0';
728 self.vehicle_shield = 0;
729 self.vehicle_shieldent.alpha = 0.75;
731 if(sound_allowed(MSG_BROADCAST, attacker))
732 spamsound (self, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTN_NORM); // FIXME: PLACEHOLDER
735 if(sound_allowed(MSG_BROADCAST, attacker))
736 spamsound (self, CH_PAIN, "onslaught/electricity_explode.wav", VOL_BASE, ATTN_NORM); // FIXME: PLACEHOLDER
741 self.vehicle_health -= damage;
743 if(sound_allowed(MSG_BROADCAST, attacker))
744 spamsound (self, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTN_NORM); // FIXME: PLACEHOLDER
747 self.velocity += force; // * (vlen(force) / self.mass);
749 if(self.vehicle_health <= 0)
752 if(self.vehicle_flags & VHF_DEATHEJECT)
753 vehicles_exit(VHEF_EJECT);
755 vehicles_exit(VHEF_RELESE);
758 vehicles_setreturn();
762 void vehicles_clearrturn()
765 // Remove "return helper", if any.
766 ret = findchain(classname, "vehicle_return");
769 if(ret.enemy == self)
772 ret.think = SUB_Remove;
773 ret.nextthink = time + 0.1;
775 if(ret.waypointsprite_attached)
776 WaypointSprite_Kill(ret.waypointsprite_attached);
784 void vehicles_return()
786 pointparticles(particleeffectnum("teleport"), self.enemy.origin + '0 0 64', '0 0 0', 1);
788 self.enemy.think = vehicles_spawn;
789 self.enemy.nextthink = time;
791 if(self.waypointsprite_attached)
792 WaypointSprite_Kill(self.waypointsprite_attached);
797 void vehicles_showwp_goaway()
799 if(self.waypointsprite_attached)
800 WaypointSprite_Kill(self.waypointsprite_attached);
806 void vehicles_showwp()
813 self.think = vehicles_return;
814 self.nextthink = self.cnt;
818 self.think = vehicles_return;
819 self.nextthink = time +1;
823 setmodel(self, "null");
824 self.team = oldself.enemy.team;
825 self.enemy = oldself.enemy;
826 setorigin(self, oldself.enemy.pos1);
828 self.nextthink = time + 5;
829 self.think = vehicles_showwp_goaway;
832 if(teamplay && self.team)
833 rgb = TeamColor(self.team);
836 WaypointSprite_Spawn("vehicle", 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, TRUE, RADARICON_POWERUP, rgb);
837 if(self.waypointsprite_attached)
839 WaypointSprite_UpdateRule(self.waypointsprite_attached, self.enemy.team, SPRITERULE_DEFAULT);
841 WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, self.nextthink);
842 WaypointSprite_Ping(self.waypointsprite_attached);
849 void vehicles_setreturn()
853 vehicles_clearrturn();
856 ret.classname = "vehicle_return";
858 ret.team = self.team;
859 ret.think = vehicles_showwp;
861 if(self.deadflag != DEAD_NO)
863 ret.cnt = time + self.vehicle_respawntime;
864 ret.nextthink = min(time + self.vehicle_respawntime, time + self.vehicle_respawntime - 5);
868 ret.nextthink = min(time + self.vehicle_respawntime, time + self.vehicle_respawntime - 1);
871 setmodel(ret, "null");
872 setorigin(ret, self.pos1 + '0 0 96');
876 void vehicles_configcheck(string configname, float check_cvar)
879 localcmd(strcat("exec ", configname, "\n"));
882 void vehicles_reset_colors()
885 float _effects, _colormap;
886 vector _glowmod, _colormod;
888 if(autocvar_g_nodepthtestplayers)
889 _effects = EF_NODEPTHTEST;
891 if(autocvar_g_fullbrightplayers)
892 _effects |= EF_FULLBRIGHT;
895 _colormap = 1024 + (self.team - 1) * 17;
902 // Find all ents attacked to main model and setup effects, colormod etc.
903 e = findchainentity(tag_entity, self);
906 if(e != self.vehicle_shieldent)
908 e.effects = _effects; // | EF_LOWPRECISION;
909 e.colormod = _colormod;
910 e.colormap = _colormap;
916 self.vehicle_hudmodel.effects = self.effects = _effects; // | EF_LOWPRECISION;
917 self.vehicle_hudmodel.colormod = self.colormod = _colormod;
918 self.vehicle_hudmodel.colormap = self.colormap = _colormap;
919 self.vehicle_viewport.effects = (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NOGUNBOB | EF_NOSHADOW | EF_LOWPRECISION | EF_SELECTABLE | EF_TELEPORT_BIT);
922 self.avelocity = '0 0 0';
923 self.velocity = '0 0 0';
924 self.effects = _effects;
927 float vehicle_initialize(string net_name,
942 void(float extflag) exitfunc,
947 addstat(STAT_HUD, AS_INT, hud);
948 addstat(STAT_VEHICLESTAT_HEALTH, AS_INT, vehicle_health);
949 addstat(STAT_VEHICLESTAT_SHIELD, AS_INT, vehicle_shield);
950 addstat(STAT_VEHICLESTAT_ENERGY, AS_INT, vehicle_energy);
952 addstat(STAT_VEHICLESTAT_AMMO1, AS_INT, vehicle_ammo1);
953 addstat(STAT_VEHICLESTAT_RELOAD1, AS_INT, vehicle_reload1);
955 addstat(STAT_VEHICLESTAT_AMMO2, AS_INT, vehicle_ammo2);
956 addstat(STAT_VEHICLESTAT_RELOAD2, AS_INT, vehicle_reload2);
959 error("vehicles: missing bodymodel!");
962 error("vehicles: missing hudmodel!");
965 self.netname = self.classname;
967 self.netname = net_name;
969 if(self.team && !teamplay)
972 self.vehicle_flags |= VHF_ISVEHICLE;
974 setmodel(self, bodymodel);
976 self.vehicle_viewport = spawn();
977 self.vehicle_hudmodel = spawn();
978 self.tur_head = spawn();
979 self.tur_head.owner = self;
980 self.takedamage = DAMAGE_AIM;
981 self.bot_attack = TRUE;
982 self.iscreature = TRUE;
983 self.damagedbycontents = TRUE;
986 self.vehicle_die = dieproc;
987 self.vehicle_exit = exitfunc;
988 self.vehicle_enter = enterproc;
989 self.PlayerPhysplug = physproc;
990 self.event_damage = vehicles_damage;
991 self.touch = vehicles_touch;
992 self.think = vehicles_spawn;
993 self.nextthink = time;
994 self.vehicle_respawntime = _respawntime;
995 self.vehicle_spawn = spawnproc;
997 if(autocvar_g_nodepthtestplayers)
998 self.effects = self.effects | EF_NODEPTHTEST;
1000 if(autocvar_g_fullbrightplayers)
1001 self.effects = self.effects | EF_FULLBRIGHT;
1003 setmodel(self.vehicle_hudmodel, hudmodel);
1004 setmodel(self.vehicle_viewport, "null");
1009 setmodel(self.tur_head, topmodel);
1010 setattachment(self.tur_head, self, toptag);
1011 setattachment(self.vehicle_hudmodel, self.tur_head, hudtag);
1012 setattachment(self.vehicle_viewport, self.vehicle_hudmodel, viewtag);
1016 setattachment(self.tur_head, self, "");
1017 setattachment(self.vehicle_hudmodel, self, hudtag);
1018 setattachment(self.vehicle_viewport, self.vehicle_hudmodel, viewtag);
1021 setsize(self, min_s, max_s);
1024 setorigin(self, self.origin);
1025 tracebox(self.origin + '0 0 100', min_s, max_s, self.origin - '0 0 10000', MOVE_WORLDONLY, self);
1026 setorigin(self, trace_endpos);
1029 self.pos1 = self.origin;
1030 self.pos2 = self.angles;
1031 self.tur_head.team = self.team;
1038 self.vehicle_exit = self.vehicle_exit;
1039 self.vehicle_enter = self.vehicle_exit;
1040 self.vehicle_die = self.vehicle_exit;
1041 self.vehicle_spawn = self.vehicle_exit;
1042 self.AuxiliaryXhair = self.AuxiliaryXhair;