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

Go to the source code of this file.

Functions

 int (entity, string,...) minigame_event
 For minigame sessions/descriptors: execute the given event Client events: mouse_moved(vector mouse_pos) return 1 to handle input, 0 to discard mouse_pressed/released(int K_Keycode) return 1 to handle input, 0 to discard note: see dpdefs/keycodes.qc for values key_pressed/released(int K_Keycode) return 1 to handle input, 0 to discard note: see dpdefs/keycodes.qc for values activate() executed when the minigame is activated for the current client deactivate() executed when the minigame is deactivated for the current client network_receive(entity received,int flags) executed each time a networked entity is received note: when this is called self == ...(0,entity) You can use the MINIG_SF_ constants to check the send flags IMPORTANT: always read in client everything you send from the server!
int minigame_count_players (entity minigame)
entity minigame_get_descriptor (string id)
entity minigame_get_owner (int id)
int minigame_next_team (int curr_team, int n_teams)
int minigame_prev_team (int curr_team, int n_teams)
string minigame_relative_tile (string start_id, int dx, int dy, int rows, int columns)
void minigame_server_sendflags (entity ent, int mgflags)
string minigame_tile_buildname (int letter, int number)
int minigame_tile_letter (string id)
string minigame_tile_name (vector pos, int rows, int columns)
int minigame_tile_number (string id)
vector minigame_tile_pos (string id, int rows, int columns)
string msle_classname (int id)
int msle_id (string class_name)
entity msle_spawn (entity minigame_session, entity e)

Variables

entity descriptor
 For minigame sessions: minigame descriptor object.
entity list_next
entity list_prev
const int MINIG_SF_ALL = 0xff
const int MINIG_SF_CREATE = 0x01
const int MINIG_SF_CUSTOM = 0x10
const int MINIG_SF_MAX = 0x80
const int MINIG_SF_UPDATE = 0x02
bool minigame_autoclean
int minigame_flags
int minigame_id
 Unique ID for the minigame session, associated with all objects currently the result of etof(minigame) on the server.

Function Documentation

◆ int()

int ( entity ,
string ,
... )

For minigame sessions/descriptors: execute the given event Client events: mouse_moved(vector mouse_pos) return 1 to handle input, 0 to discard mouse_pressed/released(int K_Keycode) return 1 to handle input, 0 to discard note: see dpdefs/keycodes.qc for values key_pressed/released(int K_Keycode) return 1 to handle input, 0 to discard note: see dpdefs/keycodes.qc for values activate() executed when the minigame is activated for the current client deactivate() executed when the minigame is deactivated for the current client network_receive(entity received,int flags) executed each time a networked entity is received note: when this is called self == ...(0,entity) You can use the MINIG_SF_ constants to check the send flags IMPORTANT: always read in client everything you send from the server!

menu_show(entity parent_menu_item) executed when the Current Game menu is shown, used to add custom entries Call HUD_MinigameMenu_CustomEntry to do so (pass ...(0,entity) as first argument) menu_click(string arg) executed when a custom menu entry is clicked Server events: start() executed when the minigame session is starting end() executed when the minigame session is shutting down join(entity player) executed when a player wants to join the session return the player team number to accept the new player, 0 to discard part(entity player) executed when a player is going to leave the session network_send(entity sent,int flags) executed each time a networked entity is sent note: when this is called self == ...(0,entity) You can use the MINIG_SF_ constants to check the send flags IMPORTANT: always read in client everything you send from the server! cmd(entity minigame_player, int argc, string command) self = client entity triggering this argv(n) = console token argc: number of console tokens command: full command string triggered when a player does "cmd minigame ..." with some unrecognized command return 1 if the minigame has handled the command impulse(entity minigame_player,int impulse) self = client entity triggering this triggered when a player does "impulse ..." return 1 if the minigame has handled the impulse

References entity().

◆ minigame_count_players()

int minigame_count_players ( entity minigame)

Definition at line 132 of file minigames.qc.

