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

Go to the source code of this file.

Functions

 STATIC_INIT (sys_phys)
void sys_phys_ai (entity this)
void sys_phys_fix (entity this, float dt)
void sys_phys_fixspeed (entity this, float maxspeed_mod)
void sys_phys_land (entity this)
void sys_phys_monitor (entity this, float dt)
bool sys_phys_override (entity this, float dt)
void sys_phys_pregame_hold (entity this)
void sys_phys_spectator_control (entity this)

Variables

float autocvar_sv_spectator_speed_multiplier
float autocvar_sv_spectator_speed_multiplier_max = 5
float autocvar_sv_spectator_speed_multiplier_min = 1

Function Documentation

◆ STATIC_INIT()

STATIC_INIT ( sys_phys )

Definition at line 130 of file sv_physics.qc.

131{
132 entity listener = new_pure(sys_phys);
133 subscribe(listener, phys_land, sys_phys_land);
134}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define subscribe(listener, T, fn)
Definition lib.qh:22
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:67
void sys_phys_land(entity this)

References entity(), new_pure, subscribe, and sys_phys_land().

◆ sys_phys_ai()

void sys_phys_ai ( entity this)

Definition at line 41 of file sv_physics.qc.

42{
43 if (!IS_BOT_CLIENT(this))
44 return;
45 bot_think(this);
46}
void bot_think(entity this)
Definition bot.qc:62
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition utils.qh:15

References bot_think(), entity(), and IS_BOT_CLIENT.

◆ sys_phys_fix()

void sys_phys_fix ( entity this,
float dt )

Definition at line 7 of file sv_physics.qc.

8{
11}
void PM_ClientMovement_UpdateStatus(entity this)
Definition player.qc:170
void WarpZone_PlayerPhysics_FixVAngle(entity this)
Definition server.qc:865

References entity(), PM_ClientMovement_UpdateStatus(), and WarpZone_PlayerPhysics_FixVAngle().

◆ sys_phys_fixspeed()

void sys_phys_fixspeed ( entity this,
float maxspeed_mod )

Definition at line 105 of file sv_physics.qc.

106{
107 float spd = max(PHYS_MAXSPEED(this), PHYS_MAXAIRSPEED(this)) * maxspeed_mod;
108 if (this.speed != spd)
109 {
110 this.speed = spd; // TODO: send this as a stat and set the below cvars on the client?
111 string temps = ftos(spd);
112 stuffcmd(this, strcat("cl_forwardspeed ", temps, "\n"));
113 stuffcmd(this, strcat("cl_backspeed ", temps, "\n"));
114 stuffcmd(this, strcat("cl_sidespeed ", temps, "\n"));
115 stuffcmd(this, strcat("cl_upspeed ", temps, "\n"));
116 }
117}
#define PHYS_MAXAIRSPEED(s)
Definition player.qh:136
#define PHYS_MAXSPEED(s)
Definition player.qh:138
float speed
Definition dynlight.qc:9
string ftos(float f)
float max(float f,...)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define stuffcmd(cl,...)
Definition progsdefs.qh:23

References entity(), ftos(), max(), PHYS_MAXAIRSPEED, PHYS_MAXSPEED, speed, strcat(), and stuffcmd.

◆ sys_phys_land()

void sys_phys_land ( entity this)

Definition at line 119 of file sv_physics.qc.

120{
122 LOG_TRACEF("landing velocity: %v (abs: %f)", this.velocity, vlen(this.velocity));
123
124 if (this.jumppadcount > 1)
125 LOG_TRACEF("%dx jumppad combo", this.jumppadcount);
126
127 this.jumppadcount = 0;
128}
bool autocvar_speedmeter
Definition player.qh:46
vector velocity
float jumppadcount
Definition jumppads.qh:28
#define LOG_TRACEF(...)
Definition log.qh:77
float vlen(vector v)

References autocvar_speedmeter, entity(), jumppadcount, LOG_TRACEF, velocity, and vlen().

Referenced by STATIC_INIT().

◆ sys_phys_monitor()

void sys_phys_monitor ( entity this,
float dt )

Definition at line 26 of file sv_physics.qc.

27{
28 int buttons = PHYS_INPUT_BUTTON_MASK(this);
30
31 // always do this so active players don't get kicked if sv_maxidle* get enabled mid-match
32 if (!PHYS_INPUT_BUTTON_CHAT(this))
33 if (buttons != CS(this).buttons_old
34 || CS(this).movement != CS(this).movement_old
35 || this.v_angle != CS(this).v_angle_old)
36 CS(this).parm_idlesince = time;
37
38 PM_check_punch(this, dt);
39}
void anticheat_physics(entity this)
Definition anticheat.qc:67
void PM_check_punch(entity this, float dt)
Definition player.qc:626
vector movement
Definition player.qh:228
vector v_angle_old
Definition player.qh:69
int buttons_old
Definition player.qh:67
vector movement_old
Definition player.qh:68
#define PHYS_INPUT_BUTTON_CHAT(s)
Definition player.qh:161
vector v_angle
Definition player.qh:236
#define PHYS_INPUT_BUTTON_MASK(s)
Definition player.qh:191
float time
ClientState CS(Client this)
Definition state.qh:47

