Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
multijump.qc File Reference
#include "multijump.qh"
#include <server/antilag.qh>
#include <common/physics/player.qh>
Include dependency graph for multijump.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PHYS_MULTIJUMP(s)
#define PHYS_MULTIJUMP_ADD(s)
#define PHYS_MULTIJUMP_CLIENT(s)
#define PHYS_MULTIJUMP_CLIENTDEFAULT(s)
#define PHYS_MULTIJUMP_COUNT(s)
#define PHYS_MULTIJUMP_DODGING(s)
#define PHYS_MULTIJUMP_MAXSPEED(s)
#define PHYS_MULTIJUMP_SPEED(s)

Functions

 MUTATOR_HOOKFUNCTION (multijump, BuildMutatorsPrettyString)
 MUTATOR_HOOKFUNCTION (multijump, BuildMutatorsString)
 MUTATOR_HOOKFUNCTION (multijump, PlayerJump)
 MUTATOR_HOOKFUNCTION (multijump, PlayerPhysics)
 REGISTER_MUTATOR (multijump, autocvar_g_multijump)
 REPLICATE (cvar_cl_multijump, bool, "cl_multijump")

Variables

int autocvar_cl_multijump = -1
bool multijump_ready

Macro Definition Documentation

◆ PHYS_MULTIJUMP

#define PHYS_MULTIJUMP ( s)
Value:
STAT(MULTIJUMP, s)
#define STAT(...)
Definition stats.qh:82

Definition at line 19 of file multijump.qc.

Referenced by MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ PHYS_MULTIJUMP_ADD

#define PHYS_MULTIJUMP_ADD ( s)
Value:
STAT(MULTIJUMP_ADD, s)

Definition at line 21 of file multijump.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ PHYS_MULTIJUMP_CLIENT

#define PHYS_MULTIJUMP_CLIENT ( s)
Value:
int autocvar_cl_multijump
Definition multijump.qc:30

Definition at line 31 of file multijump.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ PHYS_MULTIJUMP_CLIENTDEFAULT

#define PHYS_MULTIJUMP_CLIENTDEFAULT ( s)
Value:
STAT(MULTIJUMP_CLIENT, s)

Definition at line 25 of file multijump.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ PHYS_MULTIJUMP_COUNT

#define PHYS_MULTIJUMP_COUNT ( s)
Value:
STAT(MULTIJUMP_COUNT, s)

Definition at line 24 of file multijump.qc.

Referenced by MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ PHYS_MULTIJUMP_DODGING

#define PHYS_MULTIJUMP_DODGING ( s)
Value:
STAT(MULTIJUMP_DODGING, s)

Definition at line 23 of file multijump.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ PHYS_MULTIJUMP_MAXSPEED

#define PHYS_MULTIJUMP_MAXSPEED ( s)
Value:
STAT(MULTIJUMP_MAXSPEED, s)

Definition at line 22 of file multijump.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ PHYS_MULTIJUMP_SPEED

#define PHYS_MULTIJUMP_SPEED ( s)
Value:
STAT(MULTIJUMP_SPEED, s)

Definition at line 20 of file multijump.qc.

Referenced by MUTATOR_HOOKFUNCTION().

Function Documentation

◆ MUTATOR_HOOKFUNCTION() [1/4]

MUTATOR_HOOKFUNCTION ( multijump ,
BuildMutatorsPrettyString  )

Definition at line 126 of file multijump.qc.

127{
128 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Multi jump");
129}
#define M_ARGV(x, type)
Definition events.qh:17
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))

References M_ARGV, and strcat().

◆ MUTATOR_HOOKFUNCTION() [2/4]

MUTATOR_HOOKFUNCTION ( multijump ,
BuildMutatorsString  )

Definition at line 121 of file multijump.qc.

122{
123 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":multijump");
124}

References M_ARGV, and strcat().

◆ MUTATOR_HOOKFUNCTION() [3/4]

MUTATOR_HOOKFUNCTION ( multijump ,
PlayerJump  )

Definition at line 49 of file multijump.qc.

