Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
walljump.qc File Reference
#include "walljump.qh"
Include dependency graph for walljump.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PHYS_WALLJUMP(s)
#define PHYS_WALLJUMP_DELAY(s)
#define PHYS_WALLJUMP_FORCE(s)
#define PHYS_WALLJUMP_VELOCITY_XY_FACTOR(s)
#define PHYS_WALLJUMP_VELOCITY_Z_FACTOR(s)
#define TRACE(newvec)

Functions

 MUTATOR_HOOKFUNCTION (walljump, PlayerJump)
vector PlayerTouchWall (entity this)
 REGISTER_MUTATOR (walljump, true)

Macro Definition Documentation

◆ PHYS_WALLJUMP

#define PHYS_WALLJUMP ( s)
Value:
STAT(WALLJUMP, s)
#define STAT(...)
Definition stats.qh:82

Definition at line 10 of file walljump.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ PHYS_WALLJUMP_DELAY

#define PHYS_WALLJUMP_DELAY ( s)
Value:
STAT(WALLJUMP_DELAY, s)

Definition at line 13 of file walljump.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ PHYS_WALLJUMP_FORCE

#define PHYS_WALLJUMP_FORCE ( s)
Value:
STAT(WALLJUMP_FORCE, s)

Definition at line 14 of file walljump.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ PHYS_WALLJUMP_VELOCITY_XY_FACTOR

#define PHYS_WALLJUMP_VELOCITY_XY_FACTOR ( s)
Value:
STAT(WALLJUMP_VELOCITY_XY_FACTOR, s)

Definition at line 12 of file walljump.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ PHYS_WALLJUMP_VELOCITY_Z_FACTOR

#define PHYS_WALLJUMP_VELOCITY_Z_FACTOR ( s)
Value:
STAT(WALLJUMP_VELOCITY_Z_FACTOR, s)

Definition at line 11 of file walljump.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ TRACE

#define TRACE ( newvec)
Value:
tracebox (start, this.mins, this.maxs, (newvec), true, this); \
if (trace_fraction < 1 && vdist(this.origin - trace_endpos, <, dist) && trace_plane_normal_z < max_normal) \
vector mins
vector trace_endpos
vector maxs
float trace_dphitq3surfaceflags
vector origin
float trace_fraction
float Q3SURFACEFLAG_NOIMPACT
vector trace_plane_normal
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8

Referenced by PlayerTouchWall().

Function Documentation

◆ MUTATOR_HOOKFUNCTION()

MUTATOR_HOOKFUNCTION ( walljump ,
PlayerJump  )

Definition at line 36 of file walljump.qc.

