Xonotic
sv_random_gravity.qc
Go to the documentation of this file.
1 #include "sv_random_gravity.qh"
2 
3 // Random Gravity
4 
5 // Mutator by Mario
6 // Inspired by Player 2
7 
14 
15 REGISTER_MUTATOR(random_gravity, cvar("g_random_gravity"))
16 {
18  {
19  cvar_settemp("sv_gravity", cvar_string("sv_gravity")); // settemp current gravity so it's restored on match end
20  }
21 }
22 
23 float gravity_delay;
24 
25 MUTATOR_HOOKFUNCTION(random_gravity, SV_StartFrame)
26 {
27  if(game_stopped || !cvar("g_random_gravity")) return false;
28  if(time < gravity_delay) return false;
29  if(time < game_starttime) return false;
31 
34  else
36 
37  gravity_delay = time + autocvar_g_random_gravity_delay;
38 
39  LOG_TRACE("Gravity is now: ", ftos(autocvar_sv_gravity));
40 }
41 
42 MUTATOR_HOOKFUNCTION(random_gravity, BuildMutatorsString)
43 {
44  M_ARGV(0, string) = strcat(M_ARGV(0, string), ":RandomGravity");
45 }
46 
47 MUTATOR_HOOKFUNCTION(random_gravity, BuildMutatorsPrettyString)
48 {
49  M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Random gravity");
50 }
#define round_handler_IsActive()
MUTATOR_HOOKFUNCTION(random_gravity, SV_StartFrame)
#define REGISTER_MUTATOR(id, dependence)
Definition: base.qh:263
float cvar_settemp(string tmp_cvar, string tmp_value)
Definition: util.qc:696
#define round_handler_IsRoundStarted()
float autocvar_g_random_gravity_delay
float autocvar_g_random_gravity_negative_chance
float autocvar_g_random_gravity_max
float autocvar_g_random_gravity_negative
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
float autocvar_g_random_gravity_positive
#define M_ARGV(x, type)
Definition: events.qh:17
float autocvar_g_random_gravity_min
#define LOG_TRACE(...)
Definition: log.qh:81
#define MUTATOR_ONADD
Definition: base.qh:284
float time
Definition: csprogsdefs.qc:16