Xonotic
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)   for(v = kh_worldkeylist; v; v = v.kh_worldkeynext )
 

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

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 148 of file sv_keyhunt.qc.

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

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

149 {
151  kh_controller.cnt = ceil(t);
152  if(t == 0)
153  kh_controller.nextthink = time; // force
154 }
entity kh_controller
Definition: sv_keyhunt.qc:71
var kh_Think_t kh_Controller_Thinkfunc
Definition: sv_keyhunt.qc:147
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ kh_Initialize()

void kh_Initialize ( )

Definition at line 974 of file sv_keyhunt.qc.

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

Referenced by REGISTER_MUTATOR().

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  // make a KH entity for controlling the game
986 
987  setmodel(kh_controller, MDL_KH_KEY);
988  kh_key_dropped = kh_controller.modelindex;
989  /*
990  dprint(vtos(kh_controller.mins));
991  dprint(vtos(kh_controller.maxs));
992  dprint("\n");
993  */
994 #ifdef KH_PLAYER_USE_CARRIEDMODEL
995  setmodel(kh_controller, MDL_KH_KEY_CARRIED);
996  kh_key_carried = kh_controller.modelindex;
997 #else
999 #endif
1000 
1001  kh_controller.model = "";
1002  kh_controller.modelindex = 0;
1003 
1005 }
int autocvar_g_keyhunt_teams_override
Definition: sv_keyhunt.qc:29
int kh_key_dropped
Definition: sv_keyhunt.qc:82
void kh_Controller_Think(entity this)
Definition: sv_keyhunt.qc:156
entity kh_controller
Definition: sv_keyhunt.qc:71
void kh_WaitForPlayers()
Definition: sv_keyhunt.qc:862
void kh_Controller_SetThink(float t, kh_Think_t func)
Definition: sv_keyhunt.qc:148
#define setmodel(this, m)
Definition: model.qh:26
void kh_ScoreRules(int teams)
Definition: sv_keyhunt.qc:87
int kh_key_carried
Definition: sv_keyhunt.qc:82
#define new_pure(class)
purely logical entities (.origin doesn&#39;t work)
Definition: oo.qh:62
#define setthink(e, f)
int kh_teams
Definition: sv_keyhunt.qc:73
#define BITS(n)
Definition: bits.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ kh_StartRound()

void kh_StartRound ( )

Definition at line 911 of file sv_keyhunt.qc.

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

Referenced by kh_FinishRound(), and kh_WaitForPlayers().

912 {
913  if(time < game_starttime)
914  {
915  kh_Controller_SetThink(game_starttime - time + 0.1, kh_WaitForPlayers);
916  return;
917  }
918 
919  if(kh_GetMissingTeams())
920  {
922  return;
923  }
924 
925  Kill_Notification(NOTIF_ALL, NULL, MSG_CENTER, CPID_KEYHUNT);
926  Kill_Notification(NOTIF_ALL, NULL, MSG_CENTER, CPID_KEYHUNT_OTHER);
927 
928  for(int i = 0; i < NumTeams(kh_teams); ++i)
929  {
930  int teem = kh_Team_ByID(i);
931  int players = 0;
932  entity my_player = NULL;
934  if(!IS_DEAD(it) && !PHYS_INPUT_BUTTON_CHAT(it) && it.team == teem)
935  {
936  ++players;
937  if(random() * players <= 1)
938  my_player = it;
939  }
940  });
941  kh_Key_Spawn(my_player, 360 * i / NumTeams(kh_teams), i);
942  }
943 
944  kh_tracking_enabled = false;
945  Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_KEYHUNT_SCAN, autocvar_g_balance_keyhunt_delay_tracking);
947 }
#define PHYS_INPUT_BUTTON_CHAT(s)
Definition: player.qh:155
void kh_Key_Spawn(entity initial_owner, float _angle, float i)
Definition: sv_keyhunt.qc:720
bool kh_tracking_enabled
Definition: sv_keyhunt.qh:32
int NumTeams(int teams)
Definition: scores_rules.qc:17
entity() spawn
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
void kh_WaitForPlayers()
Definition: sv_keyhunt.qc:862
void kh_Controller_SetThink(float t, kh_Think_t func)
Definition: sv_keyhunt.qc:148
float autocvar_g_balance_keyhunt_delay_tracking
Definition: sv_keyhunt.qc:14
int kh_Team_ByID(int t)
Definition: sv_keyhunt.qc:62
int kh_GetMissingTeams()
Definition: sv_keyhunt.qc:845
#define NULL
Definition: post.qh:17
#define IS_DEAD(s)
Definition: utils.qh:26
entity players
Definition: main.qh:43
int kh_teams
Definition: sv_keyhunt.qc:73
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
void kh_EnableTrackingDevice()
Definition: sv_keyhunt.qc:903
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( kh  ,
false   
)

Definition at line 9 of file sv_keyhunt.qh.

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.

10 {
13  {
14  GameRules_teams(true);
18 
19  kh_Initialize();
20  }
21  return 0;
22 }
bool autocvar_g_keyhunt_team_spawns
Definition: sv_keyhunt.qh:6
#define MUTATOR_STATIC()
Definition: base.qh:288
void GameRules_spawning_teams(bool value)
Used to disable team spawns in team modes.
Definition: sv_rules.qc:22
void GameRules_limit_score(int limit)
Definition: sv_rules.qc:34
void kh_Initialize()
Definition: sv_keyhunt.qc:974
int autocvar_g_keyhunt_point_leadlimit
Definition: sv_keyhunt.qh:5
void GameRules_teams(bool value)
Definition: sv_rules.qc:6
#define autocvar_g_keyhunt_point_limit
Definition: sv_keyhunt.qh:4
void GameRules_limit_lead(int limit)
Definition: sv_rules.qc:44
#define MUTATOR_ONADD
Definition: base.qh:284
+ Here is the call graph for this function:

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.