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;
5 float autocvar_g_vehicles_allow_flagcarry;
7 void vehicles_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force);
8 void vehicles_return();
10 void vehicles_touch();
11 void vehicles_reset_colors();
12 void vehicles_clearrturn();
13 void vehicles_setreturn();
17 Send additional points of interest to be drawn, to vehicle owner
20 .entity AuxiliaryXhair[MAX_AXH];
22 float SendAuxiliaryXhair(entity to, float sf)
25 WriteByte(MSG_ENTITY, ENT_CLIENT_AUXILIARYXHAIR);
27 WriteByte(MSG_ENTITY, self.cnt);
29 WriteCoord(MSG_ENTITY, self.origin_x);
30 WriteCoord(MSG_ENTITY, self.origin_y);
31 WriteCoord(MSG_ENTITY, self.origin_z);
33 WriteByte(MSG_ENTITY, rint(self.colormod_x * 255));
34 WriteByte(MSG_ENTITY, rint(self.colormod_y * 255));
35 WriteByte(MSG_ENTITY, rint(self.colormod_z * 255));
40 void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, float axh_id)
44 axh_id = bound(0, axh_id, MAX_AXH);
45 axh = own.AuxiliaryXhair[axh_id];
47 if(axh == world || wasfreed(axh)) // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
51 axh.drawonlytoclient = own;
53 Net_LinkEntity(axh, FALSE, 0, SendAuxiliaryXhair);
59 own.AuxiliaryXhair[axh_id] = axh;
63 // SVC_TEMPENTITY based, horrible with even 50 ping. hm.
64 // WriteByte(MSG_ONE, SVC_TEMPENTITY) uses reliable messagess, never use for thinsg that need continous updates.
65 void SendAuxiliaryXhair2(entity own, vector loc, vector clr, float axh_id)
69 WriteByte(MSG_ONE, SVC_TEMPENTITY);
70 WriteByte(MSG_ONE, TE_CSQC_AUXILIARYXHAIR);
72 WriteByte(MSG_ONE, axh_id);
74 WriteCoord(MSG_ONE, loc_x);
75 WriteCoord(MSG_ONE, loc_y);
76 WriteCoord(MSG_ONE, loc_z);
78 WriteByte(MSG_ONE, rint(clr_x * 255));
79 WriteByte(MSG_ONE, rint(clr_y * 255));
80 WriteByte(MSG_ONE, rint(clr_z * 255));
87 Notifies the client that he enterd a vehicle, and sends
90 only sends vehicle_id atm (wich is a HUD_* constant, ex. HUD_SPIDERBOT)
92 void CSQCVehicleSetup(entity own, float vehicle_id)
96 WriteByte(MSG_ONE, SVC_TEMPENTITY);
97 WriteByte(MSG_ONE, TE_CSQC_VEHICLESETUP);
98 WriteByte(MSG_ONE, vehicle_id);
101 /** vehicles_locktarget
103 Generic target locking.
105 Figure out if what target is "locked" (if any), for missile tracking as such.
107 after calling, "if(self.lock_target != world && self.lock_strength == 1)" mean
108 you have a locked in target.
110 Exspects a crosshair_trace() or equivalent to be
115 .float lock_strength;
117 .float lock_soundtime;
118 void vehicles_locktarget(float incr, float decr, float _lock_time)
120 if(self.lock_target && self.lock_target.deadflag != DEAD_NO)
122 self.lock_target = world;
123 self.lock_strength = 0;
127 if(self.lock_time > time)
130 if(self.lock_soundtime < time)
132 self.lock_soundtime = time + 0.5;
133 play2(self.owner, "vehicles/locked.wav");
139 if(trace_ent != world)
141 if(teamplay && trace_ent.team == self.team)
144 if(trace_ent.deadflag != DEAD_NO)
147 if not (trace_ent.vehicle_flags & VHF_ISVEHICLE || trace_ent.turrcaps_flags & TFL_TURRCAPS_ISTURRET)
151 if(self.lock_target == world && trace_ent != world)
152 self.lock_target = trace_ent;
154 if(self.lock_target && trace_ent == self.lock_target)
156 if(self.lock_strength != 1 && self.lock_strength + incr >= 1)
158 play2(self.owner, "vehicles/lock.wav");
159 self.lock_soundtime = time + 0.8;
161 else if (self.lock_strength != 1 && self.lock_soundtime < time)
163 play2(self.owner, "vehicles/locking.wav");
164 self.lock_soundtime = time + 0.3;
169 // Have a locking target
170 // Trace hit current target
171 if(trace_ent == self.lock_target && trace_ent != world)
173 self.lock_strength = min(self.lock_strength + incr, 1);
174 if(self.lock_strength == 1)
175 self.lock_time = time + _lock_time;
180 self.lock_strength = max(self.lock_strength - decr * 2, 0);
182 self.lock_strength = max(self.lock_strength - decr, 0);
184 if(self.lock_strength == 0)
185 self.lock_target = world;
189 #define VEHICLE_UPDATE_PLAYER(fld,vhname) \
190 self.owner.vehicle_##fld = (self.vehicle_##fld / autocvar_g_vehicle_##vhname##_##fld) * 100
192 #define vehicles_sweap_collision(orig,vel,dt,acm,mult) \
193 traceline(orig, orig + vel * dt, MOVE_NORMAL, self); \
194 if(trace_fraction != 1) \
195 acm += normalize(self.origin - trace_endpos) * (vlen(vel) * mult)
197 // Hover movement support
198 float force_fromtag_power;
199 float force_fromtag_normpower;
200 vector force_fromtag_origin;
201 vector vehicles_force_fromtag_hover(string tag_name, float spring_length, float max_power)
203 force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name));
204 v_forward = normalize(v_forward) * -1;
205 traceline(force_fromtag_origin, force_fromtag_origin - (v_forward * spring_length), MOVE_NORMAL, self);
207 force_fromtag_power = (1 - trace_fraction) * max_power;
208 force_fromtag_normpower = force_fromtag_power / max_power;
210 return v_forward * force_fromtag_power;
213 // Experimental hovermode wich uses attraction/repulstion from surface insted of gravity/repulsion
214 // Can possibly be use to move abt any surface (inclusing walls/celings)
215 vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float max_power)
218 force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name));
219 v_forward = normalize(v_forward) * -1;
220 traceline(force_fromtag_origin, force_fromtag_origin - (v_forward * spring_length), MOVE_NORMAL, self);
222 // TODO - this may NOT be compatible with wall/celing movement, unhardcode 0.25 (engine count multiplier)
223 if(trace_fraction == 1.0)
225 force_fromtag_normpower = -0.25;
229 force_fromtag_power = ((1 - trace_fraction) - trace_fraction) * max_power;
230 force_fromtag_normpower = force_fromtag_power / max_power;
232 return v_forward * force_fromtag_power;
235 // Generic vehile projectile system
236 void vehicles_projectile_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
238 // Ignore damage from oterh projectiles from my owner (dont mess up volly's)
239 if(inflictor.owner == self.owner)
242 self.health -= damage;
243 self.velocity += force;
246 self.takedamage = DAMAGE_NO;
247 self.event_damage = SUB_Null;
248 self.think = self.use;
249 self.nextthink = time;
254 void vehicles_projectile_explode()
256 if(self.owner && other != world)
258 if(other == self.owner.vehicle)
261 if(other == self.owner.vehicle.tur_head)
267 self.event_damage = SUB_Null;
268 RadiusDamage (self, self.realowner, self.shot_dmg, 0, self.shot_radius, self, self.shot_force, self.totalfrags, other);
273 entity vehicles_projectile(string _mzlfx, string _mzlsound,
274 vector _org, vector _vel,
275 float _dmg, float _radi, float _force, float _size,
276 float _deahtype, float _projtype, float _health,
277 float _cull, float _clianim)
283 PROJECTILE_MAKETRIGGER(proj);
284 setorigin(proj, _org);
286 proj.shot_dmg = _dmg;
287 proj.shot_radius = _radi;
288 proj.shot_force = _force;
289 proj.totalfrags = _deahtype;
290 proj.solid = SOLID_BBOX;
291 proj.movetype = MOVETYPE_FLYMISSILE;
292 proj.flags = FL_PROJECTILE;
293 proj.bot_dodge = TRUE;
294 proj.bot_dodgerating = _dmg;
295 proj.velocity = _vel;
296 proj.touch = vehicles_projectile_explode;
297 proj.use = vehicles_projectile_explode;
299 proj.realowner = self.owner;
300 proj.think = SUB_Remove;
301 proj.nextthink = time + 30;
305 proj.takedamage = DAMAGE_AIM;
306 proj.event_damage = vehicles_projectile_damage;
307 proj.health = _health;
310 proj.flags = FL_PROJECTILE | FL_NOTARGET;
313 sound (self, CHAN_WEAPON, _mzlsound, VOL_BASE, ATTN_NORM);
316 pointparticles(particleeffectnum(_mzlfx), proj.origin, proj.velocity, 1);
319 setsize (proj, '-1 -1 -1' * _size, '1 1 1' * _size);
321 CSQCProjectile(proj, _clianim, _projtype, _cull);
325 // End generic vehile projectile system
328 Exetuted for all vehicles on (re)spawn.
329 Sets defaults for newly spawned units.
331 void vehicles_spawn()
333 dprint("Spawning vehicle: ", self.netname, "\n");
336 self.vehicle_hudmodel.viewmodelforclient = self;
339 self.touch = vehicles_touch;
340 self.event_damage = vehicles_damage;
341 self.iscreature = 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 128');
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 vehicles_touch()
380 // Vehicle currently in use
383 // Colided with world?
389 if(other.vehicle_flags & VHF_ISVEHICLE)
391 //other.velocity += self.velocity * (self.mass / other.mass);
393 else if(vehicles_crushable(other))
395 if(vlen(self.velocity) != 0)
396 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);
402 if(other.classname != "player")
405 if(other.deadflag != DEAD_NO)
408 if(other.vehicle != world)
411 // Remove this when bots know how to use vehicles.
412 if (clienttype(other) != CLIENTTYPE_REAL)
418 void vehicles_enter()
420 // Remove this when bots know how to use vehicles
421 if (clienttype(other) != CLIENTTYPE_REAL)
424 if(self.phase > time)
429 if(self.team != other.team)
432 self.vehicle_ammo1 = 0;
433 self.vehicle_ammo2 = 0;
434 self.vehicle_reload1 = 0;
435 self.vehicle_reload2 = 0;
436 self.vehicle_energy = 0;
439 self.switchweapon = other.switchweapon;
441 // .viewmodelforclient works better.
442 //self.vehicle_hudmodel.drawonlytoclient = self.owner;
444 self.vehicle_hudmodel.viewmodelforclient = self.owner;
446 self.event_damage = vehicles_damage;
448 self.owner.angles = self.angles;
449 self.owner.takedamage = DAMAGE_NO;
450 self.owner.solid = SOLID_NOT;
451 self.owner.movetype = MOVETYPE_NOCLIP;
452 self.owner.alpha = -1;
453 self.owner.vehicle = self;
454 self.owner.event_damage = SUB_Null;
455 self.owner.view_ofs = '0 0 0';
456 self.colormap = self.owner.colormap;
458 self.tur_head.colormap = self.owner.colormap;
460 self.owner.hud = self.hud;
461 self.owner.PlayerPhysplug = self.PlayerPhysplug;
463 self.owner.vehicle_ammo1 = self.vehicle_ammo1;
464 self.owner.vehicle_ammo2 = self.vehicle_ammo2;
465 self.owner.vehicle_reload1 = self.vehicle_reload1;
466 self.owner.vehicle_reload2 = self.vehicle_reload2;
468 // Cant do this, hides attached objects too.
469 //self.exteriormodeltoclient = self.owner;
470 //self.tur_head.exteriormodeltoclient = self.owner;
472 other.flags &~= FL_ONGROUND;
473 self.flags &~= FL_ONGROUND;
475 self.team = self.owner.team;
476 self.flags -= FL_NOTARGET;
479 WriteByte (MSG_ONE, SVC_SETVIEWPORT);
480 WriteEntity(MSG_ONE, self.vehicle_viewport);
482 WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
485 WriteAngle(MSG_ONE, self.tur_head.angles_x + self.angles_x); // tilt
486 WriteAngle(MSG_ONE, self.tur_head.angles_y + self.angles_y); // yaw
487 WriteAngle(MSG_ONE, 0); // roll
491 WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
492 WriteAngle(MSG_ONE, self.angles_x * -1); // tilt
493 WriteAngle(MSG_ONE, self.angles_y); // yaw
494 WriteAngle(MSG_ONE, 0); // roll
497 vehicles_clearrturn();
499 CSQCVehicleSetup(self.owner, self.hud);
501 if(other.flagcarried)
503 if(!autocvar_g_vehicles_allow_flagcarry)
504 DropFlag(other.flagcarried, world, world);
507 other.flagcarried.scale = 1;
508 setattachment(other.flagcarried, self, "");
509 setorigin(other, '0 0 96');
513 self.vehicle_enter();
516 /** vehicles_findgoodexit
517 Locates a valid location for the player to exit the vehicle.
518 Will first try prefer_spot, then up 100 random spots arround the vehicle
519 wich are in direct line of sight and empty enougth to hold a players bbox
521 vector vehicles_findgoodexit(vector prefer_spot)
526 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, prefer_spot, MOVE_NORMAL, self.owner);
527 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
530 mysize = vlen(self.maxs - self.mins);
533 v2 = 0.5 * (self.absmin + self.absmax);
534 for(i = 0; i < 100; ++i)
538 v = v2 + normalize(v) * mysize;
539 tracebox(v2, PL_MIN, PL_MAX, v, MOVE_NORMAL, self.owner);
540 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
545 exitspot = (self.origin + '0 0 48') + v_forward * mysize;
546 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
547 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
550 exitspot = (self.origin + '0 0 48') - v_forward * mysize;
551 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
552 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
555 exitspot = (self.origin + '0 0 48') + v_right * mysize;
556 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
557 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
560 exitspot = (self.origin + '0 0 48') - v_right * mysize;
561 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
562 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
570 Standarrd vehicle release fucntion.
571 custom code goes in self.vehicle_exit
573 void vehicles_exit(float eject)
576 if(self.flags & FL_CLIENT)
582 self.flags |= FL_NOTARGET;
586 msg_entity = self.owner;
587 WriteByte (MSG_ONE, SVC_SETVIEWPORT);
588 WriteEntity( MSG_ONE, self.owner);
590 WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
591 WriteAngle(MSG_ONE, 0); // pich
592 WriteAngle(MSG_ONE, self.angles_y); // yaw
593 WriteAngle(MSG_ONE, 0); // roll
595 setsize(self.owner, PL_MIN,PL_MAX);
597 self.owner.takedamage = DAMAGE_AIM;
598 self.owner.solid = SOLID_SLIDEBOX;
599 self.owner.movetype = MOVETYPE_WALK;
600 self.owner.effects &~= EF_NODRAW;
601 self.owner.alpha = 1;
602 self.owner.PlayerPhysplug = SUB_Null;
603 self.owner.vehicle = world;
604 self.owner.view_ofs = PL_VIEW_OFS;
605 self.owner.event_damage = PlayerDamage;
606 self.owner.hud = HUD_NORMAL;
607 self.owner.switchweapon = self.switchweapon;
608 //self.owner.BUTTON_USE = 0;
611 if(self.deadflag == DEAD_NO)
612 self.avelocity = '0 0 0';
614 self.vehicle_hudmodel.viewmodelforclient = self;
615 self.tur_head.nodrawtoclient = world;
616 vehicles_setreturn();
618 self.phase = time + 1;
623 if(self.owner.flagcarried)
625 self.owner.flagcarried.scale = 0.6;
626 setattachment(self.owner.flagcarried, self.owner, "");
627 setorigin(self.owner.flagcarried, FLAG_CARRY_POS);
630 sound (self, CHAN_TRIGGER, "misc/null.wav", 1, ATTN_NORM);
631 self.vehicle_exit(eject);
639 void vehicles_regen(.float timer, .float regen_field, float field_max, float rpause, float regen, float delta_time)
641 if(self.regen_field < field_max)
642 if(self.timer + rpause < time)
644 self.regen_field = min(self.regen_field + regen * delta_time, field_max);
647 self.owner.regen_field = (self.regen_field / field_max) * 100;
651 void shieldhit_think()
656 //setmodel(self, "");
661 self.nextthink = time + 0.1;
665 void vehicles_painframe()
667 //.float pain_finished; //Added by Supajoe
669 if(self.owner.vehicle_health <= 50)
670 if(self.pain_frame < time)
673 _ftmp = self.owner.vehicle_health / 50;
674 self.pain_frame = time + 0.1 + (random() * 0.5 * _ftmp);
675 pointparticles(particleeffectnum("smoke_small"), (self.origin + (randomvec() * 80)), '0 0 0', 1);
677 if(self.vehicle_flags & VHF_DMGSHAKE)
678 self.velocity += randomvec() * 30;
680 if(self.vehicle_flags & VHF_DMGROLL)
681 if(self.vehicle_flags & VHF_DMGHEADROLL)
682 self.tur_head.angles += randomvec();
684 self.angles += randomvec();
689 void vehicles_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
691 self.dmg_time = time;
693 if((self.vehicle_flags & VHF_HASSHIELD) && (self.vehicle_shield > 0))
695 if (wasfreed(self.vehicle_shieldent) || self.vehicle_shieldent == world)
697 self.vehicle_shieldent = spawn();
698 self.vehicle_shieldent.effects = EF_LOWPRECISION;
700 setmodel(self.vehicle_shieldent, "models/vhshield.md3");
701 setattachment(self.vehicle_shieldent, self, "");
702 setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
703 self.vehicle_shieldent.scale = 256 / vlen(self.maxs - self.mins);
704 self.vehicle_shieldent.think = shieldhit_think;
708 self.vehicle_shieldent.colormod = '1 1 1';
709 self.vehicle_shieldent.alpha = 0.45;
710 self.vehicle_shieldent.angles = vectoangles(normalize(hitloc - (self.origin + self.vehicle_shieldent.origin))) - self.angles;
711 self.vehicle_shieldent.nextthink = time;
713 self.vehicle_shield -= damage;
715 if(self.vehicle_shield < 0)
717 self.vehicle_shieldent.colormod = '2 0 0';
718 self.vehicle_shield = 0;
719 self.vehicle_shieldent.alpha = 0.75;
720 self.vehicle_health -= fabs(self.vehicle_shield);
724 self.vehicle_health -= damage;
726 self.velocity += force; // * (vlen(force) / self.mass);
728 if(self.vehicle_health <= 0)
731 if(self.vehicle_flags & VHF_DEATHEJECT)
732 vehicles_exit(VHEF_EJECT);
734 vehicles_exit(VHEF_RELESE);
737 vehicles_setreturn();
741 void vehicles_clearrturn()
744 // Remove "return helper", if any.
745 ret = findchain(classname, "vehicle_return");
748 if(ret.enemy == self)
751 ret.think = SUB_Remove;
752 ret.nextthink = time + 0.1;
754 if(ret.waypointsprite_attached)
755 WaypointSprite_Kill(ret.waypointsprite_attached);
763 void vehicles_return()
765 pointparticles(particleeffectnum("teleport"), self.enemy.origin + '0 0 64', '0 0 0', 1);
767 self.enemy.think = vehicles_spawn;
768 self.enemy.nextthink = time;
770 if(self.waypointsprite_attached)
771 WaypointSprite_Kill(self.waypointsprite_attached);
776 void vehicles_showwp_goaway()
778 if(self.waypointsprite_attached)
779 WaypointSprite_Kill(self.waypointsprite_attached);
785 void vehicles_showwp()
791 self.think = vehicles_return;
792 self.nextthink = self.cnt;
796 self.think = vehicles_return;
797 self.nextthink = time +1;
801 setmodel(self, "null");
802 self.team = oldself.enemy.team;
803 self.enemy = oldself.enemy;
804 setorigin(self, oldself.enemy.pos1);
806 self.nextthink = time + 5;
807 self.think = vehicles_showwp_goaway;
810 WaypointSprite_Spawn("vehicle", 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, TRUE);
811 if(self.waypointsprite_attached)
813 if(teamplay && self.team)
814 WaypointSprite_UpdateTeamRadar(self.waypointsprite_attached, RADARICON_POWERUP, TeamColor(self.team));
816 WaypointSprite_UpdateTeamRadar(self.waypointsprite_attached, RADARICON_POWERUP, '1 1 1');
818 WaypointSprite_UpdateRule(self.waypointsprite_attached, self.enemy.team, SPRITERULE_DEFAULT);
820 WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, self.nextthink);
822 WaypointSprite_Ping(self.waypointsprite_attached);
829 void vehicles_setreturn()
833 vehicles_clearrturn();
836 ret.classname = "vehicle_return";
838 ret.team = self.team;
839 ret.think = vehicles_showwp;
841 if(self.deadflag != DEAD_NO)
843 ret.cnt = time + self.vehicle_respawntime;
844 ret.nextthink = min(time + self.vehicle_respawntime, time + self.vehicle_respawntime - 5);
848 ret.nextthink = min(time + self.vehicle_respawntime, time + self.vehicle_respawntime - 1);
853 setmodel(ret, "null");
854 setorigin(ret, self.pos1 + '0 0 96');
858 void vehicles_configcheck(string configname, float check_cvar)
861 localcmd(strcat("exec ", configname, "\n"));
864 void vehicles_reset_colors()
867 float _effects, _colormap;
868 vector _glowmod, _colormod;
870 if(autocvar_g_nodepthtestplayers)
871 _effects = EF_NODEPTHTEST;
873 if(autocvar_g_fullbrightplayers)
874 _effects |= EF_FULLBRIGHT;
877 _colormap = 1024 + (self.team - 1) * 17;
884 // Find all ents attacked to main model and setup effects, colormod etc.
885 e = findchainentity(tag_entity, self);
888 if(e != self.vehicle_shieldent)
890 e.effects = _effects; // | EF_LOWPRECISION;
891 e.colormod = _colormod;
892 e.colormap = _colormap;
898 self.vehicle_hudmodel.effects = self.effects = _effects; // | EF_LOWPRECISION;
899 self.vehicle_hudmodel.colormod = self.colormod = _colormod;
900 self.vehicle_hudmodel.colormap = self.colormap = _colormap;
901 self.vehicle_viewport.effects = (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NOGUNBOB | EF_NOSHADOW | EF_LOWPRECISION | EF_SELECTABLE | EF_TELEPORT_BIT);
904 self.avelocity = '0 0 0';
905 self.velocity = '0 0 0';
906 self.effects = _effects;
909 float vehicle_initialize(string net_name,
924 void(float extflag) exitfunc,
929 addstat(STAT_HUD, AS_INT, hud);
930 addstat(STAT_VEHICLESTAT_HEALTH, AS_INT, vehicle_health);
931 addstat(STAT_VEHICLESTAT_SHIELD, AS_INT, vehicle_shield);
932 addstat(STAT_VEHICLESTAT_ENERGY, AS_INT, vehicle_energy);
934 addstat(STAT_VEHICLESTAT_AMMO1, AS_INT, vehicle_ammo1);
935 addstat(STAT_VEHICLESTAT_RELOAD1, AS_INT, vehicle_reload1);
937 addstat(STAT_VEHICLESTAT_AMMO2, AS_INT, vehicle_ammo2);
938 addstat(STAT_VEHICLESTAT_RELOAD2, AS_INT, vehicle_reload2);
941 error("vehicles: missing bodymodel!");
944 error("vehicles: missing hudmodel!");
947 self.netname = self.classname;
949 self.netname = net_name;
951 if(self.team && !teamplay)
954 self.vehicle_flags |= VHF_ISVEHICLE;
956 setmodel(self, bodymodel);
958 self.vehicle_viewport = spawn();
959 self.vehicle_hudmodel = spawn();
960 self.tur_head = spawn();
961 self.tur_head.owner = self;
962 self.takedamage = DAMAGE_AIM;
963 self.bot_attack = TRUE;
964 self.iscreature = TRUE;
967 self.vehicle_die = dieproc;
968 self.vehicle_exit = exitfunc;
969 self.vehicle_enter = enterproc;
970 self.PlayerPhysplug = physproc;
971 self.event_damage = vehicles_damage;
972 self.touch = vehicles_touch;
973 self.think = vehicles_spawn;
974 self.nextthink = time;
975 self.vehicle_respawntime = _respawntime;
976 self.vehicle_spawn = spawnproc;
978 if(autocvar_g_nodepthtestplayers)
979 self.effects = self.effects | EF_NODEPTHTEST;
981 if(autocvar_g_fullbrightplayers)
982 self.effects = self.effects | EF_FULLBRIGHT;
984 setmodel(self.vehicle_hudmodel, hudmodel);
985 setmodel(self.vehicle_viewport, "null");
990 setmodel(self.tur_head, topmodel);
991 setattachment(self.tur_head, self, toptag);
992 setattachment(self.vehicle_hudmodel, self.tur_head, hudtag);
993 setattachment(self.vehicle_viewport, self.vehicle_hudmodel, viewtag);
997 setattachment(self.tur_head, self, "");
998 setattachment(self.vehicle_hudmodel, self, hudtag);
999 setattachment(self.vehicle_viewport, self.vehicle_hudmodel, viewtag);
1002 setsize(self, min_s, max_s);
1005 setorigin(self, self.origin);
1006 tracebox(self.origin + '0 0 100', min_s, max_s, self.origin - '0 0 10000', MOVE_WORLDONLY, self);
1007 setorigin(self, trace_endpos);
1010 self.pos1 = self.origin;
1011 self.pos2 = self.angles;
1018 self.vehicle_exit = self.vehicle_exit;
1019 self.vehicle_enter = self.vehicle_exit;
1020 self.vehicle_die = self.vehicle_exit;
1021 self.vehicle_spawn = self.vehicle_exit;
1022 self.AuxiliaryXhair = self.AuxiliaryXhair;