37{
38 entity player = M_ARGV(0, entity);
39
40 if(PHYS_WALLJUMP(player))
41 if(time - STAT(LASTWJ, player) > PHYS_WALLJUMP_DELAY(player)) // can't do this on client, as it's too stupid to obey counters
42 if(!IS_ONGROUND(player))
43 if(player.move_movetype != MOVETYPE_NONE && player.move_movetype != MOVETYPE_FOLLOW && player.move_movetype != MOVETYPE_FLY && player.move_movetype != MOVETYPE_NOCLIP)
44 if(!IS_JUMP_HELD(player))
45 if(!STAT(FROZEN, player) && !StatusEffects_active(STATUSEFFECT_Frozen, player))
46 if(!IS_DEAD(player))
47 {
48 vector plane_normal = PlayerTouchWall(player);
49
50 if(plane_normal != '0 0 0')
51 {
52 float wj_force = PHYS_WALLJUMP_FORCE(player);
53 float wj_xy_factor = PHYS_WALLJUMP_VELOCITY_XY_FACTOR(player);
54 float wj_z_factor = PHYS_WALLJUMP_VELOCITY_Z_FACTOR(player);
55 player.velocity_x += plane_normal_x * wj_force;
56 player.velocity_x /= wj_xy_factor;
57 player.velocity_y += plane_normal_y * wj_force;
58 player.velocity_y /= wj_xy_factor;
59 player.velocity_z = PHYS_JUMPVELOCITY(player) * wj_z_factor;
60 if(PHYS_INPUT_BUTTON_CROUCH(player)) player.velocity_z *= -1;
61
62#ifdef SVQC
63 STAT(LASTWJ, player) = time;
64 player.oldvelocity = player.velocity;
65 Send_Effect(EFFECT_SMOKE_RING, trace_endpos, plane_normal, 5);
66 PlayerSound(player, playersound_jump, CH_PLAYER, VOL_BASE, VOICETYPE_PLAYERSOUND);
68#endif
69
70 M_ARGV(2, bool) = true; // multijump
71 }
72 }
73}
void animdecide_setaction(entity e, float action, float restart)
const int ANIMACTION_JUMP
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define M_ARGV(x, type)
Definition events.qh:17
#define PHYS_INPUT_BUTTON_CROUCH(s)
Definition player.qh:154
#define IS_DEAD(s)
Definition player.qh:245
#define PHYS_JUMPVELOCITY(s)
Definition player.qh:131
#define IS_JUMP_HELD(s)
Definition player.qh:203
float time
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:124
#define PlayerSound(this, def, chan, vol, voicetype)
const int VOICETYPE_PLAYERSOUND
const int MOVETYPE_NONE
Definition movetypes.qh:129
const int MOVETYPE_FOLLOW
Definition movetypes.qh:141
const int MOVETYPE_NOCLIP
Definition movetypes.qh:137
const int MOVETYPE_FLY
Definition movetypes.qh:134
#define IS_ONGROUND(s)
Definition movetypes.qh:16
vector
Definition self.qh:92
const float VOL_BASE
Definition sound.qh:36
const int CH_PLAYER
Definition sound.qh:20
bool StatusEffects_active(StatusEffect this, entity actor)
#define PHYS_WALLJUMP(s)
Definition walljump.qc:10
#define PHYS_WALLJUMP_FORCE(s)
Definition walljump.qc:14
vector PlayerTouchWall(entity this)
Definition walljump.qc:16
#define PHYS_WALLJUMP_VELOCITY_Z_FACTOR(s)
Definition walljump.qc:11
#define PHYS_WALLJUMP_DELAY(s)
Definition walljump.qc:13
#define PHYS_WALLJUMP_VELOCITY_XY_FACTOR(s)
Definition walljump.qc:12

References ANIMACTION_JUMP, animdecide_setaction(), CH_PLAYER, entity(), IS_DEAD, IS_JUMP_HELD, IS_ONGROUND, M_ARGV, MOVETYPE_FLY, MOVETYPE_FOLLOW, MOVETYPE_NOCLIP, MOVETYPE_NONE, PHYS_INPUT_BUTTON_CROUCH, PHYS_JUMPVELOCITY, PHYS_WALLJUMP, PHYS_WALLJUMP_DELAY, PHYS_WALLJUMP_FORCE, PHYS_WALLJUMP_VELOCITY_XY_FACTOR, PHYS_WALLJUMP_VELOCITY_Z_FACTOR, PlayerJump(), PlayerSound, PlayerTouchWall(), Send_Effect(), STAT, StatusEffects_active(), time, trace_endpos, vector, VOICETYPE_PLAYERSOUND, and VOL_BASE.

◆ PlayerTouchWall()

vector PlayerTouchWall ( entity this)

Definition at line 16 of file walljump.qc.

17{
18#define TRACE(newvec) \
19 tracebox (start, this.mins, this.maxs, (newvec), true, this); \
20 if (trace_fraction < 1 && vdist(this.origin - trace_endpos, <, dist) && trace_plane_normal_z < max_normal) \
21 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)) \
22 return trace_plane_normal;
23
24 float dist = 10, max_normal = 0.2, scaler = 100;
25 vector start = this.origin;
26 vector forward, right, _up;
27 MAKE_VECTORS(this.angles, forward, right, _up);
28 TRACE(start + forward * scaler)
29 TRACE(start - forward * scaler)
30 TRACE(start + right * scaler)
31 TRACE(start - right * scaler)
32#undef TRACE
33 return '0 0 0';
34}
#define MAKE_VECTORS(angles, forward, right, up)
Same as the makevectors builtin but uses the provided locals instead of the v_* globals.
ent angles
Definition ent_cs.qc:121
#define TRACE(newvec)

References angles, entity(), MAKE_VECTORS, origin, TRACE, and vector.

Referenced by MUTATOR_HOOKFUNCTION().

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( walljump ,
true  )