4 // Inspired by Player 2
8 MUTATOR_HOOKFUNCTION(gravity_StartFrame)
10 if(gameover || !cvar("g_random_gravity")) return FALSE;
11 if(time < gravity_delay) return FALSE;
12 if(time < game_starttime) return FALSE;
13 if(round_handler_IsActive() && !round_handler_IsRoundStarted()) return FALSE;
15 if(random() >= autocvar_g_random_gravity_negative_chance)
16 cvar_set("sv_gravity", ftos(bound(autocvar_g_random_gravity_min, random() - random() * -autocvar_g_random_gravity_negative, autocvar_g_random_gravity_max)));
18 cvar_set("sv_gravity", ftos(bound(autocvar_g_random_gravity_min, random() * autocvar_g_random_gravity_positive, autocvar_g_random_gravity_max)));
20 gravity_delay = time + autocvar_g_random_gravity_delay;
22 dprint("Gravity is now: ", ftos(autocvar_sv_gravity), "\n");
27 MUTATOR_HOOKFUNCTION(gravity_BuildMutatorsString)
29 ret_string = strcat(ret_string, ":RandomGravity");
33 MUTATOR_HOOKFUNCTION(gravity_BuildMutatorsPrettyString)
35 ret_string = strcat(ret_string, ", Random gravity");
39 MUTATOR_DEFINITION(mutator_random_gravity)
41 MUTATOR_HOOK(SV_StartFrame, gravity_StartFrame, CBC_ORDER_ANY);
42 MUTATOR_HOOK(BuildMutatorsString, gravity_BuildMutatorsString, CBC_ORDER_ANY);
43 MUTATOR_HOOK(BuildMutatorsPrettyString, gravity_BuildMutatorsPrettyString, CBC_ORDER_ANY);
47 cvar_settemp("sv_gravity", cvar_string("sv_gravity")); // settemp current gravity so it's restored on match end