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.teleportable = FALSE; // no teleporting for vehicles, too buggy
342 self.damagedbycontents = TRUE;
343 self.movetype = MOVETYPE_WALK;
344 self.solid = SOLID_SLIDEBOX;
345 self.takedamage = DAMAGE_AIM;
346 self.deadflag = DEAD_NO;
347 self.bot_attack = TRUE;
348 self.flags = FL_NOTARGET;
349 self.avelocity = '0 0 0';
350 self.velocity = '0 0 0';
353 self.lock_strength = 0;
354 self.lock_target = world;
355 self.misc_bulletcounter = 0;
358 self.angles = self.pos2;
359 setorigin(self, self.pos1 + '0 0 0');
361 pointparticles(particleeffectnum("teleport"), self.origin + '0 0 64', '0 0 0', 1);
363 vehicles_reset_colors();
364 self.vehicle_spawn();
367 // Better way of determening whats crushable needed! (fl_crushable?)
368 float vehicles_crushable(entity e)
370 if(e.classname == "player")
373 if(e.classname == "monster_zombie")
379 void vehilces_impact(float _minspeed, float _speedfac, float _maxpain)
381 if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
384 if(self.play_time < time)
386 float wc = vlen(self.velocity - self.oldvelocity);
387 //dprint("oldvel: ", vtos(self.oldvelocity), "\n");
388 //dprint("vel: ", vtos(self.velocity), "\n");
391 float take = take = min(_speedfac * wc, _maxpain);
392 Damage (self, world, world, take, DEATH_FALL, self.origin, '0 0 0');
393 self.play_time = time + 0.25;
395 //dprint("wc: ", ftos(wc), "\n");
396 //dprint("take: ", ftos(take), "\n");
401 .void() vehicle_impact;
402 void vehicles_touch()
404 // Vehicle currently in use
408 if(vehicles_crushable(other))
410 if(vlen(self.velocity) != 0)
411 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);
413 return; // Dont do selfdamage when hitting "soft targets".
416 if(self.play_time < time)
417 if(self.vehicle_impact)
418 self.vehicle_impact();
423 if(other.classname != "player")
426 if(other.deadflag != DEAD_NO)
429 if(other.vehicle != world)
432 // Remove this when bots know how to use vehicles.
433 if (clienttype(other) != CLIENTTYPE_REAL)
439 void vehicles_enter()
441 // Remove this when bots know how to use vehicles
442 if (clienttype(other) != CLIENTTYPE_REAL)
445 if(self.phase > time)
450 if(self.team != other.team)
453 RemoveGrapplingHook(other);
455 self.vehicle_ammo1 = 0;
456 self.vehicle_ammo2 = 0;
457 self.vehicle_reload1 = 0;
458 self.vehicle_reload2 = 0;
459 self.vehicle_energy = 0;
462 self.switchweapon = other.switchweapon;
464 // .viewmodelforclient works better.
465 //self.vehicle_hudmodel.drawonlytoclient = self.owner;
467 self.vehicle_hudmodel.viewmodelforclient = self.owner;
469 self.event_damage = vehicles_damage;
471 self.owner.angles = self.angles;
472 self.owner.takedamage = DAMAGE_NO;
473 self.owner.solid = SOLID_NOT;
474 self.owner.movetype = MOVETYPE_NOCLIP;
475 self.owner.alpha = -1;
476 self.owner.vehicle = self;
477 self.owner.event_damage = SUB_Null;
478 self.owner.view_ofs = '0 0 0';
479 self.colormap = self.owner.colormap;
481 self.tur_head.colormap = self.owner.colormap;
483 self.owner.hud = self.hud;
484 self.owner.PlayerPhysplug = self.PlayerPhysplug;
486 self.owner.vehicle_ammo1 = self.vehicle_ammo1;
487 self.owner.vehicle_ammo2 = self.vehicle_ammo2;
488 self.owner.vehicle_reload1 = self.vehicle_reload1;
489 self.owner.vehicle_reload2 = self.vehicle_reload2;
491 // Cant do this, hides attached objects too.
492 //self.exteriormodeltoclient = self.owner;
493 //self.tur_head.exteriormodeltoclient = self.owner;
495 other.flags &~= FL_ONGROUND;
496 self.flags &~= FL_ONGROUND;
498 self.team = self.owner.team;
499 self.flags -= FL_NOTARGET;
502 WriteByte (MSG_ONE, SVC_SETVIEWPORT);
503 WriteEntity(MSG_ONE, self.vehicle_viewport);
505 WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
508 WriteAngle(MSG_ONE, self.tur_head.angles_x + self.angles_x); // tilt
509 WriteAngle(MSG_ONE, self.tur_head.angles_y + self.angles_y); // yaw
510 WriteAngle(MSG_ONE, 0); // roll
514 WriteAngle(MSG_ONE, self.angles_x * -1); // tilt
515 WriteAngle(MSG_ONE, self.angles_y); // yaw
516 WriteAngle(MSG_ONE, 0); // roll
519 vehicles_clearrturn();
521 CSQCVehicleSetup(self.owner, self.hud);
523 MUTATOR_CALLHOOK(VehicleEnter);
525 self.vehicle_enter();
526 antilag_clear(other);
529 /** vehicles_findgoodexit
530 Locates a valid location for the player to exit the vehicle.
531 Will first try prefer_spot, then up 100 random spots arround the vehicle
532 wich are in direct line of sight and empty enougth to hold a players bbox
534 vector vehicles_findgoodexit(vector prefer_spot)
539 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, prefer_spot, MOVE_NORMAL, self.owner);
540 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
543 mysize = vlen(self.maxs - self.mins);
546 v2 = 0.5 * (self.absmin + self.absmax);
547 for(i = 0; i < 100; ++i)
551 v = v2 + normalize(v) * mysize;
552 tracebox(v2, PL_MIN, PL_MAX, v, MOVE_NORMAL, self.owner);
553 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
558 exitspot = (self.origin + '0 0 48') + v_forward * mysize;
559 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
560 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
563 exitspot = (self.origin + '0 0 48') - v_forward * mysize;
564 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
565 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
568 exitspot = (self.origin + '0 0 48') + v_right * mysize;
569 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
570 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
573 exitspot = (self.origin + '0 0 48') - v_right * mysize;
574 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
575 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
583 Standarrd vehicle release fucntion.
584 custom code goes in self.vehicle_exit
586 void vehicles_exit(float eject)
589 if(self.flags & FL_CLIENT)
595 self.flags |= FL_NOTARGET;
599 msg_entity = self.owner;
600 WriteByte (MSG_ONE, SVC_SETVIEWPORT);
601 WriteEntity( MSG_ONE, self.owner);
603 WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
604 WriteAngle(MSG_ONE, 0); // pich
605 WriteAngle(MSG_ONE, self.angles_y); // yaw
606 WriteAngle(MSG_ONE, 0); // roll
608 setsize(self.owner, PL_MIN,PL_MAX);
610 self.owner.takedamage = DAMAGE_AIM;
611 self.owner.solid = SOLID_SLIDEBOX;
612 self.owner.movetype = MOVETYPE_WALK;
613 self.owner.effects &~= EF_NODRAW;
614 self.owner.alpha = 1;
615 self.owner.PlayerPhysplug = SUB_Null;
616 self.owner.vehicle = world;
617 self.owner.view_ofs = PL_VIEW_OFS;
618 self.owner.event_damage = PlayerDamage;
619 self.owner.hud = HUD_NORMAL;
620 self.owner.switchweapon = self.switchweapon;
621 //self.owner.BUTTON_USE = 0;
623 CSQCVehicleSetup(self.owner, HUD_NORMAL);
626 if(self.deadflag == DEAD_NO)
627 self.avelocity = '0 0 0';
629 self.vehicle_hudmodel.viewmodelforclient = self;
630 self.tur_head.nodrawtoclient = world;
631 vehicles_setreturn();
633 self.phase = time + 1;
638 self.team = self.tur_head.team;
640 MUTATOR_CALLHOOK(VehicleExit);
642 sound (self, CH_TRIGGER_SINGLE, "misc/null.wav", 1, ATTN_NORM);
643 self.vehicle_exit(eject);
645 vehicles_reset_colors();
652 void vehicles_regen(.float timer, .float regen_field, float field_max, float rpause, float regen, float delta_time)
654 if(self.regen_field < field_max)
655 if(self.timer + rpause < time)
657 self.regen_field = min(self.regen_field + regen * delta_time, field_max);
660 self.owner.regen_field = (self.regen_field / field_max) * 100;
664 void shieldhit_think()
669 //setmodel(self, "");
674 self.nextthink = time + 0.1;
678 void vehicles_painframe()
680 if(self.owner.vehicle_health <= 50)
681 if(self.pain_frame < time)
684 _ftmp = self.owner.vehicle_health / 50;
685 self.pain_frame = time + 0.1 + (random() * 0.5 * _ftmp);
686 pointparticles(particleeffectnum("smoke_small"), (self.origin + (randomvec() * 80)), '0 0 0', 1);
688 if(self.vehicle_flags & VHF_DMGSHAKE)
689 self.velocity += randomvec() * 30;
691 if(self.vehicle_flags & VHF_DMGROLL)
692 if(self.vehicle_flags & VHF_DMGHEADROLL)
693 self.tur_head.angles += randomvec();
695 self.angles += randomvec();
700 void vehicles_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
702 self.dmg_time = time;
704 if((self.vehicle_flags & VHF_HASSHIELD) && (self.vehicle_shield > 0))
706 if (wasfreed(self.vehicle_shieldent) || self.vehicle_shieldent == world)
708 self.vehicle_shieldent = spawn();
709 self.vehicle_shieldent.effects = EF_LOWPRECISION;
711 setmodel(self.vehicle_shieldent, "models/vhshield.md3");
712 setattachment(self.vehicle_shieldent, self, "");
713 setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
714 self.vehicle_shieldent.scale = 256 / vlen(self.maxs - self.mins);
715 self.vehicle_shieldent.think = shieldhit_think;
718 self.vehicle_shieldent.colormod = '1 1 1';
719 self.vehicle_shieldent.alpha = 0.45;
720 self.vehicle_shieldent.angles = vectoangles(normalize(hitloc - (self.origin + self.vehicle_shieldent.origin))) - self.angles;
721 self.vehicle_shieldent.nextthink = time;
723 self.vehicle_shield -= damage;
725 if(self.vehicle_shield < 0)
727 self.vehicle_health -= fabs(self.vehicle_shield);
728 self.vehicle_shieldent.colormod = '2 0 0';
729 self.vehicle_shield = 0;
730 self.vehicle_shieldent.alpha = 0.75;
732 if(sound_allowed(MSG_BROADCAST, attacker))
733 spamsound (self, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTN_NORM); // FIXME: PLACEHOLDER
736 if(sound_allowed(MSG_BROADCAST, attacker))
737 spamsound (self, CH_PAIN, "onslaught/electricity_explode.wav", VOL_BASE, ATTN_NORM); // FIXME: PLACEHOLDER
742 self.vehicle_health -= damage;
744 if(sound_allowed(MSG_BROADCAST, attacker))
745 spamsound (self, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTN_NORM); // FIXME: PLACEHOLDER
748 self.velocity += force; // * (vlen(force) / self.mass);
750 if(self.vehicle_health <= 0)
753 if(self.vehicle_flags & VHF_DEATHEJECT)
754 vehicles_exit(VHEF_EJECT);
756 vehicles_exit(VHEF_RELESE);
759 vehicles_setreturn();
763 void vehicles_clearrturn()
766 // Remove "return helper", if any.
767 ret = findchain(classname, "vehicle_return");
770 if(ret.enemy == self)
773 ret.think = SUB_Remove;
774 ret.nextthink = time + 0.1;
776 if(ret.waypointsprite_attached)
777 WaypointSprite_Kill(ret.waypointsprite_attached);
785 void vehicles_return()
787 pointparticles(particleeffectnum("teleport"), self.enemy.origin + '0 0 64', '0 0 0', 1);
789 self.enemy.think = vehicles_spawn;
790 self.enemy.nextthink = time;
792 if(self.waypointsprite_attached)
793 WaypointSprite_Kill(self.waypointsprite_attached);
798 void vehicles_showwp_goaway()
800 if(self.waypointsprite_attached)
801 WaypointSprite_Kill(self.waypointsprite_attached);
807 void vehicles_showwp()
814 self.think = vehicles_return;
815 self.nextthink = self.cnt;
819 self.think = vehicles_return;
820 self.nextthink = time +1;
824 setmodel(self, "null");
825 self.team = oldself.enemy.team;
826 self.enemy = oldself.enemy;
827 setorigin(self, oldself.enemy.pos1);
829 self.nextthink = time + 5;
830 self.think = vehicles_showwp_goaway;
833 if(teamplay && self.team)
834 rgb = TeamColor(self.team);
837 WaypointSprite_Spawn("vehicle", 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, TRUE, RADARICON_POWERUP, rgb);
838 if(self.waypointsprite_attached)
840 WaypointSprite_UpdateRule(self.waypointsprite_attached, self.enemy.team, SPRITERULE_DEFAULT);
842 WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, self.nextthink);
843 WaypointSprite_Ping(self.waypointsprite_attached);
850 void vehicles_setreturn()
854 vehicles_clearrturn();
857 ret.classname = "vehicle_return";
859 ret.team = self.team;
860 ret.think = vehicles_showwp;
862 if(self.deadflag != DEAD_NO)
864 ret.cnt = time + self.vehicle_respawntime;
865 ret.nextthink = min(time + self.vehicle_respawntime, time + self.vehicle_respawntime - 5);
869 ret.nextthink = min(time + self.vehicle_respawntime, time + self.vehicle_respawntime - 1);
872 setmodel(ret, "null");
873 setorigin(ret, self.pos1 + '0 0 96');
877 void vehicles_configcheck(string configname, float check_cvar)
880 localcmd(strcat("exec ", configname, "\n"));
883 void vehicles_reset_colors()
886 float _effects, _colormap;
887 vector _glowmod, _colormod;
889 if(autocvar_g_nodepthtestplayers)
890 _effects = EF_NODEPTHTEST;
892 if(autocvar_g_fullbrightplayers)
893 _effects |= EF_FULLBRIGHT;
896 _colormap = 1024 + (self.team - 1) * 17;
903 // Find all ents attacked to main model and setup effects, colormod etc.
904 e = findchainentity(tag_entity, self);
907 if(e != self.vehicle_shieldent)
909 e.effects = _effects; // | EF_LOWPRECISION;
910 e.colormod = _colormod;
911 e.colormap = _colormap;
917 self.vehicle_hudmodel.effects = self.effects = _effects; // | EF_LOWPRECISION;
918 self.vehicle_hudmodel.colormod = self.colormod = _colormod;
919 self.vehicle_hudmodel.colormap = self.colormap = _colormap;
920 self.vehicle_viewport.effects = (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NOGUNBOB | EF_NOSHADOW | EF_LOWPRECISION | EF_SELECTABLE | EF_TELEPORT_BIT);
923 self.avelocity = '0 0 0';
924 self.velocity = '0 0 0';
925 self.effects = _effects;
928 float vehicle_initialize(string net_name,
943 void(float extflag) exitfunc,
948 addstat(STAT_HUD, AS_INT, hud);
949 addstat(STAT_VEHICLESTAT_HEALTH, AS_INT, vehicle_health);
950 addstat(STAT_VEHICLESTAT_SHIELD, AS_INT, vehicle_shield);
951 addstat(STAT_VEHICLESTAT_ENERGY, AS_INT, vehicle_energy);
953 addstat(STAT_VEHICLESTAT_AMMO1, AS_INT, vehicle_ammo1);
954 addstat(STAT_VEHICLESTAT_RELOAD1, AS_INT, vehicle_reload1);
956 addstat(STAT_VEHICLESTAT_AMMO2, AS_INT, vehicle_ammo2);
957 addstat(STAT_VEHICLESTAT_RELOAD2, AS_INT, vehicle_reload2);
960 error("vehicles: missing bodymodel!");
963 error("vehicles: missing hudmodel!");
966 self.netname = self.classname;
968 self.netname = net_name;
970 if(self.team && !teamplay)
973 self.vehicle_flags |= VHF_ISVEHICLE;
975 setmodel(self, bodymodel);
977 self.vehicle_viewport = spawn();
978 self.vehicle_hudmodel = spawn();
979 self.tur_head = spawn();
980 self.tur_head.owner = self;
981 self.takedamage = DAMAGE_AIM;
982 self.bot_attack = TRUE;
983 self.iscreature = TRUE;
984 self.teleportable = FALSE; // no teleporting for vehicles, too buggy
985 self.damagedbycontents = TRUE;
988 self.vehicle_die = dieproc;
989 self.vehicle_exit = exitfunc;
990 self.vehicle_enter = enterproc;
991 self.PlayerPhysplug = physproc;
992 self.event_damage = vehicles_damage;
993 self.touch = vehicles_touch;
994 self.think = vehicles_spawn;
995 self.nextthink = time;
996 self.vehicle_respawntime = _respawntime;
997 self.vehicle_spawn = spawnproc;
999 if(autocvar_g_nodepthtestplayers)
1000 self.effects = self.effects | EF_NODEPTHTEST;
1002 if(autocvar_g_fullbrightplayers)
1003 self.effects = self.effects | EF_FULLBRIGHT;
1005 setmodel(self.vehicle_hudmodel, hudmodel);
1006 setmodel(self.vehicle_viewport, "null");
1011 setmodel(self.tur_head, topmodel);
1012 setattachment(self.tur_head, self, toptag);
1013 setattachment(self.vehicle_hudmodel, self.tur_head, hudtag);
1014 setattachment(self.vehicle_viewport, self.vehicle_hudmodel, viewtag);
1018 setattachment(self.tur_head, self, "");
1019 setattachment(self.vehicle_hudmodel, self, hudtag);
1020 setattachment(self.vehicle_viewport, self.vehicle_hudmodel, viewtag);
1023 setsize(self, min_s, max_s);
1026 setorigin(self, self.origin);
1027 tracebox(self.origin + '0 0 100', min_s, max_s, self.origin - '0 0 10000', MOVE_WORLDONLY, self);
1028 setorigin(self, trace_endpos);
1031 self.pos1 = self.origin;
1032 self.pos2 = self.angles;
1033 self.tur_head.team = self.team;
1040 self.vehicle_exit = self.vehicle_exit;
1041 self.vehicle_enter = self.vehicle_exit;
1042 self.vehicle_die = self.vehicle_exit;
1043 self.vehicle_spawn = self.vehicle_exit;
1044 self.AuxiliaryXhair = self.AuxiliaryXhair;