Difference between revisions of "CGame"

From Sven Co-op
Jump to navigation Jump to search
(Created page with "This class contains methods integral to the operation of the game. You will often use these. The HTML documentation can be found here. A single global instance exists: <now...")
 
m
Line 8: Line 8:
 
</nowiki>
 
</nowiki>
 
===== Methods =====
 
===== Methods =====
 +
 +
Precache methods
 +
 +
{| class="wikitable"
 +
|- style="font-weight:bold;"
 +
! Name
 +
! Method
 +
! Description
 +
|-
 +
| PrecacheModel
 +
| int PrecacheModel(const string& in szFileName)
 +
| Precaches a model. Shuts down the game if not found. Can only be called from MapInit. Returns the model's index.
 +
|-
 +
| PrecacheModel
 +
| int PrecacheModel(CBaseEntity@ pEntity, const string& in szFileName)
 +
| Precaches a model. Shuts down the game if not found. Can only be called from MapInit. Returns the model's index.
 +
|-
 +
| PrecacheOther
 +
| void PrecacheOther(const string& in szClassName)
 +
| This effectively instances an entity with the given class name, calls precache on it, and removes the entity.
 +
|-
 +
| PrecacheMonster
 +
| void PrecacheMonster(const string& in szClassName, bool fAlly)
 +
| This effectively instances a monster entity with the given class name, calls precache on it, and removes the entity. szClassName is the given entity's classname, fAlly is whether this is an ally or enemy monster.
 +
|-
 +
| PrecacheGeneric
 +
| void PrecacheGeneric(const string& in szFileName)
 +
| Precaches a file for download to clients.
 +
|}
 +
 
AlertMessage
 
AlertMessage
 
  <nowiki>
 
  <nowiki>
Line 16: Line 46:
 
See the ALERT_TYPE enum.
 
See the ALERT_TYPE enum.
  
PrecacheModel
 
<nowiki>
 
int PrecacheModel(const string& in szFileName)
 
</nowiki>
 
Precaches a model.
 
 
Shuts down the game if not found. Can only be called from MapInit.
 
 
Returns the model's index.
 
 
PrecacheModel
 
<nowiki>
 
int PrecacheModel(CBaseEntity@ pEntity, const string& in szFileName)
 
</nowiki>
 
Precaches a model.
 
 
Shuts down the game if not found. Can only be called from entity Precache methods.
 
 
Returns the model's index.
 
 
PrecacheOther
 
<nowiki>
 
void PrecacheOther(const string& in szClassName)
 
</nowiki>
 
Precaches an entity.
 
 
This effectively instances an entity with the given class name, calls precache on it, and removes the entity.
 
 
PrecacheMonster
 
<nowiki>
 
void PrecacheMonster(const string& in szClassName, bool fAlly)
 
</nowiki>
 
Precaches a monster entity.
 
 
This effectively instances a monster entity with the given class name, calls precache on it, and removes the entity.
 
<nowiki>
 
Argument Description
 
szClassName Entity class name.
 
fAlly Whether this is an ally or enemy monster.
 
PrecacheGeneric
 
void PrecacheGeneric(const string& in szFileName)
 
Precaches a file for download to clients.
 
</nowiki>
 
  
 
GetGameName
 
GetGameName

Revision as of 21:01, 13 February 2025

This class contains methods integral to the operation of the game. You will often use these.

The HTML documentation can be found here.

A single global instance exists:

CGame g_Game;

Methods

Precache methods

Name Method Description
PrecacheModel int PrecacheModel(const string& in szFileName) Precaches a model. Shuts down the game if not found. Can only be called from MapInit. Returns the model's index.
PrecacheModel int PrecacheModel(CBaseEntity@ pEntity, const string& in szFileName) Precaches a model. Shuts down the game if not found. Can only be called from MapInit. Returns the model's index.
PrecacheOther void PrecacheOther(const string& in szClassName) This effectively instances an entity with the given class name, calls precache on it, and removes the entity.
PrecacheMonster void PrecacheMonster(const string& in szClassName, bool fAlly) This effectively instances a monster entity with the given class name, calls precache on it, and removes the entity. szClassName is the given entity's classname, fAlly is whether this is an ally or enemy monster.
PrecacheGeneric void PrecacheGeneric(const string& in szFileName) Precaches a file for download to clients.

AlertMessage

bool AlertMessage(ALERT_TYPE aType, const string& in szFormat, ...)

Outputs a message to the console. Uses SC printf formatting style. Supports a variable number of arguments.

See the ALERT_TYPE enum.


GetGameName

string GetGameName() const
Returns the game name.

GetGameVersionString
 <nowiki>
string GetGameVersionString() const

Returns the game version as a string, e.g. "5.0".

GetGameVersion

uint32 GetGameVersion() const

Returns the game version as a number, e.g. 500: major version, minor version (3.0 becomes 300, 4.0b1 becomes 401, 4.06 becomes 406, 4.5 becomes 450, etc...)