]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/vehicles/vehicles.qc
Make raptr bombs bounce if vehicle that droped them is to close to impact. Better...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / vehicles / vehicles.qc
1 float autocvar_g_vehicles_crush_dmg;
2 float autocvar_g_vehicles_crush_force;
3
4 void vehicles_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force);
5 void vehicles_return();
6 void vehicles_enter();
7 void vehicles_touch();
8 void vehicles_reset_colors();
9 void vehicles_clearrturn();
10 void vehicles_setreturn();
11
12
13 #define MAX_AXH 4
14 .entity AuxiliaryXhair[MAX_AXH];
15
16 float SendAuxiliaryXhair(entity to, float sf)
17 {
18
19         WriteByte(MSG_ENTITY, ENT_CLIENT_AUXILIARYXHAIR);
20
21         WriteByte(MSG_ENTITY, self.cnt);
22
23         WriteCoord(MSG_ENTITY, self.origin_x);
24         WriteCoord(MSG_ENTITY, self.origin_y);
25         WriteCoord(MSG_ENTITY, self.origin_z);
26
27     WriteByte(MSG_ENTITY, rint(self.colormod_x * 255));
28     WriteByte(MSG_ENTITY, rint(self.colormod_y * 255));
29     WriteByte(MSG_ENTITY, rint(self.colormod_z * 255));
30
31     return TRUE;
32 }
33
34 void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, float axh_id)
35 {
36     entity axh;
37
38     axh_id = bound(0, axh_id, MAX_AXH);
39     axh = own.AuxiliaryXhair[axh_id];
40
41     if(axh == world || wasfreed(axh))  // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
42     {
43         axh                     = spawn();
44         axh.cnt                 = axh_id;
45         axh.drawonlytoclient    = own;
46         axh.owner               = own;
47         Net_LinkEntity(axh, FALSE, 0, SendAuxiliaryXhair);
48     }
49
50     setorigin(axh, loc);
51     axh.colormod            = clr;
52     axh.SendFlags           = 0x01;
53     own.AuxiliaryXhair[axh_id] = axh;
54 }
55
56 /*
57 // SVC_TEMPENTITY based, horrible with even 50 ping. hm.
58 // WriteByte(MSG_ONE, SVC_TEMPENTITY) uses reliable messagess, never use for thinsg that need continous updates.
59 void SendAuxiliaryXhair2(entity own, vector loc, vector clr, float axh_id)
60 {
61         msg_entity = own;
62
63         WriteByte(MSG_ONE, SVC_TEMPENTITY);
64         WriteByte(MSG_ONE, TE_CSQC_AUXILIARYXHAIR);
65
66         WriteByte(MSG_ONE, axh_id);
67
68         WriteCoord(MSG_ONE, loc_x);
69         WriteCoord(MSG_ONE, loc_y);
70         WriteCoord(MSG_ONE, loc_z);
71
72     WriteByte(MSG_ONE, rint(clr_x * 255));
73     WriteByte(MSG_ONE, rint(clr_y * 255));
74     WriteByte(MSG_ONE, rint(clr_z * 255));
75
76 }
77 */
78
79 void CSQCVehicleSetup(entity own, float vehicle_id)
80 {
81         msg_entity = own;
82
83         WriteByte(MSG_ONE, SVC_TEMPENTITY);
84         WriteByte(MSG_ONE, TE_CSQC_VEHICLESETUP);
85         WriteByte(MSG_ONE, vehicle_id);
86 }
87
88 .entity lock_target;
89 .float  lock_strength;
90 .float  lock_time;
91 void vehicles_locktarget(float incr, float decr, float _lock_time)
92 {
93     if(self.lock_target && self.lock_target.deadflag != DEAD_NO)
94     {
95         self.lock_target    = world;
96         self.lock_strength  = 0;
97         self.lock_time      = 0;
98     }
99
100     if(self.lock_time > time)
101         return;
102
103     if(trace_ent != world)
104     {
105         if(teams_matter && trace_ent.team == self.team)
106             trace_ent = world;
107
108         if(trace_ent.deadflag != DEAD_NO)
109             trace_ent = world;
110
111         if not (trace_ent.vehicle_flags & VHF_ISVEHICLE || trace_ent.turrcaps_flags & TFL_TURRCAPS_ISTURRET)
112             trace_ent = world;
113     }
114
115     if(self.lock_target == world && trace_ent != world)
116         self.lock_target = trace_ent;
117
118     // Have a locking target
119     // Trace hit current target
120     if(trace_ent == self.lock_target && trace_ent != world)
121     {
122         self.lock_strength = min(self.lock_strength + incr, 1);
123         if(self.lock_strength == 1)
124             self.lock_time = time + _lock_time;
125     }
126     else
127     {
128         if(trace_ent)
129             self.lock_strength = max(self.lock_strength - decr * 2, 0);
130         else
131             self.lock_strength = max(self.lock_strength - decr, 0);
132
133         if(self.lock_strength == 0)
134             self.lock_target = world;
135     }
136 }
137
138
139 #define VEHICLE_UPDATE_PLAYER(fld,vhname) \
140 self.owner.vehicle_##fld = self.vehicle_##fld / autocvar_g_vehicle_##vhname##_##fld
141
142 #define vehicles_sweap_collision(orig,vel,dt,acm,mult) \
143 traceline(orig, orig + vel * dt, MOVE_NORMAL, self); \
144 if(trace_fraction != 1) \
145     acm += normalize(self.origin - trace_endpos) * (vlen(vel) * mult)
146
147 float  force_fromtag_power;
148 float  force_fromtag_normpower;
149 vector force_fromtag_origin;
150 vector vehicles_force_fromtag_hover(string tag_name, float spring_length, float max_power)
151 {
152     force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name));
153     v_forward  = normalize(v_forward) * -1;
154     traceline(force_fromtag_origin, force_fromtag_origin - (v_forward  * spring_length), MOVE_NORMAL, self);
155
156     force_fromtag_power = (1 - trace_fraction) * max_power;
157     force_fromtag_normpower = force_fromtag_power / max_power;
158
159     return v_forward  * force_fromtag_power;
160 }
161
162 vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float max_power)
163 {
164
165     force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name));
166     v_forward  = normalize(v_forward) * -1;
167     traceline(force_fromtag_origin, force_fromtag_origin - (v_forward  * spring_length), MOVE_NORMAL, self);
168
169     if(trace_fraction == 1.0)
170     {
171         force_fromtag_normpower = -0.25;
172         return '0 0 -200';
173     }
174
175     force_fromtag_power = ((1 - trace_fraction) - trace_fraction) * max_power;
176     force_fromtag_normpower = force_fromtag_power / max_power;
177
178     return v_forward  * force_fromtag_power;
179 }
180
181 void vehicles_projectile_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
182 {
183     self.health -= damage;
184     self.velocity += force;
185     if(self.health < 1)
186     {
187         self.takedamage = DAMAGE_NO;
188         self.event_damage = SUB_Null;
189         self.think = self.use;
190         self.nextthink = time;
191     }
192
193 }
194
195 void vehicles_projectile_explode()
196 {
197     if(self.owner && other != world)
198     {
199         if(other == self.owner.vehicle)
200             return;
201
202         if(other == self.owner.vehicle.tur_head)
203             return;
204     }
205
206         PROJECTILE_TOUCH;
207
208         self.event_damage = SUB_Null;
209     sound (self, CHAN_PROJECTILE, self.target2, VOL_BASE, ATTN_NORM);
210     pointparticles(particleeffectnum(self.target3), findbetterlocation (self.origin, 16), '0 0 0', 1);
211     RadiusDamage (self, self.realowner, self.shot_dmg, 0, self.shot_radius, self, self.shot_force, self.totalfrags, other);
212
213     remove (self);
214 }
215
216 entity vehicles_projectile(string _impactfx, string _impactsnd, string _mzlfx, string _mzlsound,
217                            vector _org, vector _vel,
218                            float _dmg, float _radi, float _force,  float _size,
219                            float _deahtype, float _projtype, float _health)
220 {
221     entity proj;
222
223     proj = spawn();
224
225     PROJECTILE_MAKETRIGGER(proj);
226     setorigin(proj, _org);
227
228     proj.shot_dmg         = _dmg;
229     proj.shot_radius      = _radi;
230     proj.shot_force       = _force;
231     proj.totalfrags       = _deahtype;
232     proj.target2          = _impactsnd;
233     proj.target3          = _impactfx;
234     proj.solid            = SOLID_BBOX;
235     proj.movetype         = MOVETYPE_FLYMISSILE;
236     proj.flags            = FL_PROJECTILE;
237     proj.bot_dodge        = TRUE;
238     proj.bot_dodgerating  = _dmg;
239     proj.velocity         = _vel;
240     proj.touch            = vehicles_projectile_explode;
241     proj.use              = vehicles_projectile_explode;
242     proj.owner            = self;
243     proj.realowner        = self.owner;
244     proj.think            = SUB_Remove;
245     proj.nextthink        = time + 30;
246
247     if(_health)
248     {
249         proj.takedamage       = DAMAGE_AIM;
250         proj.event_damage     = vehicles_projectile_damage;
251         proj.health           = _health;
252     }
253     else
254         proj.flags           = FL_PROJECTILE | FL_NOTARGET;
255
256     if(_mzlsound)
257         sound (self, CHAN_WEAPON, _mzlsound, VOL_BASE, ATTN_NORM);
258
259     if(_mzlfx)
260         pointparticles(particleeffectnum(_mzlfx), proj.origin, proj.velocity, 1);
261
262
263     setsize (proj, '-1 -1 -1' * _size, '1 1 1' * _size);
264
265     CSQCProjectile(proj, TRUE, _projtype, TRUE);
266
267     return proj;
268 }
269
270 void vehicles_spawn()
271 {
272     dprint("Spawning vehicle: ", self.netname, "\n");
273
274     // De-own & reset
275     self.vehicle_hudmodel.viewmodelforclient = self;
276     self.owner              = world;
277     self.touch              = vehicles_touch;
278     self.event_damage       = vehicles_damage;
279     self.iscreature         = TRUE;
280     self.movetype           = MOVETYPE_WALK;
281     self.solid              = SOLID_SLIDEBOX;
282     self.takedamage         = DAMAGE_AIM;
283         self.deadflag           = DEAD_NO;
284     self.bot_attack         = TRUE;
285     self.flags              = FL_NOTARGET;
286     self.avelocity          = '0 0 0';
287
288     // Reset locking
289     self.lock_strength      = 0;
290     self.lock_target        = world;
291     self.misc_bulletcounter = 0;
292
293     // Return to spawn
294     self.angles             = self.pos2;
295     setorigin(self, self.pos1 + '0 0 128');
296     // Show it
297     pointparticles(particleeffectnum("teleport"), self.origin + '0 0 64', '0 0 0', 1);
298
299     vehicles_reset_colors();
300     self.vehicle_spawn();
301 }
302
303 // Better way of determening whats crushable needed! (fl_crushable?)
304 float vehicles_crushable(entity e)
305 {
306     if(e.classname == "player")
307         return TRUE;
308
309     if(e.classname == "monster_zombie")
310         return TRUE;
311
312     return FALSE;
313 }
314
315 void vehicles_touch()
316 {
317     // Vehicle currently in use
318     if(self.owner)
319     {
320         // Colided with world?
321         if(other == world)
322         {
323             // Apply velocity based self damage here
324         }
325         else
326         {
327             if(other.vehicle_flags & VHF_ISVEHICLE)
328             {
329                 //other.velocity += self.velocity * (self.mass / other.mass);
330             }
331             else if(vehicles_crushable(other))
332             {
333                 if(vlen(self.velocity) != 0)
334                     Damage(other, self, self.owner, autocvar_g_vehicles_crush_dmg, DEATH_SBCRUSH, '0 0 0', normalize(other.origin - self.origin) * autocvar_g_vehicles_crush_force);
335             }
336         }
337         return;
338     }
339
340     if(other.classname != "player")
341         return;
342
343     if(other.deadflag != DEAD_NO)
344         return;
345
346     if(other.vehicle != world)
347         return;
348
349     // Remove this when bots know how to use vehicles.
350     if (clienttype(other) != CLIENTTYPE_REAL)
351         return;
352
353     vehicles_enter();
354 }
355
356 void vehicles_enter()
357 {
358    // Remove this when bots know how to use vehicles
359     if (clienttype(other) != CLIENTTYPE_REAL)
360         return;
361
362     if(self.phase > time)
363         return;
364
365     if(teams_matter)
366     if(self.team)
367     if(self.team != other.team)
368         return;
369
370     self.vehicle_ammo1   = 0;
371     self.vehicle_ammo2   = 0;
372     self.vehicle_reload1 = 0;
373     self.vehicle_reload2 = 0;
374     self.vehicle_energy  = 0;
375
376     self.owner          = other;
377     self.switchweapon   = other.switchweapon;
378
379     self.vehicle_hudmodel.viewmodelforclient = self.owner;
380     self.event_damage         = vehicles_damage;
381     self.nextthink            = 0;
382     self.owner.angles         = self.angles;
383     self.owner.takedamage     = DAMAGE_NO;
384     self.owner.solid          = SOLID_NOT;
385     self.owner.movetype       = MOVETYPE_NOCLIP;
386     self.owner.alpha          = -1;
387     self.owner.vehicle        = self;
388     self.owner.event_damage   = SUB_Null;
389     self.owner.view_ofs       = '0 0 0';
390     self.colormap             = self.owner.colormap;
391     if(self.tur_head)
392         self.tur_head.colormap    = self.owner.colormap;
393
394     self.owner.hud            = self.hud;
395     self.owner.PlayerPhysplug = self.PlayerPhysplug;
396
397     self.owner.vehicle_ammo1    = self.vehicle_ammo1;
398     self.owner.vehicle_ammo2    = self.vehicle_ammo2;
399     self.owner.vehicle_reload1  = self.vehicle_reload1;
400     self.owner.vehicle_reload2  = self.vehicle_reload2;
401
402     // Cnnt do this, hides attached objects too.
403     //self.exteriormodeltoclient = self.owner;
404     //self.tur_head.exteriormodeltoclient = self.owner;
405
406     other.flags &~= FL_ONGROUND;
407     self.flags  &~= FL_ONGROUND;
408
409     self.team                 = self.owner.team;
410     self.flags               -= FL_NOTARGET;
411
412     msg_entity = other;
413     WriteByte (MSG_ONE, SVC_SETVIEWPORT);
414     WriteEntity(MSG_ONE, self.vehicle_viewport);
415
416     WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
417     if(self.tur_head)
418     {
419         WriteAngle(MSG_ONE, self.tur_head.angles_x + self.angles_x); // tilt
420         WriteAngle(MSG_ONE, self.tur_head.angles_y + self.angles_y); // yaw
421         WriteAngle(MSG_ONE, 0);                                      // roll
422     }
423     else
424     {
425         WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
426         WriteAngle(MSG_ONE,  self.angles_x * -1); // tilt
427         WriteAngle(MSG_ONE,  self.angles_y);      // yaw
428         WriteAngle(MSG_ONE,  0);                  // roll
429     }
430
431     vehicles_clearrturn();
432
433     CSQCVehicleSetup(self.owner, self.hud);
434
435     self.vehicle_enter();
436 }
437
438 void vehicles_exit(float eject)
439 {
440         self.flags |= FL_NOTARGET;
441
442     if (self.owner)
443     {
444         msg_entity = self.owner;
445         WriteByte (MSG_ONE, SVC_SETVIEWPORT);
446         WriteEntity( MSG_ONE, self.owner);
447
448         WriteByte (MSG_ONE, SVC_SETVIEWANGLES); // 10 = SVC_SETVIEWANGLES
449         WriteAngle(MSG_ONE, 0);                 // tilt
450         WriteAngle(MSG_ONE, self.angles_y);     // yaw
451         WriteAngle(MSG_ONE, 0);                 // roll
452
453         setsize(self.owner, PL_MIN,PL_MAX);
454
455         self.owner.takedamage     = DAMAGE_AIM;
456         self.owner.solid          = SOLID_SLIDEBOX;
457         self.owner.movetype       = MOVETYPE_WALK;
458         self.owner.effects        &~= EF_NODRAW;
459         self.owner.alpha          = 1;
460         self.owner.PlayerPhysplug = SUB_Null;
461         self.owner.vehicle        = world;
462         self.owner.view_ofs       = PL_VIEW_OFS;
463         self.owner.event_damage   = PlayerDamage;
464         self.owner.hud            = HUD_NORMAL;
465         self.owner.switchweapon   = self.switchweapon;
466         self.owner.BUTTON_USE     = 0;
467     }
468
469     if(self.deadflag == DEAD_NO)
470         self.avelocity          = '0 0 0';
471
472     self.vehicle_hudmodel.viewmodelforclient = self;
473         self.tur_head.nodrawtoclient             = self;
474     vehicles_setreturn();
475
476     self.phase = time + 1;
477
478     if(!teams_matter)
479         self.team = 0;
480
481     self.vehicle_exit(eject);
482     self.owner = world;
483 }
484
485
486 void vehicles_regen(.float timer, .float regen_field, float field_max, float rpause, float regen, float delta_time)
487 {
488     if(self.regen_field < field_max)
489     if(self.timer + rpause < time)
490     {
491         self.regen_field = min(self.regen_field + regen * delta_time, field_max);
492
493         if(self.owner)
494             self.owner.regen_field = self.regen_field / field_max;
495     }
496 }
497
498 void shieldhit_think()
499 {
500     self.alpha -= 0.1;
501     if (self.alpha <= 0)
502     {
503         //setmodel(self, "");
504         self.alpha = -1;
505     }
506     else
507     {
508         self.nextthink = time + 0.1;
509     }
510 }
511
512 void vehicles_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
513 {
514     self.dmg_time = time;
515
516     if((self.vehicle_flags & VHF_HASSHIELD) && (self.vehicle_shield > 0))
517     {
518         if (wasfreed(self.vehicle_shieldent) || self.vehicle_shieldent == world)
519         {
520             self.vehicle_shieldent = spawn();
521             self.vehicle_shieldent.effects = EF_LOWPRECISION;
522
523             setmodel(self.vehicle_shieldent, "models/vhshield.md3");
524             setattachment(self.vehicle_shieldent, self, "");
525             setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
526             self.vehicle_shieldent.scale       = 256 / vlen(self.maxs - self.mins);
527             self.vehicle_shieldent.think       = shieldhit_think;
528         }
529
530
531         self.vehicle_shieldent.colormod    = '1 1 1';
532         self.vehicle_shieldent.alpha       = 0.45;
533         self.vehicle_shieldent.angles      = vectoangles(normalize(hitloc - (self.origin + self.vehicle_shieldent.origin))) - self.angles;
534         self.vehicle_shieldent.nextthink   = time;
535
536         self.vehicle_shield -= damage;
537
538         if(self.vehicle_shield < 0)
539         {
540             self.vehicle_shieldent.colormod = '2 0 0';
541             self.vehicle_shield             = 0;
542             self.vehicle_shieldent.alpha    = 0.75;
543             self.vehicle_health            -= fabs(self.vehicle_shield);
544         }
545     }
546     else
547         self.vehicle_health -= damage;
548
549     self.velocity += force; // * (vlen(force) / self.mass);
550
551     if(self.vehicle_health <= 0)
552     {
553         if(self.owner)
554             if(self.vehicle_flags & VHF_DEATHEJECT)
555                 vehicles_exit(VHEF_EJECT);
556             else
557                 vehicles_exit(VHEF_RELESE);
558
559         self.vehicle_die();
560         vehicles_setreturn();
561     }
562 }
563
564 void vehicles_return()
565 {
566     pointparticles(particleeffectnum("teleport"), self.enemy.origin + '0 0 64', '0 0 0', 1);
567
568     self.enemy.think     = vehicles_spawn;
569     self.enemy.nextthink = time;
570
571     remove(self);
572 }
573
574 void vehicles_clearrturn()
575 {
576     entity ret;
577     // Remove "return helper", if any.
578     ret = findchain(classname, "vehicle_return");
579     while(ret)
580     {
581         if(ret.enemy == self)
582         {
583             ret.classname   = "";
584             ret.think       = SUB_Remove;
585             ret.nextthink   = time + 0.1;
586             return;
587         }
588
589         ret = ret.chain;
590     }
591 }
592
593 void vehicles_setreturn()
594 {
595     entity ret;
596
597     vehicles_clearrturn();
598
599     ret = spawn();
600     ret.classname   = "vehicle_return";
601     ret.enemy       = self;
602     ret.think       = vehicles_return;
603     ret.nextthink   = time + self.vehicle_respawntime;
604 }
605
606 float vehicles_customizeentityforclient()
607 {
608     if(self.deadflag  == DEAD_DEAD)
609         return FALSE;
610     else
611         return TRUE;
612 }
613
614 void vehicles_configcheck(string  configname, float check_cvar)
615 {
616     if(check_cvar == 0)
617         localcmd(strcat("exec ", configname, "\n"));
618 }
619
620 void vehicles_reset_colors()
621 {
622     entity e;
623     float _effects, _colormap;
624     vector _glowmod, _colormod;
625
626     if(autocvar_g_nodepthtestplayers)
627         _effects = EF_NODEPTHTEST;
628
629     if(autocvar_g_fullbrightplayers)
630         _effects |= EF_FULLBRIGHT;
631
632     if(self.team)
633         _colormap = 1024 + (self.team - 1) * 17;
634     else
635         _colormap = 1024;
636
637     _glowmod    = '0 0 0';
638     _colormod   = '0 0 0';
639
640     // Find all ents attacked to main model and setup effects, colormod etc.
641     e = findchainentity(tag_entity, self);
642     while(e)
643     {
644         if(e != self.vehicle_shieldent)
645         {
646             e.effects   = _effects;
647             e.colormod  = _colormod;
648             e.colormap  = _colormap;
649             e.alpha     = 1;
650         }
651         e = e.chain;
652     }
653
654     self.vehicle_hudmodel.effects  = self.effects  = _effects;
655     self.vehicle_hudmodel.colormod = self.colormod = _colormod;
656     self.vehicle_hudmodel.colormap = self.colormap = _colormap;
657
658     self.alpha          = 1;
659     self.avelocity      = '0 0 0';
660     self.velocity       = '0 0 0';
661
662 }
663
664 float vehicle_initialize(string  net_name,
665                          string  bodymodel,
666                          string  topmodel,
667                          string  hudmodel,
668                          string  toptag,
669                          string  hudtag,
670                          string  viewtag,
671                          float   vhud,
672                          vector min_s,
673                          vector max_s,
674                          float  nodrop,
675                          void()  spawnproc,
676                          float   _respawntime,
677                          float() physproc,
678                          void()  enterproc,
679                          void(float extflag) exitfunc,
680                          void() dieproc,
681                          void() thinkproc )
682 {
683     addstat(STAT_HUD, AS_INT,  hud);
684         addstat(STAT_VEHICLESTAT_HEALTH,  AS_FLOAT, vehicle_health);
685         addstat(STAT_VEHICLESTAT_SHIELD,  AS_FLOAT, vehicle_shield);
686         addstat(STAT_VEHICLESTAT_ENERGY,  AS_FLOAT, vehicle_energy);
687
688         addstat(STAT_VEHICLESTAT_AMMO1,   AS_INT,   vehicle_ammo1);
689         addstat(STAT_VEHICLESTAT_RELOAD1, AS_FLOAT, vehicle_reload1);
690
691         addstat(STAT_VEHICLESTAT_AMMO2,   AS_INT,   vehicle_ammo2);
692         addstat(STAT_VEHICLESTAT_RELOAD2, AS_FLOAT, vehicle_reload2);
693
694     if(bodymodel == "")
695         error("vehicles: missing bodymodel!");
696
697     if(hudmodel == "")
698         error("vehicles: missing hudmodel!");
699
700     if(net_name == "")
701         self.netname = self.classname;
702     else
703         self.netname = net_name;
704
705     if(self.team && !teams_matter)
706         self.team = 0;
707
708     self.vehicle_flags |= VHF_ISVEHICLE;
709
710     setmodel(self, bodymodel);
711
712     self.vehicle_viewport   = spawn();
713     self.vehicle_hudmodel   = spawn();
714     self.tur_head           = spawn();
715     self.tur_head.owner     = self;
716     self.takedamage         = DAMAGE_AIM;
717     self.bot_attack         = TRUE;
718     self.iscreature         = TRUE;
719     self.hud                = vhud;
720
721     self.customizeentityforclient = vehicles_customizeentityforclient;
722     self.vehicle_die         = dieproc;
723     self.vehicle_exit        = exitfunc;
724     self.vehicle_enter       = enterproc;
725     self.PlayerPhysplug      = physproc;
726     self.event_damage        = vehicles_damage;
727     self.touch               = vehicles_touch;
728     self.think               = vehicles_spawn;
729     self.nextthink           = time;
730     self.vehicle_respawntime = _respawntime;
731     self.vehicle_spawn       = spawnproc;
732
733     if(autocvar_g_nodepthtestplayers)
734         self.effects = self.effects | EF_NODEPTHTEST;
735
736     if(autocvar_g_fullbrightplayers)
737         self.effects = self.effects | EF_FULLBRIGHT;
738
739     setmodel(self.vehicle_hudmodel, hudmodel);
740     setmodel(self.vehicle_viewport, "null");
741
742
743     if(topmodel != "")
744     {
745         setmodel(self.tur_head, topmodel);
746         setattachment(self.tur_head, self, toptag);
747         setattachment(self.vehicle_hudmodel, self.tur_head, hudtag);
748         setattachment(self.vehicle_viewport, self.vehicle_hudmodel, viewtag);
749     }
750     else
751     {
752         setattachment(self.tur_head, self, "");
753         setattachment(self.vehicle_hudmodel, self, hudtag);
754         setattachment(self.vehicle_viewport, self.vehicle_hudmodel, viewtag);
755     }
756
757     setsize(self, min_s, max_s);
758     if not (nodrop)
759     {
760         setorigin(self, self.origin);
761         tracebox(self.origin + '0 0 100', min_s, max_s, self.origin - '0 0 10000', MOVE_WORLDONLY, self);
762         setorigin(self, trace_endpos);
763     }
764
765     self.pos1 = self.origin;
766     self.pos2 = self.angles;
767
768     return TRUE;
769 }
770
771
772 void bugmenot()
773 {
774     self.vehicle_exit       = self.vehicle_exit;
775     self.vehicle_enter      = self.vehicle_exit;
776     self.vehicle_die        = self.vehicle_exit;
777     self.vehicle_spawn      = self.vehicle_exit;
778     self.AuxiliaryXhair     = self.AuxiliaryXhair;
779 }