123 lines
4.8 KiB
C++
123 lines
4.8 KiB
C++
/*
|
|
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
|
|
*
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
* copyright notice and this permission notice appear in all copies.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
|
|
/*! @file NSGameRules.h
|
|
@brief Gamerule top level class.
|
|
|
|
There's a lot of methods you're allowed to override.
|
|
*/
|
|
|
|
/** This class represents active gamerules. */
|
|
class NSGameRules:NSIO
|
|
{
|
|
private:
|
|
int m_iIntermission;
|
|
float m_flIntermissionTime;
|
|
float m_flIntermissionCycle;
|
|
|
|
public:
|
|
void NSGameRules(void);
|
|
|
|
/* overrides */
|
|
virtual void Save(float);
|
|
virtual void Restore(string,string);
|
|
|
|
/** Overridable: Called when all map entities have initialized. */
|
|
virtual void InitPostEnts(void);
|
|
|
|
/* logic */
|
|
/** Overridable: Called every server frame. */
|
|
virtual void FrameStart(void);
|
|
/** Overridable: Called when a client issues a console command. */
|
|
virtual bool ConsoleCommand(NSClientPlayer,string);
|
|
/** Overridable: Called when a client issues a client command. */
|
|
virtual bool ClientCommand(NSClient,string);
|
|
|
|
/* client */
|
|
/** Overridable: Called when a NSClientPlayer joins the server. */
|
|
virtual void PlayerConnect(NSClientPlayer);
|
|
/** Overridable: Called when a NSClientPlayer leaves the server. */
|
|
virtual void PlayerDisconnect(NSClientPlayer);
|
|
/** Overridable: Called when a NSClientPlayer issues the `kill` console command. */
|
|
virtual void PlayerKill(NSClientPlayer);
|
|
/** Overridable: Called when a NSClientPlayer spawns, called sometime after joining. */
|
|
virtual void PlayerSpawn(NSClientPlayer);
|
|
/** Overridable: Called before running physics on the NSClientPlayer in question. */
|
|
virtual void PlayerPreFrame(NSClientPlayer);
|
|
/** Overridable: Called after running physics on the NSClientPlayer in question. */
|
|
virtual void PlayerPostFrame(NSClientPlayer);
|
|
/** Overridable: Called when a NSClientPlayer dies in the game. */
|
|
virtual void PlayerDeath(NSClientPlayer);
|
|
/** Overridable: Called when a NSClientPlayer feels pain. */
|
|
virtual void PlayerPain(NSClientPlayer);
|
|
/** Overridable: Called to check if a NSClientPlayer can attack. */
|
|
virtual bool PlayerCanAttack(NSClientPlayer);
|
|
|
|
/* level transitions */
|
|
/** Overridable: Called to set up new level parms for any NSClientPlayer. */
|
|
virtual void LevelNewParms(void);
|
|
/** Overridable: Called to store parms for a specific NSClientPlayer. */
|
|
virtual void LevelChangeParms(NSClientPlayer);
|
|
|
|
/* Entities/Item manipulation */
|
|
/** Overridable: Returns how many items players can carry in a given slot. */
|
|
virtual int MaxItemPerSlot(int);
|
|
/** Overridable: Returns if NSMonster or NSTalkMonster entities can spawn. */
|
|
virtual bool MonstersSpawn(void);
|
|
/** Overridable: shim to handle application of direct damage. */
|
|
virtual void DamageApply(entity,entity,float,int,damageType_t);
|
|
/** Checks if an entity can be attacked from a given position. */
|
|
virtual bool DamageCheckTrace(entity,vector);
|
|
/** Overridable: shim to handle application of indirect radius damage. */
|
|
virtual void DamageRadius(vector,entity,float,float,int,int);
|
|
|
|
/* end of a game */
|
|
/** Called when intermission starts. */
|
|
virtual void IntermissionStart(void);
|
|
/** Called when intermission calls a new map. */
|
|
virtual void IntermissionCycle(void);
|
|
/** Called when intermission ents. */
|
|
virtual void IntermissionEnd(void);
|
|
/** Returns if the gamerules find themselves in an intermission. */
|
|
virtual bool InIntermission(void);
|
|
|
|
/** Returns if this gamerule considers itself teamplay oriented. */
|
|
virtual bool IsTeamplay(void);
|
|
/** Returns if the gamerule is a multiplayer game. */
|
|
virtual bool IsMultiplayer(void);
|
|
|
|
/* chat related methods */
|
|
/** Called by Nuclide when the server has received a chat message
|
|
that is to be distributed amongst all clients, regardless of team. */
|
|
virtual void ChatMessageAll(NSClient, string);
|
|
|
|
/** Called by Nuclide when the server has received a chat message
|
|
that is to be distributed amongst all clients of the same team. */
|
|
virtual void ChatMessageTeam(NSClient, string);
|
|
|
|
/* spectator */
|
|
/*
|
|
virtual void SpectatorConnect(NSClientPlayer);
|
|
virtual void SpectatorDisconnect(NSClientPlayer);
|
|
virtual void SpectatorThink(NSClientPlayer);
|
|
*/
|
|
|
|
};
|
|
|
|
/* our currently running mode */
|
|
NSGameRules g_grMode;
|
|
|
|
#define CGameRules NSGameRules
|