]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/minigames/minigames.qh
Merge branch 'TimePath/globalforces' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / minigames / minigames.qh
1 #pragma once
2
3 // previous node in a doubly linked list
4 .entity list_prev;
5 // next node in a linked list
6 .entity list_next;
7
8 entity minigame_get_descriptor(string id);
9
10 // Get letter index of a tile name
11 int minigame_tile_letter(string id);
12
13 // Get number index of a tile name
14 // Note: this is 0 based, useful for mathematical operations
15 // Note: Since the tile notation starts from the bottom left,
16 //      you may want to do number_of_rows - what_this_function_returns or something
17 int minigame_tile_number(string id);
18
19 // Get relative position of the center of a given tile
20 vector minigame_tile_pos(string id, int rows, int columns);
21
22 // Get a tile name from indices
23 string minigame_tile_buildname(int letter, int number);
24
25 // Get the id of a tile relative to the given one
26 string minigame_relative_tile(string start_id, int dx, int dy, int rows, int columns);
27
28 // Get tile name from a relative position (matches the tile covering a square area)
29 string minigame_tile_name(vector pos, int rows, int columns);
30
31 // Get the next team number (note: team numbers are between 1 and n_teams, inclusive)
32 int minigame_next_team(int curr_team, int n_teams);
33
34 // Get the previous team number
35 int minigame_prev_team(int curr_team, int 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, int mgflags);
40
41 // count the number of players in a minigame session
42 int 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(int K_Keycode)
52 ///                     return 1 to handle input, 0 to discard
53 ///             note: see dpdefs/keycodes.qc for values
54 ///     key_pressed/released(int 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,int 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,int 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, int 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,int 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 .int(entity,string,...)   minigame_event;
98
99 // For run-time gameplay entities: Whether to be removed when the game is deactivated
100 .bool minigame_autoclean;
101
102 // For run-time gameplay entities: some place to store flags safely
103 .int 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 int MINIG_SF_CREATE  = 0x01; // Create a new object
109 const int MINIG_SF_UPDATE  = 0x02; // miscellaneous entity update
110 const int MINIG_SF_CUSTOM  = 0x10; // a customized networked event
111 const int MINIG_SF_MAX     = 0x80; // maximum flag value sent over the network
112 const int 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 int msle_id(string class_name);
122 string msle_classname(int id);