]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/minigames/minigames.qh
Minigame code and cfg
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / minigames / minigames.qh
1 #ifndef MINIGAMES_H
2 #define MINIGAMES_H
3
4 entity minigame_descriptors;
5
6 // previous node in a doubly linked list
7 .entity list_prev;
8 // next node in a linked list
9 .entity list_next;
10
11 entity minigame_get_descriptor(string id);
12
13 // Get letter index of a tile name
14 float minigame_tile_letter(string id);
15
16 // Get number index of a tile name
17 // Note: this is 0 based, useful for mathematical operations
18 // Note: Since the tile notation starts from the bottom left, 
19 //      you may want to do number_of_rows - what_this_function_returns or something
20 float minigame_tile_number(string id);
21
22 // Get relative position of the center of a given tile
23 vector minigame_tile_pos(string id, float rows, float columns);
24
25 // Get a tile name from indices
26 string minigame_tile_buildname(float letter, float number);
27
28 // Get the id of a tile relative to the given one
29 string minigame_relative_tile(string start_id, float dx, float dy, float rows, float columns);
30
31 // Get tile name from a relative position (matches the tile covering a square area)
32 string minigame_tile_name(vector pos, float rows, float columns);
33
34 // Get the next team number (note: team numbers are between 1 and n_teams, inclusive)
35 float minigame_next_team(float curr_team, float n_teams);
36
37 // set send flags only when on server
38 // (for example in game logic which can be used both in client and server
39 void minigame_server_sendflags(entity ent, float mgflags);
40
41 // count the number of players in a minigame session
42 float minigame_count_players(entity minigame);
43
44 /// For minigame sessions: minigame descriptor object
45 .entity descriptor;
46
47 /// For minigame sessions/descriptors: execute the given event
48 /// Client events:
49 ///     mouse_moved(vector mouse_pos)
50 ///                     return 1 to handle input, 0 to discard
51 ///     mouse_pressed/released(float K_Keycode)
52 ///                     return 1 to handle input, 0 to discard
53 ///             note: see dpdefs/keycodes.qc for values
54 ///     key_pressed/released(float K_Keycode)
55 ///             return 1 to handle input, 0 to discard
56 ///             note: see dpdefs/keycodes.qc for values
57 ///     activate()
58 ///             executed when the minigame is activated for the current client
59 ///     deactivate()
60 ///             executed when the minigame is deactivated for the current client
61 ///     network_receive(entity received,float flags)
62 ///             executed each time a networked entity is received
63 ///             note: when this is called self == ...(0,entity)
64 ///             You can use the MINIG_SF_ constants to check the send flags
65 ///             IMPORTANT: always read in client everything you send from the server!
66 ///     menu_show(entity parent_menu_item)
67 ///             executed when the Current Game menu is shown, used to add custom entries
68 ///             Call HUD_MinigameMenu_CustomEntry to do so (pass ...(0,entity) as first argument)
69 ///     menu_click(string arg)
70 ///             executed when a custom menu entry is clicked
71 /// Server events:
72 ///     start()
73 ///             executed when the minigame session is starting
74 ///     end()
75 ///             executed when the minigame session is shutting down
76 ///     join(entity player)
77 ///             executed when a player wants to join the session
78 ///             return the player team number to accept the new player, 0 to discard
79 ///     part(entity player)
80 ///             executed when a player is going to leave the session
81 ///     network_send(entity sent,float flags)
82 ///             executed each time a networked entity is sent
83 ///             note: when this is called self == ...(0,entity)
84 ///             You can use the MINIG_SF_ constants to check the send flags
85 ///             IMPORTANT: always read in client everything you send from the server!
86 ///     cmd(entity minigame_player, float argc, string command)
87 ///             self = client entity triggering this
88 ///             argv(n) = console token 
89 ///             argc: number of console tokens
90 ///             command: full command string
91 ///             triggered when a player does "cmd minigame ..." with some unrecognized command
92 ///             return 1 if the minigame has handled the command
93 ///     impulse(entity minigame_player,float impulse)
94 ///             self = client entity triggering this
95 ///             triggered when a player does "impulse ..."
96 ///             return 1 if the minigame has handled the impulse
97 .float(entity,string,...)   minigame_event;
98
99 // For run-time gameplay entities: Whether to be removed when the game is deactivated
100 .float minigame_autoclean;
101
102 // For run-time gameplay entities: some place to store flags safely
103 .float minigame_flags;
104
105 // Send flags, set to .SendFlags on networked entities to send entity information
106 // Flag values for customized events must be powers of 2 in the range
107 // [MINIG_SF_CUSTOM, MINIG_SF_MAX] (inclusive)
108 const float MINIG_SF_CREATE  = 0x01; // Create a new object
109 const float MINIG_SF_UPDATE  = 0x02; // miscellaneous entity update
110 const float MINIG_SF_CUSTOM  = 0x10; // a customized networked event
111 const float MINIG_SF_MAX     = 0x80; // maximum flag value sent over the network
112 const float MINIG_SF_ALL     = 0xff; // use to resend everything
113
114
115 // Spawn linked entity on the server or local entity on the client
116 // This entity will be removed automatically when the minigame ends
117 entity msle_spawn(entity minigame_session, string class_name);
118
119 #include "minigame/all.qh"
120
121 float msle_id(string class_name);
122 string msle_classname(float id);
123
124 #endif