Xonotic
sv_vehicles.qc File Reference
+ Include dependency graph for sv_vehicles.qc:

Go to the source code of this file.

Functions

bool AuxiliaryXhair_customize (entity this, entity client)
 
void CSQCVehicleSetup (entity own, int vehicle_id)
 
bool SendAuxiliaryXhair (entity this, entity to, int sf)
 
void shieldhit_think (entity this)
 
void UpdateAuxiliaryXhair (entity own, vector loc, vector clr, int axh_id)
 
bool vehicle_addplayerslot (entity _owner, entity _slot, int _hud, Model _hud_model, bool(entity, float) _framefunc, void(entity, bool) _exitfunc, float(entity, entity) _enterfunc)
 
vector vehicle_aimturret (entity _vehic, vector _target, entity _turrret, string _tagname, float _pichlimit_min, float _pichlimit_max, float _rotlimit_min, float _rotlimit_max, float _aimspeed, float dt)
 
bool vehicle_impulse (entity this, int imp)
 
bool vehicle_initialize (entity this, Vehicle info, bool nodrop)
 
entity vehicle_tossgib (entity this, entity _template, vector _vel, string _tag, bool _burn, bool _explode, float _maxtime, vector _rot)
 
void vehicle_use (entity this, entity actor, entity trigger)
 
void vehicles_clearreturn (entity veh)
 
bool vehicles_crushable (entity e)
 
