Xonotic
doublejump.qc
Go to the documentation of this file.
1 #include "doublejump.qh"
2 
3 #ifdef GAMEQC
4 #ifdef SVQC
5  #include <server/antilag.qh>
6 #endif
8 
9 #ifdef SVQC
10 REGISTER_MUTATOR(doublejump, autocvar_sv_doublejump);
11 #elif defined(CSQC)
12 REGISTER_MUTATOR(doublejump, true);
13 #endif
14 
15 #define PHYS_DOUBLEJUMP(s) STAT(DOUBLEJUMP, s)
16 
17 
19 {
20  entity player = M_ARGV(0, entity);
21 
22  if (PHYS_DOUBLEJUMP(player))
23  {
24  tracebox(player.origin + '0 0 0.01', player.mins, player.maxs, player.origin - '0 0 0.01', MOVE_NORMAL, player);
25  if (trace_fraction < 1 && trace_plane_normal_z > 0.7)
26  {
27  M_ARGV(2, bool) = true;
28 
29  // we MUST clip velocity here!
30  float f = player.velocity * trace_plane_normal;
31  if (f < 0)
32  player.velocity -= f * trace_plane_normal;
33  }
34  }
35 }
36 #endif
#define REGISTER_MUTATOR(id, dependence)
Definition: base.qh:263
entity() spawn
const float MOVE_NORMAL
Definition: csprogsdefs.qc:252
#define M_ARGV(x, type)
Definition: events.qh:17
bool PlayerJump(entity this)
Definition: player.qc:330
vector trace_plane_normal
Definition: csprogsdefs.qc:38
#define MUTATOR_HOOKFUNCTION(...)
Definition: base.qh:310