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