void vehicles_damage (entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
 
void vehicles_enter (entity pl, entity veh)
 
void vehicles_exit (entity vehic, bool eject)
 
vector vehicles_findgoodexit (entity this, entity player, vector prefer_spot)
 
void vehicles_frame (entity this, entity actor)
 
void vehicles_gib_explode (entity this)
 
void vehicles_gib_think (entity this)
 
void vehicles_gib_touch (entity this, entity toucher)
 
bool vehicles_heal (entity targ, entity inflictor, float amount, float limit)
 
void vehicles_impact (entity this, float _minspeed, float _speedfac, float _maxpain)
 
void vehicles_locktarget (entity this, float incr, float decr, float _lock_time)
 
void vehicles_painframe (entity this)
 
entity vehicles_projectile (entity this, entity _mzlfx, Sound _mzlsound, vector _org, vector _vel, float _dmg, float _radi, float _force, float _size, int _deahtype, float _projtype, float _health, bool _cull, bool _clianim, entity _owner)
 
void vehicles_projectile_damage (entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
 
void vehicles_projectile_explode (entity this, entity toucher)
 
void vehicles_projectile_explode_think (entity this)
 
void vehicles_projectile_explode_use (entity this, entity actor, entity trigger)
 
void vehicles_regen (entity this, float timer,.float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale)
 
void vehicles_regen_resource (entity this, float timer,.float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale, Resource resource)
 
void vehicles_reset (entity this)
 
void vehicles_reset_colors (entity this, entity player)
 
void vehicles_return (entity this)
 
void vehicles_setreturn (entity veh)
 
void vehicles_showwp (entity this)
 
void vehicles_showwp_goaway (entity this)
 
void vehicles_spawn (entity this)
 
void vehicles_think (entity this)
 
void vehicles_touch (entity this, entity toucher)
 

Variables

vector axh_prevcolors
 
vector axh_prevorigin
 
int old_vehicle_flags
 

Function Documentation

◆ AuxiliaryXhair_customize()

bool AuxiliaryXhair_customize ( entity  this,
entity  client 
)

Definition at line 37 of file sv_vehicles.qc.

References cnt, entity(), and owner.

Referenced by UpdateAuxiliaryXhair().

38 {
39  entity e = WaypointSprite_getviewentity(client);
40  entity axh = e.(AuxiliaryXhair[this.cnt]);
41  return axh.owner == this.owner; // cheaply check if the client's axh owner is the same as our real owner
42 }
entity() spawn
entity owner
Definition: main.qh:73
float cnt
Definition: powerups.qc:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCVehicleSetup()

void CSQCVehicleSetup ( entity  own,
int  vehicle_id 
)

Definition at line 80 of file sv_vehicles.qc.

References entity(), IS_REAL_CLIENT, MAX_AXH, msg_entity, MSG_ONE, NULL, and WriteByte().

Referenced by vehicles_enter(), and vehicles_exit().

81 {
82  if(!IS_REAL_CLIENT(own))
83  return;
84 
85  msg_entity = own;
86 
87  WriteHeader(MSG_ONE, TE_CSQC_VEHICLESETUP);
88  WriteByte(MSG_ONE, vehicle_id);
89 
90  if(vehicle_id == 0 || vehicle_id == HUD_NORMAL)
91  {
92  for(int i = 0; i < MAX_AXH; ++i)
93  {
94  entity axh = own.(AuxiliaryXhair[i]);
95  own.(AuxiliaryXhair[i]) = NULL;
96 
97  if(axh.owner == own && axh != NULL && !wasfreed(axh))
98  delete(axh);
99  }
100  }
101 }
entity() spawn
const int MAX_AXH
Definition: cl_vehicles.qh:23
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
entity msg_entity
Definition: progsdefs.qc:63
#define NULL
Definition: post.qh:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendAuxiliaryXhair()

bool SendAuxiliaryXhair ( entity  this,
entity  to,
int  sf 
)

Definition at line 15 of file sv_vehicles.qc.

References cnt, origin, rint(), and WriteByte().

Referenced by UpdateAuxiliaryXhair().

16 {
17  WriteHeader(MSG_ENTITY, ENT_CLIENT_AUXILIARYXHAIR);
18  WriteByte(MSG_ENTITY, sf);
19 
20  WriteByte(MSG_ENTITY, this.cnt);
21 
22  if(sf & 2)
23  {
24  WriteVector(MSG_ENTITY, this.origin);
25  }
26 
27  if(sf & 4)
28  {
29  WriteByte(MSG_ENTITY, rint(this.colormod_x * 255));
30  WriteByte(MSG_ENTITY, rint(this.colormod_y * 255));
31  WriteByte(MSG_ENTITY, rint(this.colormod_z * 255));
32  }
33 
34  return true;
35 }
origin
Definition: ent_cs.qc:114
float cnt
Definition: powerups.qc:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shieldhit_think()

void shieldhit_think ( entity  this)

Definition at line 589 of file sv_vehicles.qc.

References alpha, EF_NODRAW, effects, nextthink, and time.

Referenced by vehicles_damage().

590 {
591  this.alpha -= 0.1;
592  if (this.alpha <= 0)
593  {
594  // setmodel(this, MDL_Null);
595  this.alpha = -1;
596  this.effects |= EF_NODRAW;
597  }
598  else
599  {
600  this.nextthink = time + 0.1;
601  }
602 }
float alpha
Definition: items.qc:14
float effects
Definition: csprogsdefs.qc:111
const float EF_NODRAW
Definition: csprogsdefs.qc:305
float nextthink
Definition: csprogsdefs.qc:121
float time
Definition: csprogsdefs.qc:16
+ Here is the caller graph for this function:

◆ UpdateAuxiliaryXhair()

void UpdateAuxiliaryXhair ( entity  own,
vector  loc,
vector  clr,
int  axh_id 
)

Definition at line 47 of file sv_vehicles.qc.

References AuxiliaryXhair_customize(), bound(), entity(), IS_REAL_CLIENT, MAX_AXH, NULL, SendAuxiliaryXhair(), and setorigin().

48 {
49  if(!IS_REAL_CLIENT(own))
50  return;
51 
52  axh_id = bound(0, axh_id, MAX_AXH);
53  entity axh = own.(AuxiliaryXhair[axh_id]);
54 
55  if(axh == NULL || wasfreed(axh)) // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist? Mario: because of sloppy code like this)
56  {
57  axh = new(auxiliary_xhair);
58  axh.cnt = axh_id;
59  //axh.drawonlytoclient = own; // not spectatable
60  setcefc(axh, AuxiliaryXhair_customize);
61  axh.owner = own;
62  Net_LinkEntity(axh, false, 0, SendAuxiliaryXhair);
63  }
64 
65  if(loc != axh.axh_prevorigin)
66  {
67  setorigin(axh, loc);
68  axh.SendFlags |= 2;
69  }
70 
71  if(clr != axh.axh_prevcolors)
72  {
73  axh.colormod = clr;
74  axh.SendFlags |= 4;
75  }
76 
77  own.(AuxiliaryXhair[axh_id]) = axh; // set it anyway...?
78 }
entity() spawn
const int MAX_AXH
Definition: cl_vehicles.qh:23
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
#define NULL
Definition: post.qh:17
setorigin(ent, v)
bool AuxiliaryXhair_customize(entity this, entity client)
Definition: sv_vehicles.qc:37
bool SendAuxiliaryXhair(entity this, entity to, int sf)
Definition: sv_vehicles.qc:15
+ Here is the call graph for this function:

◆ vehicle_addplayerslot()

bool vehicle_addplayerslot ( entity  _owner,
entity  _slot,
int  _hud,
Model  _hud_model,
bool(entity, float _framefunc,
void(entity, bool _exitfunc,
float(entity, entity _enterfunc 
)

Definition at line 330 of file sv_vehicles.qc.

References EF_ADDITIVE, EF_DOUBLESIDED, EF_FULLBRIGHT, EF_LOWPRECISION, EF_NODEPTHTEST, EF_NOGUNBOB, EF_NOSHADOW, EF_SELECTABLE, EF_TELEPORT_BIT, setmodel, VHF_MULTISLOT, and VHF_PLAYERSLOT.

336 {
337  if(!(_owner.vehicle_flags & VHF_MULTISLOT))
338  _owner.vehicle_flags |= VHF_MULTISLOT;
339 
340  _slot.PlayerPhysplug = _framefunc;
341  _slot.vehicle_exit = _exitfunc;
342  _slot.vehicle_enter = _enterfunc;
343  STAT(HUD, _slot) = _hud;
344  _slot.vehicle_flags = VHF_PLAYERSLOT;
345  _slot.vehicle_viewport = new(vehicle_viewport);
346  _slot.vehicle_hudmodel = new(vehicle_hudmodel);
347  _slot.vehicle_hudmodel.viewmodelforclient = _slot;
349 
350  setmodel(_slot.vehicle_hudmodel, _hud_model);
351  setmodel(_slot.vehicle_viewport, MDL_Null);
352 
353  setattachment(_slot.vehicle_hudmodel, _slot, "");
354  setattachment(_slot.vehicle_viewport, _slot.vehicle_hudmodel, "");
355 
356  return true;
357 }
const int VHF_PLAYERSLOT
Vehicle has multiple player slots.
Definition: vehicle.qh:76
float EF_NOGUNBOB
const float EF_NODEPTHTEST
Definition: csprogsdefs.qc:304
const float EF_NOSHADOW
Definition: csprogsdefs.qc:306
const int EF_TELEPORT_BIT
const float EF_ADDITIVE
Definition: csprogsdefs.qc:300
#define setmodel(this, m)
Definition: model.qh:26
const float EF_FULLBRIGHT
Definition: csprogsdefs.qc:303
const int VHF_MULTISLOT
Add random head angles each frame if health < 50%.
Definition: vehicle.qh:75
const int EF_DOUBLESIDED
const float EF_SELECTABLE
Definition: csprogsdefs.qc:309
float EF_LOWPRECISION

◆ vehicle_aimturret()

vector vehicle_aimturret ( entity  _vehic,
vector  _target,
entity  _turrret,
string  _tagname,
float  _pichlimit_min,
float  _pichlimit_max,
float  _rotlimit_min,
float  _rotlimit_max,
float  _aimspeed,
float  dt 
)

Definition at line 359 of file sv_vehicles.qc.

References AnglesTransform_FromAngles(), AnglesTransform_LeftDivide(), AnglesTransform_Normalize(), AnglesTransform_ToAngles(), bound(), gettagindex, gettaginfo, normalize(), vectoangles(), and vector().

362 {
363  vector vtmp, vtag;
364  float ftmp;
365  vtag = gettaginfo(_turrret, gettagindex(_turrret, _tagname));
366  vtmp = vectoangles(normalize(_target - vtag));
368  vtmp = AnglesTransform_Normalize(vtmp, true);
369  ftmp = _aimspeed * dt;
370  vtmp_y = bound(-ftmp, vtmp_y, ftmp);
371  vtmp_x = bound(-ftmp, vtmp_x, ftmp);
372  _turrret.angles_y = bound(_rotlimit_min, _turrret.angles_y + vtmp_y, _rotlimit_max);
373  _turrret.angles_x = bound(_pichlimit_min, _turrret.angles_x + vtmp_x, _pichlimit_max);
374  return vtag;
375 }
vector AnglesTransform_ToAngles(vector v)
vector AnglesTransform_FromAngles(vector v)
#define gettaginfo
Definition: post.qh:32
#define gettagindex
Definition: dpextensions.qh:16
vector AnglesTransform_Normalize(vector t, float minimize_roll)
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector AnglesTransform_LeftDivide(vector from_transform, vector to_transform)
+ Here is the call graph for this function:

◆ vehicle_impulse()

bool vehicle_impulse ( entity  this,
int  imp 
)

Definition at line 921 of file sv_vehicles.qc.

References bool, entity(), IS_DEAD, stuffcmd, v, and vehicle.

Referenced by ImpulseCommands().

922 {
923  entity v = this.vehicle;
924  if (!v) return false;
925  if (IS_DEAD(v)) return false;
926  bool(entity,int) f = v.vehicles_impulse;
927  if (f && f(this,imp)) return true;
928  switch (imp)
929  {
930  case IMP_weapon_drop.impulse:
931  {
932  stuffcmd(this, "\ntoggle cl_eventchase_vehicle\nset _vehicles_shownchasemessage 1\n");
933  return true;
934  }
935  }
936  return false;
937 }
int int int imp
Definition: impulse.qc:90
entity() spawn
#define bool
Definition: _all.inc:24
#define IS_DEAD(s)
Definition: utils.qh:26
#define stuffcmd(cl,...)
Definition: progsdefs.qh:23
vector v
Definition: ent_cs.qc:116
entity vehicle
Definition: impulse.qc:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicle_initialize()

bool vehicle_initialize ( entity  this,
Vehicle  info,
bool  nodrop 
)

Definition at line 1174 of file sv_vehicles.qc.

References active, ACTIVE_ACTIVE, ACTIVE_NOT, angles, autocvar_g_fullbrightplayers, autocvar_g_nodepthtestplayers, autocvar_g_playerclip_collisions, bot_attack, DAMAGE_NO, damagedbycontents, DPCONTENTS_BODY, DPCONTENTS_PLAYERCLIP, DPCONTENTS_SOLID, dphitcontentsmask, EF_FULLBRIGHT, EF_NODEPTHTEST, EF_NODRAW, effects, find(), func_null(), g_bot_targets, g_damagedbycontents, Vehicle::head_model, Vehicle::hud_model, IL_PUSH(), iscreature, LOG_DEBUG, Vehicle::m_maxs, Vehicle::m_mins, Vehicle::model, MOVE_WORLDONLY, MUTATOR_CALLHOOK, nextthink, NULL, origin, pos1, pos2, random(), respawntime, setmodel, setorigin(), setthink, takedamage, target, targetname, team, teamplay, teleportable, time, trace_endpos, tur_head, use, vehicle_use(), vehicledef, Vehicle::vehicleid, vehicles_touch(), and VHF_ISVEHICLE.

Referenced by TEST().

1175 {
1176  if(!autocvar_g_vehicles)
1177  return false;
1178 
1179  if(!info.vehicleid)
1180  return false;
1181 
1182  if(!this.tur_head)
1183  info.vr_precache(info);
1184 
1185  if(this.targetname && this.targetname != "")
1186  {
1187  this.vehicle_controller = find(NULL, target, this.targetname);
1188  if(!this.vehicle_controller)
1189  {
1190  LOG_DEBUG("^1WARNING: ^7Vehicle with invalid .targetname");
1191  this.active = ACTIVE_ACTIVE;
1192  }
1193  else
1194  {
1195  this.team = this.vehicle_controller.team;
1196  this.use = vehicle_use;
1197 
1198  if(teamplay)
1199  {
1200  if(this.vehicle_controller.team == 0)
1201  this.active = ACTIVE_NOT;
1202  else
1203  this.active = ACTIVE_ACTIVE;
1204  }
1205  }
1206  }
1207  else { this.active = ACTIVE_ACTIVE; }
1208 
1209  if(this.team && (!teamplay || !autocvar_g_vehicles_teams))
1210  this.team = 0;
1211 
1212  if(this.mdl == "" || !this.mdl)
1213  _setmodel(this, info.model);
1214  else
1215  _setmodel(this, this.mdl);
1216 
1217  this.vehicle_flags |= VHF_ISVEHICLE;
1218 
1219  this.vehicle_viewport = new(vehicle_viewport);
1220  this.vehicle_hudmodel = new(vehicle_hudmodel);
1221  this.tur_head = new(tur_head);
1222  this.tur_head.owner = this;
1223  this.takedamage = DAMAGE_NO;
1224  this.bot_attack = true;
1225  IL_PUSH(g_bot_targets, this);
1226  this.iscreature = true;
1227  this.teleportable = false; // no teleporting for vehicles, too buggy
1228  this.damagedbycontents = true;
1230  this.vehicleid = info.vehicleid;
1231  this.vehicledef = info;
1232  this.PlayerPhysplug = info.PlayerPhysplug;
1233  this.event_damage = func_null;
1234  this.event_heal = func_null;
1235  settouch(this, vehicles_touch);
1236  setthink(this, vehicles_spawn);
1237  this.nextthink = time;
1238  this.effects = EF_NODRAW;
1240 
1243 
1245  this.effects |= EF_NODEPTHTEST;
1246 
1248  this.effects |= EF_FULLBRIGHT;
1249 
1250  _setmodel(this.vehicle_hudmodel, info.hud_model);
1251  setmodel(this.vehicle_viewport, MDL_Null);
1252 
1253  if(info.head_model != "")
1254  {
1255  _setmodel(this.tur_head, info.head_model);
1256  setattachment(this.tur_head, this, info.tag_head);
1257  setattachment(this.vehicle_hudmodel, this.tur_head, info.tag_hud);
1258  setattachment(this.vehicle_viewport, this.vehicle_hudmodel, info.tag_view);
1259  }
1260  else
1261  {
1262  setattachment(this.tur_head, this, "");
1263  setattachment(this.vehicle_hudmodel, this, info.tag_hud);
1264  setattachment(this.vehicle_viewport, this.vehicle_hudmodel, info.tag_view);
1265  }
1266 
1267  setsize(this, info.m_mins, info.m_maxs);
1268 
1269  info.vr_setup(info, this);
1270 
1271  if(!nodrop)
1272  {
1273  setorigin(this, this.origin);
1274  tracebox(this.origin + '0 0 100', info.m_mins, info.m_maxs, this.origin - '0 0 10000', MOVE_WORLDONLY, this);
1275  setorigin(this, trace_endpos);
1276  }
1277 
1278  this.pos1 = this.origin;
1279  this.pos2 = this.angles;
1280  this.tur_head.team = this.team;
1281 
1282  if(this.active == ACTIVE_NOT)
1283  this.nextthink = 0; // wait until activated
1284  else if(autocvar_g_vehicles_delayspawn)
1285  this.nextthink = time + this.respawntime + (random() * autocvar_g_vehicles_delayspawn_jitter);
1286  else
1287  this.nextthink = time + game_starttime;
1288 
1289  if(MUTATOR_CALLHOOK(VehicleInit, this))
1290  return false;
1291 
1292  return true;
1293 }
string hud_model
cockpit model
Definition: vehicle.qh:18
void vehicle_use(entity this, entity actor, entity trigger)
Definition: sv_vehicles.qc:530
int vehicleid
Definition: vehicle.qh:4
bool autocvar_g_nodepthtestplayers
Definition: client.qh:33
float respawntime
Definition: items.qh:36
void vehicles_spawn(entity this)
bool iscreature
Definition: main.qh:42
int team
Definition: main.qh:157
entity tur_head
Definition: sv_turrets.qh:29
IntrusiveList g_damagedbycontents
Definition: damage.qh:155
float bot_attack
Definition: api.qh:38
string head_model
full name of tur_head model
Definition: vehicle.qh:16
const int VHF_ISVEHICLE
Definition: vehicle.qh:63
float DPCONTENTS_PLAYERCLIP
origin
Definition: ent_cs.qc:114
const float EF_NODEPTHTEST
Definition: csprogsdefs.qc:304
float effects
Definition: csprogsdefs.qc:111
IntrusiveList g_bot_targets
Definition: api.qh:149
string model
full name of model
Definition: vehicle.qh:12
#define setmodel(this, m)
Definition: model.qh:26
const float EF_NODRAW
Definition: csprogsdefs.qc:305
const float EF_FULLBRIGHT
Definition: csprogsdefs.qc:303
vector m_mins
vehicle hitbox size
Definition: vehicle.qh:30
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
float damagedbycontents
Definition: damage.qh:48
vector m_maxs
vehicle hitbox size
Definition: vehicle.qh:32
const int ACTIVE_ACTIVE
Definition: defs.qh:37
#define NULL
Definition: post.qh:17
float DPCONTENTS_SOLID
vector trace_endpos
Definition: csprogsdefs.qc:37
float takedamage
Definition: progsdefs.qc:147
float teamplay
Definition: progsdefs.qc:31
float nextthink
Definition: csprogsdefs.qc:121
bool autocvar_g_fullbrightplayers
Definition: client.qh:16
entity vehicledef
Definition: vehicle.qh:80
float DPCONTENTS_BODY
string targetname
Definition: progsdefs.qc:194
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
int active
Definition: defs.qh:34
vector pos1
Definition: subs.qh:50
float teleportable
Definition: teleporters.qh:24
setorigin(ent, v)
float dphitcontentsmask
#define setthink(e, f)
vector angles
Definition: csprogsdefs.qc:104
#define use
Definition: csprogsdefs.qh:50
string target
Definition: progsdefs.qc:193
float MOVE_WORLDONLY
bool autocvar_g_playerclip_collisions
Definition: client.qh:17
const int ACTIVE_NOT
Definition: defs.qh:36
float time
Definition: csprogsdefs.qc:16
vector pos2
Definition: subs.qh:50
float DAMAGE_NO
Definition: progsdefs.qc:282
var void func_null()
void vehicles_touch(entity this, entity toucher)
Definition: sv_vehicles.qc:888
#define LOG_DEBUG(...)
Definition: log.qh:85
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicle_tossgib()

entity vehicle_tossgib ( entity  this,
entity  _template,
vector  _vel,
string  _tag,
bool  _burn,
bool  _explode,
float  _maxtime,
vector  _rot 
)

Definition at line 298 of file sv_vehicles.qc.

References EF_FLAME, EF_LOWPRECISION, entity(), gettagindex, gettaginfo, MOVETYPE_TOSS, random(), set_movetype(), setorigin(), setthink, SOLID_CORPSE, time, vector(), vehicles_gib_explode(), vehicles_gib_think(), and vehicles_gib_touch().

299 {
300  entity _gib = new(vehicle_gib);
301  _setmodel(_gib, _template.model);
302  vector org = gettaginfo(this, gettagindex(this, _tag));
303  setorigin(_gib, org);
304  _gib.velocity = _vel;
306  _gib.solid = SOLID_CORPSE;
307  _gib.colormod = '-0.5 -0.5 -0.5';
308  _gib.effects = EF_LOWPRECISION;
309  _gib.avelocity = _rot;
310 
311  if(_burn)
312  _gib.effects |= EF_FLAME;
313 
314  if(_explode)
315  {
317  _gib.nextthink = time + random() * _explode;
318  settouch(_gib, vehicles_gib_touch);
319  }
320  else
321  {
322  _gib.cnt = time + _maxtime;
324  _gib.nextthink = time + _maxtime - 1;
325  _gib.alpha = 1;
326  }
327  return _gib;
328 }
void vehicles_gib_explode(entity this)
Definition: sv_vehicles.qc:276
const float EF_FLAME
Definition: csprogsdefs.qc:302
float MOVETYPE_TOSS
Definition: progsdefs.qc:252
entity() spawn
#define gettaginfo
Definition: post.qh:32
#define gettagindex
Definition: dpextensions.qh:16
vector(float skel, float bonenum) _skel_get_boneabs_hidden
void vehicles_gib_touch(entity this, entity toucher)
Definition: sv_vehicles.qc:284
setorigin(ent, v)
#define setthink(e, f)
void vehicles_gib_think(entity this)
Definition: sv_vehicles.qc:289
float time
Definition: csprogsdefs.qc:16
void set_movetype(entity this, int mt)
float EF_LOWPRECISION
const float SOLID_CORPSE
Definition: csprogsdefs.qc:249
+ Here is the call graph for this function:

◆ vehicle_use()

void vehicle_use ( entity  this,
entity  actor,
entity  trigger 
)

Definition at line 530 of file sv_vehicles.qc.

References active, ACTIVE_ACTIVE, ACTIVE_NOT, EF_NODRAW, effects, IS_DEAD, LOG_DEBUG, netname, nextthink, setthink, time, tur_head, vehicles_reset_colors(), and vehicles_setreturn().

Referenced by vehicle_initialize().

531 {
532  LOG_DEBUG("vehicle ", this.netname, " used by ", actor.classname);
533 
534  this.tur_head.team = actor.team;
535 
536  if(this.tur_head.team == 0)
537  this.active = ACTIVE_NOT;
538  else
539  this.active = ACTIVE_ACTIVE;
540 
541  if(this.active == ACTIVE_ACTIVE && !IS_DEAD(this) && !game_stopped)
542  {
543  LOG_DEBUG("Respawning vehicle: ", this.netname);
544  if(this.effects & EF_NODRAW)
545  {
546  setthink(this, vehicles_spawn);
547  this.nextthink = time + 3;
548  }
549  else
550  {
551  vehicles_setreturn(this);
552  vehicles_reset_colors(this, actor);
553  }
554  }
555 }
void vehicles_setreturn(entity veh)
Definition: sv_vehicles.qc:507
void vehicles_spawn(entity this)
entity tur_head
Definition: sv_turrets.qh:29
string netname
Definition: powerups.qc:20
float effects
Definition: csprogsdefs.qc:111
const float EF_NODRAW
Definition: csprogsdefs.qc:305
const int ACTIVE_ACTIVE
Definition: defs.qh:37
#define IS_DEAD(s)
Definition: utils.qh:26
float nextthink
Definition: csprogsdefs.qc:121
int active
Definition: defs.qh:34
#define setthink(e, f)
void vehicles_reset_colors(entity this, entity player)
Definition: sv_vehicles.qc:377
const int ACTIVE_NOT
Definition: defs.qh:36
float time
Definition: csprogsdefs.qc:16
#define LOG_DEBUG(...)
Definition: log.qh:85
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_clearreturn()

void vehicles_clearreturn ( entity  veh)

Definition at line 430 of file sv_vehicles.qc.

References entity(), IL_EACH, and vehicles_spawn().

Referenced by vehicles_enter(), vehicles_reset(), and vehicles_setreturn().

431 {
432  // Remove "return helper" entities, if any.
433  IL_EACH(g_vehicle_returners, it.wp00 == veh,
434  {
435  it.classname = "";
436  setthink(it, SUB_Remove);
437  it.nextthink = time + 0.1;
438  IL_REMOVE(g_vehicle_returners, it);
439 
440  if(it.waypointsprite_attached)
441  WaypointSprite_Kill(it.waypointsprite_attached);
442  });
443 }
#define IL_EACH(this, cond, body)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_crushable()

bool vehicles_crushable ( entity  e)

Definition at line 735 of file sv_vehicles.qc.

References IS_MONSTER, IS_PLAYER, and time.

Referenced by vehicles_touch().

736 {
737  if(IS_PLAYER(e) && time >= e.vehicle_enter_delay)
738  return true;
739 
740  if(IS_MONSTER(e))
741  return true;
742 
743  return false;
744 }
#define IS_MONSTER(v)
Definition: utils.qh:21
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the caller graph for this function:

◆ vehicles_damage()

void vehicles_damage ( entity  this,
entity  inflictor,
entity  attacker,
float  damage,
int  deathtype,
.entity  weaponentity,
vector  hitloc,
vector  force 
)

Definition at line 633 of file sv_vehicles.qc.

References angles, antilag_clear(), ATTEN_NORM, CH_PAIN, damageforcescale, DEATH_ISWEAPON, DEATH_WEAPONOF, EF_LOWPRECISION, EF_NODRAW, enemy, fabs(), GetResource(), maxs, mins, MSG_BROADCAST, normalize(), NULL, origin, owner, pain_finished, RES_HEALTH, setmodel, setorigin(), setthink, shieldhit_think(), TakeResource(), time, vectoangles(), vehicledef, vehicles_exit(), vehicles_setreturn(), velocity, VHF_DEATHEJECT, VHF_HASSHIELD, vlen(), and VOL_BASE.

Referenced by vehicles_enter(), and vehicles_spawn().

634 {
635  this.dmg_time = time;
636 
637  // WEAPONTODO
638  if(DEATH_ISWEAPON(deathtype, WEP_VORTEX))
639  damage *= autocvar_g_vehicles_vortex_damagerate;
640  else if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN))
641  damage *= autocvar_g_vehicles_machinegun_damagerate;
642  else if(DEATH_ISWEAPON(deathtype, WEP_RIFLE))
643  damage *= autocvar_g_vehicles_rifle_damagerate;
644  else if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER))
645  damage *= autocvar_g_vehicles_vaporizer_damagerate;
646  else if(DEATH_ISWEAPON(deathtype, WEP_SEEKER))
647  damage *= autocvar_g_vehicles_tag_damagerate;
648  else if(DEATH_WEAPONOF(deathtype) != WEP_Null)
649  damage *= autocvar_g_vehicles_weapon_damagerate;
650 
651  this.enemy = attacker;
652 
653  this.pain_finished = time;
654 
655  if((this.vehicle_flags & VHF_HASSHIELD) && (this.vehicle_shield > 0))
656  {
657  if (wasfreed(this.vehicle_shieldent) || this.vehicle_shieldent == NULL)
658  {
659  this.vehicle_shieldent = new(vehicle_shieldent);
660  this.vehicle_shieldent.effects = EF_LOWPRECISION;
661 
662  setmodel(this.vehicle_shieldent, MDL_VEH_SHIELD);
663  setattachment(this.vehicle_shieldent, this, "");
664  setorigin(this.vehicle_shieldent, real_origin(this) - this.origin);
665  this.vehicle_shieldent.scale = 256 / vlen(this.maxs - this.mins);
666  setthink(this.vehicle_shieldent, shieldhit_think);
667  }
668 
669  this.vehicle_shieldent.colormod = '1 1 1';
670  this.vehicle_shieldent.alpha = 0.45;
671  this.vehicle_shieldent.angles = vectoangles(normalize(hitloc - (this.origin + this.vehicle_shieldent.origin))) - this.angles;
672  this.vehicle_shieldent.nextthink = time;
673  this.vehicle_shieldent.effects &= ~EF_NODRAW;
674 
675  this.vehicle_shield -= damage;
676 
677  if(this.vehicle_shield < 0)
678  {
679  TakeResource(this, RES_HEALTH, fabs(this.vehicle_shield));
680  this.vehicle_shieldent.colormod = '2 0 0';
681  this.vehicle_shield = 0;
682  this.vehicle_shieldent.alpha = 0.75;
683 
684  if(sound_allowed(MSG_BROADCAST, attacker))
685  spamsound (this, CH_PAIN, SND_ONS_HIT2, VOL_BASE, ATTEN_NORM); // FIXME: PLACEHOLDER
686  }
687  else
688  if(sound_allowed(MSG_BROADCAST, attacker))
689  spamsound (this, CH_PAIN, SND_ONS_ELECTRICITY_EXPLODE, VOL_BASE, ATTEN_NORM); // FIXME: PLACEHOLDER
690 
691  }
692  else
693  {
694  TakeResource(this, RES_HEALTH, damage);
695 
696  if(sound_allowed(MSG_BROADCAST, attacker))
697  spamsound (this, CH_PAIN, SND_ONS_HIT2, VOL_BASE, ATTEN_NORM); // FIXME: PLACEHOLDER
698  }
699 
700  if(this.damageforcescale < 1 && this.damageforcescale > 0)
701  this.velocity += force * this.damageforcescale;
702  else
703  this.velocity += force;
704 
705  if(GetResource(this, RES_HEALTH) <= 0)
706  {
707  if(this.owner)
708  {
709  if(this.vehicle_flags & VHF_DEATHEJECT)
710  vehicles_exit(this, VHEF_EJECT);
711  else
712  vehicles_exit(this, VHEF_RELEASE);
713  }
714 
715  antilag_clear(this, this);
716 
717  Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid);
718  info.vr_death(info, this);
719  vehicles_setreturn(this);
720  }
721 }
const int VHF_HASSHIELD
Indicates vehicle.
Definition: vehicle.qh:64
void shieldhit_think(entity this)
Definition: sv_vehicles.qc:589
void vehicles_setreturn(entity veh)
Definition: sv_vehicles.qc:507
const int CH_PAIN
Definition: sound.qh:18
float damageforcescale
Definition: damage.qh:137
vector maxs
Definition: csprogsdefs.qc:113
origin
Definition: ent_cs.qc:114
void antilag_clear(entity e, entity store)
Definition: antilag.qc:114
entity owner
Definition: main.qh:73
#define DEATH_WEAPONOF(t)
Definition: all.qh:41
void TakeResource(entity receiver, Resource res_type, float amount)
Takes an entity some resource.
Definition: cl_resources.qc:31
#define setmodel(this, m)
Definition: model.qh:26
RES_HEALTH
Definition: ent_cs.qc:126
const float EF_NODRAW
Definition: csprogsdefs.qc:305
entity enemy
Definition: sv_ctf.qh:143
vector mins
Definition: csprogsdefs.qc:113
#define NULL
Definition: post.qh:17
const float VOL_BASE
Definition: sound.qh:36
const float ATTEN_NORM
Definition: sound.qh:30
entity vehicledef
Definition: vehicle.qh:80
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
float pain_finished
const int VHF_DEATHEJECT
Vehicles energy regenerates.
Definition: vehicle.qh:68
setorigin(ent, v)
#define setthink(e, f)
vector angles
Definition: csprogsdefs.qc:104
void vehicles_exit(entity vehic, bool eject)
Definition: sv_vehicles.qc:788
#define DEATH_ISWEAPON(t, w)
Definition: all.qh:42
float time
Definition: csprogsdefs.qc:16
vector velocity
Definition: csprogsdefs.qc:103
float EF_LOWPRECISION
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_enter()

