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

Go to the source code of this file.

Macros

#define autocvar_g_keyhunt_point_limit   cvar("g_keyhunt_point_limit")
#define FOR_EACH_KH_KEY(v)

Typedefs

using kh_Think_t = void()

Functions

void kh_Controller_SetThink (float t, kh_Think_t func)
void kh_Initialize ()
void kh_StartRound ()
 REGISTER_MUTATOR (kh, false)

Variables

int autocvar_g_keyhunt_point_leadlimit
bool autocvar_g_keyhunt_team_spawns
entity kh_next
bool kh_tracking_enabled
entity kh_worldkeylist
entity kh_worldkeynext

Macro Definition Documentation

◆ autocvar_g_keyhunt_point_limit

#define autocvar_g_keyhunt_point_limit   cvar("g_keyhunt_point_limit")

Definition at line 4 of file sv_keyhunt.qh.

Referenced by REGISTER_MUTATOR().

◆ FOR_EACH_KH_KEY

#define FOR_EACH_KH_KEY ( v)
Value:
for(v = kh_worldkeylist; v; v = v.kh_worldkeynext )
entity kh_worldkeylist
Definition sv_keyhunt.qh:24

Definition at line 27 of file sv_keyhunt.qh.

Referenced by kh_FinishRound(), kh_Key_AllOwnedByWhichTeam(), kh_Key_AssignTo(), kh_Key_Think(), kh_LoserTeam(), kh_update_state(), kh_WinnerTeam(), and MUTATOR_HOOKFUNCTION().

Typedef Documentation

◆ kh_Think_t

using kh_Think_t = void()

Definition at line 35 of file sv_keyhunt.qh.

Function Documentation

◆ kh_Controller_SetThink()

void kh_Controller_SetThink ( float t,
kh_Think_t func )

Definition at line 155 of file sv_keyhunt.qc.

156{
158 kh_controller.cnt = ceil(t);
159 if(t == 0)
160 kh_controller.nextthink = time; // force
161}
float time
float ceil(float f)
var kh_Think_t kh_Controller_Thinkfunc
entity kh_controller
Definition sv_keyhunt.qc:76

References ceil(), kh_controller, kh_Controller_Thinkfunc, and time.

Referenced by kh_FinishRound(), kh_Initialize(), kh_StartRound(), and kh_WaitForPlayers().

◆ kh_Initialize()

void kh_Initialize ( )

Definition at line 974 of file sv_keyhunt.qc.

975{
976 // setup variables
978 if(kh_teams < 2)
979 kh_teams = cvar("g_keyhunt_teams"); // read the cvar directly as it gets written earlier in the same frame
980 kh_teams = BITS(bound(2, kh_teams, 4));
981
982 // use a temp entity to avoid linking kh_controller to the world with setmodel
983 entity tmp_ent = spawn();
984 setmodel(tmp_ent, MDL_KH_KEY);
985 kh_key_dropped = tmp_ent.modelindex;
986
987#ifdef KH_PLAYER_USE_CARRIEDMODEL
988 setmodel(tmp_ent, MDL_KH_KEY_CARRIED);
989 kh_key_carried = tmp_ent.modelindex;
990#else
992#endif
993
994 delete(tmp_ent);
995
996 // make a KH entity for controlling the game
1000
1002}
#define BITS(n)
Definition bits.qh:9
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define setmodel(this, m)
Definition model.qh:26
#define spawn
float bound(float min, float value, float max)
float cvar(string name)
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:67
#define setthink(e, f)
void kh_ScoreRules(int teams)
Definition sv_keyhunt.qc:91
int autocvar_g_keyhunt_teams_override
Definition sv_keyhunt.qc:35
void kh_Controller_Think(entity this)
int kh_key_dropped
Definition sv_keyhunt.qc:86
void kh_Controller_SetThink(float t, kh_Think_t func)
int kh_key_carried
Definition sv_keyhunt.qc:86
void kh_WaitForPlayers()
int kh_teams
Definition sv_keyhunt.qc:77

References autocvar_g_keyhunt_teams_override, BITS, bound(), cvar(), entity(), kh_controller, kh_Controller_SetThink(), kh_Controller_Think(), kh_key_carried, kh_key_dropped, kh_ScoreRules(), kh_teams, kh_WaitForPlayers(), new_pure, setmodel, setthink, and spawn.

Referenced by REGISTER_MUTATOR().

◆ kh_StartRound()

void kh_StartRound ( )

Definition at line 908 of file sv_keyhunt.qc.

