]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/doublejump/doublejump.qc
Cleanse the physics hooks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / doublejump / doublejump.qc
1 #ifdef IMPLEMENTATION
2 #ifdef SVQC
3         #include <server/antilag.qh>
4 #endif
5 #include <common/physics/player.qh>
6
7 #ifdef SVQC
8 REGISTER_MUTATOR(doublejump, autocvar_sv_doublejump);
9 #elif defined(CSQC)
10 REGISTER_MUTATOR(doublejump, true);
11 #endif
12
13 #define PHYS_DOUBLEJUMP(s)                     STAT(DOUBLEJUMP, s)
14
15
16 MUTATOR_HOOKFUNCTION(doublejump, PlayerJump)
17 {
18     entity player = M_ARGV(0, entity);
19
20         if (PHYS_DOUBLEJUMP(player))
21         {
22                 tracebox(player.origin + '0 0 0.01', player.mins, player.maxs, player.origin - '0 0 0.01', MOVE_NORMAL, player);
23                 if (trace_fraction < 1 && trace_plane_normal_z > 0.7)
24                 {
25                         M_ARGV(2, bool) = true;
26
27                         // we MUST clip velocity here!
28                         float f = player.velocity * trace_plane_normal;
29                         if (f < 0)
30                                 player.velocity -= f * trace_plane_normal;
31                 }
32         }
33 }
34
35 #endif