void vehicles_enter ( entity  pl,
entity  veh 
)

Definition at line 939 of file sv_vehicles.qc.

References antilag_clear(), CS(), CSQCModel_UnlinkEntity(), CSQCVehicleSetup(), DAMAGE_NO, DIFF_TEAM, entity(), FL_NOTARGET, FOREACH_CLIENT, func_null(), IS_BOT_CLIENT, IS_DEAD, IS_PLAYER, IS_REAL_CLIENT, MAX_WEAPONSLOTS, MOVETYPE_NOCLIP, msg_entity, MSG_ONE, MUTATOR_CALLHOOK, NULL, RemoveGrapplingHooks(), SAME_TEAM, set_movetype(), SOLID_NOT, Team_ColorRGB(), teamplay, time, UNSET_DUCKED, UNSET_ONGROUND, vehicles_clearreturn(), vehicles_damage(), vehicles_heal(), vehicles_reset_colors(), VHF_MULTISLOT, VHF_SHIELDREGEN, weaponentities, WriteAngle(), WriteByte(), and WriteEntity().

Referenced by PlayerUseKey(), and vehicles_touch().

940 {
941  // Remove this when bots know how to use vehicles
942  if((IS_BOT_CLIENT(pl) && !autocvar_g_vehicles_allow_bots))
943  return;
944 
945  if((!IS_PLAYER(pl))
946  || (veh.phase >= time)
947  || (pl.vehicle_enter_delay >= time)
948  || (STAT(FROZEN, pl))
949  || (IS_DEAD(pl))
950  || (pl.vehicle)
951  ) { return; }
952 
953  Vehicle info = veh.vehicledef; //REGISTRY_GET(Vehicles, veh.vehicleid);
954 
955  if(autocvar_g_vehicles_enter) // vehicle's touch function should handle this if entering via use key is disabled (TODO)
956  if(veh.vehicle_flags & VHF_MULTISLOT)
957  if(veh.owner && SAME_TEAM(pl, veh))
958  {
959  // we don't need a return value or anything here
960  // if successful the owner check below will prevent anything weird
961  info.vr_gunner_enter(info, veh, pl);
962  }
963 
964  if(veh.owner)
965  return; // got here and didn't enter the gunner, return
966 
967  if(teamplay)
968  if(veh.team)
969  if(DIFF_TEAM(pl, veh))
970  if(autocvar_g_vehicles_steal)
971  {
972  FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, veh), Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_VEHICLE_STEAL));
973 
974  Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_VEHICLE_STEAL_SELF);
975 
976  veh.vehicle_shield = 0;
977  veh.old_vehicle_flags = veh.vehicle_flags; // make a backup just so we're not permanently crippling this vehicle
978  veh.vehicle_flags &= ~VHF_SHIELDREGEN;
979 
980  if (autocvar_g_vehicles_steal_show_waypoint) {
981  entity wp = WaypointSprite_Spawn(WP_VehicleIntruder, 0, 0, pl, '0 0 68', NULL, veh.team, veh, wps_intruder, true, RADARICON_DANGER);
982  wp.colormod = Team_ColorRGB(pl.team);
983  }
984  }
985  else return;
986 
988 
989  veh.vehicle_ammo1 = 0;
990  veh.vehicle_ammo2 = 0;
991  veh.vehicle_reload1 = 0;
992  veh.vehicle_reload2 = 0;
993  veh.vehicle_energy = 0;
994 
995  veh.owner = pl;
996  pl.vehicle = veh;
997 
998  // .viewmodelforclient works better.
999  //veh.vehicle_hudmodel.drawonlytoclient = veh.owner;
1000 
1001  veh.vehicle_hudmodel.viewmodelforclient = pl;
1002 
1003  UNSET_DUCKED(pl);
1004  pl.view_ofs = STAT(PL_VIEW_OFS, pl);
1005  setsize(pl, STAT(PL_MIN, pl), STAT(PL_MAX, pl));
1006 
1007  veh.event_damage = vehicles_damage;
1008  veh.event_heal = vehicles_heal;
1009  veh.nextthink = 0;
1010  pl.items &= ~IT_USING_JETPACK;
1011  pl.angles = veh.angles;
1012  pl.takedamage = DAMAGE_NO;
1013  pl.solid = SOLID_NOT;
1014  pl.disableclientprediction = 1; // physics is no longer run, so this won't be reset
1016  pl.teleportable = false;
1017  pl.alpha = -1;
1018  pl.event_damage = func_null;
1019  pl.view_ofs = '0 0 0';
1020  veh.colormap = pl.colormap;
1021  if(veh.tur_head)
1022  veh.tur_head.colormap = pl.colormap;
1023  for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
1024  {
1025  .entity weaponentity = weaponentities[slot];
1026  veh.(weaponentity) = new(temp_wepent);
1027  veh.(weaponentity).m_switchweapon = pl.(weaponentity).m_switchweapon;
1028  }
1029  STAT(HUD, pl) = veh.vehicleid;
1030  pl.PlayerPhysplug = veh.PlayerPhysplug;
1031 
1032  pl.vehicle_ammo1 = veh.vehicle_ammo1;
1033  pl.vehicle_ammo2 = veh.vehicle_ammo2;
1034  pl.vehicle_reload1 = veh.vehicle_reload1;
1035  pl.vehicle_reload2 = veh.vehicle_reload2;
1036  pl.vehicle_energy = veh.vehicle_energy;
1037 
1038  // Cant do this, hides attached objects too.
1039  //veh.exteriormodeltoclient = veh.owner;
1040  //veh.tur_head.exteriormodeltoclient = veh.owner;
1041 
1042  UNSET_ONGROUND(pl);
1043  UNSET_ONGROUND(veh);
1044 
1045  veh.team = pl.team;
1046  veh.flags -= FL_NOTARGET;
1047 
1048  vehicles_reset_colors(veh, pl);
1049 
1050  if (IS_REAL_CLIENT(pl))
1051  {
1052  Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_VEHICLE_ENTER);
1053 
1054  msg_entity = pl;
1055  WriteByte (MSG_ONE, SVC_SETVIEWPORT);
1056  WriteEntity(MSG_ONE, veh.vehicle_viewport);
1057 
1058  // NOTE: engine networked
1059  WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
1060  if(veh.tur_head)
1061  {
1062  WriteAngle(MSG_ONE, veh.tur_head.angles_x + veh.angles_x); // tilt
1063  WriteAngle(MSG_ONE, veh.tur_head.angles_y + veh.angles_y); // yaw
1064  WriteAngle(MSG_ONE, 0); // roll
1065  }
1066  else
1067  {
1068  WriteAngle(MSG_ONE, veh.angles_x * -1); // tilt
1069  WriteAngle(MSG_ONE, veh.angles_y); // yaw
1070  WriteAngle(MSG_ONE, 0); // roll
1071  }
1072  }
1073 
1074  vehicles_clearreturn(veh);
1075 
1076  CSQCVehicleSetup(pl, veh.vehicleid);
1077 
1078  MUTATOR_CALLHOOK(VehicleEnter, pl, veh);
1079 
1081  info.vr_enter(info, veh);
1082 
1083  antilag_clear(pl, CS(pl));
1084 }
const float SOLID_NOT
Definition: csprogsdefs.qc:244
bool vehicles_heal(entity targ, entity inflictor, float amount, float limit)
Definition: sv_vehicles.qc:723
vector Team_ColorRGB(int teamid)
Definition: teams.qh:76
void vehicles_clearreturn(entity veh)
Definition: sv_vehicles.qc:430
entity() spawn
ClientState CS(Client this)
Definition: state.qh:47
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define UNSET_DUCKED(s)
Definition: player.qh:208
void antilag_clear(entity e, entity store)
Definition: antilag.qc:114
#define DIFF_TEAM(a, b)
Definition: teams.qh:240
#define UNSET_ONGROUND(s)
Definition: movetypes.qh:18
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
void vehicles_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition: sv_vehicles.qc:633
entity msg_entity
Definition: progsdefs.qc:63
const int VHF_SHIELDREGEN
Vehicle has shileding.
Definition: vehicle.qh:65
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
void CSQCVehicleSetup(entity own, int vehicle_id)
Definition: sv_vehicles.qc:80
#define NULL
Definition: post.qh:17
#define SAME_TEAM(a, b)
Definition: teams.qh:239
float teamplay
Definition: progsdefs.qc:31
#define IS_DEAD(s)
Definition: utils.qh:26
void RemoveGrapplingHooks(entity pl)
Definition: hook.qc:78
float MOVETYPE_NOCLIP
Definition: progsdefs.qc:254
const int VHF_MULTISLOT
Add random head angles each frame if health < 50%.
Definition: vehicle.qh:75
void CSQCModel_UnlinkEntity(entity e)
Definition: sv_model.qc:129
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition: utils.qh:15
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
float FL_NOTARGET
Definition: progsdefs.qc:238
void vehicles_reset_colors(entity this, entity player)
Definition: sv_vehicles.qc:377
float time
Definition: csprogsdefs.qc:16
float DAMAGE_NO
Definition: progsdefs.qc:282
void set_movetype(entity this, int mt)
#define IS_PLAYER(v)
Definition: utils.qh:9
var void func_null()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_exit()