133{
134 int pl_num = 0;
135 entity e;
136#ifdef SVQC
137 for(e = minigame.minigame_players; e; e = e.list_next)
138#elif defined(CSQC)
139 e = NULL;
140 while( (e = findfloat(e,minigame_id,minigame.minigame_id)) )
141 if ( e.classname == "minigame_player" )
142#endif
143 ++pl_num;
144 return pl_num;
145}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity findfloat(entity start,.float field, float match)
int minigame_id
Unique ID for the minigame session, associated with all objects currently the result of etof(minigame...
Definition minigames.qh:49
#define NULL
Definition post.qh:14

References entity(), findfloat(), minigame_id, and NULL.

Referenced by bd_server_event(), c4_server_event(), pp_server_event(), ps_server_event(), and ttt_server_event().

◆ minigame_get_descriptor()

entity minigame_get_descriptor ( string id)

Definition at line 5 of file minigames.qc.

6{
7 FOREACH(Minigames, it.netname == id, return it);
8 return NULL;
9}
#define FOREACH(list, cond, body)
Definition iter.qh:19

References entity(), FOREACH, minigame_get_descriptor(), and NULL.

Referenced by HUD_MinigameBoard(), HUD_MinigameStatus(), minigame_get_descriptor(), and start_minigame().

◆ minigame_get_owner()

entity minigame_get_owner ( int id)

Definition at line 11 of file minigames.qc.

12{
13 entity e = NULL;
14 while( (e = findfloat(e, minigame_id, id)) )
15 if ( e.classname == "minigame" )
16 return e;
17 return NULL;
18}

References entity(), findfloat(), minigame_id, and NULL.

Referenced by NET_HANDLE().

◆ minigame_next_team()

int minigame_next_team ( int curr_team,
int n_teams )

Definition at line 74 of file minigames.qc.

75{
76 return curr_team % n_teams + 1;
77}

Referenced by c4_move(), c4_server_event(), pp_move(), pp_server_event(), ttt_move(), and ttt_server_event().

◆ minigame_prev_team()

int minigame_prev_team ( int curr_team,
int n_teams )

Definition at line 80 of file minigames.qc.

81{
82 return curr_team % n_teams - 1;
83}

◆ minigame_relative_tile()

string minigame_relative_tile ( string start_id,
int dx,
int dy,
int rows,
int columns )

Definition at line 49 of file minigames.qc.

50{
51 int letter = minigame_tile_letter(start_id);
52 int number = minigame_tile_number(start_id);
53 letter = (letter+dx) % columns;
54 number = (number+dy) % rows;
55 if ( letter < 0 )
56 letter = columns + letter;
57 if ( number < 0 )
58 number = rows + number;
59 return minigame_tile_buildname(letter, number);
60}
int minigame_tile_letter(string id)
Definition minigames.qc:21
string minigame_tile_buildname(int letter, int number)
Definition minigames.qc:43
int minigame_tile_number(string id)
Definition minigames.qc:30
int int number
Definition impulse.qc:89

References minigame_tile_buildname(), minigame_tile_letter(), minigame_tile_number(), and number.

◆ minigame_server_sendflags()

◆ minigame_tile_buildname()

string minigame_tile_buildname ( int letter,
int number )

◆ minigame_tile_letter()

◆ minigame_tile_name()

string minigame_tile_name ( vector pos,
int rows,
int columns )

Definition at line 63 of file minigames.qc.

64{
65 if ( pos_x < 0 || pos_x > 1 || pos_y < 0 || pos_y > 1 )
66 return ""; // no tile
67
68 int letter = floor(pos_x * columns);
69 int number = floor((1-pos_y) * rows);
70 return minigame_tile_buildname(letter, number);
71}
float floor(float f)

References floor(), minigame_tile_buildname(), number, and vector.

◆ minigame_tile_number()

◆ minigame_tile_pos()

vector minigame_tile_pos ( string id,
int rows,
int columns )

Definition at line 36 of file minigames.qc.

37{
38 return vec2((minigame_tile_letter(id) + 0.5) / columns,
39 (1 - (minigame_tile_number(id) + 0.5) / rows));
40}
#define vec2(...)
Definition vector.qh:95

References minigame_tile_letter(), minigame_tile_number(), vec2, and vector.

Referenced by nmm_spawn_tile().

◆ msle_classname()

string msle_classname ( int id)

Definition at line 121 of file minigames.qc.

122{
123 if ( id == 1 ) return "minigame";
124 if ( id == 2 ) return "minigame_player";
125 int i = msle_base_id;
126#define MSLE(Name, Fields) ++i; if ( id == i ) return #Name;
128#undef MSLE
129 return "";
130}
#define MINIGAME_SIMPLELINKED_ENTITIES
Set up automatic entity read/write functionality To ensure that everything is handled automatically,...
Definition all.qh:100
const int msle_base_id
Definition minigames.qc:109

References MINIGAME_SIMPLELINKED_ENTITIES, and msle_base_id.

Referenced by NET_HANDLE().

◆ msle_id()

int msle_id ( string class_name)

Definition at line 110 of file minigames.qc.

111{
112 if ( class_name == "minigame" ) return 1;
113 if ( class_name == "minigame_player" ) return 2;
114 int i = msle_base_id;
115#define MSLE(Name, Fields) ++i; if ( class_name == #Name ) return i;
117#undef MSLE
118 return 0;
119}

References MINIGAME_SIMPLELINKED_ENTITIES, and msle_base_id.

Referenced by minigame_SendEntity().

◆ msle_spawn()

entity msle_spawn ( entity minigame_session,
entity e )

Definition at line 96 of file minigames.qc.

97{
98 e.owner = minigame_session;
99 e.minigame_id = minigame_session.minigame_id;
100 e.descriptor = minigame_session.descriptor;
101 e.minigame_autoclean = 1;
102 #ifdef SVQC
105 #endif
106 return e;
107}
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
Definition net.qh:167
#define setcefc(e, f)
bool minigame_CheckSend(entity this, entity client)
bool minigame_SendEntity(entity this, entity to, int sf)

References entity(), minigame_CheckSend(), minigame_SendEntity(), Net_LinkEntity(), and setcefc.

Referenced by bd_editor_place(), bd_load_piece(), c4_move(), nmm_server_event(), pong_ai_spawn(), pong_paddle_spawn(), pong_server_event(), pp_move(), pp_setup_pieces(), ps_setup_pieces(), and ttt_move().

Variable Documentation

◆ descriptor

entity descriptor

For minigame sessions: minigame descriptor object.

Definition at line 45 of file minigames.qh.

Referenced by bd_controller_send(), minigame_SendEntity(), and NET_HANDLE().

◆ list_next

entity list_next

Definition at line 6 of file minigames.qh.

Referenced by HUD_MinigameMenu_Click_ExpandCollapse().

◆ list_prev

entity list_prev

Definition at line 4 of file minigames.qh.

◆ MINIG_SF_ALL

const int MINIG_SF_ALL = 0xff

◆ MINIG_SF_CREATE

const int MINIG_SF_CREATE = 0x01

Definition at line 112 of file minigames.qh.

Referenced by minigame_SendEntity(), and NET_HANDLE().

◆ MINIG_SF_CUSTOM

const int MINIG_SF_CUSTOM = 0x10

Definition at line 114 of file minigames.qh.

◆ MINIG_SF_MAX

const int MINIG_SF_MAX = 0x80

Definition at line 115 of file minigames.qh.

◆ MINIG_SF_UPDATE

◆ minigame_autoclean

bool minigame_autoclean

Definition at line 104 of file minigames.qh.

◆ minigame_flags

int minigame_flags

Definition at line 107 of file minigames.qh.

Referenced by minigame_SendEntity(), and NET_HANDLE().

◆ minigame_id