Nuclide
Software Development Kit for id Technology (BETA)
GameRules.h
1/*
2 * Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
151{
152public:
153 void ncRuleDelegate(void);
154
155 /* overrides */
156 virtual void Save(float);
157 virtual void Restore(string,string);
158 virtual void RestoreComplete(void);
159 virtual void Input(entity, string, string);
160
162 virtual void InitPostEnts(void);
163
164 /* logic */
166 virtual void Precache(void);
167
169 virtual void FrameStart(void);
171 virtual bool ConsoleCommand(ncPlayer,string);
173 virtual bool ClientCommand(ncClient,string);
175 virtual bool ImpulseCommand(ncClient, float);
176
177 /* client */
179 virtual void PlayerConnect(ncPlayer);
181 virtual void PlayerDisconnect(ncPlayer);
183 virtual void PlayerKill(ncPlayer);
185 virtual void PlayerSpawn(ncPlayer);
187 virtual void PlayerPreFrame(ncPlayer);
189 virtual void PlayerPostFrame(ncPlayer);
191 virtual void PlayerDeath(ncPlayer, ncEntity, ncEntity, string);
193 virtual void PlayerPain(ncPlayer, ncActor, ncDict);
195 virtual bool PlayerCanAttack(ncPlayer);
197 virtual void NPCDeath(ncActor, ncEntity, ncEntity);
198
203 virtual bool PlayerRequestRespawn(ncPlayer);
204
207 virtual bool PlayerRequestTeam(ncPlayer, int team);
208
209 /* level transitions */
211 virtual void LevelNewParms(void);
213 virtual void LevelChangeParms(ncPlayer);
214
215 /* Entities/Item manipulation */
217 virtual int MaxItemPerSlot(int);
219 virtual bool MonstersSpawn(void);
220
221 /* end of a game */
223 virtual void IntermissionStart(void);
225 virtual void IntermissionCycle(void);
227 virtual void IntermissionEnd(void);
229 virtual void IntermissionToPlayer(ncPlayer);
231 virtual bool InIntermission(void);
232
234 virtual bool IsTeamplay(void);
236 virtual bool IsMultiplayer(void);
237
238
239 /* chat related methods */
242 virtual void ChatMessageAll(ncClient, string);
243
246 virtual void ChatMessageTeam(ncClient, string);
247
249 virtual string Title(void);
250
251 nonvirtual void LinkProgs(void);
252 nonvirtual ncRuleDelegate ActiveInstance(void);
253
254 /* spectator */
255 /*
256 virtual void SpectatorConnect(ncPlayer);
257 virtual void SpectatorDisconnect(ncPlayer);
258 virtual void SpectatorThink(ncPlayer);
259 */
260private:
261 int m_iIntermission;
262 float m_flIntermissionTime;
263 float m_flIntermissionCycle;
264 entity m_eIntermissionPoint;
265};
266
267/* our currently running mode */
268ncRuleDelegate g_grMode;
269var float g_ruleCProgs;
270var string g_ruleCName;
271
272#define CGameRules ncRuleDelegate
273#define RULEMAP(x, y, z) x.y = externvalue(g_ruleCProgs, z); if (!x.y) { x.y = ncRuleDelegate::y; }
274
275void RuleC_Init(void);
This entity class represents an object with choreographed/free-form movement.
Definition: Actor.h:93
This entity class is the lowest client/player class.
Definition: Client.h:26
This class is responsible for handling groups of key/value pairs.
Definition: Dict.h:42
ncEntity is the lowest of the user-accessible entity class.
Definition: Entity.h:75
This class is responsible for handling core entity functionality.
Definition: IO.h:78
This entity class represents every player client.
Definition: Player.h:142
This class represents active gamerules.
Definition: GameRules.h:151
virtual void FrameStart(void)
Overridable: Called every server frame.
Definition: GameRules.qc:93
virtual void PlayerDisconnect(ncPlayer)
Overridable: Called when a ncPlayer leaves the server.
Definition: GameRules.qc:126
virtual void IntermissionToPlayer(ncPlayer)
Run to send a specific player to an intermission.
Definition: GameRules.qc:287
virtual void InitPostEnts(void)
Overridable: Called when all map entities have initialized.
Definition: GameRules.qc:82
virtual int MaxItemPerSlot(int)
Overridable: Returns how many items players can carry in a given slot.
Definition: GameRules.qc:215
virtual void LevelNewParms(void)
Overridable: Called to set up new level parms for any ncPlayer.
Definition: GameRules.qc:187
virtual void PlayerPreFrame(ncPlayer)
Overridable: Called before running physics on the ncPlayer in question.
Definition: GameRules.qc:175
virtual void NPCDeath(ncActor, ncEntity, ncEntity)
Overridable:: Called when an NPC gets killed.
Definition: GameRules.qc:142
nonvirtual ncRuleDelegate ActiveInstance(void)
Definition: GameRules.qc:428
virtual void PlayerSpawn(ncPlayer)
Overridable: Called when a ncPlayer spawns, called sometime after joining.
Definition: GameRules.qc:170
virtual bool IsTeamplay(void)
Returns if this gamerule considers itself teamplay oriented.
Definition: GameRules.qc:323
virtual void RestoreComplete(void)
Called when the entity has been successfully restored from a savegame file.
Definition: GameRules.qc:74
virtual void LevelChangeParms(ncPlayer)
Overridable: Called to store parms for a specific ncPlayer.
Definition: GameRules.qc:192
virtual void Precache(void)
Overridable: Called from initents().
Definition: GameRules.qc:87
virtual bool ClientCommand(ncClient, string)
Overridable: Called when a client issues a client command.
Definition: GameRules.qc:109
virtual bool PlayerRequestRespawn(ncPlayer)
Overridable: called when a ncPlayer requests a respawn.
Definition: GameRules.qc:358
void ncRuleDelegate(void)
Definition: GameRules.qc:22
virtual void ChatMessageTeam(ncClient, string)
Called by Nuclide when the server has received a chat message that is to be distributed amongst all c...
Definition: GameRules.qc:387
virtual void IntermissionEnd(void)
Called when intermission ends.
Definition: GameRules.qc:334
virtual void PlayerConnect(ncPlayer)
Overridable: Called when a ncPlayer joins the server.
Definition: GameRules.qc:121
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: GameRules.qc:45
virtual void ChatMessageAll(ncClient, string)
Called by Nuclide when the server has received a chat message that is to be distributed amongst all c...
Definition: GameRules.qc:370
virtual bool PlayerRequestTeam(ncPlayer, int team)
Overridable: called when a ncPlayer requests joining a specific team.
Definition: GameRules.qc:364
virtual void IntermissionCycle(void)
Called when the intermission system calls a new map.
Definition: GameRules.qc:236
virtual bool ImpulseCommand(ncClient, float)
Overridable: Called when a client issues an impulse command.
Definition: GameRules.qc:115
virtual void PlayerPain(ncPlayer, ncActor, ncDict)
Overridable: Called when a ncPlayer feels pain.
Definition: GameRules.qc:164
virtual void Input(entity, string, string)
Called when we are being prompted by another object/function with an input message.
Definition: GameRules.qc:69
virtual bool MonstersSpawn(void)
Overridable: Returns if ncMonster or ncTalkMonster entities can spawn.
Definition: GameRules.qc:316
virtual string Title(void)
Returns the title of the gamemode running.
Definition: GameRules.qc:418
virtual bool InIntermission(void)
Returns if the gamerules find themselves in an intermission.
Definition: GameRules.qc:310
virtual bool IsMultiplayer(void)
Returns if the gamerule is a multiplayer game.
Definition: GameRules.qc:328
virtual void PlayerPostFrame(ncPlayer)
Overridable: Called after running physics on the ncPlayer in question.
Definition: GameRules.qc:180
virtual bool ConsoleCommand(ncPlayer, string)
Overridable: Called when the server issues a console command.
Definition: GameRules.qc:104
nonvirtual void LinkProgs(void)
Definition: GameRules.qc:434
virtual void PlayerDeath(ncPlayer, ncEntity, ncEntity, string)
Overridable: Called when a ncPlayer dies in the game.
Definition: GameRules.qc:147
virtual bool PlayerCanAttack(ncPlayer)
Overridable: Called to check if a ncPlayer can attack.
Definition: GameRules.qc:352
virtual void Restore(string, string)
Similar to ncIO::SpawnKey() but for save-game fields.
Definition: GameRules.qc:53
virtual void IntermissionStart(void)
Called when intermission starts.
Definition: GameRules.qc:221
virtual void PlayerKill(ncPlayer)
Overridable: Called when a ncPlayer issues the kill console command.
Definition: GameRules.qc:131