void vehicles_exit ( entity  vehic,
bool  eject 
)

Definition at line 788 of file sv_vehicles.qc.

References ATTEN_NORM, CH_TRIGGER_SINGLE, CSQCVehicleSetup(), DAMAGE_AIM, default_player_alpha, EF_NODRAW, entity(), FL_NOTARGET, func_null(), IS_DEAD, IS_REAL_CLIENT, LOG_TRACE, MAX_WEAPONSLOTS, MOVETYPE_WALK, msg_entity, MSG_ONE, MUTATOR_CALLHOOK, NULL, PlayerDamage(), set_movetype(), SOLID_SLIDEBOX, sound, teamplay, TELEPORT_NORMAL, time, vehicles_reset_colors(), vehicles_setreturn(), VHF_PLAYERSLOT, VHF_SHIELDREGEN, weaponentities, WriteAngle(), WriteByte(), and WriteEntity().

Referenced by ClientDisconnect(), ClientKill_Now(), Damage(), player_regen(), PlayerPreThink(), PlayerUseKey(), PutObserverInServer(), PutPlayerInServer(), vehicles_damage(), and vehicles_reset().

789 {
790  entity player = vehic.owner;
791 
792  if(vehicles_exit_running)
793  {
794  LOG_TRACE("^1vehicles_exit already running! this is not good...");
795  return;
796  }
797 
798  vehicles_exit_running = true;
799 
800  if(vehic.vehicle_flags & VHF_PLAYERSLOT)
801  {
802  vehic.vehicle_exit(vehic, eject);
803  vehicles_exit_running = false;
804  return;
805  }
806 
807  if (player)
808  {
809  if (IS_REAL_CLIENT(player))
810  {
811  msg_entity = player;
812  WriteByte (MSG_ONE, SVC_SETVIEWPORT);
813  WriteEntity( MSG_ONE, player);
814 
815  // NOTE: engine networked
816  WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
817  WriteAngle(MSG_ONE, 0);
818  WriteAngle(MSG_ONE, vehic.angles_y);
819  WriteAngle(MSG_ONE, 0);
820  }
821 
822  setsize(player, STAT(PL_MIN, player), STAT(PL_MAX, player));
823 
824  player.takedamage = DAMAGE_AIM;
825  player.solid = SOLID_SLIDEBOX;
826  set_movetype(player, MOVETYPE_WALK);
827  player.effects &= ~EF_NODRAW;
828  player.teleportable = TELEPORT_NORMAL;
829  player.alpha = default_player_alpha;
830  player.PlayerPhysplug = func_null;
831  player.vehicle = NULL;
832  player.view_ofs = STAT(PL_VIEW_OFS, player);
833  player.event_damage = PlayerDamage;
834  STAT(HUD, player) = HUD_NORMAL;
835  for(int slot = 0; slot < MAX_WEAPONSLOTS; ++ slot)
836  {
837  .entity weaponentity = weaponentities[slot];
838  player.(weaponentity).m_switchweapon = vehic.(weaponentity).m_switchweapon;
839  delete(vehic.(weaponentity)); // no longer needed
840  }
841  player.last_vehiclecheck = time + 3;
842  player.vehicle_enter_delay = time + 2;
843 
844  CSQCVehicleSetup(player, HUD_NORMAL);
845 
846  Kill_Notification(NOTIF_ONE, player, MSG_CENTER, CPID_VEHICLES);
847  Kill_Notification(NOTIF_ONE, player, MSG_CENTER, CPID_VEHICLES_OTHER); // kill all vehicle notifications when exiting a vehicle?
848  }
849 
850  vehic.flags |= FL_NOTARGET;
851 
852  if(!IS_DEAD(vehic))
853  vehic.avelocity = '0 0 0';
854 
855  vehic.tur_head.nodrawtoclient = NULL;
856 
857  if(!teamplay)
858  vehic.team = 0;
859 
860  WaypointSprite_Kill(vehic.wps_intruder);
861 
862  MUTATOR_CALLHOOK(VehicleExit, player, vehic);
863 
864  vehic.team = vehic.tur_head.team;
865 
866  if(vehic.old_vehicle_flags & VHF_SHIELDREGEN)
867  vehic.vehicle_flags |= VHF_SHIELDREGEN;
868  vehic.old_vehicle_flags = 0;
869 
870  sound (vehic, CH_TRIGGER_SINGLE, SND_Null, 1, ATTEN_NORM);
871  vehic.vehicle_hudmodel.viewmodelforclient = vehic;
872  vehic.phase = time + 1;
873 
874  vehic.vehicle_exit(vehic, eject);
875 
876  vehicles_setreturn(vehic);
877  vehicles_reset_colors(vehic, NULL);
878  vehic.owner = NULL;
879 
880  CSQCMODEL_AUTOINIT(vehic);
881 
882  if(player)
883  player.oldorigin = player.origin; // player's location is set by the exit functions, so we need to do this after everything
884 
885  vehicles_exit_running = false;
886 }
const float SOLID_SLIDEBOX
Definition: csprogsdefs.qc:247
float MOVETYPE_WALK
Definition: progsdefs.qc:249
const int VHF_PLAYERSLOT
Vehicle has multiple player slots.
Definition: vehicle.qh:76
void vehicles_setreturn(entity veh)
Definition: sv_vehicles.qc:507
const int TELEPORT_NORMAL
Definition: teleporters.qh:26
entity() spawn
float DAMAGE_AIM
Definition: progsdefs.qc:284
void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition: player.qc:229
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
const float EF_NODRAW
Definition: csprogsdefs.qc:305
entity msg_entity
Definition: progsdefs.qc:63
const int VHF_SHIELDREGEN
Vehicle has shileding.
Definition: vehicle.qh:65
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
void CSQCVehicleSetup(entity own, int vehicle_id)
Definition: sv_vehicles.qc:80
#define NULL
Definition: post.qh:17
float teamplay
Definition: progsdefs.qc:31
#define IS_DEAD(s)
Definition: utils.qh:26
const float ATTEN_NORM
Definition: sound.qh:30
const int CH_TRIGGER_SINGLE
Definition: sound.qh:13
#define LOG_TRACE(...)
Definition: log.qh:81
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
float default_player_alpha
Definition: world.qh:66
float FL_NOTARGET
Definition: progsdefs.qc:238
#define sound(e, c, s, v, a)
Definition: sound.qh:52
void vehicles_reset_colors(entity this, entity player)
Definition: sv_vehicles.qc:377
float time
Definition: csprogsdefs.qc:16
void set_movetype(entity this, int mt)
var void func_null()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_findgoodexit()

