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
114 void vh_crosshair_trace(entity player)
119 lag = ANTILAG_LATENCY(self);
122 if(clienttype(self) != CLIENTTYPE_REAL)
124 if(autocvar_g_antilag == 0 || self.cvar_cl_noantilag)
125 lag = 0; // only do hitscan, but no antilag
131 antilag_takeback(pl, time - lag);
133 antilag_takeback(pl.vehicle, time - lag);
137 crosshair_trace(player);
145 antilag_restore(pl.vehicle);
149 .float lock_strength;
151 .float lock_soundtime;
152 void vehicles_locktarget(float incr, float decr, float _lock_time)
154 if(self.lock_target && self.lock_target.deadflag != DEAD_NO)
156 self.lock_target = world;
157 self.lock_strength = 0;
161 if(self.lock_time > time)
164 if(self.lock_soundtime < time)
166 self.lock_soundtime = time + 0.5;
167 play2(self.owner, "vehicles/locked.wav");
173 if(trace_ent != world)
175 if(teamplay && trace_ent.team == self.team)
178 if(trace_ent.deadflag != DEAD_NO)
181 if not (trace_ent.vehicle_flags & VHF_ISVEHICLE || trace_ent.turrcaps_flags & TFL_TURRCAPS_ISTURRET || trace_ent.classname == "player")
185 if(self.lock_target == world && trace_ent != world)
186 self.lock_target = trace_ent;
188 if(self.lock_target && trace_ent == self.lock_target)
190 if(self.lock_strength != 1 && self.lock_strength + incr >= 1)
192 play2(self.owner, "vehicles/lock.wav");
193 self.lock_soundtime = time + 0.8;
195 else if (self.lock_strength != 1 && self.lock_soundtime < time)
197 play2(self.owner, "vehicles/locking.wav");
198 self.lock_soundtime = time + 0.3;
203 // Have a locking target
204 // Trace hit current target
205 if(trace_ent == self.lock_target && trace_ent != world)
207 self.lock_strength = min(self.lock_strength + incr, 1);
208 if(self.lock_strength == 1)
209 self.lock_time = time + _lock_time;
214 self.lock_strength = max(self.lock_strength - decr * 2, 0);
216 self.lock_strength = max(self.lock_strength - decr, 0);
218 if(self.lock_strength == 0)
219 self.lock_target = world;
223 #define VEHICLE_UPDATE_PLAYER(fld,vhname) \
224 self.owner.vehicle_##fld = (self.vehicle_##fld / autocvar_g_vehicle_##vhname##_##fld) * 100
226 #define vehicles_sweap_collision(orig,vel,dt,acm,mult) \
227 traceline(orig, orig + vel * dt, MOVE_NORMAL, self); \
228 if(trace_fraction != 1) \
229 acm += normalize(self.origin - trace_endpos) * (vlen(vel) * mult)
231 // Hover movement support
232 float force_fromtag_power;
233 float force_fromtag_normpower;
234 vector force_fromtag_origin;
235 vector vehicles_force_fromtag_hover(string tag_name, float spring_length, float max_power)
237 force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name));
238 v_forward = normalize(v_forward) * -1;
239 traceline(force_fromtag_origin, force_fromtag_origin - (v_forward * spring_length), MOVE_NORMAL, self);
241 force_fromtag_power = (1 - trace_fraction) * max_power;
242 force_fromtag_normpower = force_fromtag_power / max_power;
244 return v_forward * force_fromtag_power;
247 // Experimental hovermode wich uses attraction/repulstion from surface insted of gravity/repulsion
248 // Can possibly be use to move abt any surface (inclusing walls/celings)
249 vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float max_power)
252 force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name));
253 v_forward = normalize(v_forward) * -1;
254 traceline(force_fromtag_origin, force_fromtag_origin - (v_forward * spring_length), MOVE_NORMAL, self);
256 // TODO - this may NOT be compatible with wall/celing movement, unhardcode 0.25 (engine count multiplier)
257 if(trace_fraction == 1.0)
259 force_fromtag_normpower = -0.25;
263 force_fromtag_power = ((1 - trace_fraction) - trace_fraction) * max_power;
264 force_fromtag_normpower = force_fromtag_power / max_power;
266 return v_forward * force_fromtag_power;
269 // Generic vehile projectile system
270 void vehicles_projectile_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
272 // Ignore damage from oterh projectiles from my owner (dont mess up volly's)
273 if(inflictor.owner == self.owner)
276 self.health -= damage;
277 self.velocity += force;
280 self.takedamage = DAMAGE_NO;
281 self.event_damage = SUB_Null;
282 self.think = self.use;
283 self.nextthink = time;
288 void vehicles_projectile_explode()
290 if(self.owner && other != world)
292 if(other == self.owner.vehicle)
295 if(other == self.owner.vehicle.tur_head)
301 self.event_damage = SUB_Null;
302 RadiusDamage (self, self.realowner, self.shot_dmg, 0, self.shot_radius, self, self.shot_force, self.totalfrags, other);
307 entity vehicles_projectile(string _mzlfx, string _mzlsound,
308 vector _org, vector _vel,
309 float _dmg, float _radi, float _force, float _size,
310 float _deahtype, float _projtype, float _health,
311 float _cull, float _clianim)
317 PROJECTILE_MAKETRIGGER(proj);
318 setorigin(proj, _org);
320 proj.shot_dmg = _dmg;
321 proj.shot_radius = _radi;
322 proj.shot_force = _force;
323 proj.totalfrags = _deahtype;
324 proj.solid = SOLID_BBOX;
325 proj.movetype = MOVETYPE_FLYMISSILE;
326 proj.flags = FL_PROJECTILE;
327 proj.bot_dodge = TRUE;
328 proj.bot_dodgerating = _dmg;
329 proj.velocity = _vel;
330 proj.touch = vehicles_projectile_explode;
331 proj.use = vehicles_projectile_explode;
333 proj.realowner = self.owner;
334 proj.think = SUB_Remove;
335 proj.nextthink = time + 30;
339 proj.takedamage = DAMAGE_AIM;
340 proj.event_damage = vehicles_projectile_damage;
341 proj.health = _health;
344 proj.flags = FL_PROJECTILE | FL_NOTARGET;
347 sound (self, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTN_NORM);
350 pointparticles(particleeffectnum(_mzlfx), proj.origin, proj.velocity, 1);
353 setsize (proj, '-1 -1 -1' * _size, '1 1 1' * _size);
355 CSQCProjectile(proj, _clianim, _projtype, _cull);
359 // End generic vehile projectile system
362 Exetuted for all vehicles on (re)spawn.
363 Sets defaults for newly spawned units.
365 void vehicles_spawn()
367 dprint("Spawning vehicle: ", self.netname, "\n");
370 self.vehicle_hudmodel.viewmodelforclient = self;
373 self.touch = vehicles_touch;
374 self.event_damage = vehicles_damage;
375 self.iscreature = TRUE;
376 self.damagedbycontents = TRUE;
377 self.movetype = MOVETYPE_WALK;
378 self.solid = SOLID_SLIDEBOX;
379 self.takedamage = DAMAGE_AIM;
380 self.deadflag = DEAD_NO;
381 self.bot_attack = TRUE;
382 self.flags = FL_NOTARGET;
383 self.avelocity = '0 0 0';
384 self.velocity = '0 0 0';
387 self.lock_strength = 0;
388 self.lock_target = world;
389 self.misc_bulletcounter = 0;
392 self.angles = self.pos2;
393 setorigin(self, self.pos1 + '0 0 128');
395 pointparticles(particleeffectnum("teleport"), self.origin + '0 0 64', '0 0 0', 1);
397 vehicles_reset_colors();
398 self.vehicle_spawn();
401 // Better way of determening whats crushable needed! (fl_crushable?)
402 float vehicles_crushable(entity e)
404 if(e.classname == "player")
407 if(e.classname == "monster_zombie")
413 void vehicles_touch()
415 // Vehicle currently in use
418 // Colided with world?
424 if(other.vehicle_flags & VHF_ISVEHICLE)
426 //other.velocity += self.velocity * (self.mass / other.mass);
428 else if(vehicles_crushable(other))
430 if(vlen(self.velocity) != 0)
431 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);
437 if(other.classname != "player")
440 if(other.deadflag != DEAD_NO)
443 if(other.vehicle != world)
446 // Remove this when bots know how to use vehicles.
447 if (clienttype(other) != CLIENTTYPE_REAL)
453 void vehicles_enter()
455 // Remove this when bots know how to use vehicles
456 if (clienttype(other) != CLIENTTYPE_REAL)
459 if(self.phase > time)
464 if(self.team != other.team)
467 RemoveGrapplingHook(other);
469 self.vehicle_ammo1 = 0;
470 self.vehicle_ammo2 = 0;
471 self.vehicle_reload1 = 0;
472 self.vehicle_reload2 = 0;
473 self.vehicle_energy = 0;
476 self.switchweapon = other.switchweapon;
478 // .viewmodelforclient works better.
479 //self.vehicle_hudmodel.drawonlytoclient = self.owner;
481 self.vehicle_hudmodel.viewmodelforclient = self.owner;
483 self.event_damage = vehicles_damage;
485 self.owner.angles = self.angles;
486 self.owner.takedamage = DAMAGE_NO;
487 self.owner.solid = SOLID_NOT;
488 self.owner.movetype = MOVETYPE_NOCLIP;
489 self.owner.alpha = -1;
490 self.owner.vehicle = self;
491 self.owner.event_damage = SUB_Null;
492 self.owner.view_ofs = '0 0 0';
493 self.colormap = self.owner.colormap;
495 self.tur_head.colormap = self.owner.colormap;
497 self.owner.hud = self.hud;
498 self.owner.PlayerPhysplug = self.PlayerPhysplug;
500 self.owner.vehicle_ammo1 = self.vehicle_ammo1;
501 self.owner.vehicle_ammo2 = self.vehicle_ammo2;
502 self.owner.vehicle_reload1 = self.vehicle_reload1;
503 self.owner.vehicle_reload2 = self.vehicle_reload2;
505 // Cant do this, hides attached objects too.
506 //self.exteriormodeltoclient = self.owner;
507 //self.tur_head.exteriormodeltoclient = self.owner;
509 other.flags &~= FL_ONGROUND;
510 self.flags &~= FL_ONGROUND;
512 self.team = self.owner.team;
513 self.flags -= FL_NOTARGET;
516 WriteByte (MSG_ONE, SVC_SETVIEWPORT);
517 WriteEntity(MSG_ONE, self.vehicle_viewport);
519 WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
522 WriteAngle(MSG_ONE, self.tur_head.angles_x + self.angles_x); // tilt
523 WriteAngle(MSG_ONE, self.tur_head.angles_y + self.angles_y); // yaw
524 WriteAngle(MSG_ONE, 0); // roll
528 WriteAngle(MSG_ONE, self.angles_x * -1); // tilt
529 WriteAngle(MSG_ONE, self.angles_y); // yaw
530 WriteAngle(MSG_ONE, 0); // roll
533 vehicles_clearrturn();
535 CSQCVehicleSetup(self.owner, self.hud);
537 if(other.flagcarried)
539 if(!autocvar_g_vehicles_allow_flagcarry)
540 DropFlag(other.flagcarried, world, world);
543 other.flagcarried.scale = 1;
544 setattachment(other.flagcarried, self, "");
545 setorigin(other, '0 0 96');
549 self.vehicle_enter();
552 /** vehicles_findgoodexit
553 Locates a valid location for the player to exit the vehicle.
554 Will first try prefer_spot, then up 100 random spots arround the vehicle
555 wich are in direct line of sight and empty enougth to hold a players bbox
557 vector vehicles_findgoodexit(vector prefer_spot)
562 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, prefer_spot, MOVE_NORMAL, self.owner);
563 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
566 mysize = vlen(self.maxs - self.mins);
569 v2 = 0.5 * (self.absmin + self.absmax);
570 for(i = 0; i < 100; ++i)
574 v = v2 + normalize(v) * mysize;
575 tracebox(v2, PL_MIN, PL_MAX, v, MOVE_NORMAL, self.owner);
576 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
581 exitspot = (self.origin + '0 0 48') + v_forward * mysize;
582 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
583 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
586 exitspot = (self.origin + '0 0 48') - v_forward * mysize;
587 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
588 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
591 exitspot = (self.origin + '0 0 48') + v_right * mysize;
592 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
593 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
596 exitspot = (self.origin + '0 0 48') - v_right * mysize;
597 tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
598 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
606 Standarrd vehicle release fucntion.
607 custom code goes in self.vehicle_exit
609 void vehicles_exit(float eject)
612 if(self.flags & FL_CLIENT)
618 self.flags |= FL_NOTARGET;
622 msg_entity = self.owner;
623 WriteByte (MSG_ONE, SVC_SETVIEWPORT);
624 WriteEntity( MSG_ONE, self.owner);
626 WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
627 WriteAngle(MSG_ONE, 0); // pich
628 WriteAngle(MSG_ONE, self.angles_y); // yaw
629 WriteAngle(MSG_ONE, 0); // roll
631 setsize(self.owner, PL_MIN,PL_MAX);
633 self.owner.takedamage = DAMAGE_AIM;
634 self.owner.solid = SOLID_SLIDEBOX;
635 self.owner.movetype = MOVETYPE_WALK;
636 self.owner.effects &~= EF_NODRAW;
637 self.owner.alpha = 1;
638 self.owner.PlayerPhysplug = SUB_Null;
639 self.owner.vehicle = world;
640 self.owner.view_ofs = PL_VIEW_OFS;
641 self.owner.event_damage = PlayerDamage;
642 self.owner.hud = HUD_NORMAL;
643 self.owner.switchweapon = self.switchweapon;
644 //self.owner.BUTTON_USE = 0;
647 if(self.deadflag == DEAD_NO)
648 self.avelocity = '0 0 0';
650 self.vehicle_hudmodel.viewmodelforclient = self;
651 self.tur_head.nodrawtoclient = world;
652 vehicles_setreturn();
654 self.phase = time + 1;
659 self.team = self.tur_head.team;
661 if(self.owner.flagcarried)
663 self.owner.flagcarried.scale = 0.6;
664 setattachment(self.owner.flagcarried, self.owner, "");
665 setorigin(self.owner.flagcarried, FLAG_CARRY_POS);
668 sound (self, CH_TRIGGER_SINGLE, "misc/null.wav", 1, ATTN_NORM);
669 self.vehicle_exit(eject);
671 vehicles_reset_colors();
678 void vehicles_regen(.float timer, .float regen_field, float field_max, float rpause, float regen, float delta_time)
680 if(self.regen_field < field_max)
681 if(self.timer + rpause < time)
683 self.regen_field = min(self.regen_field + regen * delta_time, field_max);
686 self.owner.regen_field = (self.regen_field / field_max) * 100;
690 void shieldhit_think()
695 //setmodel(self, "");
700 self.nextthink = time + 0.1;
704 void vehicles_painframe()
706 //.float pain_finished; //Added by Supajoe
708 if(self.owner.vehicle_health <= 50)
709 if(self.pain_frame < time)
712 _ftmp = self.owner.vehicle_health / 50;
713 self.pain_frame = time + 0.1 + (random() * 0.5 * _ftmp);
714 pointparticles(particleeffectnum("smoke_small"), (self.origin + (randomvec() * 80)), '0 0 0', 1);
716 if(self.vehicle_flags & VHF_DMGSHAKE)
717 self.velocity += randomvec() * 30;
719 if(self.vehicle_flags & VHF_DMGROLL)
720 if(self.vehicle_flags & VHF_DMGHEADROLL)
721 self.tur_head.angles += randomvec();
723 self.angles += randomvec();
728 void vehicles_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
730 self.dmg_time = time;
732 if((self.vehicle_flags & VHF_HASSHIELD) && (self.vehicle_shield > 0))
734 if (wasfreed(self.vehicle_shieldent) || self.vehicle_shieldent == world)
736 self.vehicle_shieldent = spawn();
737 self.vehicle_shieldent.effects = EF_LOWPRECISION;
739 setmodel(self.vehicle_shieldent, "models/vhshield.md3");
740 setattachment(self.vehicle_shieldent, self, "");
741 setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
742 self.vehicle_shieldent.scale = 256 / vlen(self.maxs - self.mins);
743 self.vehicle_shieldent.think = shieldhit_think;
746 self.vehicle_shieldent.colormod = '1 1 1';
747 self.vehicle_shieldent.alpha = 0.45;
748 self.vehicle_shieldent.angles = vectoangles(normalize(hitloc - (self.origin + self.vehicle_shieldent.origin))) - self.angles;
749 self.vehicle_shieldent.nextthink = time;
751 self.vehicle_shield -= damage;
753 if(self.vehicle_shield < 0)
755 self.vehicle_health -= fabs(self.vehicle_shield);
756 self.vehicle_shieldent.colormod = '2 0 0';
757 self.vehicle_shield = 0;
758 self.vehicle_shieldent.alpha = 0.75;
760 if(sound_allowed(MSG_BROADCAST, attacker))
761 spamsound (self, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTN_NORM); // FIXME: PLACEHOLDER
764 if(sound_allowed(MSG_BROADCAST, attacker))
765 spamsound (self, CH_PAIN, "onslaught/electricity_explode.wav", VOL_BASE, ATTN_NORM); // FIXME: PLACEHOLDER
770 self.vehicle_health -= damage;
772 if(sound_allowed(MSG_BROADCAST, attacker))
773 spamsound (self, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTN_NORM); // FIXME: PLACEHOLDER
776 self.velocity += force; // * (vlen(force) / self.mass);
778 if(self.vehicle_health <= 0)
781 if(self.vehicle_flags & VHF_DEATHEJECT)
782 vehicles_exit(VHEF_EJECT);
784 vehicles_exit(VHEF_RELESE);
787 vehicles_setreturn();
791 void vehicles_clearrturn()
794 // Remove "return helper", if any.
795 ret = findchain(classname, "vehicle_return");
798 if(ret.enemy == self)
801 ret.think = SUB_Remove;
802 ret.nextthink = time + 0.1;
804 if(ret.waypointsprite_attached)
805 WaypointSprite_Kill(ret.waypointsprite_attached);
813 void vehicles_return()
815 pointparticles(particleeffectnum("teleport"), self.enemy.origin + '0 0 64', '0 0 0', 1);
817 self.enemy.think = vehicles_spawn;
818 self.enemy.nextthink = time;
820 if(self.waypointsprite_attached)
821 WaypointSprite_Kill(self.waypointsprite_attached);
826 void vehicles_showwp_goaway()
828 if(self.waypointsprite_attached)
829 WaypointSprite_Kill(self.waypointsprite_attached);
835 void vehicles_showwp()
842 self.think = vehicles_return;
843 self.nextthink = self.cnt;
847 self.think = vehicles_return;
848 self.nextthink = time +1;
852 setmodel(self, "null");
853 self.team = oldself.enemy.team;
854 self.enemy = oldself.enemy;
855 setorigin(self, oldself.enemy.pos1);
857 self.nextthink = time + 5;
858 self.think = vehicles_showwp_goaway;
861 if(teamplay && self.team)
862 rgb = TeamColor(self.team);
865 WaypointSprite_Spawn("vehicle", 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, TRUE, RADARICON_POWERUP, rgb);
866 if(self.waypointsprite_attached)
868 WaypointSprite_UpdateRule(self.waypointsprite_attached, self.enemy.team, SPRITERULE_DEFAULT);
870 WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, self.nextthink);
871 WaypointSprite_Ping(self.waypointsprite_attached);
878 void vehicles_setreturn()
882 vehicles_clearrturn();
885 ret.classname = "vehicle_return";
887 ret.team = self.team;
888 ret.think = vehicles_showwp;
890 if(self.deadflag != DEAD_NO)
892 ret.cnt = time + self.vehicle_respawntime;
893 ret.nextthink = min(time + self.vehicle_respawntime, time + self.vehicle_respawntime - 5);
897 ret.nextthink = min(time + self.vehicle_respawntime, time + self.vehicle_respawntime - 1);
900 setmodel(ret, "null");
901 setorigin(ret, self.pos1 + '0 0 96');
905 void vehicles_configcheck(string configname, float check_cvar)
908 localcmd(strcat("exec ", configname, "\n"));
911 void vehicles_reset_colors()
914 float _effects, _colormap;
915 vector _glowmod, _colormod;
917 if(autocvar_g_nodepthtestplayers)
918 _effects = EF_NODEPTHTEST;
920 if(autocvar_g_fullbrightplayers)
921 _effects |= EF_FULLBRIGHT;
924 _colormap = 1024 + (self.team - 1) * 17;
931 // Find all ents attacked to main model and setup effects, colormod etc.
932 e = findchainentity(tag_entity, self);
935 if(e != self.vehicle_shieldent)
937 e.effects = _effects; // | EF_LOWPRECISION;
938 e.colormod = _colormod;
939 e.colormap = _colormap;
945 self.vehicle_hudmodel.effects = self.effects = _effects; // | EF_LOWPRECISION;
946 self.vehicle_hudmodel.colormod = self.colormod = _colormod;
947 self.vehicle_hudmodel.colormap = self.colormap = _colormap;
948 self.vehicle_viewport.effects = (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NOGUNBOB | EF_NOSHADOW | EF_LOWPRECISION | EF_SELECTABLE | EF_TELEPORT_BIT);
951 self.avelocity = '0 0 0';
952 self.velocity = '0 0 0';
953 self.effects = _effects;
956 float vehicle_initialize(string net_name,
971 void(float extflag) exitfunc,
976 addstat(STAT_HUD, AS_INT, hud);
977 addstat(STAT_VEHICLESTAT_HEALTH, AS_INT, vehicle_health);
978 addstat(STAT_VEHICLESTAT_SHIELD, AS_INT, vehicle_shield);
979 addstat(STAT_VEHICLESTAT_ENERGY, AS_INT, vehicle_energy);
981 addstat(STAT_VEHICLESTAT_AMMO1, AS_INT, vehicle_ammo1);
982 addstat(STAT_VEHICLESTAT_RELOAD1, AS_INT, vehicle_reload1);
984 addstat(STAT_VEHICLESTAT_AMMO2, AS_INT, vehicle_ammo2);
985 addstat(STAT_VEHICLESTAT_RELOAD2, AS_INT, vehicle_reload2);
988 error("vehicles: missing bodymodel!");
991 error("vehicles: missing hudmodel!");
994 self.netname = self.classname;
996 self.netname = net_name;
998 if(self.team && !teamplay)
1001 self.vehicle_flags |= VHF_ISVEHICLE;
1003 setmodel(self, bodymodel);
1005 self.vehicle_viewport = spawn();
1006 self.vehicle_hudmodel = spawn();
1007 self.tur_head = spawn();
1008 self.tur_head.owner = self;
1009 self.takedamage = DAMAGE_AIM;
1010 self.bot_attack = TRUE;
1011 self.iscreature = TRUE;
1012 self.damagedbycontents = TRUE;
1015 self.vehicle_die = dieproc;
1016 self.vehicle_exit = exitfunc;
1017 self.vehicle_enter = enterproc;
1018 self.PlayerPhysplug = physproc;
1019 self.event_damage = vehicles_damage;
1020 self.touch = vehicles_touch;
1021 self.think = vehicles_spawn;
1022 self.nextthink = time;
1023 self.vehicle_respawntime = _respawntime;
1024 self.vehicle_spawn = spawnproc;
1026 if(autocvar_g_nodepthtestplayers)
1027 self.effects = self.effects | EF_NODEPTHTEST;
1029 if(autocvar_g_fullbrightplayers)
1030 self.effects = self.effects | EF_FULLBRIGHT;
1032 setmodel(self.vehicle_hudmodel, hudmodel);
1033 setmodel(self.vehicle_viewport, "null");
1038 setmodel(self.tur_head, topmodel);
1039 setattachment(self.tur_head, self, toptag);
1040 setattachment(self.vehicle_hudmodel, self.tur_head, hudtag);
1041 setattachment(self.vehicle_viewport, self.vehicle_hudmodel, viewtag);
1045 setattachment(self.tur_head, self, "");
1046 setattachment(self.vehicle_hudmodel, self, hudtag);
1047 setattachment(self.vehicle_viewport, self.vehicle_hudmodel, viewtag);
1050 setsize(self, min_s, max_s);
1053 setorigin(self, self.origin);
1054 tracebox(self.origin + '0 0 100', min_s, max_s, self.origin - '0 0 10000', MOVE_WORLDONLY, self);
1055 setorigin(self, trace_endpos);
1058 self.pos1 = self.origin;
1059 self.pos2 = self.angles;
1060 self.tur_head.team = self.team;
1067 self.vehicle_exit = self.vehicle_exit;
1068 self.vehicle_enter = self.vehicle_exit;
1069 self.vehicle_die = self.vehicle_exit;
1070 self.vehicle_spawn = self.vehicle_exit;
1071 self.AuxiliaryXhair = self.AuxiliaryXhair;