]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/vehicles/sv_vehicles.qc
500bc60c8cebf0cea22b394456074e163392131c
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / sv_vehicles.qc
1 #include "sv_vehicles.qh"
2
3 #if 0
4 bool vehicle_send(entity to, int sf)
5 {
6         WriteByte(MSG_ENTITY, ENT_CLIENT_VEHICLE);
7         WriteByte(MSG_ENTITY, sf);
8
9         if(sf & VSF_SPAWN)
10         {
11                 WriteByte(MSG_ENTITY, self.vehicleid);
12         }
13
14         if(sf & VSF_SETUP)
15         {
16                 // send stuff?
17         }
18
19         if(sf & VSF_ENTER)
20         {
21                 // player handles the .vehicle stuff, we need only set ourselves up for driving
22
23                 // send stuff?
24         }
25
26         if(sf & VSF_EXIT)
27         {
28                 // senf stuff?
29         }
30
31         if(sf & VSF_PRECACHE)
32         {
33                 // send stuff?!
34         }
35
36         return true;
37 }
38 #endif
39
40 bool SendAuxiliaryXhair(entity this, entity to, int sf)
41 {
42
43         WriteByte(MSG_ENTITY, ENT_CLIENT_AUXILIARYXHAIR);
44
45         WriteByte(MSG_ENTITY, self.cnt);
46
47         WriteCoord(MSG_ENTITY, self.origin_x);
48         WriteCoord(MSG_ENTITY, self.origin_y);
49         WriteCoord(MSG_ENTITY, self.origin_z);
50
51         WriteByte(MSG_ENTITY, rint(self.colormod_x * 255));
52         WriteByte(MSG_ENTITY, rint(self.colormod_y * 255));
53         WriteByte(MSG_ENTITY, rint(self.colormod_z * 255));
54
55         return true;
56 }
57
58 void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, int axh_id)
59 {
60         if(!IS_REAL_CLIENT(own))
61                 return;
62
63         entity axh;
64
65         axh_id = bound(0, axh_id, MAX_AXH);
66         axh = own.(AuxiliaryXhair[axh_id]);
67
68         if(axh == world || wasfreed(axh))  // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
69         {
70                 axh                                      = spawn();
71                 axh.cnt                          = axh_id;
72                 axh.drawonlytoclient    = own;
73                 axh.owner                          = own;
74                 Net_LinkEntity(axh, false, 0, SendAuxiliaryXhair);
75         }
76
77         setorigin(axh, loc);
78         axh.colormod                    = clr;
79         axh.SendFlags              = 0x01;
80         own.(AuxiliaryXhair[axh_id]) = axh;
81 }
82
83 void CSQCVehicleSetup(entity own, int vehicle_id)
84 {
85         if(!IS_REAL_CLIENT(own))
86                 return;
87
88         msg_entity = own;
89
90         WriteByte(MSG_ONE, SVC_TEMPENTITY);
91         WriteByte(MSG_ONE, TE_CSQC_VEHICLESETUP);
92         WriteByte(MSG_ONE, vehicle_id);
93 }
94
95 vector targetdrone_getnewspot()
96 {SELFPARAM();
97         vector spot;
98         int i;
99         for(i = 0; i < 100; ++i)
100         {
101                 spot = self.origin + randomvec() * 1024;
102                 tracebox(spot, self.mins, self.maxs, spot, MOVE_NORMAL, self);
103                 if(trace_fraction == 1.0 && trace_startsolid == 0 && trace_allsolid == 0)
104                         return spot;
105         }
106         return self.origin;
107 }
108
109 void vehicles_locktarget(float incr, float decr, float _lock_time)
110 {SELFPARAM();
111         if(self.lock_target && self.lock_target.deadflag != DEAD_NO)
112         {
113                 self.lock_target        = world;
114                 self.lock_strength  = 0;
115                 self.lock_time    = 0;
116         }
117
118         if(self.lock_time > time)
119         {
120                 if(self.lock_target)
121                 if(self.lock_soundtime < time)
122                 {
123                         self.lock_soundtime = time + 0.5;
124                         play2(self.owner, "vehicles/locked.wav");
125                 }
126
127                 return;
128         }
129
130         if(trace_ent != world)
131         {
132                 if(SAME_TEAM(trace_ent, self))
133                         trace_ent = world;
134
135                 if(trace_ent.deadflag != DEAD_NO)
136                         trace_ent = world;
137
138                 if(!(IS_VEHICLE(trace_ent) || IS_TURRET(trace_ent)))
139                         trace_ent = world;
140
141                 if(trace_ent.alpha <= 0.5 && trace_ent.alpha != 0)
142                         trace_ent = world; // invisible
143         }
144
145         if(self.lock_target == world && trace_ent != world)
146                 self.lock_target = trace_ent;
147
148         if(self.lock_target && trace_ent == self.lock_target)
149         {
150                 if(self.lock_strength != 1 && self.lock_strength + incr >= 1)
151                 {
152                         play2(self.owner, "vehicles/lock.wav");
153                         self.lock_soundtime = time + 0.8;
154                 }
155                 else if (self.lock_strength != 1 && self.lock_soundtime < time)
156                 {
157                         play2(self.owner, "vehicles/locking.wav");
158                         self.lock_soundtime = time + 0.3;
159                 }
160         }
161
162         // Have a locking target
163         // Trace hit current target
164         if(trace_ent == self.lock_target && trace_ent != world)
165         {
166                 self.lock_strength = min(self.lock_strength + incr, 1);
167                 if(self.lock_strength == 1)
168                         self.lock_time = time + _lock_time;
169         }
170         else
171         {
172                 if(trace_ent)
173                         self.lock_strength = max(self.lock_strength - decr * 2, 0);
174                 else
175                         self.lock_strength = max(self.lock_strength - decr, 0);
176
177                 if(self.lock_strength == 0)
178                         self.lock_target = world;
179         }
180 }
181
182 vector vehicles_force_fromtag_hover(string tag_name, float spring_length, float max_power)
183 {SELFPARAM();
184         force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name));
185         v_forward  = normalize(v_forward) * -1;
186         traceline(force_fromtag_origin, force_fromtag_origin - (v_forward  * spring_length), MOVE_NORMAL, self);
187
188         force_fromtag_power = (1 - trace_fraction) * max_power;
189         force_fromtag_normpower = force_fromtag_power / max_power;
190
191         return v_forward  * force_fromtag_power;
192 }
193
194 vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float max_power)
195 {SELFPARAM();
196
197         force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name));
198         v_forward  = normalize(v_forward) * -1;
199         traceline(force_fromtag_origin, force_fromtag_origin - (v_forward  * spring_length), MOVE_NORMAL, self);
200
201         // TODO - this may NOT be compatible with wall/celing movement, unhardcode 0.25 (engine count multiplier)
202         if(trace_fraction == 1.0)
203         {
204                 force_fromtag_normpower = -0.25;
205                 return '0 0 -200';
206         }
207
208         force_fromtag_power = ((1 - trace_fraction) - trace_fraction) * max_power;
209         force_fromtag_normpower = force_fromtag_power / max_power;
210
211         return v_forward  * force_fromtag_power;
212 }
213
214 // projectile handling
215 void vehicles_projectile_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
216 {SELFPARAM();
217         // Ignore damage from oterh projectiles from my owner (dont mess up volly's)
218         if(inflictor.owner == self.owner)
219                 return;
220
221         self.health -= damage;
222         self.velocity += force;
223         if(self.health < 1)
224         {
225                 self.takedamage = DAMAGE_NO;
226                 self.event_damage = func_null;
227                 self.think = self.use;
228                 self.nextthink = time;
229         }
230 }
231
232 void vehicles_projectile_explode()
233 {SELFPARAM();
234         if(self.owner && other != world)
235         {
236                 if(other == self.owner.vehicle)
237                         return;
238
239                 if(other == self.owner.vehicle.tur_head)
240                         return;
241         }
242
243         PROJECTILE_TOUCH;
244
245         self.event_damage = func_null;
246         RadiusDamage (self, self.realowner, self.shot_dmg, 0, self.shot_radius, self, world, self.shot_force, self.totalfrags, other);
247
248         remove (self);
249 }
250
251 entity vehicles_projectile(string _mzlfx, string _mzlsound,
252                                                    vector _org, vector _vel,
253                                                    float _dmg, float _radi, float _force,  float _size,
254                                                    int _deahtype, float _projtype, float _health,
255                                                    bool _cull, bool _clianim, entity _owner)
256 {SELFPARAM();
257         entity proj;
258
259         proj = spawn();
260
261         PROJECTILE_MAKETRIGGER(proj);
262         setorigin(proj, _org);
263
264         proj.shot_dmg            = _dmg;
265         proj.shot_radius          = _radi;
266         proj.shot_force    = _force;
267         proj.totalfrags    = _deahtype;
268         proj.solid                      = SOLID_BBOX;
269         proj.movetype            = MOVETYPE_FLYMISSILE;
270         proj.flags                      = FL_PROJECTILE;
271         proj.bot_dodge          = true;
272         proj.bot_dodgerating  = _dmg;
273         proj.velocity            = _vel;
274         proj.touch                      = vehicles_projectile_explode;
275         proj.use                          = vehicles_projectile_explode;
276         proj.owner                      = self;
277         proj.realowner          = _owner;
278         proj.think                      = SUB_Remove;
279         proj.nextthink          = time + 30;
280
281         if(_health)
282         {
283                 proj.takedamage    = DAMAGE_AIM;
284                 proj.event_damage        = vehicles_projectile_damage;
285                 proj.health                = _health;
286         }
287         else
288                 proj.flags                 = FL_PROJECTILE | FL_NOTARGET;
289
290         if(_mzlsound)
291                 _sound (self, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTEN_NORM);
292
293         if(_mzlfx)
294                 Send_Effect_(_mzlfx, proj.origin, proj.velocity, 1);
295
296         setsize (proj, '-1 -1 -1' * _size, '1 1 1' * _size);
297
298         CSQCProjectile(proj, _clianim, _projtype, _cull);
299
300         return proj;
301 }
302
303 void vehicles_gib_explode()
304 {SELFPARAM();
305         sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
306         Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
307         Send_Effect(EFFECT_EXPLOSION_SMALL, self.wp00.origin + '0 0 64', '0 0 0', 1);
308         remove(self);
309 }
310
311 void vehicles_gib_think()
312 {SELFPARAM();
313         self.alpha -= 0.1;
314         if(self.cnt >= time)
315                 remove(self);
316         else
317                 self.nextthink = time + 0.1;
318 }
319
320 entity vehicle_tossgib(entity _template, vector _vel, string _tag, bool _burn, bool _explode, float _maxtime, vector _rot)
321 {SELFPARAM();
322         entity _gib = spawn();
323         _setmodel(_gib, _template.model);
324         setorigin(_gib, gettaginfo(self, gettagindex(self, _tag)));
325         _gib.velocity = _vel;
326         _gib.movetype = MOVETYPE_TOSS;
327         _gib.solid = SOLID_CORPSE;
328         _gib.colormod = '-0.5 -0.5 -0.5';
329         _gib.effects = EF_LOWPRECISION;
330         _gib.avelocity = _rot;
331
332         if(_burn)
333                 _gib.effects |= EF_FLAME;
334
335         if(_explode)
336         {
337                 _gib.think = vehicles_gib_explode;
338                 _gib.nextthink = time + random() * _explode;
339                 _gib.touch = vehicles_gib_explode;
340         }
341         else
342         {
343                 _gib.cnt = time + _maxtime;
344                 _gib.think = vehicles_gib_think;
345                 _gib.nextthink = time + _maxtime - 1;
346                 _gib.alpha = 1;
347         }
348         return _gib;
349 }
350
351 bool vehicle_addplayerslot(     entity _owner,
352                                                                 entity _slot,
353                                                                 int _hud,
354                                                                 string _hud_model,
355                                                                 bool() _framefunc,
356                                                                 void(bool) _exitfunc, float() _enterfunc)
357 {
358         if(!(_owner.vehicle_flags & VHF_MULTISLOT))
359                 _owner.vehicle_flags |= VHF_MULTISLOT;
360
361         _slot.PlayerPhysplug = _framefunc;
362         _slot.vehicle_exit = _exitfunc;
363         _slot.vehicle_enter = _enterfunc;
364         _slot.hud = _hud;
365         _slot.vehicle_flags = VHF_PLAYERSLOT;
366         _slot.vehicle_viewport = spawn();
367         _slot.vehicle_hudmodel = spawn();
368         _slot.vehicle_hudmodel.viewmodelforclient = _slot;
369         _slot.vehicle_viewport.effects = (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NOGUNBOB | EF_NOSHADOW | EF_LOWPRECISION | EF_SELECTABLE | EF_TELEPORT_BIT);
370
371         _setmodel(_slot.vehicle_hudmodel, _hud_model);
372         setmodel(_slot.vehicle_viewport, MDL_Null);
373
374         setattachment(_slot.vehicle_hudmodel, _slot, "");
375         setattachment(_slot.vehicle_viewport, _slot.vehicle_hudmodel, "");
376
377         return true;
378 }
379
380 vector vehicle_aimturret(entity _vehic, vector _target, entity _turrret, string _tagname,
381                                                  float _pichlimit_min, float _pichlimit_max,
382                                                  float _rotlimit_min, float _rotlimit_max, float _aimspeed)
383 {
384         vector vtmp, vtag;
385         float ftmp;
386         vtag = gettaginfo(_turrret, gettagindex(_turrret, _tagname));
387         vtmp = vectoangles(normalize(_target - vtag));
388         vtmp = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(_vehic.angles), AnglesTransform_FromAngles(vtmp))) - _turrret.angles;
389         vtmp = AnglesTransform_Normalize(vtmp, true);
390         ftmp = _aimspeed * frametime;
391         vtmp_y = bound(-ftmp, vtmp_y, ftmp);
392         vtmp_x = bound(-ftmp, vtmp_x, ftmp);
393         _turrret.angles_y = bound(_rotlimit_min, _turrret.angles_y + vtmp_y, _rotlimit_max);
394         _turrret.angles_x = bound(_pichlimit_min, _turrret.angles_x + vtmp_x, _pichlimit_max);
395         return vtag;
396 }
397
398 void vehicles_reset_colors()
399 {SELFPARAM();
400         entity e;
401         float _effects = 0, _colormap;
402         vector _glowmod, _colormod;
403
404         if(autocvar_g_nodepthtestplayers)
405                 _effects |= EF_NODEPTHTEST;
406
407         if(autocvar_g_fullbrightplayers)
408                 _effects |= EF_FULLBRIGHT;
409
410         if(self.team)
411                 _colormap = 1024 + (self.team - 1) * 17;
412         else
413                 _colormap = 1024;
414
415         _glowmod  = '0 0 0';
416         _colormod = '0 0 0';
417
418         // Find all ents attacked to main model and setup effects, colormod etc.
419         e = findchainentity(tag_entity, self);
420         while(e)
421         {
422                 if(e != self.vehicle_shieldent)
423                 {
424                         e.effects   = _effects; //  | EF_LOWPRECISION;
425                         e.colormod  = _colormod;
426                         e.colormap  = _colormap;
427                         e.alpha  = 1;
428                 }
429                 e = e.chain;
430         }
431         // Also check head tags
432         e = findchainentity(tag_entity, self.tur_head);
433         while(e)
434         {
435                 if(e != self.vehicle_shieldent)
436                 {
437                         e.effects   = _effects; //  | EF_LOWPRECISION;
438                         e.colormod  = _colormod;
439                         e.colormap  = _colormap;
440                         e.alpha  = 1;
441                 }
442                 e = e.chain;
443         }
444
445         self.vehicle_hudmodel.effects  = self.effects  = _effects; // | EF_LOWPRECISION;
446         self.vehicle_hudmodel.colormod = self.colormod = _colormod;
447         self.vehicle_hudmodel.colormap = self.colormap = _colormap;
448         self.vehicle_viewport.effects = (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NOGUNBOB | EF_NOSHADOW | EF_LOWPRECISION | EF_SELECTABLE | EF_TELEPORT_BIT);
449
450         self.alpha       = 1;
451         self.avelocity = '0 0 0';
452         self.velocity  = '0 0 0';
453         self.effects   = _effects;
454 }
455
456 void vehicles_clearreturn(entity veh)
457 {
458         entity ret;
459         // Remove "return helper", if any.
460         ret = findchain(classname, "vehicle_return");
461         while(ret)
462         {
463                 if(ret.wp00 == veh)
464                 {
465                         ret.classname   = "";
466                         ret.think          = SUB_Remove;
467                         ret.nextthink   = time + 0.1;
468
469                         if(ret.waypointsprite_attached)
470                                 WaypointSprite_Kill(ret.waypointsprite_attached);
471
472                         return;
473                 }
474                 ret = ret.chain;
475         }
476 }
477
478 void vehicles_spawn();
479 void vehicles_return()
480 {SELFPARAM();
481         Send_Effect(EFFECT_TELEPORT, self.wp00.origin + '0 0 64', '0 0 0', 1);
482
483         self.wp00.think  = vehicles_spawn;
484         self.wp00.nextthink = time;
485
486         if(self.waypointsprite_attached)
487                 WaypointSprite_Kill(self.waypointsprite_attached);
488
489         remove(self);
490 }
491
492 void vehicles_showwp_goaway()
493 {SELFPARAM();
494         if(self.waypointsprite_attached)
495                 WaypointSprite_Kill(self.waypointsprite_attached);
496
497         remove(self);
498
499 }
500
501 void vehicles_showwp()
502 {SELFPARAM();
503         entity oldself = world;
504         vector rgb;
505
506         if(self.cnt)
507         {
508                 self.think        = vehicles_return;
509                 self.nextthink  = self.cnt;
510         }
511         else
512         {
513                 self.think        = vehicles_return;
514                 self.nextthink  = time +1;
515
516                 oldself = self;
517                 setself(spawn());
518                 setmodel(self, MDL_Null);
519                 self.team = oldself.wp00.team;
520                 self.wp00 = oldself.wp00;
521                 setorigin(self, oldself.wp00.pos1);
522
523                 self.nextthink = time + 5;
524                 self.think = vehicles_showwp_goaway;
525         }
526
527         if(teamplay && self.team)
528                 rgb = Team_ColorRGB(self.team);
529         else
530                 rgb = '1 1 1';
531         entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Vehicle);
532         wp.colormod = rgb;
533         if(self.waypointsprite_attached)
534         {
535                 WaypointSprite_UpdateRule(self.waypointsprite_attached, self.wp00.team, SPRITERULE_DEFAULT);
536                 if(this == NULL)
537                         WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, self.nextthink);
538                 WaypointSprite_Ping(self.waypointsprite_attached);
539         }
540
541         if(this)
542                 setself(this);
543 }
544
545 void vehicles_setreturn(entity veh)
546 {
547         entity ret;
548
549         vehicles_clearreturn(veh);
550
551         ret = spawn();
552         ret.classname   = "vehicle_return";
553         ret.wp00           = veh;
554         ret.team                = veh.team;
555         ret.think          = vehicles_showwp;
556
557         if(veh.deadflag != DEAD_NO)
558         {
559                 ret.cnt          = time + veh.respawntime;
560                 ret.nextthink   = min(time + veh.respawntime, time + veh.respawntime - 5);
561         }
562         else
563         {
564                 ret.nextthink   = min(time + veh.respawntime, time + veh.respawntime - 1);
565         }
566
567         setmodel(ret, MDL_Null);
568         setorigin(ret, veh.pos1 + '0 0 96');
569
570 }
571
572 void vehicle_use()
573 {SELFPARAM();
574         LOG_TRACE("vehicle ",self.netname, " used by ", activator.classname, "\n");
575
576         self.tur_head.team = activator.team;
577
578         if(self.tur_head.team == 0)
579                 self.active = ACTIVE_NOT;
580         else
581                 self.active = ACTIVE_ACTIVE;
582
583         if(self.active == ACTIVE_ACTIVE && self.deadflag == DEAD_NO && !gameover)
584         {
585                 LOG_TRACE("Respawning vehicle: ", self.netname, "\n");
586                 if(self.effects & EF_NODRAW)
587                 {
588                         self.think = vehicles_spawn;
589                         self.nextthink = time + 3;
590                 }
591                 else
592                 {
593                         vehicles_setreturn(self);
594                         vehicles_reset_colors();
595                 }
596         }
597 }
598
599 void vehicles_regen(float timer, .float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale)
600 {SELFPARAM();
601         if(self.(regen_field) < field_max)
602         if(timer + rpause < time)
603         {
604                 if(_healthscale)
605                         regen = regen * (self.vehicle_health / self.max_health);
606
607                 self.(regen_field) = min(self.(regen_field) + regen * delta_time, field_max);
608
609                 if(self.owner)
610                         self.owner.(regen_field) = (self.(regen_field) / field_max) * 100;
611         }
612 }
613
614 void shieldhit_think()
615 {SELFPARAM();
616         self.alpha -= 0.1;
617         if (self.alpha <= 0)
618         {
619                 // setmodel(self, MDL_Null);
620                 self.alpha = -1;
621                 self.effects |= EF_NODRAW;
622         }
623         else
624         {
625                 self.nextthink = time + 0.1;
626         }
627 }
628
629 void vehicles_painframe()
630 {SELFPARAM();
631         if(self.owner.vehicle_health <= 50)
632         if(self.pain_frame < time)
633         {
634                 float _ftmp;
635                 _ftmp = self.owner.vehicle_health / 50;
636                 self.pain_frame = time + 0.1 + (random() * 0.5 * _ftmp);
637                 pointparticles(particleeffectnum(EFFECT_SMOKE_SMALL), (self.origin + (randomvec() * 80)), '0 0 0', 1);
638
639                 if(self.vehicle_flags & VHF_DMGSHAKE)
640                         self.velocity += randomvec() * 30;
641
642                 if(self.vehicle_flags & VHF_DMGROLL)
643                         if(self.vehicle_flags & VHF_DMGHEADROLL)
644                                 self.tur_head.angles += randomvec();
645                         else
646                                 self.angles += randomvec();
647
648         }
649 }
650
651 void vehicles_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
652 {SELFPARAM();
653         self.dmg_time = time;
654
655         // WEAPONTODO
656         if(DEATH_ISWEAPON(deathtype, WEP_VORTEX.m_id))
657                 damage *= autocvar_g_vehicles_vortex_damagerate;
658
659         if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN.m_id))
660                 damage *= autocvar_g_vehicles_machinegun_damagerate;
661
662         if(DEATH_ISWEAPON(deathtype, WEP_RIFLE.m_id))
663                 damage *= autocvar_g_vehicles_rifle_damagerate;
664
665         if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER.m_id))
666                 damage *= autocvar_g_vehicles_vaporizer_damagerate;
667
668         if(DEATH_ISWEAPON(deathtype, WEP_SEEKER.m_id))
669                 damage *= autocvar_g_vehicles_tag_damagerate;
670
671         if(DEATH_WEAPONOFWEAPONDEATH(deathtype))
672                 damage *= autocvar_g_vehicles_weapon_damagerate;
673
674         self.enemy = attacker;
675
676         self.pain_finished = time;
677
678         if((self.vehicle_flags & VHF_HASSHIELD) && (self.vehicle_shield > 0))
679         {
680                 if (wasfreed(self.vehicle_shieldent) || self.vehicle_shieldent == world)
681                 {
682                         self.vehicle_shieldent = spawn();
683                         self.vehicle_shieldent.effects = EF_LOWPRECISION;
684
685                         setmodel(self.vehicle_shieldent, MDL_VEH_SHIELD);
686                         setattachment(self.vehicle_shieldent, self, "");
687                         setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
688                         self.vehicle_shieldent.scale       = 256 / vlen(self.maxs - self.mins);
689                         self.vehicle_shieldent.think       = shieldhit_think;
690                 }
691
692                 self.vehicle_shieldent.colormod = '1 1 1';
693                 self.vehicle_shieldent.alpha = 0.45;
694                 self.vehicle_shieldent.angles = vectoangles(normalize(hitloc - (self.origin + self.vehicle_shieldent.origin))) - self.angles;
695                 self.vehicle_shieldent.nextthink = time;
696                 self.vehicle_shieldent.effects &= ~EF_NODRAW;
697
698                 self.vehicle_shield -= damage;
699
700                 if(self.vehicle_shield < 0)
701                 {
702                         self.vehicle_health -= fabs(self.vehicle_shield);
703                         self.vehicle_shieldent.colormod = '2 0 0';
704                         self.vehicle_shield = 0;
705                         self.vehicle_shieldent.alpha = 0.75;
706
707                         if(sound_allowed(MSG_BROADCAST, attacker))
708                                 spamsound (self, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTEN_NORM);   // FIXME: PLACEHOLDER
709                 }
710                 else
711                         if(sound_allowed(MSG_BROADCAST, attacker))
712                                 spamsound (self, CH_PAIN, "onslaught/electricity_explode.wav", VOL_BASE, ATTEN_NORM);  // FIXME: PLACEHOLDER
713
714         }
715         else
716         {
717                 self.vehicle_health -= damage;
718
719                 if(sound_allowed(MSG_BROADCAST, attacker))
720                         spamsound (self, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTEN_NORM);  // FIXME: PLACEHOLDER
721         }
722
723         if(self.damageforcescale < 1 && self.damageforcescale > 0)
724                 self.velocity += force * self.damageforcescale;
725         else
726                 self.velocity += force;
727
728         if(self.vehicle_health <= 0)
729         {
730                 if(self.owner)
731                         if(self.vehicle_flags & VHF_DEATHEJECT)
732                                 vehicles_exit(VHEF_EJECT);
733                         else
734                                 vehicles_exit(VHEF_RELEASE);
735
736
737                 antilag_clear(self);
738
739                 Vehicle info = get_vehicleinfo(self.vehicleid);
740                 info.vr_death(info);
741                 vehicles_setreturn(self);
742         }
743 }
744
745 float vehicles_crushable(entity e)
746 {
747         if(IS_PLAYER(e) && time >= e.vehicle_enter_delay)
748                 return true;
749
750         if(IS_MONSTER(e))
751                 return true;
752
753         return false;
754 }
755
756 void vehicles_impact(float _minspeed, float _speedfac, float _maxpain)
757 {SELFPARAM();
758         if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
759                 return;
760
761         if(self.play_time < time)
762         {
763                 float wc = vlen(self.velocity - self.oldvelocity);
764                 //dprint("oldvel: ", vtos(self.oldvelocity), "\n");
765                 //dprint("vel: ", vtos(self.velocity), "\n");
766                 if(_minspeed < wc)
767                 {
768                         float take = min(_speedfac * wc, _maxpain);
769                         Damage (self, world, world, take, DEATH_FALL, self.origin, '0 0 0');
770                         self.play_time = time + 0.25;
771
772                         //dprint("wc: ", ftos(wc), "\n");
773                         //dprint("take: ", ftos(take), "\n");
774                 }
775         }
776 }
777
778 // vehicle enter/exit handling
779 vector vehicles_findgoodexit(vector prefer_spot)
780 {SELFPARAM();
781         //vector exitspot;
782         float mysize;
783
784         tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, prefer_spot, MOVE_NORMAL, self.owner);
785         if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
786                 return prefer_spot;
787
788         mysize = 1.5 * vlen(self.maxs - self.mins);
789         float i;
790         vector v, v2;
791         v2 = 0.5 * (self.absmin + self.absmax);
792         for(i = 0; i < 100; ++i)
793         {
794                 v = randomvec();
795                 v_z = 0;
796                 v = v2 + normalize(v) * mysize;
797                 tracebox(v2, PL_MIN, PL_MAX, v, MOVE_NORMAL, self.owner);
798                 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
799                         return v;
800         }
801
802         /*
803         exitspot = (self.origin + '0 0 48') + v_forward * mysize;
804         tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
805         if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
806                 return exitspot;
807
808         exitspot = (self.origin + '0 0 48') - v_forward * mysize;
809         tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
810         if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
811                 return exitspot;
812
813         exitspot = (self.origin + '0 0 48') + v_right * mysize;
814         tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
815         if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
816                 return exitspot;
817
818         exitspot = (self.origin + '0 0 48') - v_right * mysize;
819         tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner);
820         if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
821                 return exitspot;
822         */
823
824         return self.origin;
825 }
826
827 void vehicles_exit(bool eject)
828 {SELFPARAM();
829         entity _vehicle;
830         entity _player;
831
832         if(vehicles_exit_running)
833         {
834                 LOG_TRACE("^1vehicles_exit allready running! this is not good..\n");
835                 return;
836         }
837
838         vehicles_exit_running = true;
839         if(IS_CLIENT(self))
840         {
841                 _vehicle = self.vehicle;
842
843                 if (_vehicle.vehicle_flags & VHF_PLAYERSLOT)
844                 {
845                         _vehicle.vehicle_exit(eject);
846                         setself(this);
847                         vehicles_exit_running = false;
848                         return;
849                 }
850         }
851         else
852                 _vehicle = self;
853
854         _player = _vehicle.owner;
855
856         setself(_vehicle);
857
858         if (_player)
859         {
860                 if (IS_REAL_CLIENT(_player))
861                 {
862                         msg_entity = _player;
863                         WriteByte (MSG_ONE, SVC_SETVIEWPORT);
864                         WriteEntity( MSG_ONE, _player);
865
866                         WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
867                         WriteAngle(MSG_ONE, 0);
868                         WriteAngle(MSG_ONE, _vehicle.angles_y);
869                         WriteAngle(MSG_ONE, 0);
870                 }
871
872                 setsize(_player, PL_MIN,PL_MAX);
873
874                 _player.takedamage              = DAMAGE_AIM;
875                 _player.solid                   = SOLID_SLIDEBOX;
876                 _player.movetype                = MOVETYPE_WALK;
877                 _player.effects            &= ~EF_NODRAW;
878                 _player.teleportable    = TELEPORT_NORMAL;
879                 _player.alpha                   = 1;
880                 _player.PlayerPhysplug  = func_null;
881                 _player.vehicle                 = world;
882                 _player.view_ofs                = PL_VIEW_OFS;
883                 _player.event_damage    = PlayerDamage;
884                 _player.hud                             = HUD_NORMAL;
885                 _player.switchweapon    = _vehicle.switchweapon;
886                 _player.last_vehiclecheck = time + 3;
887                 _player.vehicle_enter_delay = time + 2;
888
889                 CSQCVehicleSetup(_player, HUD_NORMAL);
890         }
891         _vehicle.flags |= FL_NOTARGET;
892
893         if(_vehicle.deadflag == DEAD_NO)
894                 _vehicle.avelocity = '0 0 0';
895
896         _vehicle.tur_head.nodrawtoclient = world;
897
898         if(!teamplay)
899                 _vehicle.team = 0;
900
901         Kill_Notification(NOTIF_ONE, _player, MSG_CENTER_CPID, CPID_VEHICLES);
902         Kill_Notification(NOTIF_ONE, _player, MSG_CENTER_CPID, CPID_VEHICLES_OTHER); // kill all vehicle notifications when exiting a vehicle?
903
904         WaypointSprite_Kill(_vehicle.wps_intruder);
905
906         MUTATOR_CALLHOOK(VehicleExit, _player, _vehicle);
907
908         _vehicle.team = _vehicle.tur_head.team;
909
910         sound (_vehicle, CH_TRIGGER_SINGLE, SND_Null, 1, ATTEN_NORM);
911         _vehicle.vehicle_hudmodel.viewmodelforclient = _vehicle;
912         _vehicle.phase = time + 1;
913
914         _vehicle.vehicle_exit(eject);
915
916         vehicles_setreturn(_vehicle);
917         vehicles_reset_colors();
918         _vehicle.owner = world;
919
920         CSQCMODEL_AUTOINIT(self);
921
922         setself(this);
923         vehicles_exit_running = false;
924 }
925
926 void vehicles_touch()
927 {SELFPARAM();
928         if(MUTATOR_CALLHOOK(VehicleTouch, self, other))
929                 return;
930
931         // Vehicle currently in use
932         if(self.owner)
933         {
934                 if(!forbidWeaponUse(self.owner))
935                 if(other != world)
936                 if((self.origin_z + self.maxs_z) > (other.origin_z))
937                 if(vehicles_crushable(other))
938                 {
939                         if(vlen(self.velocity) >= 30)
940                                 Damage(other, self, self.owner, autocvar_g_vehicles_crush_dmg, DEATH_VH_CRUSH, '0 0 0', normalize(other.origin - self.origin) * autocvar_g_vehicles_crush_force);
941
942                         return; // Dont do selfdamage when hitting "soft targets".
943                 }
944
945                 if(self.play_time < time) {
946                         Vehicle info = get_vehicleinfo(self.vehicleid);
947                         info.vr_impact(info);
948                 }
949
950                 return;
951         }
952
953         if(autocvar_g_vehicles_enter)
954                 return;
955
956         vehicles_enter(other, self);
957 }
958
959 bool vehicle_impulse(int imp)
960 {SELFPARAM();
961         switch(imp)
962         {
963                 case 17:
964                 {
965                         stuffcmd(self, "\ntoggle cl_eventchase_vehicle\nset _vehicles_shownchasemessage 1\n");
966                         return true;
967                 }
968         }
969
970         return false;
971 }
972
973 void vehicles_enter(entity pl, entity veh)
974 {SELFPARAM();
975    // Remove this when bots know how to use vehicles
976         if((IS_BOT_CLIENT(pl) && !autocvar_g_vehicles_allow_bots))
977                 return;
978
979         if((!IS_PLAYER(pl))
980         || (veh.phase >= time)
981         || (pl.vehicle_enter_delay >= time)
982         || (pl.frozen)
983         || (pl.deadflag != DEAD_NO)
984         || (pl.vehicle)
985         ) { return; }
986
987         if(autocvar_g_vehicles_enter) // vehicle's touch function should handle this if entering via use key is disabled (TODO)
988         if(veh.vehicle_flags & VHF_MULTISLOT)
989         if(veh.owner)
990         {
991                 setself(veh);
992                 other = pl; // TODO: fix
993
994                 if(!veh.gunner1)
995                 if(time >= veh.gun1.phase)
996                 if(veh.gun1.vehicle_enter)
997                 if(veh.gun1.vehicle_enter())
998                 {
999                         setself(this);
1000                         return;
1001                 }
1002
1003                 if(!veh.gunner2)
1004                 if(time >= veh.gun2.phase)
1005                 if(veh.gun2.vehicle_enter)
1006                 if(veh.gun2.vehicle_enter())
1007                 {
1008                         setself(this);
1009                         return;
1010                 }
1011
1012                 setself(this);
1013         }
1014
1015         if(teamplay)
1016         if(veh.team)
1017         if(DIFF_TEAM(pl, veh))
1018         if(autocvar_g_vehicles_steal)
1019         {
1020                 entity head;
1021                 FOR_EACH_PLAYER(head) if(SAME_TEAM(head, veh))
1022                         Send_Notification(NOTIF_ONE, head, MSG_CENTER, CENTER_VEHICLE_STEAL);
1023
1024                 Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_VEHICLE_STEAL_SELF);
1025
1026                 if (autocvar_g_vehicles_steal_show_waypoint) {
1027                         entity wp = WaypointSprite_Spawn(WP_VehicleIntruder, 0, 0, pl, '0 0 68', world, veh.team, veh, wps_intruder, true, RADARICON_DANGER);
1028                         wp.colormod = Team_ColorRGB(pl.team);
1029                 }
1030         }
1031         else return;
1032
1033         RemoveGrapplingHook(pl);
1034
1035         veh.vehicle_ammo1 = 0;
1036         veh.vehicle_ammo2 = 0;
1037         veh.vehicle_reload1 = 0;
1038         veh.vehicle_reload2 = 0;
1039         veh.vehicle_energy = 0;
1040
1041         veh.owner = pl;
1042         pl.vehicle = veh;
1043
1044         // .viewmodelforclient works better.
1045         //veh.vehicle_hudmodel.drawonlytoclient = veh.owner;
1046
1047         veh.vehicle_hudmodel.viewmodelforclient = pl;
1048
1049         tracebox(pl.origin, PL_MIN, PL_MAX, pl.origin, false, pl);
1050         pl.crouch = false;
1051         pl.view_ofs = PL_VIEW_OFS;
1052         setsize (pl, PL_MIN, PL_MAX);
1053
1054         veh.event_damage        = vehicles_damage;
1055         veh.nextthink           = 0;
1056         pl.angles                       = veh.angles;
1057         pl.takedamage           = DAMAGE_NO;
1058         pl.solid                        = SOLID_NOT;
1059         pl.movetype                     = MOVETYPE_NOCLIP;
1060         pl.teleportable         = false;
1061         pl.alpha                        = -1;
1062         pl.event_damage         = func_null;
1063         pl.view_ofs                     = '0 0 0';
1064         veh.colormap            = pl.colormap;
1065         if(veh.tur_head)
1066                 veh.tur_head.colormap = pl.colormap;
1067         veh.switchweapon = pl.switchweapon;
1068         pl.hud = veh.vehicleid;
1069         pl.PlayerPhysplug = veh.PlayerPhysplug;
1070
1071         pl.vehicle_ammo1 = veh.vehicle_ammo1;
1072         pl.vehicle_ammo2 = veh.vehicle_ammo2;
1073         pl.vehicle_reload1 = veh.vehicle_reload1;
1074         pl.vehicle_reload2 = veh.vehicle_reload2;
1075         pl.vehicle_energy = veh.vehicle_energy;
1076
1077         // Cant do this, hides attached objects too.
1078         //veh.exteriormodeltoclient = veh.owner;
1079         //veh.tur_head.exteriormodeltoclient = veh.owner;
1080
1081         pl.flags &= ~FL_ONGROUND;
1082         veh.flags &= ~FL_ONGROUND;
1083
1084         veh.team = pl.team;
1085         veh.flags -= FL_NOTARGET;
1086
1087         if (IS_REAL_CLIENT(pl))
1088         {
1089                 Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_VEHICLE_ENTER);
1090
1091                 msg_entity = pl;
1092                 WriteByte (MSG_ONE, SVC_SETVIEWPORT);
1093                 WriteEntity(MSG_ONE, veh.vehicle_viewport);
1094
1095                 WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
1096                 if(veh.tur_head)
1097                 {
1098                         WriteAngle(MSG_ONE, veh.tur_head.angles_x + veh.angles_x); // tilt
1099                         WriteAngle(MSG_ONE, veh.tur_head.angles_y + veh.angles_y); // yaw
1100                         WriteAngle(MSG_ONE, 0);                                                                   // roll
1101                 }
1102                 else
1103                 {
1104                         WriteAngle(MSG_ONE, veh.angles_x * -1); // tilt
1105                         WriteAngle(MSG_ONE, veh.angles_y);        // yaw
1106                         WriteAngle(MSG_ONE, 0);                           // roll
1107                 }
1108         }
1109
1110         vehicles_clearreturn(veh);
1111
1112         CSQCVehicleSetup(pl, veh.vehicleid);
1113
1114         MUTATOR_CALLHOOK(VehicleEnter, pl, veh);
1115
1116         setself(veh);
1117         CSQCModel_UnlinkEntity(veh);
1118         Vehicle info = get_vehicleinfo(veh.vehicleid);
1119         info.vr_enter(info);
1120         setself(this);
1121
1122         antilag_clear(pl);
1123 }
1124
1125 void vehicles_think()
1126 {SELFPARAM();
1127         self.nextthink = time;
1128
1129         if(self.owner)
1130                 self.owner.vehicle_weapon2mode = self.vehicle_weapon2mode;
1131
1132         Vehicle info = get_vehicleinfo(self.vehicleid);
1133         info.vr_think(info);
1134
1135         CSQCMODEL_AUTOUPDATE(self);
1136 }
1137
1138 // initialization
1139 void vehicles_spawn()
1140 {SELFPARAM();
1141         LOG_TRACE("Spawning vehicle: ", self.classname, "\n");
1142
1143         // disown & reset
1144         self.vehicle_hudmodel.viewmodelforclient = self;
1145
1146         self.owner                              = world;
1147         self.touch                              = vehicles_touch;
1148         self.event_damage               = vehicles_damage;
1149         self.iscreature                 = true;
1150         self.teleportable               = false; // no teleporting for vehicles, too buggy
1151         self.damagedbycontents  = true;
1152         self.movetype                   = MOVETYPE_WALK;
1153         self.solid                              = SOLID_SLIDEBOX;
1154         self.takedamage                 = DAMAGE_AIM;
1155         self.deadflag                   = DEAD_NO;
1156         self.bot_attack                 = true;
1157         self.flags                              = FL_NOTARGET;
1158         self.avelocity                  = '0 0 0';
1159         self.velocity                   = '0 0 0';
1160         self.think                              = vehicles_think;
1161         self.nextthink                  = time;
1162
1163         // Reset locking
1164         self.lock_strength = 0;
1165         self.lock_target = world;
1166         self.misc_bulletcounter = 0;
1167
1168         // Return to spawn
1169         self.angles = self.pos2;
1170         setorigin(self, self.pos1);
1171         // Show it
1172         Send_Effect(EFFECT_TELEPORT, self.origin + '0 0 64', '0 0 0', 1);
1173
1174         if(self.vehicle_controller)
1175                 self.team = self.vehicle_controller.team;
1176
1177         entity head; // remove hooks (if any)
1178         FOR_EACH_PLAYER(head)
1179         if(head.hook.aiment == self)
1180                 RemoveGrapplingHook(head);
1181
1182         vehicles_reset_colors();
1183
1184         Vehicle info = get_vehicleinfo(self.vehicleid);
1185         info.vr_spawn(info);
1186
1187         CSQCMODEL_AUTOINIT(self);
1188 }
1189
1190 bool vehicle_initialize(entity veh, bool nodrop)
1191 {SELFPARAM();
1192         if(!autocvar_g_vehicles)
1193                 return false;
1194
1195         if(!veh.vehicleid)
1196                 return false;
1197
1198         if(!veh.tur_head) {
1199                 Vehicle info = get_vehicleinfo(veh.vehicleid);
1200                 info.vr_precache(info);
1201         }
1202
1203         if(self.targetname && self.targetname != "")
1204         {
1205                 self.vehicle_controller = find(world, target, self.targetname);
1206                 if(!self.vehicle_controller)
1207                 {
1208                         bprint("^1WARNING: ^7Vehicle with invalid .targetname\n");
1209                         self.active = ACTIVE_ACTIVE;
1210                 }
1211                 else
1212                 {
1213                         self.team = self.vehicle_controller.team;
1214                         self.use = vehicle_use;
1215
1216                         if(teamplay)
1217                         {
1218                                 if(self.vehicle_controller.team == 0)
1219                                         self.active = ACTIVE_NOT;
1220                                 else
1221                                         self.active = ACTIVE_ACTIVE;
1222                         }
1223                 }
1224         }
1225         else { self.active = ACTIVE_ACTIVE; }
1226
1227         if(self.team && (!teamplay || !autocvar_g_vehicles_teams))
1228                 self.team = 0;
1229
1230         if(self.mdl == "" || !self.mdl)
1231                 _setmodel(self, veh.model);
1232         else
1233                 _setmodel(self, self.mdl);
1234
1235         self.vehicle_flags |= VHF_ISVEHICLE;
1236
1237         self.vehicle_viewport           = spawn();
1238         self.vehicle_hudmodel           = spawn();
1239         self.tur_head                           = spawn();
1240         self.tur_head.owner                     = self;
1241         self.takedamage                         = DAMAGE_NO;
1242         self.bot_attack                         = true;
1243         self.iscreature                         = true;
1244         self.teleportable                       = false; // no teleporting for vehicles, too buggy
1245         self.damagedbycontents          = true;
1246         self.vehicleid                          = veh.vehicleid;
1247         self.PlayerPhysplug                     = veh.PlayerPhysplug;
1248         self.event_damage                       = func_null;
1249         self.touch                                      = vehicles_touch;
1250         self.think                                      = vehicles_spawn;
1251         self.nextthink                          = time;
1252         self.effects                            = EF_NODRAW;
1253         self.dphitcontentsmask          = DPCONTENTS_BODY | DPCONTENTS_SOLID;
1254
1255         if(autocvar_g_playerclip_collisions)
1256                 self.dphitcontentsmask |= DPCONTENTS_PLAYERCLIP;
1257
1258         if(autocvar_g_nodepthtestplayers)
1259                 self.effects |= EF_NODEPTHTEST;
1260
1261         if(autocvar_g_fullbrightplayers)
1262                 self.effects |= EF_FULLBRIGHT;
1263
1264         _setmodel(self.vehicle_hudmodel, veh.hud_model);
1265         setmodel(self.vehicle_viewport, MDL_Null);
1266
1267         if(veh.head_model != "")
1268         {
1269                 _setmodel(self.tur_head, veh.head_model);
1270                 setattachment(self.tur_head, self, veh.tag_head);
1271                 setattachment(self.vehicle_hudmodel, self.tur_head, veh.tag_hud);
1272                 setattachment(self.vehicle_viewport, self.vehicle_hudmodel, veh.tag_view);
1273         }
1274         else
1275         {
1276                 setattachment(self.tur_head, self, "");
1277                 setattachment(self.vehicle_hudmodel, self, veh.tag_hud);
1278                 setattachment(self.vehicle_viewport, self.vehicle_hudmodel, veh.tag_view);
1279         }
1280
1281         setsize(self, veh.mins, veh.maxs);
1282
1283         if(!nodrop)
1284         {
1285                 setorigin(self, self.origin);
1286                 tracebox(self.origin + '0 0 100', veh.mins, veh.maxs, self.origin - '0 0 10000', MOVE_WORLDONLY, self);
1287                 setorigin(self, trace_endpos);
1288         }
1289
1290         self.pos1 = self.origin;
1291         self.pos2 = self.angles;
1292         self.tur_head.team = self.team;
1293
1294         Vehicle info = get_vehicleinfo(veh.vehicleid);
1295         info.vr_setup(info);
1296
1297         if(self.active == ACTIVE_NOT)
1298                 self.nextthink = 0; // wait until activated
1299         else if(autocvar_g_vehicles_delayspawn)
1300                 self.nextthink = time + self.respawntime + (random() * autocvar_g_vehicles_delayspawn_jitter);
1301         else
1302                 self.nextthink = time + game_starttime;
1303
1304         if(MUTATOR_CALLHOOK(VehicleSpawn))
1305                 return false;
1306
1307         return true;
1308 }