vector vehicles_findgoodexit ( entity  this,
entity  player,
vector  prefer_spot 
)

Definition at line 764 of file sv_vehicles.qc.

References absmax, absmin, maxs, mins, MOVE_NORMAL, normalize(), origin, randomvec(), trace_allsolid, trace_fraction, trace_startsolid, v, vector(), and vlen().

765 {
766  // TODO: we actually want the player's size here
767  tracebox(this.origin + '0 0 32', PL_MIN_CONST, PL_MAX_CONST, prefer_spot, MOVE_NORMAL, player);
769  return prefer_spot;
770 
771  float mysize = 1.5 * vlen(this.maxs - this.mins);
772  vector v;
773  vector v2 = 0.5 * (this.absmin + this.absmax);
774  for(int i = 0; i < autocvar_g_vehicles_exit_attempts; ++i)
775  {
776  v = randomvec();
777  v_z = 0;
778  v = v2 + normalize(v) * mysize;
779  tracebox(v2, PL_MIN_CONST, PL_MAX_CONST, v, MOVE_NORMAL, player);
781  return v;
782  }
783 
784  return this.origin;
785 }
const float MOVE_NORMAL
Definition: csprogsdefs.qc:252
vector maxs
Definition: csprogsdefs.qc:113
origin
Definition: ent_cs.qc:114
vector absmax
Definition: csprogsdefs.qc:92
vector mins
Definition: csprogsdefs.qc:113
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector v
Definition: ent_cs.qc:116
float trace_startsolid
Definition: csprogsdefs.qc:35
vector absmin
Definition: csprogsdefs.qc:92
float trace_allsolid
Definition: csprogsdefs.qc:34
float trace_fraction
Definition: csprogsdefs.qc:36
+ Here is the call graph for this function:

◆ vehicles_frame()

void vehicles_frame ( entity  this,
entity  actor 
)

Definition at line 628 of file sv_vehicles.qc.

References vehicles_painframe().

629 {
630  vehicles_painframe(this);
631 }
void vehicles_painframe(entity this)
Definition: sv_vehicles.qc:604
+ Here is the call graph for this function:

◆ vehicles_gib_explode()

void vehicles_gib_explode ( entity  this)

Definition at line 276 of file sv_vehicles.qc.

References ATTEN_NORM, CH_SHOTS, origin, randomvec(), sound, VOL_BASE, and wp00.

Referenced by vehicle_tossgib(), and vehicles_gib_touch().

277 {
278  sound (this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
279  Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (this.origin + '0 0 100'), '0 0 0', 1);
280  Send_Effect(EFFECT_EXPLOSION_SMALL, this.wp00.origin + '0 0 64', '0 0 0', 1);
281  delete(this);
282 }
entity wp00
Definition: api.qh:56
origin
Definition: ent_cs.qc:114
const float VOL_BASE
Definition: sound.qh:36
const float ATTEN_NORM
Definition: sound.qh:30
const int CH_SHOTS
Definition: sound.qh:14
#define sound(e, c, s, v, a)
Definition: sound.qh:52
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_gib_think()

void vehicles_gib_think ( entity  this)

Definition at line 289 of file sv_vehicles.qc.

References alpha, cnt, nextthink, and time.

Referenced by vehicle_tossgib().

290 {
291  this.alpha -= 0.1;
292  if(this.cnt >= time)
293  delete(this);
294  else
295  this.nextthink = time + 0.1;
296 }
float alpha
Definition: items.qc:14
float cnt
Definition: powerups.qc:24
float nextthink
Definition: csprogsdefs.qc:121
float time
Definition: csprogsdefs.qc:16
+ Here is the caller graph for this function:

◆ vehicles_gib_touch()

void vehicles_gib_touch ( entity  this,
entity  toucher 
)

Definition at line 284 of file sv_vehicles.qc.

References vehicles_gib_explode().

Referenced by vehicle_tossgib().

285 {
286  vehicles_gib_explode(this);
287 }
void vehicles_gib_explode(entity this)
Definition: sv_vehicles.qc:276
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_heal()

bool vehicles_heal ( entity  targ,
entity  inflictor,
float  amount,
float  limit 
)

Definition at line 723 of file sv_vehicles.qc.

References GetResource(), GiveResourceWithLimit(), RES_HEALTH, and RES_LIMIT_NONE.

Referenced by vehicles_enter(), and vehicles_spawn().

724 {
725  float true_limit = ((limit != RES_LIMIT_NONE) ? limit : targ.max_health);
726  if(GetResource(targ, RES_HEALTH) <= 0 || GetResource(targ, RES_HEALTH) >= true_limit)
727  return false;
728 
729  GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit);
730  if(targ.owner)
731  targ.owner.vehicle_health = (GetResource(targ, RES_HEALTH) / targ.max_health) * 100;
732  return true;
733 }
RES_HEALTH
Definition: ent_cs.qc:126
void GiveResourceWithLimit(entity receiver, Resource res_type, float amount, float limit)
Gives an entity some resource but not more than a limit.
const int RES_LIMIT_NONE
Definition: resources.qh:46
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_impact()

void vehicles_impact ( entity  this,
float  _minspeed,
float  _speedfac,
float  _maxpain 
)