50{
51 entity player = M_ARGV(0, entity);
52
53 if(!PHYS_MULTIJUMP(player)) { return; }
54
55 int client_multijump = PHYS_MULTIJUMP_CLIENT(player);
56 if(client_multijump == -1)
57 client_multijump = PHYS_MULTIJUMP_CLIENTDEFAULT(player);
58 if(client_multijump > 1)
59 return; // nope
60
61 if (!IS_JUMP_HELD(player) && !IS_ONGROUND(player) && client_multijump) // jump button pressed this frame and we are in midair
62 player.multijump_ready = true; // this is necessary to check that we released the jump button and pressed it again
63 else
64 player.multijump_ready = false;
65
66 int phys_multijump = PHYS_MULTIJUMP(player);
67
68 if(!M_ARGV(2, bool) && player.multijump_ready && (PHYS_MULTIJUMP_COUNT(player) < phys_multijump || phys_multijump == -1) && player.velocity_z > PHYS_MULTIJUMP_SPEED(player) &&
69 (!PHYS_MULTIJUMP_MAXSPEED(player) || vdist(player.velocity, <=, PHYS_MULTIJUMP_MAXSPEED(player))))
70 {
71 if (PHYS_MULTIJUMP(player))
72 {
73 if (!PHYS_MULTIJUMP_ADD(player)) // in this case we make the z velocity == jumpvelocity
74 {
75 if (player.velocity_z < PHYS_JUMPVELOCITY(player))
76 {
77 M_ARGV(2, bool) = true;
78 player.velocity_z = 0;
79 }
80 }
81 else
82 M_ARGV(2, bool) = true;
83
84 if(M_ARGV(2, bool))
85 {
86 if(PHYS_MULTIJUMP_DODGING(player))
87 if(PHYS_CS(player).movement_x != 0 || PHYS_CS(player).movement_y != 0) // don't remove all speed if player isnt pressing any movement keys
88 {
89 float curspeed;
90 vector wishvel, wishdir;
91
92/*#ifdef SVQC
93 curspeed = max(
94 vlen(vec2(player.velocity)), // current xy speed
95 vlen(vec2(antilag_takebackavgvelocity(player, max(player.lastteleporttime + sys_frametime, time - 0.25), time))) // average xy topspeed over the last 0.25 secs
96 );
97#elif defined(CSQC)*/
98 curspeed = vlen(vec2(player.velocity));
99//#endif
100
101 makevectors(player.v_angle_y * '0 1 0');
102 wishvel = v_forward * PHYS_CS(player).movement_x + v_right * PHYS_CS(player).movement_y;
103 wishdir = normalize(wishvel);
104
105 player.velocity_x = wishdir_x * curspeed; // allow "dodging" at a multijump
106 player.velocity_y = wishdir_y * curspeed;
107 // keep velocity_z unchanged!
108 }
109 if (PHYS_MULTIJUMP(player) > 0)
110 {
111 player.multijump_count += 1;
112 }
113 }
114 }
115 player.multijump_ready = false; // require releasing and pressing the jump button again for the next jump
116 }
117}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define PHYS_CS(s)
Definition player.qh:258
#define PHYS_JUMPVELOCITY(s)
Definition player.qh:131
#define IS_JUMP_HELD(s)
Definition player.qh:203
vector v_right
vector v_forward
float vlen(vector v)
vector normalize(vector v)
#define IS_ONGROUND(s)
Definition movetypes.qh:16
#define PHYS_MULTIJUMP_MAXSPEED(s)
Definition multijump.qc:22
#define PHYS_MULTIJUMP_ADD(s)
Definition multijump.qc:21
#define PHYS_MULTIJUMP(s)
Definition multijump.qc:19
#define PHYS_MULTIJUMP_COUNT(s)
Definition multijump.qc:24
#define PHYS_MULTIJUMP_DODGING(s)
Definition multijump.qc:23
#define PHYS_MULTIJUMP_CLIENTDEFAULT(s)
Definition multijump.qc:25
#define PHYS_MULTIJUMP_SPEED(s)
Definition multijump.qc:20
#define PHYS_MULTIJUMP_CLIENT(s)
Definition multijump.qc:31
#define makevectors
Definition post.qh:21
vector
Definition self.qh:92
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8
#define vec2(...)
Definition vector.qh:90

References entity(), IS_JUMP_HELD, IS_ONGROUND, M_ARGV, makevectors, normalize(), PHYS_CS, PHYS_JUMPVELOCITY, PHYS_MULTIJUMP, PHYS_MULTIJUMP_ADD, PHYS_MULTIJUMP_CLIENT, PHYS_MULTIJUMP_CLIENTDEFAULT, PHYS_MULTIJUMP_COUNT, PHYS_MULTIJUMP_DODGING, PHYS_MULTIJUMP_MAXSPEED, PHYS_MULTIJUMP_SPEED, PlayerJump(), v_forward, v_right, vdist, vec2, vector, and vlen().

◆ MUTATOR_HOOKFUNCTION() [4/4]

MUTATOR_HOOKFUNCTION ( multijump ,
PlayerPhysics  )

Definition at line 36 of file multijump.qc.

37{
38 entity player = M_ARGV(0, entity);
39
40#ifdef CSQC
41 player.multijump_count = PHYS_MULTIJUMP_COUNT(player);
42#endif
43 if(!PHYS_MULTIJUMP(player)) { return; }
44
45 if(IS_ONGROUND(player))
46 player.multijump_count = 0;
47}

References entity(), IS_ONGROUND, M_ARGV, PHYS_MULTIJUMP, and PHYS_MULTIJUMP_COUNT.

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( multijump ,
autocvar_g_multijump  )

References autocvar_g_multijump.

◆ REPLICATE()

REPLICATE ( cvar_cl_multijump ,
bool ,
"cl_multijump"  )

Variable Documentation

◆ autocvar_cl_multijump

int autocvar_cl_multijump = -1

Definition at line 30 of file multijump.qc.

◆ multijump_ready

bool multijump_ready

Definition at line 27 of file multijump.qc.