Nuclide
Software Development Kit for id Technology (BETA)
NSGameRules.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
27{
28public:
29 void ncGameRules(void);
30
31 /* overrides */
32 virtual void Save(float);
33 virtual void Restore(string,string);
34 virtual void RestoreComplete(void);
35 virtual void Input(entity, string, string);
36
38 virtual void InitPostEnts(void);
39
40 /* logic */
42 virtual void FrameStart(void);
44 virtual bool ConsoleCommand(ncPlayer,string);
46 virtual bool ClientCommand(ncClient,string);
48 virtual bool ImpulseCommand(ncClient, float);
49
50 /* client */
52 virtual void PlayerConnect(ncPlayer);
54 virtual void PlayerDisconnect(ncPlayer);
56 virtual void PlayerKill(ncPlayer);
58 virtual void PlayerSpawn(ncPlayer);
60 virtual void PlayerPreFrame(ncPlayer);
62 virtual void PlayerPostFrame(ncPlayer);
64 virtual void PlayerDeath(ncPlayer, ncEntity, ncEntity, string);
66 virtual void PlayerPain(ncPlayer, ncActor, ncDict);
68 virtual bool PlayerCanAttack(ncPlayer);
70 virtual void NPCDeath(ncActor, ncEntity, ncEntity);
71
76 virtual bool PlayerRequestRespawn(ncPlayer);
77
80 virtual bool PlayerRequestTeam(ncPlayer, int team);
81
82 /* level transitions */
84 virtual void LevelNewParms(void);
86 virtual void LevelChangeParms(ncPlayer);
87
88 /* Entities/Item manipulation */
90 virtual int MaxItemPerSlot(int);
92 virtual bool MonstersSpawn(void);
93
94 /* end of a game */
96 virtual void IntermissionStart(void);
98 virtual void IntermissionCycle(void);
100 virtual void IntermissionEnd(void);
102 virtual void IntermissionToPlayer(ncPlayer);
104 virtual bool InIntermission(void);
105
107 virtual bool IsTeamplay(void);
109 virtual bool IsMultiplayer(void);
110
111
112 /* chat related methods */
115 virtual void ChatMessageAll(ncClient, string);
116
119 virtual void ChatMessageTeam(ncClient, string);
120
122 virtual string Title(void);
123
124 nonvirtual ncGameRules CreateRules(void);
125
126 /* spectator */
127 /*
128 virtual void SpectatorConnect(ncPlayer);
129 virtual void SpectatorDisconnect(ncPlayer);
130 virtual void SpectatorThink(ncPlayer);
131 */
132private:
133 int m_iIntermission;
134 float m_flIntermissionTime;
135 float m_flIntermissionCycle;
136 entity m_eIntermissionPoint;
137};
138
139/* our currently running mode */
140ncGameRules g_grMode;
141var float g_ruleCProgs;
142var string g_ruleCName;
143
144#define CGameRules ncGameRules
145#define RULEMAP(x, y, z) x.y = externvalue(g_ruleCProgs, z); if (!x.y) { x.y = ncGameRules::y; }
This entity class represents an object with choreographed/free-form movement.
Definition: NSNavAI.h:72
This entity class is the lowest client/player class.
Definition: NSClient.h:26
This class is responsible for handling groups of key/value pairs.
Definition: NSDict.h:42
ncEntity is the lowest of the user-accessible entity class.
Definition: NSEntity.h:54
This class represents active gamerules.
Definition: NSGameRules.h:27
virtual bool IsMultiplayer(void)
Returns if the gamerule is a multiplayer game.
Definition: NSGameRules.qc:329
virtual bool ClientCommand(ncClient, string)
Overridable: Called when a client issues a client command.
Definition: NSGameRules.qc:98
virtual void FrameStart(void)
Overridable: Called every server frame.
Definition: NSGameRules.qc:88
virtual void NPCDeath(ncActor, ncEntity, ncEntity)
Overridable:: Called when an NPC gets killed.
Definition: NSGameRules.qc:134
virtual void PlayerConnect(ncPlayer)
Overridable: Called when a ncPlayer joins the server.
Definition: NSGameRules.qc:110
virtual string Title(void)
Returns the title of the gamemode running.
Definition: NSGameRules.qc:419
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: NSGameRules.qc:388
virtual void PlayerPreFrame(ncPlayer)
Overridable: Called before running physics on the ncPlayer in question.
Definition: NSGameRules.qc:176
virtual void PlayerDeath(ncPlayer, ncEntity, ncEntity, string)
Overridable: Called when a ncPlayer dies in the game.
Definition: NSGameRules.qc:139
void ncGameRules(void)
Definition: NSGameRules.qc:22
virtual void RestoreComplete(void)
Called when the entity has been successfully restored from a savegame file.
Definition: NSGameRules.qc:74
virtual bool IsTeamplay(void)
Returns if this gamerule considers itself teamplay oriented.
Definition: NSGameRules.qc:324
virtual void PlayerKill(ncPlayer)
Overridable: Called when a ncPlayer issues the kill console command.
Definition: NSGameRules.qc:123
nonvirtual ncGameRules CreateRules(void)
Definition: NSGameRules.qc:429
virtual void IntermissionToPlayer(ncPlayer)
Run to send a specific player to an intermission.
Definition: NSGameRules.qc:288
virtual void IntermissionEnd(void)
Called when intermission ends.
Definition: NSGameRules.qc:335
virtual bool PlayerCanAttack(ncPlayer)
Overridable: Called to check if a ncPlayer can attack.
Definition: NSGameRules.qc:353
virtual void PlayerDisconnect(ncPlayer)
Overridable: Called when a ncPlayer leaves the server.
Definition: NSGameRules.qc:117
virtual bool InIntermission(void)
Returns if the gamerules find themselves in an intermission.
Definition: NSGameRules.qc:311
virtual void PlayerPain(ncPlayer, ncActor, ncDict)
Overridable: Called when a ncPlayer feels pain.
Definition: NSGameRules.qc:165
virtual void PlayerSpawn(ncPlayer)
Overridable: Called when a ncPlayer spawns, called sometime after joining.
Definition: NSGameRules.qc:171
virtual void Input(entity, string, string)
Called when we are being prompted by another object/function with an input message.
Definition: NSGameRules.qc:69
virtual int MaxItemPerSlot(int)
Overridable: Returns how many items players can carry in a given slot.
Definition: NSGameRules.qc:216
virtual void Restore(string, string)
Similar to ncIO::SpawnKey() but for save-game fields.
Definition: NSGameRules.qc:53
virtual bool ConsoleCommand(ncPlayer, string)
Overridable: Called when a client issues a console command.
Definition: NSGameRules.qc:93
virtual void IntermissionCycle(void)
Called when the intermission system calls a new map.
Definition: NSGameRules.qc:237
virtual bool PlayerRequestTeam(ncPlayer, int team)
Overridable: called when a ncPlayer requests joining a specific team.
Definition: NSGameRules.qc:365
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition: NSGameRules.qc:45
virtual void IntermissionStart(void)
Called when intermission starts.
Definition: NSGameRules.qc:222
virtual void PlayerPostFrame(ncPlayer)
Overridable: Called after running physics on the ncPlayer in question.
Definition: NSGameRules.qc:181
virtual bool MonstersSpawn(void)
Overridable: Returns if ncMonster or ncTalkMonster entities can spawn.
Definition: NSGameRules.qc:317
virtual void LevelNewParms(void)
Overridable: Called to set up new level parms for any ncPlayer.
Definition: NSGameRules.qc:188
virtual void LevelChangeParms(ncPlayer)
Overridable: Called to store parms for a specific ncPlayer.
Definition: NSGameRules.qc:193
virtual bool ImpulseCommand(ncClient, float)
Overridable: Called when a client issues an impulse command.
Definition: NSGameRules.qc:104
virtual void InitPostEnts(void)
Overridable: Called when all map entities have initialized.
Definition: NSGameRules.qc:82
virtual bool PlayerRequestRespawn(ncPlayer)
Overridable: called when a ncPlayer requests a respawn.
Definition: NSGameRules.qc:359
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: NSGameRules.qc:371
This class is responsible for handling core entity functionality.
Definition: NSIO.h:78
This entity class represents every player client.
Definition: NSClientPlayer.h:28