Definition at line 746 of file sv_vehicles.qc.

References Damage(), DMG_NOWEP, min(), NULL, oldvelocity, Q3SURFACEFLAG_NOIMPACT, time, trace_dphitq3surfaceflags, vdist, velocity, and vlen().

747 {
749  return;
750 
751  if(this.play_time < time)
752  {
753  if(vdist(this.velocity - this.oldvelocity, >, _minspeed))
754  {
755  float wc = vlen(this.velocity - this.oldvelocity);
756  float take = min(_speedfac * wc, _maxpain);
757  Damage(this, NULL, NULL, take, DEATH_FALL.m_id, DMG_NOWEP, this.origin, '0 0 0');
758  this.play_time = time + 0.25;
759  }
760  }
761 }
float trace_dphitq3surfaceflags
vector oldvelocity
Definition: main.qh:38
#define DMG_NOWEP
Definition: damage.qh:126
#define NULL
Definition: post.qh:17
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition: damage.qc:583
float Q3SURFACEFLAG_NOIMPACT
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition: vector.qh:8
float time
Definition: csprogsdefs.qc:16
vector velocity
Definition: csprogsdefs.qc:103
+ Here is the call graph for this function:

◆ vehicles_locktarget()

void vehicles_locktarget ( entity  this,
float  incr,
float  decr,
float  _lock_time 
)

Definition at line 103 of file sv_vehicles.qc.

References IS_DEAD, IS_TURRET, IS_VEHICLE, max(), min(), NULL, owner, SAME_TEAM, time, and trace_ent.

104 {
105  if(this.lock_target && IS_DEAD(this.lock_target))
106  {
107  this.lock_target = NULL;
108  this.lock_strength = 0;
109  this.lock_time = 0;
110  }
111 
112  if(this.lock_time > time)
113  {
114  if(this.lock_target)
115  if(this.lock_soundtime < time)
116  {
117  this.lock_soundtime = time + 0.5;
118  play2(this.owner, "vehicles/locked.wav");
119  }
120 
121  return;
122  }
123 
124  if(trace_ent != NULL)
125  {
126  if(SAME_TEAM(trace_ent, this))
127  trace_ent = NULL;
128 
129  if(IS_DEAD(trace_ent))
130  trace_ent = NULL;
131 
133  trace_ent = NULL;
134 
135  if(trace_ent.alpha <= 0.5 && trace_ent.alpha != 0)
136  trace_ent = NULL; // invisible
137  }
138 
139  if(this.lock_target == NULL && trace_ent != NULL)
140  this.lock_target = trace_ent;
141 
142  if(this.lock_target && trace_ent == this.lock_target)
143  {
144  if(this.lock_strength != 1 && this.lock_strength + incr >= 1)
145  {
146  play2(this.owner, "vehicles/lock.wav");
147  this.lock_soundtime = time + 0.8;
148  }
149  else if (this.lock_strength != 1 && this.lock_soundtime < time)
150  {
151  play2(this.owner, "vehicles/locking.wav");
152  this.lock_soundtime = time + 0.3;
153  }
154  }
155 
156  // Have a locking target
157  // Trace hit current target
158  if(trace_ent == this.lock_target && trace_ent != NULL)
159  {
160  this.lock_strength = min(this.lock_strength + incr, 1);
161  if(this.lock_strength == 1)
162  this.lock_time = time + _lock_time;
163  }
164  else
165  {
166  if(trace_ent)
167  this.lock_strength = max(this.lock_strength - decr * 2, 0);
168  else
169  this.lock_strength = max(this.lock_strength - decr, 0);
170 
171  if(this.lock_strength == 0)
172  this.lock_target = NULL;
173  }
174 }
entity owner
Definition: main.qh:73
#define IS_TURRET(v)
Definition: utils.qh:23
entity trace_ent
Definition: csprogsdefs.qc:40
#define NULL
Definition: post.qh:17
#define SAME_TEAM(a, b)
Definition: teams.qh:239
#define IS_DEAD(s)
Definition: utils.qh:26
#define IS_VEHICLE(v)
Definition: utils.qh:22
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:

◆ vehicles_painframe()

void vehicles_painframe ( entity  this)

Definition at line 604 of file sv_vehicles.qc.

References angles, GetResource(), max(), max_health, myhealth, origin, owner, random(), randomvec(), RES_HEALTH, time, tur_head, velocity, VHF_DMGHEADROLL, VHF_DMGROLL, and VHF_DMGSHAKE.

Referenced by vehicles_frame(), and vehicles_think().

605 {
606  int myhealth = ((this.owner) ? this.owner.vehicle_health : ((GetResource(this, RES_HEALTH) / this.max_health) * 100));
607 
608  if(myhealth <= 50)
609  if(this.pain_frame < time)
610  {
611  float _ftmp = myhealth / 50;
612  this.pain_frame = time + max(0.1, 0.1 + (random() * 0.5 * _ftmp));
613  Send_Effect(EFFECT_SMOKE_SMALL, (this.origin + (randomvec() * 80)), '0 0 0', 1);
614 
615  if(this.vehicle_flags & VHF_DMGSHAKE)
616  this.velocity += randomvec() * 30;
617 
618  if(this.vehicle_flags & VHF_DMGROLL)
619  {
620  if(this.vehicle_flags & VHF_DMGHEADROLL)
621  this.tur_head.angles += randomvec();
622  else
623  this.angles += randomvec();
624  }
625  }
626 }
const int VHF_DMGROLL
Add random velocity each frame if health < 50%.
Definition: vehicle.qh:73
entity tur_head
Definition: sv_turrets.qh:29
const int VHF_DMGSHAKE
Vehicle is airborn.
Definition: vehicle.qh:72
origin
Definition: ent_cs.qc:114
entity owner
Definition: main.qh:73
RES_HEALTH
Definition: ent_cs.qc:126
float max_health
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
float myhealth
Definition: view.qc:577
const int VHF_DMGHEADROLL
Add random angles each frame if health < 50%.
Definition: vehicle.qh:74
vector angles
Definition: csprogsdefs.qc:104
float time
Definition: csprogsdefs.qc:16
vector velocity
Definition: csprogsdefs.qc:103
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_projectile()

entity vehicles_projectile ( entity  this,
entity  _mzlfx,
Sound  _mzlsound,
vector  _org,
vector  _vel,
float  _dmg,
float  _radi,
float  _force,
float  _size,
int  _deahtype,
float  _projtype,
float  _health,
bool  _cull,
bool  _clianim,
entity  _owner 
)

Definition at line 223 of file sv_vehicles.qc.

References ATTEN_NORM, CH_WEAPON_A, CSQCProjectile(), DAMAGE_AIM, entity(), FL_NOTARGET, g_bot_dodge, g_projectiles, IL_PUSH(), MOVETYPE_FLYMISSILE, PROJECTILE_MAKETRIGGER, RES_HEALTH, set_movetype(), setorigin(), SetResourceExplicit(), setthink, SOLID_BBOX, sound, TC, time, vehicles_projectile_damage(), vehicles_projectile_explode(), vehicles_projectile_explode_use(), and VOL_BASE.

228 {
229  TC(Sound, _mzlsound);
230  entity proj = new(vehicles_projectile);
231 
233  setorigin(proj, _org);
234 
235  proj.shot_dmg = _dmg;
236  proj.shot_radius = _radi;
237  proj.shot_force = _force;
238  proj.projectiledeathtype = _deahtype;
239  proj.solid = SOLID_BBOX;
241  proj.flags = FL_PROJECTILE;
242  IL_PUSH(g_projectiles, proj);
243  IL_PUSH(g_bot_dodge, proj);
244  proj.bot_dodge = true;
245  proj.bot_dodgerating = _dmg;
246  proj.velocity = _vel;
247  settouch(proj, vehicles_projectile_explode);
249  proj.owner = this;
250  proj.realowner = _owner;
251  setthink(proj, SUB_Remove);
252  proj.nextthink = time + 30;
253 
254  if(_health)
255  {
256  proj.takedamage = DAMAGE_AIM;
257  proj.event_damage = vehicles_projectile_damage;
258  SetResourceExplicit(proj, RES_HEALTH, _health);
259  }
260  else
261  proj.flags |= FL_NOTARGET;
262 
263  if(_mzlsound != SND_Null)
264  sound (this, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTEN_NORM);
265 
266  if(_mzlfx != EFFECT_Null)
267  Send_Effect(_mzlfx, proj.origin, proj.velocity, 1);
268 
269  setsize (proj, '-1 -1 -1' * _size, '1 1 1' * _size);
270 
271  CSQCProjectile(proj, _clianim, _projtype, _cull);
272 
273  return proj;
274 }
void vehicles_projectile_explode(entity this, entity toucher)
Definition: sv_vehicles.qc:194
#define PROJECTILE_MAKETRIGGER(e)
Definition: common.qh:29
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
Definition: cl_resources.qc:15
entity() spawn
float DAMAGE_AIM
Definition: progsdefs.qc:284
void CSQCProjectile(entity e, float clientanimate, int type, float docull)
IntrusiveList g_bot_dodge
Definition: api.qh:150
RES_HEALTH
Definition: ent_cs.qc:126
void vehicles_projectile_explode_use(entity this, entity actor, entity trigger)
Definition: sv_vehicles.qc:218
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
const int CH_WEAPON_A
Definition: sound.qh:7
const float VOL_BASE
Definition: sound.qh:36
#define TC(T, sym)
Definition: _all.inc:82
void vehicles_projectile_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition: sv_vehicles.qc:177
Definition: sound.qh:119
const float ATTEN_NORM
Definition: sound.qh:30
float MOVETYPE_FLYMISSILE
Definition: progsdefs.qc:255
IntrusiveList g_projectiles
Definition: common.qh:46
const float SOLID_BBOX
Definition: csprogsdefs.qc:246
setorigin(ent, v)
#define setthink(e, f)
entity vehicles_projectile(entity this, entity _mzlfx, Sound _mzlsound, vector _org, vector _vel, float _dmg, float _radi, float _force, float _size, int _deahtype, float _projtype, float _health, bool _cull, bool _clianim, entity _owner)
Definition: sv_vehicles.qc:223
float FL_NOTARGET
Definition: progsdefs.qc:238
#define sound(e, c, s, v, a)
Definition: sound.qh:52
float time
Definition: csprogsdefs.qc:16
void set_movetype(entity this, int mt)
+ Here is the call graph for this function:

◆ vehicles_projectile_damage()

void vehicles_projectile_damage ( entity  this,
entity  inflictor,
entity  attacker,
float  damage,
int  deathtype,
.entity  weaponentity,
vector  hitloc,
vector  force 
)

Definition at line 177 of file sv_vehicles.qc.

References DAMAGE_NO, func_null(), GetResource(), nextthink, RES_HEALTH, setthink, takedamage, TakeResource(), time, and velocity.

Referenced by vehicles_projectile().

