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)
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

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 121 of file minigames.qc.

122{
123 int pl_num = 0;
124 entity e;
125#ifdef SVQC
126 for(e = minigame.minigame_players; e; e = e.list_next)
127#elif defined(CSQC)
128 e = NULL;
129 while( (e = findentity(e,owner,minigame)) )
130 if ( e.classname == "minigame_player" )
131#endif
132 pl_num++;
133 return pl_num;
134}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity owner
Definition main.qh:87
entity findentity(entity start,.entity field, entity match)
#define NULL
Definition post.qh:14

References entity(), findentity(), NULL, and owner.

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(), NET_HANDLE(), and start_minigame().

◆ minigame_next_team()

int minigame_next_team ( int curr_team,
int n_teams )

Definition at line 65 of file minigames.qc.

66{
67 return curr_team % n_teams + 1;
68}

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 71 of file minigames.qc.

72{
73 return curr_team % n_teams - 1;
74}

◆ minigame_relative_tile()

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

Definition at line 40 of file minigames.qc.

41{
42 int letter = minigame_tile_letter(start_id);
43 int number = minigame_tile_number(start_id);
44 letter = (letter+dx) % columns;
45 number = (number+dy) % rows;
46 if ( letter < 0 )
47 letter = columns + letter;
48 if ( number < 0 )
49 number = rows + number;
50 return minigame_tile_buildname(letter, number);
51}
int minigame_tile_letter(string id)
Definition minigames.qc:12
string minigame_tile_buildname(int letter, int number)
Definition minigames.qc:34
int minigame_tile_number(string id)
Definition minigames.qc:21
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 54 of file minigames.qc.

55{
56 if ( pos_x < 0 || pos_x > 1 || pos_y < 0 || pos_y > 1 )
57 return ""; // no tile
58
59 int letter = floor(pos_x * columns);
60 int number = floor((1-pos_y) * rows);
61 return minigame_tile_buildname(letter, number);
62}
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 27 of file minigames.qc.

28{
29 return vec2((minigame_tile_letter(id) + 0.5) / columns,
30 (1 - (minigame_tile_number(id) + 0.5) / rows));
31}
#define vec2(...)
Definition vector.qh:90

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 110 of file minigames.qc.

111{
112 if ( id == 1 ) return "minigame";
113 if ( id == 2 ) return "minigame_player";
114 int i = msle_base_id;
115#define MSLE(Name, Fields) i++; if ( id == i ) return #Name;
117#undef MSLE
118 return "";
119}
#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:98

References MINIGAME_SIMPLELINKED_ENTITIES, and msle_base_id.

Referenced by NET_HANDLE().

◆ msle_id()

int msle_id ( string class_name)

Definition at line 99 of file minigames.qc.

100{
101 if ( class_name == "minigame" ) return 1;
102 if ( class_name == "minigame_player" ) return 2;
103 int i = msle_base_id;
104#define MSLE(Name, Fields) i++; if ( class_name == #Name ) return i;
106#undef MSLE
107 return 0;
108}

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 87 of file minigames.qc.

88{
89 e.owner = minigame_session;
90 e.minigame_autoclean = 1;
91 #ifdef SVQC
94 #endif
95 return e;
96}
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
Definition net.qh:123
#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 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 108 of file minigames.qh.

Referenced by minigame_SendEntity(), and NET_HANDLE().

◆ MINIG_SF_CUSTOM

const int MINIG_SF_CUSTOM = 0x10

Definition at line 110 of file minigames.qh.

◆ MINIG_SF_MAX

const int MINIG_SF_MAX = 0x80

Definition at line 111 of file minigames.qh.

◆ MINIG_SF_UPDATE

◆ minigame_autoclean

bool minigame_autoclean

Definition at line 100 of file minigames.qh.

◆ minigame_flags

int minigame_flags

Definition at line 103 of file minigames.qh.

Referenced by minigame_SendEntity(), and NET_HANDLE().