]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/doublejump/doublejump.qc
Merge branch 'TimePath/modules'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / doublejump / doublejump.qc
1 #include "doublejump.qh"
2
3 #ifdef GAMEQC
4 #ifdef SVQC
5         #include <server/antilag.qh>
6 #endif
7 #include <common/physics/player.qh>
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
18 MUTATOR_HOOKFUNCTION(doublejump, PlayerJump)
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