References anticheat_physics(), buttons_old, CS(), entity(), movement, movement_old, PHYS_INPUT_BUTTON_CHAT, PHYS_INPUT_BUTTON_MASK, PM_check_punch(), time, v_angle, and v_angle_old.

◆ sys_phys_override()

bool sys_phys_override ( entity this,
float dt )

Definition at line 13 of file sv_physics.qc.

14{
15 int buttons = PHYS_INPUT_BUTTON_MASK(this);
16 float idlesince = CS(this).parm_idlesince;
17 CS(this).parm_idlesince = time; // in the case that physics are overridden
18 if (PM_check_specialcommand(this, buttons))
19 return true;
20 if (this.PlayerPhysplug && this.PlayerPhysplug(this, dt))
21 return true;
22 CS(this).parm_idlesince = idlesince;
23 return false;
24}
bool PM_check_specialcommand(entity this, int buttons)
Definition player.qc:593

References CS(), entity(), PHYS_INPUT_BUTTON_MASK, PM_check_specialcommand(), and time.

◆ sys_phys_pregame_hold()

void sys_phys_pregame_hold ( entity this)

Definition at line 48 of file sv_physics.qc.

49{
50 if (!IS_PLAYER(this))
51 return;
52 const bool allowed_to_move = (time >= game_starttime && !game_stopped);
53 if (!allowed_to_move)
54 {
55 this.velocity = '0 0 0';
58 }
59 else if (this.disableclientprediction == 2)
60 {
61 if (this.move_movetype == MOVETYPE_NONE)
64 }
65}
#define IS_PLAYER(s)
Definition player.qh:242
float game_starttime
Definition stats.qh:82
float game_stopped
Definition stats.qh:81
float disableclientprediction
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_WALK
Definition movetypes.qh:132
const int MOVETYPE_NONE
Definition movetypes.qh:129
float move_movetype
Definition movetypes.qh:76

References disableclientprediction, entity(), game_starttime, game_stopped, IS_PLAYER, move_movetype, MOVETYPE_NONE, MOVETYPE_WALK, set_movetype(), time, and velocity.

◆ sys_phys_spectator_control()

void sys_phys_spectator_control ( entity this)

Definition at line 67 of file sv_physics.qc.

68{
69 float maxspeed_mod = autocvar_sv_spectator_speed_multiplier;
70 if (!STAT(SPECTATORSPEED, this))
71 STAT(SPECTATORSPEED, this) = maxspeed_mod;
72 if ((CS(this).impulse >= 1 && CS(this).impulse <= 19)
73 || (CS(this).impulse >= 200 && CS(this).impulse <= 209)
74 || (CS(this).impulse >= 220 && CS(this).impulse <= 229))
75 {
76 if (this.lastclassname != STR_PLAYER)
77 {
78 if (CS(this).impulse == 10
79 || CS(this).impulse == 15
80 || CS(this).impulse == 18
81 || (CS(this).impulse >= 200 && CS(this).impulse <= 209))
82 {
84 STAT(SPECTATORSPEED, this) + 0.5,
86 }
87 else if (CS(this).impulse == 11)
88 STAT(SPECTATORSPEED, this) = maxspeed_mod;
89 else if (CS(this).impulse == 12
90 || CS(this).impulse == 16
91 || CS(this).impulse == 19
92 || (CS(this).impulse >= 220 && CS(this).impulse <= 229))
93 {
95 STAT(SPECTATORSPEED, this) - 0.5,
97 }
98 else if (CS(this).impulse >= 1 && CS(this).impulse <= 9)
99 STAT(SPECTATORSPEED, this) = 1 + 0.5 * (CS(this).impulse - 1);
100 } // otherwise just clear
101 CS(this).impulse = 0;
102 }
103}
string lastclassname
Definition player.qh:70
#define STAT(...)
Definition stats.qh:82
float bound(float min, float value, float max)
float impulse
Definition progsdefs.qc:158
float autocvar_sv_spectator_speed_multiplier_max
Definition sv_physics.qc:5
float autocvar_sv_spectator_speed_multiplier
Definition sv_physics.qc:3
float autocvar_sv_spectator_speed_multiplier_min
Definition sv_physics.qc:4
const string STR_PLAYER
Definition utils.qh:5

References autocvar_sv_spectator_speed_multiplier, autocvar_sv_spectator_speed_multiplier_max, autocvar_sv_spectator_speed_multiplier_min, bound(), CS(), entity(), impulse, lastclassname, STAT, and STR_PLAYER.

Variable Documentation

◆ autocvar_sv_spectator_speed_multiplier

float autocvar_sv_spectator_speed_multiplier

Definition at line 3 of file sv_physics.qc.

Referenced by sys_phys_spectator_control().

◆ autocvar_sv_spectator_speed_multiplier_max

float autocvar_sv_spectator_speed_multiplier_max = 5

Definition at line 5 of file sv_physics.qc.

Referenced by sys_phys_spectator_control().

◆ autocvar_sv_spectator_speed_multiplier_min

float autocvar_sv_spectator_speed_multiplier_min = 1

Definition at line 4 of file sv_physics.qc.

Referenced by sys_phys_spectator_control().