]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/doublejump/doublejump.qc
Merge branch 'master' into Mirio/balance
[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     SELFPARAM();
19         if (PHYS_DOUBLEJUMP(self))
20         {
21                 tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
22                 if (trace_fraction < 1 && trace_plane_normal_z > 0.7)
23                 {
24                         player_multijump = true;
25
26                         // we MUST clip velocity here!
27                         float f = self.velocity * trace_plane_normal;
28                         if (f < 0)
29                                 self.velocity -= f * trace_plane_normal;
30                 }
31         }
32         return false;
33 }
34
35 #endif