Xonotic
racer.qc
Go to the documentation of this file.
1 #include "racer.qh"
2 
3 #if defined(SVQC)
6 #endif
7 
8 #ifdef GAMEQC
9 
10 #ifdef SVQC
11 bool autocvar_g_vehicle_racer = true;
12 
13 float autocvar_g_vehicle_racer_thinkrate = 0.05; // TODO: any higher causes it to sink in liquids
14 
15 float autocvar_g_vehicle_racer_speed_afterburn = 3000;
16 // energy consumed per second
17 float autocvar_g_vehicle_racer_afterburn_cost = 130;
18 
19 float autocvar_g_vehicle_racer_waterburn_cost = 5;
20 float autocvar_g_vehicle_racer_waterburn_speed = 750;
21 
22 float autocvar_g_vehicle_racer_water_speed_forward = 600;
23 float autocvar_g_vehicle_racer_water_speed_strafe = 600;
24 
25 float autocvar_g_vehicle_racer_pitchlimit = 30;
26 
27 float autocvar_g_vehicle_racer_water_downforce = 0.03;
28 float autocvar_g_vehicle_racer_water_upforcedamper = 15;
29 
30 float autocvar_g_vehicle_racer_anglestabilizer = 1.75;
31 float autocvar_g_vehicle_racer_downforce = 0.01;
32 
33 float autocvar_g_vehicle_racer_speed_forward = 650;
34 float autocvar_g_vehicle_racer_speed_strafe = 650;
35 float autocvar_g_vehicle_racer_springlength = 90;
36 float autocvar_g_vehicle_racer_upforcedamper = 2;
37 float autocvar_g_vehicle_racer_friction = 0.45;
38 
39 float autocvar_g_vehicle_racer_water_time = 5;
40 
41 //float autocvar_g_vehicle_racer_collision_multiplier = 0.05;
42 
43 // 0 = hover, != 0 = maglev
44 int autocvar_g_vehicle_racer_hovertype = 0;
45 // NOTE!! x 4 (4 engines)
46 float autocvar_g_vehicle_racer_hoverpower = 8000;
47 
48 float autocvar_g_vehicle_racer_turnroll = 30;
49 float autocvar_g_vehicle_racer_turnspeed = 220;
50 float autocvar_g_vehicle_racer_pitchspeed = 125;
51 
52 float autocvar_g_vehicle_racer_energy = 100;
53 float autocvar_g_vehicle_racer_energy_regen = 90;
54 float autocvar_g_vehicle_racer_energy_regen_pause = 0.35;
55 
56 float autocvar_g_vehicle_racer_health = 200;
57 float autocvar_g_vehicle_racer_health_regen = 0;
58 float autocvar_g_vehicle_racer_health_regen_pause = 0;
59 
60 float autocvar_g_vehicle_racer_shield = 100;
61 float autocvar_g_vehicle_racer_shield_regen = 30;
62 float autocvar_g_vehicle_racer_shield_regen_pause = 1;
63 
64 bool autocvar_g_vehicle_racer_rocket_locktarget = true;
65 float autocvar_g_vehicle_racer_rocket_locking_time = 0.35;
66 float autocvar_g_vehicle_racer_rocket_locking_releasetime = 0.5;
67 float autocvar_g_vehicle_racer_rocket_locked_time = 4;
68 
69 float autocvar_g_vehicle_racer_respawntime = 35;
70 
71 float autocvar_g_vehicle_racer_blowup_radius = 250;
72 float autocvar_g_vehicle_racer_blowup_coredamage = 250;
73 float autocvar_g_vehicle_racer_blowup_edgedamage = 15;
74 float autocvar_g_vehicle_racer_blowup_forceintensity = 250;
75 
76 // Factor of old velocity to keep after collision
77 float autocvar_g_vehicle_racer_bouncefactor = 0.25;
78 // if != 0, New veloctiy after bounce = 0 if new velocity < this
79 float autocvar_g_vehicle_racer_bouncestop = 0;
80 // "minspeed_for_pain speedchange_to_pain_factor max_damage"
81 vector autocvar_g_vehicle_racer_bouncepain = '200 0.15 150';
82 
83 .float racer_watertime;
84 .float racer_air_finished; // TODO: use a standard air meter for entities
85 
86 var .vector(entity this, string tag_name, float spring_length, float max_power) racer_force_from_tag;
87 
88 void racer_align4point(entity this, entity player, float _delta)
89 {
90  vector push_vector;
91  float fl_push, fr_push, bl_push, br_push;
92 
93  push_vector = this.racer_force_from_tag(this, "tag_engine_fr", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower);
94  fr_push = force_fromtag_normpower;
95  //vehicles_sweap_collision(force_fromtag_origin, this.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier);
96 
97  push_vector += this.racer_force_from_tag(this, "tag_engine_fl", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower);
98  fl_push = force_fromtag_normpower;
99  //vehicles_sweap_collision(force_fromtag_origin, this.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier);
100 
101  push_vector += this.racer_force_from_tag(this, "tag_engine_br", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower);
102  br_push = force_fromtag_normpower;
103  //vehicles_sweap_collision(force_fromtag_origin, this.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier);
104 
105  push_vector += this.racer_force_from_tag(this, "tag_engine_bl", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower);
106  bl_push = force_fromtag_normpower;
107  //vehicles_sweap_collision(force_fromtag_origin, this.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier);
108 
109  this.velocity += push_vector * _delta;
110 
111  float uforce = autocvar_g_vehicle_racer_upforcedamper;
112 
113  int cont = pointcontents(this.origin - '0 0 64');
114  if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
115  {
116  uforce = autocvar_g_vehicle_racer_water_upforcedamper;
117 
118  if(PHYS_INPUT_BUTTON_CROUCH(player) && time < this.racer_air_finished)
119  this.velocity_z += 30;
120  else
121  this.velocity_z += 200;
122  }
123 
124 
125  // Anti ocilation
126  if(this.velocity_z > 0)
127  this.velocity_z *= 1 - uforce * _delta;
128 
129  push_vector_x = (fl_push - bl_push);
130  push_vector_x += (fr_push - br_push);
131  push_vector_x *= 360;
132 
133  push_vector_z = (fr_push - fl_push);
134  push_vector_z += (br_push - bl_push);
135  push_vector_z *= 360;
136 
137  // Apply angle diffrance
138  this.angles_z += push_vector_z * _delta;
139  this.angles_x += push_vector_x * _delta;
140 
141  // Apply stabilizer
142  this.angles_x *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * _delta);
143  this.angles_z *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * _delta);
144 }
145 
146 void racer_fire_rocket_aim(entity this, entity player, string tagname, entity trg)
147 {
148  vector v = gettaginfo(this, gettagindex(this, tagname));
149  racer_fire_rocket(this, player, v, v_forward, trg);
150 }
151 
152 bool racer_frame(entity this, float dt)
153 {
154  entity player = this;
155  entity vehic = player.vehicle;
156  return = true;
157 
158 #ifdef SVQC
159  if(game_stopped)
160  {
161  vehic.solid = SOLID_NOT;
162  vehic.takedamage = DAMAGE_NO;
163  set_movetype(vehic, MOVETYPE_NONE);
164  return;
165  }
166 #endif
167 
168  vehicles_frame(vehic, player);
169 
170  int cont = Mod_Q1BSP_SuperContentsFromNativeContents(pointcontents(vehic.origin));
171  if(!(cont & DPCONTENTS_WATER))
172  vehic.racer_air_finished = 0;
173  else if (!vehic.racer_air_finished)
174  vehic.racer_air_finished = time + autocvar_g_vehicle_racer_water_time;
175 
176 #ifdef SVQC
177  if(IS_DEAD(vehic))
178  {
179  PHYS_INPUT_BUTTON_ATCK(player) = PHYS_INPUT_BUTTON_ATCK2(player) = false;
180  return;
181  }
182 #endif
183 
184  racer_align4point(vehic, player, dt);
185 
186 #ifdef SVQC
187  PHYS_INPUT_BUTTON_ZOOM(player) = PHYS_INPUT_BUTTON_CROUCH(player) = false;
188 #endif
189 
190  vehic.angles_x *= -1;
191 
192  // Yaw
193  float ftmp = autocvar_g_vehicle_racer_turnspeed * dt;
194  ftmp = bound(-ftmp, shortangle_f(player.v_angle_y - vehic.angles_y, vehic.angles_y), ftmp);
195  vehic.angles_y = anglemods(vehic.angles_y + ftmp);
196 
197  // Roll
198  vehic.angles_z += -ftmp * autocvar_g_vehicle_racer_turnroll * dt;
199 
200  // Pitch
201  ftmp = autocvar_g_vehicle_racer_pitchspeed * dt;
202  ftmp = bound(-ftmp, shortangle_f(player.v_angle_x - vehic.angles_x, vehic.angles_x), ftmp);
203  vehic.angles_x = bound(-autocvar_g_vehicle_racer_pitchlimit, anglemods(vehic.angles_x + ftmp), autocvar_g_vehicle_racer_pitchlimit);
204 
205  makevectors(vehic.angles);
206  vehic.angles_x *= -1;
207 
208  //ftmp = vehic.velocity_z;
209  vector df = vehic.velocity * -autocvar_g_vehicle_racer_friction;
210  //vehic.velocity_z = ftmp;
211 
212  if(PHYS_CS(player).movement)
213  {
214  if(cont & DPCONTENTS_LIQUIDSMASK)
215  {
216  if(PHYS_CS(player).movement_x) { df += v_forward * ((PHYS_CS(player).movement_x > 0) ? autocvar_g_vehicle_racer_water_speed_forward : -autocvar_g_vehicle_racer_water_speed_forward); }
217  if(PHYS_CS(player).movement_y) { df += v_right * ((PHYS_CS(player).movement_y > 0) ? autocvar_g_vehicle_racer_water_speed_strafe : -autocvar_g_vehicle_racer_water_speed_strafe); }
218  }
219  else
220  {
221  if(PHYS_CS(player).movement_x) { df += v_forward * ((PHYS_CS(player).movement_x > 0) ? autocvar_g_vehicle_racer_speed_forward : -autocvar_g_vehicle_racer_speed_forward); }
222  if(PHYS_CS(player).movement_y) { df += v_right * ((PHYS_CS(player).movement_y > 0) ? autocvar_g_vehicle_racer_speed_strafe : -autocvar_g_vehicle_racer_speed_strafe); }
223  }
224 
225 #ifdef SVQC
226  if(vehic.sound_nexttime < time || vehic.sounds != 1)
227  {
228  vehic.sounds = 1;
229  vehic.sound_nexttime = time + 10.922667; //soundlength("vehicles/racer_move.wav");
230  sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_RACER_MOVE, VOL_VEHICLEENGINE, ATTEN_NORM);
231  }
232 #endif
233  }
234 #ifdef SVQC
235  else
236  {
237  if(vehic.sound_nexttime < time || vehic.sounds != 0)
238  {
239  vehic.sounds = 0;
240  vehic.sound_nexttime = time + 11.888604; //soundlength("vehicles/racer_idle.wav");
241  sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_RACER_IDLE, VOL_VEHICLEENGINE, ATTEN_NORM);
242  }
243  }
244 #endif
245 
246  // Afterburn
247  if (PHYS_INPUT_BUTTON_JUMP(player) && vehic.vehicle_energy >= (autocvar_g_vehicle_racer_afterburn_cost * dt))
248  {
249 #ifdef SVQC
250  if(time - vehic.wait > 0.2)
251  pointparticles(EFFECT_RACER_BOOSTER, vehic.origin - v_forward * 32, v_forward * vlen(vehic.velocity), 1);
252 #endif
253 
254  vehic.wait = time;
255 
256  if(cont & DPCONTENTS_LIQUIDSMASK)
257  {
258  vehic.vehicle_energy -= autocvar_g_vehicle_racer_waterburn_cost * dt;
259  df += (v_forward * autocvar_g_vehicle_racer_waterburn_speed);
260  }
261  else
262  {
263  vehic.vehicle_energy -= autocvar_g_vehicle_racer_afterburn_cost * dt;
264  df += (v_forward * autocvar_g_vehicle_racer_speed_afterburn);
265  }
266 
267 #ifdef SVQC
268  // TODO: move these to the client side where they belong
269  // NOTE: reusing .invincible_finished here as delay counter for the smoke effect
270  if(vehic.invincible_finished < time)
271  {
272  traceline(vehic.origin, vehic.origin - '0 0 256', MOVE_NORMAL, vehic);
273  if(trace_fraction != 1.0)
274  pointparticles(EFFECT_SMOKE_SMALL, trace_endpos, '0 0 0', 1);
275 
276  vehic.invincible_finished = time + 0.1 + (random() * 0.1);
277  }
278 
279  // NOTE: reusing .strength_finished here as a sound delay counter
280  if(vehic.strength_finished < time)
281  {
282  vehic.strength_finished = time + 10.922667; //soundlength("vehicles/racer_boost.wav");
283  sound (vehic.tur_head, CH_TRIGGER_SINGLE, SND_VEH_RACER_BOOST, VOL_VEHICLEENGINE, ATTEN_NORM);
284  }
285 #endif
286  }
287  else
288  {
289  vehic.strength_finished = 0;
290  sound (vehic.tur_head, CH_TRIGGER_SINGLE, SND_Null, VOL_VEHICLEENGINE, ATTEN_NORM);
291  }
292 
293  if(cont & DPCONTENTS_LIQUIDSMASK)
294  vehic.racer_watertime = time;
295 
296  float dforce = autocvar_g_vehicle_racer_downforce;
297  if(time - vehic.racer_watertime <= 3)
298  dforce = autocvar_g_vehicle_racer_water_downforce;
299 
300  df -= v_up * (vlen(vehic.velocity) * dforce);
301  PHYS_CS(player).movement = vehic.velocity += df * dt;
302 
303 #ifdef SVQC
304 
305  Weapon wep1 = WEP_RACER;
306  .entity weaponentity = weaponentities[0]; // TODO: unhardcode
307  if (!weaponLocked(player) && !weaponUseForbidden(player))
308  if (PHYS_INPUT_BUTTON_ATCK(player))
309  if (wep1.wr_checkammo1(wep1, vehic, weaponentity))
310  {
311  wep1.wr_think(wep1, vehic, weaponentity, 1);
312  }
313 
314  if(autocvar_g_vehicle_racer_rocket_locktarget)
315  {
316  if(time >= vehic.vehicle_last_trace)
317  {
318  crosshair_trace(player);
319 
320  vehicles_locktarget(vehic, (1 / autocvar_g_vehicle_racer_rocket_locking_time) * dt,
321  (1 / autocvar_g_vehicle_racer_rocket_locking_releasetime) * dt,
322  autocvar_g_vehicle_racer_rocket_locked_time);
323 
324  vehic.vehicle_last_trace = time + autocvar_g_vehicle_racer_thinkrate;
325  }
326 
327  if(vehic.lock_target)
328  {
329  if(vehic.lock_strength == 1)
330  UpdateAuxiliaryXhair(player, real_origin(vehic.lock_target), '1 0 0', 0);
331  else if(vehic.lock_strength > 0.5)
332  UpdateAuxiliaryXhair(player, real_origin(vehic.lock_target), '0 1 0', 0);
333  else if(vehic.lock_strength < 0.5)
334  UpdateAuxiliaryXhair(player, real_origin(vehic.lock_target), '0 0 1', 0);
335  }
336  }
337 
338  if (!weaponLocked(player) && !weaponUseForbidden(player))
339  if(time > vehic.delay)
340  if(PHYS_INPUT_BUTTON_ATCK2(player))
341  {
342  vehic.misc_bulletcounter += 1;
343  vehic.delay = time + 0.3;
344 
345  if(vehic.misc_bulletcounter == 1)
346  {
347  racer_fire_rocket_aim(vehic, player, "tag_rocket_r", (vehic.lock_strength == 1 && vehic.lock_target) ? vehic.lock_target : NULL);
348  player.vehicle_ammo2 = 50;
349  }
350  else if(vehic.misc_bulletcounter == 2)
351  {
352  racer_fire_rocket_aim(vehic, player, "tag_rocket_l", (vehic.lock_strength == 1 && vehic.lock_target) ? vehic.lock_target : NULL);
353  vehic.lock_strength = 0;
354  vehic.lock_target = NULL;
355  vehic.misc_bulletcounter = 0;
356  vehic.delay = time + autocvar_g_vehicle_racer_rocket_refire;
357  vehic.lip = time;
358  player.vehicle_ammo2 = 0;
359  }
360  }
361  else if(vehic.misc_bulletcounter == 0)
362  player.vehicle_ammo2 = 100;
363 
364  player.vehicle_reload2 = bound(0, 100 * ((time - vehic.lip) / (vehic.delay - vehic.lip)), 100);
365 
366  if(vehic.vehicle_flags & VHF_SHIELDREGEN)
367  vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_racer_shield, autocvar_g_vehicle_racer_shield_regen_pause, autocvar_g_vehicle_racer_shield_regen, dt, true);
368 
369  if(vehic.vehicle_flags & VHF_HEALTHREGEN)
370  vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_racer_health, autocvar_g_vehicle_racer_health_regen_pause, autocvar_g_vehicle_racer_health_regen, dt, false, RES_HEALTH);
371 
372  if(vehic.vehicle_flags & VHF_ENERGYREGEN)
373  vehicles_regen(vehic, vehic.wait, vehicle_energy, autocvar_g_vehicle_racer_energy, autocvar_g_vehicle_racer_energy_regen_pause, autocvar_g_vehicle_racer_energy_regen, dt, false);
374 
375  VEHICLE_UPDATE_PLAYER_RESOURCE(player, vehic, health, racer, RES_HEALTH);
376  VEHICLE_UPDATE_PLAYER(player, vehic, energy, racer);
377 
378  if(vehic.vehicle_flags & VHF_HASSHIELD)
379  VEHICLE_UPDATE_PLAYER(player, vehic, shield, racer);
380 
381  PHYS_INPUT_BUTTON_ATCK(player) = PHYS_INPUT_BUTTON_ATCK2(player) = false;
382 #endif
383 
384  setorigin(player, vehic.origin + '0 0 32');
385 #ifdef SVQC
386  player.oldorigin = player.origin; // negate fall damage
387 #endif
388  player.velocity = vehic.velocity;
389 }
390 #endif
391 
392 #ifdef SVQC
393 void racer_think(entity this)
394 {
395  float dt = autocvar_g_vehicle_racer_thinkrate;
396 
397  this.nextthink = time + dt;
398 
399  tracebox(this.origin, this.mins, this.maxs, this.origin - ('0 0 1' * autocvar_g_vehicle_racer_springlength), MOVE_NOMONSTERS, this);
400 
401  vector df = this.velocity * -autocvar_g_vehicle_racer_friction;
402  df_z += (1 - trace_fraction) * autocvar_g_vehicle_racer_hoverpower + sin(time * 2) * (autocvar_g_vehicle_racer_springlength * 2);
403 
404  float forced = autocvar_g_vehicle_racer_upforcedamper;
405 
406  //int cont = pointcontents(this.origin - '0 0 64');
407  traceline(this.origin - '0 0 64', this.origin - '0 0 64', MOVE_NOMONSTERS, this);
408  //if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
409  if(trace_dpstartcontents & DPCONTENTS_LIQUIDSMASK)
410  {
411  forced = autocvar_g_vehicle_racer_water_upforcedamper;
412  this.velocity_z += 200;
413  }
414 
415  this.velocity += df * dt;
416  if(this.velocity_z > 0)
417  this.velocity_z *= 1 - forced * dt;
418 
419  this.angles_x *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * dt);
420  this.angles_z *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * dt);
421 
422  CSQCMODEL_AUTOUPDATE(this);
423 }
424 
425 void racer_exit(entity this, int eject)
426 {
427  vector spot;
428 
429  setthink(this, racer_think);
430  this.nextthink = time;
432  sound (this.tur_head, CH_TRIGGER_SINGLE, SND_Null, VOL_VEHICLEENGINE, ATTEN_NORM);
433 
434  if(!this.owner)
435  return;
436 
437  makevectors(this.angles);
438  if(eject)
439  {
440  spot = this.origin + v_forward * 100 + '0 0 64';
441  spot = vehicles_findgoodexit(this, this.owner, spot);
442  setorigin(this.owner, spot);
443  this.owner.velocity = (v_up + v_forward * 0.25) * 750;
444  this.owner.oldvelocity = this.owner.velocity;
445  }
446  else
447  {
448  if(vdist(this.velocity, >, 2 * autocvar_sv_maxairspeed))
449  {
450  this.owner.velocity = normalize(this.velocity) * autocvar_sv_maxairspeed * 2;
451  this.owner.velocity_z += 200;
452  spot = this.origin + v_forward * 32 + '0 0 32';
453  spot = vehicles_findgoodexit(this, this.owner, spot);
454  }
455  else
456  {
457  this.owner.velocity = this.velocity * 0.5;
458  this.owner.velocity_z += 10;
459  spot = this.origin - v_forward * 200 + '0 0 32';
460  spot = vehicles_findgoodexit(this, this.owner, spot);
461  }
462  this.owner.oldvelocity = this.owner.velocity;
463  setorigin(this.owner , spot);
464  }
465  antilag_clear(this.owner, CS(this.owner));
466  this.owner = NULL;
467 }
468 
469 void racer_blowup(entity this)
470 {
471  this.deadflag = DEAD_DEAD;
472  this.vehicle_exit(this, VHEF_NORMAL);
473 
474  RadiusDamage (this, this.enemy, autocvar_g_vehicle_racer_blowup_coredamage,
475  autocvar_g_vehicle_racer_blowup_edgedamage,
476  autocvar_g_vehicle_racer_blowup_radius, NULL, NULL,
477  autocvar_g_vehicle_racer_blowup_forceintensity,
478  DEATH_VH_WAKI_DEATH.m_id, DMG_NOWEP, NULL);
479 
480  this.nextthink = time + autocvar_g_vehicle_racer_respawntime;
481  setthink(this, vehicles_spawn);
483  this.effects = EF_NODRAW;
484  this.solid = SOLID_NOT;
485 
486  this.colormod = '0 0 0';
487  this.avelocity = '0 0 0';
488  this.velocity = '0 0 0';
489 
490  setorigin(this, this.pos1);
491 }
492 
493 void racer_blowup_think(entity this)
494 {
495  this.nextthink = time;
496 
497  if(time >= this.delay)
498  racer_blowup(this);
499 
500  //CSQCMODEL_AUTOUPDATE(this);
501 }
502 
503 void racer_deadtouch(entity this, entity toucher)
504 {
505  this.avelocity_x *= 0.7;
506  this.cnt -= 1;
507  if(this.cnt <= 0)
508  racer_blowup(this);
509 }
510 
511 spawnfunc(vehicle_racer)
512 {
513  if(!autocvar_g_vehicle_racer) { delete(this); return; }
514  if(!vehicle_initialize(this, VEH_RACER, false)) { delete(this); return; }
515 }
516 
517 #endif // SVQC
518 
519 METHOD(Racer, vr_impact, void(Racer thisveh, entity instance))
520 {
521 #ifdef SVQC
522  if(autocvar_g_vehicle_racer_bouncepain)
523  vehicles_impact(instance, autocvar_g_vehicle_racer_bouncepain_x, autocvar_g_vehicle_racer_bouncepain_y, autocvar_g_vehicle_racer_bouncepain_z);
524 #endif
525 }
526 
527 METHOD(Racer, vr_enter, void(Racer thisveh, entity instance))
528 {
529  set_movetype(instance, MOVETYPE_BOUNCE);
530 #ifdef SVQC
531  instance.owner.vehicle_health = (GetResource(instance, RES_HEALTH) / autocvar_g_vehicle_racer_health) * 100;
532  instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_racer_shield) * 100;
533 
534  if(instance.owner.flagcarried)
535  setorigin(instance.owner.flagcarried, '-190 0 96');
536 #endif
537 }
538 
539 METHOD(Racer, vr_spawn, void(Racer thisveh, entity instance))
540 {
541 #ifdef SVQC
542  if(autocvar_g_vehicle_racer_hovertype != 0)
543  instance.racer_force_from_tag = vehicles_force_fromtag_maglev;
544  else
545  instance.racer_force_from_tag = vehicles_force_fromtag_hover;
546 
547  setthink(instance, racer_think);
548  instance.nextthink = time;
549  SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_racer_health);
550  instance.vehicle_shield = autocvar_g_vehicle_racer_shield;
551 
552  set_movetype(instance, MOVETYPE_TOSS);
553  instance.solid = SOLID_SLIDEBOX;
554  instance.delay = time;
555  instance.scale = 0.5; // FIXME: this be hakkz, fix the models insted (scale body, add tag_viewport to the hudmodel).
556  instance.mass = 900;
557 
558  setattachment(instance.vehicle_hudmodel, instance, "");
559  setattachment(instance.vehicle_viewport, instance, "tag_viewport");
560 
561  instance.PlayerPhysplug = racer_frame;
562 
563  instance.bouncefactor = autocvar_g_vehicle_racer_bouncefactor;
564  instance.bouncestop = autocvar_g_vehicle_racer_bouncestop;
565  instance.damageforcescale = 0.5;
566  SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_racer_health);
567  instance.vehicle_shield = autocvar_g_vehicle_racer_shield;
568 #endif
569 }
570 
571 METHOD(Racer, vr_death, void(Racer thisveh, entity instance))
572 {
573 #ifdef SVQC
574  setSendEntity(instance, func_null); // stop networking this racer (for now)
575  SetResourceExplicit(instance, RES_HEALTH, 0);
576  instance.event_damage = func_null;
577  instance.solid = SOLID_CORPSE;
578  instance.takedamage = DAMAGE_NO;
579  instance.deadflag = DEAD_DYING;
580  set_movetype(instance, MOVETYPE_BOUNCE);
581  instance.wait = time;
582  instance.delay = 2 + time + random() * 3;
583  instance.cnt = 1 + random() * 2;
584  settouch(instance, racer_deadtouch);
585 
586  Send_Effect(EFFECT_EXPLOSION_MEDIUM, instance.origin, '0 0 0', 1);
587 
588  if(random() < 0.5)
589  instance.avelocity_z = 32;
590  else
591  instance.avelocity_z = -32;
592 
593  instance.avelocity_x = -vlen(instance.velocity) * 0.2;
594  instance.velocity += '0 0 700';
595  instance.colormod = '-0.5 -0.5 -0.5';
596 
597  setthink(instance, racer_blowup_think);
598  instance.nextthink = time;
599 #endif
600 }
601 
602 #ifdef CSQC
603 METHOD(Racer, vr_hud, void(Racer thisveh))
604 {
605  Vehicles_drawHUD(VEH_RACER.m_icon, "vehicle_racer_weapon1", "vehicle_racer_weapon2",
606  "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
607  "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color);
608 }
609 METHOD(Racer, vr_crosshair, void(Racer thisveh, entity player))
610 {
612 }
613 #endif
614 METHOD(Racer, vr_setup, void(Racer thisveh, entity instance))
615 {
616 #ifdef SVQC
617  instance.vehicle_exit = racer_exit;
618 
619  // we have no need to network energy
620  if(autocvar_g_vehicle_racer_energy && autocvar_g_vehicle_racer_energy_regen)
621  instance.vehicle_flags |= VHF_ENERGYREGEN;
622 
623  if(autocvar_g_vehicle_racer_shield)
624  instance.vehicle_flags |= VHF_HASSHIELD;
625 
626  if(autocvar_g_vehicle_racer_shield_regen)
627  instance.vehicle_flags |= VHF_SHIELDREGEN;
628 
629  if(autocvar_g_vehicle_racer_health_regen)
630  instance.vehicle_flags |= VHF_HEALTHREGEN;
631 
632  instance.respawntime = autocvar_g_vehicle_racer_respawntime;
633  SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_racer_health);
634  instance.vehicle_shield = autocvar_g_vehicle_racer_shield;
635  instance.max_health = GetResource(instance, RES_HEALTH);
636 #endif
637 
638 #ifdef CSQC
639  AuxiliaryXhair[0].axh_image = vCROSS_LOCK; // Rocket
640 #endif
641 }
642 
643 #endif
const float SOLID_NOT
Definition: csprogsdefs.qc:244
#define PHYS_INPUT_BUTTON_ATCK2(s)
Definition: player.qh:148
float DEAD_DYING
Definition: progsdefs.qc:275
#define PHYS_INPUT_BUTTON_JUMP(s)
Definition: player.qh:147
float MOVETYPE_NONE
Definition: progsdefs.qc:246
#define PHYS_INPUT_BUTTON_CROUCH(s)
Definition: player.qh:150
const float SOLID_SLIDEBOX
Definition: csprogsdefs.qc:247
const int VHF_HASSHIELD
Indicates vehicle.
Definition: vehicle.qh:64
const float CONTENT_LAVA
Definition: csprogsdefs.qc:240
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: sv_vehicles.qc:572
ERASEABLE float anglemods(float v)
Definition: angle.qc:13
vector colormod
Definition: powerups.qc:21
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
void Vehicles_drawCrosshair(string crosshair)
Definition: cl_vehicles.qc:299
void vehicles_spawn(entity this)
bool weaponUseForbidden(entity player)
float MOVETYPE_TOSS
Definition: progsdefs.qc:252
entity tur_head
Definition: sv_turrets.qh:29
entity() spawn
const float MOVE_NORMAL
Definition: csprogsdefs.qc:252
ClientState CS(Client this)
Definition: state.qh:47
void Vehicles_drawHUD(string vehicle, string vehicleWeapon1, string vehicleWeapon2, string iconAmmo1, vector colorAmmo1, string iconAmmo2, vector colorAmmo2)
Definition: cl_vehicles.qc:123
vector maxs
Definition: csprogsdefs.qc:113
#define PHYS_INPUT_BUTTON_ZOOM(s)
Definition: player.qh:149
void vehicles_regen(entity this, float timer,.float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale)
Definition: sv_vehicles.qc:557
spawnfunc(info_player_attacker)
Definition: sv_assault.qc:283
origin
Definition: ent_cs.qc:114
void antilag_clear(entity e, entity store)
Definition: antilag.qc:114
#define gettaginfo
Definition: post.qh:32
vector avelocity
Definition: csprogsdefs.qc:105
float MOVETYPE_BOUNCE
Definition: progsdefs.qc:256
#define METHOD(cname, name, prototype)
Definition: oo.qh:257
float effects
Definition: csprogsdefs.qc:111
#define DMG_NOWEP
Definition: damage.qh:126
entity owner
Definition: main.qh:73
#define gettagindex
Definition: dpextensions.qh:16
float DEAD_DEAD
Definition: progsdefs.qc:276
void crosshair_trace(entity pl)
Definition: tracing.qc:508
void vehicles_impact(entity this, float _minspeed, float _speedfac, float _maxpain)
Definition: sv_vehicles.qc:746
RES_HEALTH
Definition: ent_cs.qc:126
const float EF_NODRAW
Definition: csprogsdefs.qc:305
bool weaponLocked(entity player)
entity enemy
Definition: sv_ctf.qh:143
const float MOVE_NOMONSTERS
Definition: csprogsdefs.qc:253
vector mins
Definition: csprogsdefs.qc:113
const int VHF_SHIELDREGEN
Vehicle has shileding.
Definition: vehicle.qh:65
float cnt
Definition: powerups.qc:24
const float CONTENT_SLIME
Definition: csprogsdefs.qc:239
entity AuxiliaryXhair[MAX_AXH]
Definition: cl_vehicles.qh:24
vector v_up
Definition: csprogsdefs.qc:31
const float CONTENT_WATER
Definition: csprogsdefs.qc:238
#define pointparticles
Definition: csprogsdefs.qh:13
float delay
Definition: subs.qh:38
#define setSendEntity(e, f)
Definition: self.qh:97
#define NULL
Definition: post.qh:17
float trace_dpstartcontents
ERASEABLE float shortangle_f(float ang1, float ang2)
Definition: angle.qc:29
const string vCROSS_LOCK
Definition: cl_vehicles.qh:18
vector trace_endpos
Definition: csprogsdefs.qc:37
#define PHYS_INPUT_BUTTON_ATCK(s)
Definition: player.qh:146
void vehicles_frame(entity this, entity actor)
Definition: sv_vehicles.qc:628
#define IS_DEAD(s)
Definition: utils.qh:26
const float ATTEN_NORM
Definition: sound.qh:30
vector autocvar_hud_progressbar_vehicles_ammo1_color
Definition: cl_vehicles.qh:10
float nextthink
Definition: csprogsdefs.qc:121
float DPCONTENTS_WATER
const int CH_TRIGGER_SINGLE
Definition: sound.qh:13
vector movement
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector v
Definition: ent_cs.qc:116
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
float deadflag
Definition: progsdefs.qc:149
const int VHF_HEALTHREGEN
Vehicles shield regenerates.
Definition: vehicle.qh:66
void vehicles_locktarget(entity this, float incr, float decr, float _lock_time)
Definition: sv_vehicles.qc:103
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition: vector.qh:8
const int VHF_ENERGYREGEN
Vehicles health regenerates.
Definition: vehicle.qh:67
float health
Definition: progsdefs.qc:137
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
vector v_right
Definition: csprogsdefs.qc:31
vector autocvar_hud_progressbar_vehicles_ammo2_color
Definition: cl_vehicles.qh:11
vector pos1
Definition: subs.qh:50
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
setorigin(ent, v)
#define setthink(e, f)
void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, int axh_id)
Definition: sv_vehicles.qc:47
vector angles
Definition: csprogsdefs.qc:104
float DPCONTENTS_LIQUIDSMASK
#define sound(e, c, s, v, a)
Definition: sound.qh:52
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition: weapon.qh:41
float time
Definition: csprogsdefs.qc:16
vector velocity
Definition: csprogsdefs.qc:103
#define makevectors
Definition: post.qh:21
const string vCROSS_GUIDE
Definition: cl_vehicles.qh:15
float trace_fraction
Definition: csprogsdefs.qc:36
Definition: racer.qh:5
float DAMAGE_NO
Definition: progsdefs.qc:282
bool vehicle_initialize(entity this, Vehicle info, bool nodrop)
void set_movetype(entity this, int mt)
var void func_null()
vector vehicles_findgoodexit(entity this, entity player, vector prefer_spot)
Definition: sv_vehicles.qc:764
vector v_forward
Definition: csprogsdefs.qc:31
float solid
Definition: csprogsdefs.qc:99
const float SOLID_CORPSE
Definition: csprogsdefs.qc:249