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 142 of file sv_physics.qc.

143{
144 entity listener = new_pure(sys_phys);
145 subscribe(listener, phys_land, sys_phys_land);
146}
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 42 of file sv_physics.qc.

43{
44 if (!IS_BOT_CLIENT(this))
45 return;
46 bot_think(this);
47}
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{
12}
void PM_ClientMovement_UpdateStatus(entity this)
Definition player.qc:161
void Physics_UpdateStats(entity this)
Definition player.qc:44
void WarpZone_PlayerPhysics_FixVAngle(entity this)
Definition server.qc:865

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

◆ sys_phys_fixspeed()

void sys_phys_fixspeed ( entity this,
float maxspeed_mod )

Definition at line 106 of file sv_physics.qc.

107{
108 float spd = max(PHYS_MAXSPEED(this), PHYS_MAXAIRSPEED(this)) * maxspeed_mod;
109 if (this.speed != spd)
110 {
111 this.speed = spd; // TODO: send this as a stat and set the below cvars on the client?
112 string temps = ftos(spd);
113 stuffcmd(this, strcat("cl_forwardspeed ", temps, "\n"));
114 stuffcmd(this, strcat("cl_backspeed ", temps, "\n"));
115 stuffcmd(this, strcat("cl_sidespeed ", temps, "\n"));
116 stuffcmd(this, strcat("cl_upspeed ", temps, "\n"));
117 }
118
119 if (this.jumpspeedcap_min != autocvar_sv_jumpspeedcap_min)
120 {
121 this.jumpspeedcap_min = autocvar_sv_jumpspeedcap_min;
122 stuffcmd(this, sprintf("\ncl_jumpspeedcap_min \"%s\"\n", autocvar_sv_jumpspeedcap_min));
123 }
124 if (this.jumpspeedcap_max != autocvar_sv_jumpspeedcap_max)
125 {
126 this.jumpspeedcap_max = autocvar_sv_jumpspeedcap_max;
127 stuffcmd(this, sprintf("\ncl_jumpspeedcap_max \"%s\"\n", autocvar_sv_jumpspeedcap_max));
128 }
129}
string autocvar_sv_jumpspeedcap_max
Definition player.qh:47
#define PHYS_MAXAIRSPEED(s)
Definition player.qh:134
#define PHYS_MAXSPEED(s)
Definition player.qh:136
string autocvar_sv_jumpspeedcap_min
Definition player.qh:49
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 autocvar_sv_jumpspeedcap_max, autocvar_sv_jumpspeedcap_min, entity(), ftos(), max(), PHYS_MAXAIRSPEED, PHYS_MAXSPEED, speed, strcat(), and stuffcmd.

◆ sys_phys_land()

void sys_phys_land ( entity this)

Definition at line 131 of file sv_physics.qc.

132{
134 LOG_TRACEF("landing velocity: %v (abs: %f)", this.velocity, vlen(this.velocity));
135
136 if (this.jumppadcount > 1)
137 LOG_TRACEF("%dx jumppad combo", this.jumppadcount);
138
139 this.jumppadcount = 0;
140}
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 27 of file sv_physics.qc.

28{
29 int buttons = PHYS_INPUT_BUTTON_MASK(this);
31
32 // always do this so active players don't get kicked if sv_maxidle* get enabled mid-match
33 if (!PHYS_INPUT_BUTTON_CHAT(this))
34 if (buttons != CS(this).buttons_old
35 || CS(this).movement != CS(this).movement_old
36 || this.v_angle != CS(this).v_angle_old)
37 CS(this).parm_idlesince = time;
38
39 PM_check_punch(this, dt);
40}
void anticheat_physics(entity this)
Definition anticheat.qc:67
void PM_check_punch(entity this, float dt)
Definition player.qc:617
vector movement
Definition player.qh:229
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:159
vector v_angle
Definition player.qh:237
#define PHYS_INPUT_BUTTON_MASK(s)
Definition player.qh:189
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 14 of file sv_physics.qc.

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

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 49 of file sv_physics.qc.

50{
51 if (!IS_PLAYER(this))
52 return;
53 const bool allowed_to_move = (time >= game_starttime && !game_stopped);
54 if (!allowed_to_move)
55 {
56 this.velocity = '0 0 0';
59 }
60 else if (this.disableclientprediction == 2)
61 {
62 if (this.move_movetype == MOVETYPE_NONE)
65 }
66}
#define IS_PLAYER(s)
Definition player.qh:243
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 68 of file sv_physics.qc.

69{
70 float maxspeed_mod = autocvar_sv_spectator_speed_multiplier;
71 if (!STAT(SPECTATORSPEED, this))
72 STAT(SPECTATORSPEED, this) = maxspeed_mod;
73 if ((CS(this).impulse >= 1 && CS(this).impulse <= 19)
74 || (CS(this).impulse >= 200 && CS(this).impulse <= 209)
75 || (CS(this).impulse >= 220 && CS(this).impulse <= 229))
76 {
77 if (this.lastclassname != STR_PLAYER)
78 {
79 if (CS(this).impulse == 10
80 || CS(this).impulse == 15
81 || CS(this).impulse == 18
82 || (CS(this).impulse >= 200 && CS(this).impulse <= 209))
83 {
85 STAT(SPECTATORSPEED, this) + 0.5,
87 }
88 else if (CS(this).impulse == 11)
89 STAT(SPECTATORSPEED, this) = maxspeed_mod;
90 else if (CS(this).impulse == 12
91 || CS(this).impulse == 16
92 || CS(this).impulse == 19
93 || (CS(this).impulse >= 220 && CS(this).impulse <= 229))
94 {
96 STAT(SPECTATORSPEED, this) - 0.5,
98 }
99 else if (CS(this).impulse >= 1 && CS(this).impulse <= 9)
100 STAT(SPECTATORSPEED, this) = 1 + 0.5 * (CS(this).impulse - 1);
101 } // otherwise just clear
102 CS(this).impulse = 0;
103 }
104}
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().