]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/minigames/minigame/all.qh
Use int and bool in minigame code
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / minigames / minigame / all.qh
1 #if defined(SVQC)
2 #include "../sv_minigames.qh"
3 #elif defined(CSQC)
4 #include "../cl_minigames.qh"
5 #endif
6
7 /**
8
9 How to create a minigame
10 ========================
11
12 Create a file for your minigame in this directory and #include it here.
13 (ttt.qc implements tic tac toe and can be used as an example)
14 and add your minigame to REGISTERED_MINIGAMES (see below)
15
16 Required functions
17 ------------------
18
19 SVQC:
20         int minigame_event_<id>(entity minigame, string event, ...count)
21                 see ../minigames.qh for a detailed explanation
22 CSQC:
23         void minigame_hud_board_<id>(vector pos, vector mySize)
24                 draws the main game board inside the rectangle defined by pos and mySize
25                 (That rectangle is expressed in window coordinates)
26         void minigame_hud_status_<id>(vector pos, vector mySize)
27                 draws the game status panel inside the rectangle defined by pos and mySize
28                 (That rectangle is expressed in window coordinates)
29                 This panel shows eg scores, captured pieces and so on
30         int minigame_event_<id>(entity minigame, string event, ...count)
31                 see ../minigames.qh for a detailed explanation
32
33 Managing entities
34 -----------------
35
36 You can link entities without having to worry about them if their classname
37 has been defined in MINIGAME_SIMPLELINKED_ENTITIES (see below)
38 Such entities can be spawned with msle_spawn and the system
39 will handle networking and cleanup automatically.
40 You'll still need to set .SendFlags according to what you specified in FIELD
41 in order for them to be sent, ../minigames.qh defines some constants to be
42 used as send flags for minigame entities:
43
44 * MINIG_SF_CREATE
45         Used when creating a new object, you can use this to define fields that don't change
46 * MINIG_SF_UPDATE
47         A miscellaneous update, can be safely used if the entity has just a few fields
48 * MINIG_SF_CUSTOM
49         Starting value for custom flags, since there are bit-wise flags, 
50         the following values shall be MINIG_SF_CUSTOM*2, MINIG_SF_CUSTOM*4 and MINIG_SF_CUSTOM*8.
51 * MINIG_SF_MAX
52         Maximum flag value that will be networked
53 * MINIG_SF_ALL
54         Mask matching all possible flags
55
56 Note: As of now, flags are sent as a single byte
57
58 Even for non-networked entities, the system provides a system to remove
59 automatically unneeded entities when the minigame is over, the requirement is
60 that .owner is set to the minigame session entity and .minigame_autoclean is true.
61 */
62
63 #include "nmm.qc"
64 #include "ttt.qc"
65
66 /**
67  * Registration:
68  *      MINIGAME(id,"Name")
69  *              id    (QuakeC symbol) Game identifier, used to find the functions explained above
70  *              "Name"(String)        Human readable name for the game, shown in the UI
71  */
72 #define REGISTERED_MINIGAMES \
73         MINIGAME(nmm, "Nine Men's Morris") \
74         MINIGAME(ttt, "Tic Tac Toe") \
75         /*empty line*/
76
77 /**
78  * Set up automatic entity read/write functionality
79  * To ensure that everything is handled automatically, spawn on the server using msle_spawn
80  * Syntax:
81  *      MSLE(classname,Field...) \ 
82  *              classname: Identifier used to recognize the type of the entity
83  *                         (must be set as .classname on the sent entities)
84  *              Field... : List of FIELD calls
85  *      FIELD(sendflags, Type, field)
86  *              sendflags: Send flags that signal when this field has to be sent
87  *              Type     : Type of the entity field. Used to determine WriteX/ReadX functions.
88  *                         Follows a list of accepted values
89  *                      Byte
90  *                      Char
91  *                      Short
92  *                      Long
93  *                      Coord
94  *                      Angle
95  *                      String   Note: strzoned on client
96  *                      Float    Note: implemented as Write/Read Coord
97  *                      Vector   Note: implemented as Write/Read Coord on _x _y _z
98  *                      Vector2D Note: implemented as Write/Read Coord on _x _y
99  * Note:
100  *      classname and netname are always sent
101  *      MSLE stands for Minigame Simple Linked Entity
102  */
103 #define MINIGAME_SIMPLELINKED_ENTITIES \
104         MSLE(minigame_board_piece,FIELD(MINIG_SF_CREATE,Byte,team) FIELD(MINIG_SF_UPDATE, Short, minigame_flags) FIELD(MINIG_SF_UPDATE, Vector2D,origin)) \
105         /*empty line*/