178 {
179  // Ignore damage from oterh projectiles from my owner (dont mess up volly's)
180  if(inflictor.owner == this.owner)
181  return;
182 
183  TakeResource(this, RES_HEALTH, damage);
184  this.velocity += force;
185  if(GetResource(this, RES_HEALTH) < 1)
186  {
187  this.takedamage = DAMAGE_NO;
188  this.event_damage = func_null;
189  setthink(this, adaptor_think2use);
190  this.nextthink = time;
191  }
192 }
void TakeResource(entity receiver, Resource res_type, float amount)
Takes an entity some resource.
Definition: cl_resources.qc:31
RES_HEALTH
Definition: ent_cs.qc:126
float takedamage
Definition: progsdefs.qc:147
float nextthink
Definition: csprogsdefs.qc:121
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
#define setthink(e, f)
float time
Definition: csprogsdefs.qc:16
vector velocity
Definition: csprogsdefs.qc:103
float DAMAGE_NO
Definition: progsdefs.qc:282
var void func_null()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_projectile_explode()

void vehicles_projectile_explode ( entity  this,
entity  toucher 
)

Definition at line 194 of file sv_vehicles.qc.

References DMG_NOWEP, func_null(), NULL, owner, PROJECTILE_TOUCH, projectiledeathtype, RadiusDamage(), and realowner.

Referenced by vehicles_projectile(), vehicles_projectile_explode_think(), and vehicles_projectile_explode_use().

195 {
196  if(this.owner && toucher != NULL)
197  {
198  if(toucher == this.owner.vehicle)
199  return;
200 
201  if(toucher == this.owner.vehicle.tur_head)
202  return;
203  }
204 
205  PROJECTILE_TOUCH(this, toucher);
206 
207  this.event_damage = func_null;
208  RadiusDamage (this, this.realowner, this.shot_dmg, 0, this.shot_radius, this, NULL, this.shot_force, this.projectiledeathtype, DMG_NOWEP, toucher);
209 
210  delete(this);
211 }
#define DMG_NOWEP
Definition: damage.qh:126
entity owner
Definition: main.qh:73
#define PROJECTILE_TOUCH(e, t)
Definition: common.qh:27
#define NULL
Definition: post.qh:17
float RadiusDamage(entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity cantbe, entity mustbe, float forceintensity, int deathtype,.entity weaponentity, entity directhitentity)
Definition: damage.qc:1057
entity realowner
Definition: common.qh:25
var void func_null()
int projectiledeathtype
Definition: common.qh:20
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_projectile_explode_think()

void vehicles_projectile_explode_think ( entity  this)

Definition at line 213 of file sv_vehicles.qc.

References NULL, and vehicles_projectile_explode().

214 {
216 }
void vehicles_projectile_explode(entity this, entity toucher)
Definition: sv_vehicles.qc:194
#define NULL
Definition: post.qh:17
+ Here is the call graph for this function:

◆ vehicles_projectile_explode_use()

void vehicles_projectile_explode_use ( entity  this,
entity  actor,
entity  trigger 
)

Definition at line 218 of file sv_vehicles.qc.

References vehicles_projectile_explode().

Referenced by vehicles_projectile().

219 {
220  vehicles_projectile_explode(this, trigger);
221 }
void vehicles_projectile_explode(entity this, entity toucher)
Definition: sv_vehicles.qc:194
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_regen()

void vehicles_regen ( entity  this,
float  timer,
.float  regen_field,
float  field_max,
float  rpause,
float  regen,
float  delta_time,
float  _healthscale 
)

Definition at line 557 of file sv_vehicles.qc.

References GetResource(), max_health, min(), owner, RES_HEALTH, and time.

558 {
559  if(this.(regen_field) < field_max)
560  if(timer + rpause < time)
561  {
562  if(_healthscale)
563  regen = regen * (GetResource(this, RES_HEALTH) / this.max_health);
564 
565  this.(regen_field) = min(this.(regen_field) + regen * delta_time, field_max);
566 
567  if(this.owner)
568  this.owner.(regen_field) = (this.(regen_field) / field_max) * 100;
569  }
570 }
entity owner
Definition: main.qh:73
RES_HEALTH
Definition: ent_cs.qc:126
float max_health
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:

◆ vehicles_regen_resource()

void vehicles_regen_resource ( entity  this,
float  timer,
.float  regen_field,
float  field_max,
float  rpause,
float  regen,
float  delta_time,
float  _healthscale,
Resource  resource 
)

Definition at line 572 of file sv_vehicles.qc.

References GetResource(), max_health, min(), owner, SetResource(), and time.

573 {
574  float resource_amount = GetResource(this, resource);
575 
576  if(resource_amount < field_max)
577  if(timer + rpause < time)
578  {
579  if(_healthscale)
580  regen = regen * (resource_amount / this.max_health);
581 
582  SetResource(this, resource, min(resource_amount + regen * delta_time, field_max));
583 
584  if(this.owner)
585  this.owner.(regen_field) = (GetResource(this, resource) / field_max) * 100;
586  }
587 }
entity owner
Definition: main.qh:73
void SetResource(entity e, Resource res_type, float amount)
Sets the current amount of resource the given entity will have.
Definition: cl_resources.qc:26
float max_health
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:

◆ vehicles_reset()

void vehicles_reset ( entity  this)

Definition at line 1101 of file sv_vehicles.qc.

References active, ACTIVE_NOT, owner, vehicles_clearreturn(), vehicles_exit(), and vehicles_spawn().

Referenced by vehicles_spawn().

1102 {
1103  if(this.owner)
1104  vehicles_exit(this, VHEF_RELEASE);
1105 
1106  vehicles_clearreturn(this);
1107 
1108  if(this.active != ACTIVE_NOT)
1109  vehicles_spawn(this);
1110 }
void vehicles_spawn(entity this)
void vehicles_clearreturn(entity veh)
Definition: sv_vehicles.qc:430
entity owner
Definition: main.qh:73
int active
Definition: defs.qh:34
void vehicles_exit(entity vehic, bool eject)
Definition: sv_vehicles.qc:788
const int ACTIVE_NOT
Definition: defs.qh:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_reset_colors()

void vehicles_reset_colors ( entity  this,
entity  player 
)

Definition at line 377 of file sv_vehicles.qc.

References alpha, autocvar_g_fullbrightplayers, autocvar_g_nodepthtestplayers, avelocity, colormap, colormod, EF_ADDITIVE, EF_DOUBLESIDED, EF_FULLBRIGHT, EF_LOWPRECISION, EF_NODEPTHTEST, EF_NOGUNBOB, EF_NOSHADOW, EF_SELECTABLE, EF_TELEPORT_BIT, effects, FOREACH_ENTITY_ENT, tag_entity, team, teamplay, tur_head, vector(), vehicledef, and velocity.

Referenced by vehicle_use(), vehicles_enter(), vehicles_exit(), and vehicles_spawn().

378 {
379  int eff = 0, cmap;
380  const vector cmod = '0 0 0';
381  if(this.team && teamplay)
382  cmap = 1024 + (this.team - 1) * 17;
383  else if(player)
384  cmap = player.colormap;
385  else
386  cmap = 1024;
388  eff |= EF_NODEPTHTEST;
390  eff |= EF_FULLBRIGHT;
391 
392  // Find all ents attacked to main model and setup effects, colormod etc.
394  {
395  if(it == this.vehicle_shieldent)
396  continue;
397 
398  it.effects = eff;
399  it.colormod = cmod;
400  it.colormap = cmap;
401  it.alpha = 1;
402  });
403 
404  // Also check head tags
406  {
407  if(it == this.vehicle_shieldent)
408  continue;
409 
410  it.effects = eff;
411  it.colormod = cmod;
412  it.colormap = cmap;
413  it.alpha = 1;
414  });
415 
416  this.vehicle_hudmodel.effects = this.effects = eff; // | EF_LOWPRECISION;
417  this.vehicle_hudmodel.colormod = this.colormod = cmod;
418  this.vehicle_hudmodel.colormap = this.colormap = cmap;
420 
421  this.alpha = 1;
422  this.avelocity = '0 0 0';
423  this.velocity = '0 0 0';
424  this.effects = eff;
425 
426  Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid);
427  info.vr_setcolors(info, this);
428 }
float colormap
Definition: csprogsdefs.qc:131
float alpha
Definition: items.qc:14
bool autocvar_g_nodepthtestplayers
Definition: client.qh:33
vector colormod
Definition: powerups.qc:21
int team
Definition: main.qh:157
entity tur_head
Definition: sv_turrets.qh:29
float EF_NOGUNBOB
const float EF_NODEPTHTEST
Definition: csprogsdefs.qc:304
vector avelocity
Definition: csprogsdefs.qc:105
float effects
Definition: csprogsdefs.qc:111
const float EF_NOSHADOW
Definition: csprogsdefs.qc:306
#define FOREACH_ENTITY_ENT(fld, match, body)
Definition: iter.qh:179
const int EF_TELEPORT_BIT
const float EF_ADDITIVE
Definition: csprogsdefs.qc:300
const float EF_FULLBRIGHT
Definition: csprogsdefs.qc:303
float teamplay
Definition: progsdefs.qc:31
vector(float skel, float bonenum) _skel_get_boneabs_hidden
bool autocvar_g_fullbrightplayers
Definition: client.qh:16
entity vehicledef
Definition: vehicle.qh:80
const int EF_DOUBLESIDED
entity tag_entity
vector velocity
Definition: csprogsdefs.qc:103
const float EF_SELECTABLE
Definition: csprogsdefs.qc:309
float EF_LOWPRECISION
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_return()

void vehicles_return ( entity  this)

Definition at line 446 of file sv_vehicles.qc.

References setthink, time, and wp00.

Referenced by vehicles_showwp().

447 {
448  Send_Effect(EFFECT_TELEPORT, this.wp00.origin + '0 0 64', '0 0 0', 1);
449 
451  this.wp00.nextthink = time;
452 
453  if(this.waypointsprite_attached)
454  WaypointSprite_Kill(this.waypointsprite_attached);
455 
456  delete(this);
457 }
void vehicles_spawn(entity this)
entity wp00
Definition: api.qh:56
#define setthink(e, f)
float time
Definition: csprogsdefs.qc:16
+ Here is the caller graph for this function:

◆ vehicles_setreturn()

void vehicles_setreturn ( entity  veh)

Definition at line 507 of file sv_vehicles.qc.

References entity(), IL_PUSH(), IS_DEAD, min(), setorigin(), setthink, time, vehicles_clearreturn(), and vehicles_showwp().

Referenced by vehicle_use(), vehicles_damage(), and vehicles_exit().

508 {
510 
511  entity ret = new(vehicle_return);
512  IL_PUSH(g_vehicle_returners, ret);
513  ret.wp00 = veh;
514  ret.team = veh.team;
516 
517  if(IS_DEAD(veh))
518  {
519  ret.cnt = time + veh.respawntime;
520  ret.nextthink = min(time + veh.respawntime, time + veh.respawntime - 5);
521  }
522  else
523  {
524  ret.nextthink = min(time + veh.respawntime, time + veh.respawntime - 1);
525  }
526 
527  setorigin(ret, veh.pos1 + '0 0 96');
528 }
void vehicles_showwp(entity this)
Definition: sv_vehicles.qc:467
void vehicles_clearreturn(entity veh)
Definition: sv_vehicles.qc:430
entity() spawn
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define IS_DEAD(s)
Definition: utils.qh:26
setorigin(ent, v)
#define setthink(e, f)
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_showwp()

