4 #include <common/minigames/sv_minigames.qh>
6 #include <common/minigames/cl_minigames.qh>
11 How to create a minigame
12 ========================
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)
22 int <id>_server_event(entity minigame, string event, ...count)
23 see ../minigames.qh for a detailed explanation
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
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:
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
50 A miscellaneous update, can be safely used if the entity has just a few fields
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.
55 Maximum flag value that will be networked
57 Mask matching all possible flags
59 Note: As of now, flags are sent as a single byte
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.
75 * Set up automatic entity read/write functionality
76 * To ensure that everything is handled automatically, spawn on the server using msle_spawn
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
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
97 * classname and netname are always sent
98 * MSLE stands for Minigame Simple Linked Entity
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)) \