Xonotic
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! 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. More...
 
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. More...
 
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.

◆ minigame_count_players()

int minigame_count_players ( entity  minigame)

Definition at line 121 of file minigames.qc.

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

Referenced by bd_close_editor(), c4_move(), pp_next_match(), ps_move(), and ttt_next_match().

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 }
entity() spawn
entity owner
Definition: main.qh:73
#define NULL
Definition: post.qh:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ minigame_get_descriptor()

entity minigame_get_descriptor ( string  id)

Definition at line 5 of file minigames.qc.

References FOREACH, and NULL.

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

6 {
7  FOREACH(Minigames, it.netname == id, return it);
8  return NULL;
9 }
#define NULL
Definition: post.qh:17
#define FOREACH(list, cond, body)
Definition: iter.qh:19
+ Here is the caller graph for this function:

◆ minigame_next_team()

int minigame_next_team ( int  curr_team,
int  n_teams 
)

Definition at line 65 of file minigames.qc.

Referenced by c4_move(), pp_move(), pp_next_match(), ttt_move(), and ttt_next_match().

66 {
67  return curr_team % n_teams + 1;
68 }
+ Here is the caller graph for this function:

◆ 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.

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

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_number(string id)
Definition: minigames.qc:21
int int number
Definition: impulse.qc:89
int minigame_tile_letter(string id)
Definition: minigames.qc:12
string minigame_tile_buildname(int letter, int number)
Definition: minigames.qc:34
+ Here is the call graph for this function:

◆ minigame_server_sendflags()

void minigame_server_sendflags ( entity  ent,
int  mgflags 
)

Definition at line 78 of file minigames.qc.

Referenced by bd_activate_editor(), bd_check_winner(), bd_close_editor(), bd_controller_update(), bd_do_next_match(), bd_editor_place(), bd_load_piece(), bd_move(), bd_move_dozer(), bd_reset_moves(), bd_restart_match(), c4_move(), pp_move(), pp_next_match(), pp_setup_pieces(), ps_move(), ps_move_piece(), ps_setup_pieces(), ttt_move(), and ttt_next_match().

79 {
80  #ifdef SVQC
81  ent.SendFlags |= mgflags;
82  #endif
83 }
+ Here is the caller graph for this function:

◆ minigame_tile_buildname()

string minigame_tile_buildname ( int  letter,
int  number 
)

Definition at line 34 of file minigames.qc.

References chr2str, ftos(), and strcat().

Referenced by bd_close_editor(), bd_fill_recurse(), bd_move_dozer(), bd_save_controller_piece(), bd_unfill_recurse(), c4_get_lowest_tile(), c4_winning_piece(), minigame_relative_tile(), minigame_tile_name(), nmm_spawn_tile_square(), nmm_tile_build_hmill(), nmm_tile_build_vmill(), pp_setup_pieces(), pp_valid_move(), pp_winning_piece(), ps_move(), ps_move_piece(), ps_setup_pieces(), ps_winning_piece(), and ttt_winning_piece().

35 {
36  return strcat(chr2str('a'+letter),ftos(number+1));
37 }
int int number
Definition: impulse.qc:89
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define chr2str
Definition: dpextensions.qh:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ minigame_tile_letter()

int minigame_tile_letter ( string  id)

Definition at line 12 of file minigames.qc.

References str2chr, and substring().

Referenced by bd_close_editor(), bd_do_fill(), bd_editor_place(), bd_load_piece(), bd_move_dozer(), bd_valid_tile(), c4_get_lowest_tile(), c4_valid_tile(), c4_winning_piece(), minigame_relative_tile(), minigame_tile_pos(), nmm_tile_adjacent(), nmm_tile_build_hmill(), nmm_tile_build_vmill(), pp_valid_move(), pp_valid_tile(), pp_winning_piece(), ps_move(), ps_tile_blacklisted(), ps_valid_tile(), ps_winning_piece(), ttt_valid_tile(), and ttt_winning_piece().

13 {
14  return str2chr(substring(id,0,1),0)-'a';
15 }
#define str2chr
Definition: dpextensions.qh:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ minigame_tile_name()

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

Definition at line 54 of file minigames.qc.

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

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 }
int int number
Definition: impulse.qc:89
string minigame_tile_buildname(int letter, int number)
Definition: minigames.qc:34
+ Here is the call graph for this function:

◆ minigame_tile_number()

int minigame_tile_number ( string  id)

Definition at line 21 of file minigames.qc.

References stof(), and substring().

Referenced by bd_close_editor(), bd_do_fill(), bd_editor_place(), bd_load_piece(), bd_move_dozer(), bd_valid_tile(), c4_valid_tile(), c4_winning_piece(), minigame_relative_tile(), minigame_tile_pos(), nmm_tile_adjacent(), nmm_tile_build_hmill(), nmm_tile_build_vmill(), pp_valid_move(), pp_valid_tile(), pp_winning_piece(), ps_move(), ps_tile_blacklisted(), ps_valid_tile(), ps_winning_piece(), ttt_valid_tile(), and ttt_winning_piece().

22 {
23  return stof(substring(id,1,-1)) -1 ;
24 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ minigame_tile_pos()

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

Definition at line 27 of file minigames.qc.

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

Referenced by bd_close_editor(), c4_move(), nmm_spawn_tile(), pp_next_match(), ps_move(), and ttt_next_match().

28 {
29  return vec2((minigame_tile_letter(id) + 0.5) / columns,
30  (1 - (minigame_tile_number(id) + 0.5) / rows));
31 }
int minigame_tile_number(string id)
Definition: minigames.qc:21
int minigame_tile_letter(string id)
Definition: minigames.qc:12
#define vec2(...)
Definition: vector.qh:90
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msle_classname()

string msle_classname ( int  id)

Definition at line 110 of file minigames.qc.

References MINIGAME_SIMPLELINKED_ENTITIES, and msle_base_id.

Referenced by NET_HANDLE().

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 }
const int msle_base_id
Definition: minigames.qc:98
#define MINIGAME_SIMPLELINKED_ENTITIES
How to create a minigame
Definition: all.qh:100
+ Here is the caller graph for this function:

◆ msle_id()

int msle_id ( string  class_name)

Definition at line 99 of file minigames.qc.

References MINIGAME_SIMPLELINKED_ENTITIES, and msle_base_id.

Referenced by minigame_SendEntity().

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 }
const int msle_base_id
Definition: minigames.qc:98
#define MINIGAME_SIMPLELINKED_ENTITIES
How to create a minigame
Definition: all.qh:100
+ Here is the caller graph for this function:

◆ msle_spawn()

entity msle_spawn ( entity  minigame_session,
entity  e 
)

Definition at line 87 of file minigames.qc.

References minigame_CheckSend(), and minigame_SendEntity().

Referenced by bd_editor_place(), bd_load_piece(), c4_move(), nmm_in_mill(), pp_move(), pp_setup_pieces(), ps_setup_pieces(), and ttt_move().

88 {
89  e.owner = minigame_session;
90  e.minigame_autoclean = 1;
91  #ifdef SVQC
92  setcefc(e, minigame_CheckSend);
93  Net_LinkEntity(e, false, 0, minigame_SendEntity);
94  #endif
95  return e;
96 }
bool minigame_CheckSend(entity this, entity client)
bool minigame_SendEntity(entity this, entity to, int sf)
Definition: sv_minigames.qc:64
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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