void vehicles_showwp ( entity  this)

Definition at line 467 of file sv_vehicles.qc.

References entity(), NULL, setorigin(), setthink, spawn(), SPRITERULE_DEFAULT, Team_ColorRGB(), teamplay, time, vector(), vehicles_return(), vehicles_showwp_goaway(), and wp00.

Referenced by vehicles_setreturn().

468 {
469  entity ent = this;
470 
471  if(ent.cnt)
472  {
474  ent.nextthink = ent.cnt;
475  }
476  else
477  {
479  ent.nextthink = time + 1;
480 
481  ent = spawn();
482  ent.team = this.wp00.team;
483  ent.wp00 = this.wp00;
484  setorigin(ent, this.wp00.pos1);
485 
486  ent.nextthink = time + 5;
488  }
489 
490  vector rgb;
491  if(teamplay && ent.team)
492  rgb = Team_ColorRGB(ent.team);
493  else
494  rgb = '1 1 1';
495  entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, ent, '0 0 64', NULL, 0, ent, waypointsprite_attached, true, RADARICON_Vehicle);
496  wp.wp_extra = ent.wp00.vehicleid;
497  wp.colormod = rgb;
498  if(ent.waypointsprite_attached)
499  {
500  WaypointSprite_UpdateRule(ent.waypointsprite_attached, ent.wp00.team, SPRITERULE_DEFAULT);
501  if(this == NULL)
502  WaypointSprite_UpdateBuildFinished(ent.waypointsprite_attached, ent.nextthink);
503  WaypointSprite_Ping(ent.waypointsprite_attached);
504  }
505 }
void vehicles_showwp_goaway(entity this)
Definition: sv_vehicles.qc:459
const int SPRITERULE_DEFAULT
vector Team_ColorRGB(int teamid)
Definition: teams.qh:76
entity() spawn
entity wp00
Definition: api.qh:56
#define NULL
Definition: post.qh:17
float teamplay
Definition: progsdefs.qc:31
vector(float skel, float bonenum) _skel_get_boneabs_hidden
setorigin(ent, v)
void vehicles_return(entity this)
Definition: sv_vehicles.qc:446
#define setthink(e, f)
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_showwp_goaway()

void vehicles_showwp_goaway ( entity  this)

Definition at line 459 of file sv_vehicles.qc.

Referenced by vehicles_showwp().

460 {
461  if(this.waypointsprite_attached)
462  WaypointSprite_Kill(this.waypointsprite_attached);
463 
464  delete(this);
465 }
+ Here is the caller graph for this function:

◆ vehicles_spawn()

void vehicles_spawn ( entity  this)

Definition at line 1113 of file sv_vehicles.qc.

References angles, avelocity, bot_attack, classname, DAMAGE_AIM, damagedbycontents, DEAD_NO, deadflag, FL_NOTARGET, flags, FOREACH_CLIENT, g_bot_targets, IL_PUSH(), IS_PLAYER, iscreature, LOG_DEBUG, MAX_WEAPONSLOTS, misc_bulletcounter, MOVETYPE_WALK, nextthink, NULL, origin, owner, pos1, pos2, RemoveHook(), set_movetype(), setorigin(), setthink, solid, SOLID_SLIDEBOX, takedamage, team, teleportable, time, vehicledef, vehicles_damage(), vehicles_heal(), vehicles_reset(), vehicles_reset_colors(), vehicles_think(), vehicles_touch(), velocity, and weaponentities.

Referenced by vehicles_clearreturn(), and vehicles_reset().

1114 {
1115  LOG_DEBUG("Spawning vehicle: ", this.classname);
1116 
1117  // disown & reset
1118  this.vehicle_hudmodel.viewmodelforclient = this;
1119 
1120  this.owner = NULL;
1121  settouch(this, vehicles_touch);
1122  this.event_damage = vehicles_damage;
1123  this.event_heal = vehicles_heal;
1124  this.reset = vehicles_reset;
1125  this.iscreature = true;
1126  this.teleportable = false; // no teleporting for vehicles, too buggy
1127  this.damagedbycontents = true;
1128  set_movetype(this, MOVETYPE_WALK);
1129  this.solid = SOLID_SLIDEBOX;
1130  this.takedamage = DAMAGE_AIM;
1131  this.deadflag = DEAD_NO;
1132  if(!this.bot_attack)
1133  IL_PUSH(g_bot_targets, this);
1134  this.bot_attack = true;
1135  this.flags = FL_NOTARGET;
1136  this.avelocity = '0 0 0';
1137  this.velocity = '0 0 0';
1138  setthink(this, vehicles_think);
1139  this.nextthink = time;
1140 
1141  // Reset locking
1142  this.lock_strength = 0;
1143  this.lock_target = NULL;
1144  this.misc_bulletcounter = 0;
1145 
1146  // Return to spawn
1147  this.angles = this.pos2;
1148  setorigin(this, this.pos1);
1149  // Show it
1150  Send_Effect(EFFECT_TELEPORT, this.origin + '0 0 64', '0 0 0', 1);
1151 
1152  if(this.vehicle_controller)
1153  this.team = this.vehicle_controller.team;
1154 
1156  {
1157  for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
1158  {
1159  .entity weaponentity = weaponentities[slot];
1160  if(it.(weaponentity).hook.aiment == this)
1161  RemoveHook(it.(weaponentity).hook);
1162  }
1163  });
1164 
1165 
1166  Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid);
1167  info.vr_spawn(info, this);
1168 
1169  vehicles_reset_colors(this, NULL);
1170 
1171  CSQCMODEL_AUTOINIT(this);
1172 }
bool vehicles_heal(entity targ, entity inflictor, float amount, float limit)
Definition: sv_vehicles.qc:723
const float SOLID_SLIDEBOX
Definition: csprogsdefs.qc:247
float MOVETYPE_WALK
Definition: progsdefs.qc:249
bool iscreature
Definition: main.qh:42
int team
Definition: main.qh:157
float DAMAGE_AIM
Definition: progsdefs.qc:284
float bot_attack
Definition: api.qh:38
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
origin
Definition: ent_cs.qc:114
string classname
Definition: csprogsdefs.qc:107
vector avelocity
Definition: csprogsdefs.qc:105
entity owner
Definition: main.qh:73
IntrusiveList g_bot_targets
Definition: api.qh:149
void vehicles_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition: sv_vehicles.qc:633
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
float damagedbycontents
Definition: damage.qh:48
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
float misc_bulletcounter
Definition: common.qh:18
#define NULL
Definition: post.qh:17
void vehicles_think(entity this)
float takedamage
Definition: progsdefs.qc:147
float nextthink
Definition: csprogsdefs.qc:121
entity vehicledef
Definition: vehicle.qh:80
float deadflag
Definition: progsdefs.qc:149
float flags
Definition: csprogsdefs.qc:129
void vehicles_reset(entity this)
vector pos1
Definition: subs.qh:50
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
float teleportable
Definition: teleporters.qh:24
setorigin(ent, v)
float DEAD_NO
Definition: progsdefs.qc:274
#define setthink(e, f)
vector angles
Definition: csprogsdefs.qc:104
float FL_NOTARGET
Definition: progsdefs.qc:238
void vehicles_reset_colors(entity this, entity player)
Definition: sv_vehicles.qc:377
float time
Definition: csprogsdefs.qc:16
vector velocity
Definition: csprogsdefs.qc:103
vector pos2
Definition: subs.qh:50
void set_movetype(entity this, int mt)
#define IS_PLAYER(v)
Definition: utils.qh:9
void RemoveHook(entity this)
Definition: hook.qc:96
void vehicles_touch(entity this, entity toucher)
Definition: sv_vehicles.qc:888
#define LOG_DEBUG(...)
Definition: log.qh:85
float solid
Definition: csprogsdefs.qc:99
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_think()

void vehicles_think ( entity  this)

Definition at line 1086 of file sv_vehicles.qc.

References nextthink, owner, time, vehicledef, and vehicles_painframe().

Referenced by vehicles_spawn().

1087 {
1088  this.nextthink = time + autocvar_g_vehicles_thinkrate;
1089 
1090  if(this.owner)
1091  STAT(VEHICLESTAT_W2MODE, this.owner) = STAT(VEHICLESTAT_W2MODE, this);
1092 
1093  Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid);
1094  info.vr_think(info, this);
1095 
1096  vehicles_painframe(this);
1097 
1098  CSQCMODEL_AUTOUPDATE(this);
1099 }
entity owner
Definition: main.qh:73
float nextthink
Definition: csprogsdefs.qc:121
entity vehicledef
Definition: vehicle.qh:80
void vehicles_painframe(entity this)
Definition: sv_vehicles.qc:604
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vehicles_touch()

void vehicles_touch ( entity  this,
entity  toucher 
)

Definition at line 888 of file sv_vehicles.qc.

References Damage(), DMG_NOWEP, MUTATOR_CALLHOOK, normalize(), NULL, owner, time, vdist, vehicledef, vehicles_crushable(), vehicles_enter(), velocity, and weaponLocked().

Referenced by vehicle_initialize(), and vehicles_spawn().

889 {
890  if(MUTATOR_CALLHOOK(VehicleTouch, this, toucher))
891  return;
892 
893  // Vehicle currently in use
894  if(this.owner)
895  {
896  if(toucher != NULL)
897  if((this.origin_z + this.maxs_z) > (toucher.origin_z))
898  if(vehicles_crushable(toucher))
899  if(!weaponLocked(this.owner))
900  {
901  if(vdist(this.velocity, >=, autocvar_g_vehicles_crush_minspeed))
902  Damage(toucher, this, this.owner, autocvar_g_vehicles_crush_dmg, DEATH_VH_CRUSH.m_id, DMG_NOWEP, '0 0 0', normalize(toucher.origin - this.origin) * autocvar_g_vehicles_crush_force);
903 
904  return; // Dont do selfdamage when hitting "soft targets".
905  }
906 
907  if(this.play_time < time) {
908  Vehicle info = this.vehicledef; //REGISTRY_GET(Vehicles, this.vehicleid);
909  info.vr_impact(info, this);
910  }
911 
912  return;
913  }
914 
915  if(autocvar_g_vehicles_enter)
916  return;
917 
918  vehicles_enter(toucher, this);
919 }
bool vehicles_crushable(entity e)
Definition: sv_vehicles.qc:735
#define DMG_NOWEP
Definition: damage.qh:126
entity owner
Definition: main.qh:73
void vehicles_enter(entity pl, entity veh)
Definition: sv_vehicles.qc:939
bool weaponLocked(entity player)
#define NULL
Definition: post.qh:17
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition: damage.qc:583
entity vehicledef
Definition: vehicle.qh:80
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition: vector.qh:8
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
float time
Definition: csprogsdefs.qc:16
vector velocity
Definition: csprogsdefs.qc:103
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ axh_prevcolors

vector axh_prevcolors

Definition at line 45 of file sv_vehicles.qc.

◆ axh_prevorigin

vector axh_prevorigin

Definition at line 44 of file sv_vehicles.qc.

◆ old_vehicle_flags

int old_vehicle_flags

Definition at line 787 of file sv_vehicles.qc.