2 #include "../sv_minigames.qh"
4 #include "../cl_minigames.qh"
9 How to create a minigame
10 ========================
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)
20 int <id>_server_event(entity minigame, string event, ...count)
21 see ../minigames.qh for a detailed explanation
23 void <id>_hud_board(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 <id>_hud_status(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 <id>_client_event(entity minigame, string event, ...count)
31 see ../minigames.qh for a detailed explanation
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:
45 Used when creating a new object, you can use this to define fields that don't change
46 Don't add MINIG_SF_CREATE to SendFlags on your own
48 A miscellaneous update, can be safely used if the entity has just a few fields
50 Starting value for custom flags, since there are bit-wise flags,
51 the following values shall be MINIG_SF_CUSTOM*2, MINIG_SF_CUSTOM*4 and MINIG_SF_CUSTOM*8.
53 Maximum flag value that will be networked
55 Mask matching all possible flags
57 Note: As of now, flags are sent as a single byte
59 Even for non-networked entities, the system provides a system to remove
60 automatically unneeded entities when the minigame is over, the requirement is
61 that .owner is set to the minigame session entity and .minigame_autoclean is true.
74 * Set up automatic entity read/write functionality
75 * To ensure that everything is handled automatically, spawn on the server using msle_spawn
77 * MSLE(classname,Field...) \
78 * classname: Identifier used to recognize the type of the entity
79 * (must be set as .classname on the sent entities)
80 * Field... : List of FIELD calls
81 * FIELD(sendflags, Type, field)
82 * sendflags: Send flags that signal when this field has to be sent
83 * Type : Type of the entity field. Used to determine WriteX/ReadX functions.
84 * Follows a list of accepted values
91 * String Note: strzoned on client
92 * Float Note: implemented as Write/Read Coord
93 * Vector Note: implemented as Write/Read Coord on _x _y _z
94 * Vector2D Note: implemented as Write/Read Coord on _x _y
96 * classname and netname are always sent
97 * MSLE stands for Minigame Simple Linked Entity
99 #define MINIGAME_SIMPLELINKED_ENTITIES \
100 MSLE(minigame_board_piece,FIELD(MINIG_SF_CREATE,Byte,team) FIELD(MINIG_SF_UPDATE, Short, minigame_flags) FIELD(MINIG_SF_UPDATE, Vector2D,origin)) \
101 MSLE(pong_paddle,FIELD(MINIG_SF_CREATE,Byte,team) FIELD(MINIG_SF_CREATE,Float,pong_length) FIELD(MINIG_SF_UPDATE,Vector2D,origin)) \
102 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)) \
103 MSLE(pong_ai, FIELD(MINIG_SF_CREATE,Byte,team) FIELD(PONG_SF_PLAYERSCORE, Long, pong_score)) \