909{
910 if(time < game_starttime)
911 {
913 return;
914 }
915
917 {
919 return;
920 }
921
922 Kill_Notification(NOTIF_ALL, NULL, MSG_CENTER, CPID_KEYHUNT);
923 Kill_Notification(NOTIF_ALL, NULL, MSG_CENTER, CPID_KEYHUNT_OTHER);
924
925 for(int i = 0; i < NumTeams(kh_teams); ++i)
926 {
927 int teem = kh_Team_ByID(i);
928 int players = 0;
929 entity my_player = NULL;
931 if(!IS_DEAD(it) && !PHYS_INPUT_BUTTON_CHAT(it) && it.team == teem)
932 {
933 ++players;
934 if(random() * players <= 1)
935 my_player = it;
936 }
937 });
938 kh_Key_Spawn(my_player, 360 * i / NumTeams(kh_teams), i);
939 }
940
941 kh_tracking_enabled = false;
943 {
944 Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_KEYHUNT_SCAN, autocvar_g_balance_keyhunt_delay_tracking);
946 }
947}
entity players
Definition main.qh:57
#define IS_DEAD(s)
Definition player.qh:245
#define PHYS_INPUT_BUTTON_CHAT(s)
Definition player.qh:159
#define IS_PLAYER(s)
Definition player.qh:243
float game_starttime
Definition stats.qh:82
float random(void)
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573
void Kill_Notification(NOTIF broadcast, entity client, MSG net_type, CPID net_cpid)
Definition all.qc:1537
#define NULL
Definition post.qh:14
int NumTeams(int teams)
void kh_EnableTrackingDevice()
int kh_Team_ByID(int t)
Definition sv_keyhunt.qc:67
int kh_GetMissingTeams()
void kh_Key_Spawn(entity initial_owner, float _angle, float i)
float autocvar_g_balance_keyhunt_delay_tracking
Definition sv_keyhunt.qc:15
bool kh_tracking_enabled
Definition sv_keyhunt.qh:32
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50

References autocvar_g_balance_keyhunt_delay_tracking, entity(), FOREACH_CLIENT, game_starttime, IS_DEAD, IS_PLAYER, kh_Controller_SetThink(), kh_EnableTrackingDevice(), kh_GetMissingTeams(), kh_Key_Spawn(), kh_Team_ByID(), kh_teams, kh_tracking_enabled, kh_WaitForPlayers(), Kill_Notification(), NULL, NumTeams(), PHYS_INPUT_BUTTON_CHAT, players, random(), Send_Notification(), and time.

Referenced by kh_FinishRound(), and kh_WaitForPlayers().

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( kh ,
false  )

Definition at line 9 of file sv_keyhunt.qh.

10{
13 {
14 GameRules_teams(true);
18
20 }
21 return 0;
22}
#define MUTATOR_ONADD
Definition base.qh:309
#define MUTATOR_STATIC()
Definition base.qh:313
bool autocvar_g_keyhunt_team_spawns
Definition sv_keyhunt.qh:6
#define autocvar_g_keyhunt_point_limit
Definition sv_keyhunt.qh:4
int autocvar_g_keyhunt_point_leadlimit
Definition sv_keyhunt.qh:5
void kh_Initialize()
void GameRules_limit_score(int limit)
Definition sv_rules.qc:23
void GameRules_teams(bool value)
Definition sv_rules.qc:3
void GameRules_limit_lead(int limit)
Definition sv_rules.qc:33
#define GameRules_spawning_teams(value)
Used to disable team spawns in team modes.
Definition sv_rules.qh:35

References autocvar_g_keyhunt_point_leadlimit, autocvar_g_keyhunt_point_limit, autocvar_g_keyhunt_team_spawns, GameRules_limit_lead(), GameRules_limit_score(), GameRules_spawning_teams, GameRules_teams(), kh_Initialize(), MUTATOR_ONADD, and MUTATOR_STATIC.

Variable Documentation

◆ autocvar_g_keyhunt_point_leadlimit

int autocvar_g_keyhunt_point_leadlimit

Definition at line 5 of file sv_keyhunt.qh.

Referenced by REGISTER_MUTATOR().

◆ autocvar_g_keyhunt_team_spawns

bool autocvar_g_keyhunt_team_spawns

Definition at line 6 of file sv_keyhunt.qh.

Referenced by REGISTER_MUTATOR().

◆ kh_next

entity kh_next

Definition at line 33 of file sv_keyhunt.qh.

◆ kh_tracking_enabled

◆ kh_worldkeylist

entity kh_worldkeylist

Definition at line 24 of file sv_keyhunt.qh.

Referenced by havocbot_goalrating_kh(), kh_Key_Remove(), and kh_Key_Spawn().

◆ kh_worldkeynext

entity kh_worldkeynext

Definition at line 25 of file sv_keyhunt.qh.