Game (ZScript)

From ZCWiki
Jump to: navigation, search

The Game object allows scripts to manipulate various game related items, settings, etc.

Syntax

The Game object (or a pointer to it, more specifically) is automatically made available to ZScript scripts; you do not need to declare a Game variable or instantiate it in any way.

The syntax for accessing the methods and properties associated with Game is as follows:

Game->method-or-property;

where method-or-property is one of the methods or properties listed below. As with any expression, you can use Game methods or properties as the evaluation criteria in control loops, if statements, and so forth.

Methods and Properties

Methods

GetCurDMap

Returns the number of the current dmap.

Introduced in Version

2.5 (beta)

Protyotype and Arguments
int GetCurDMap()

GetCurDMapScreen

Retrieves the number of the current screen within the current dmap.

Introduced in Version

2.5 (beta)

Protyotype and Arguments
int GetCurDMapScreen()

GetCurMap

Retrieves the number of the current map.

Introduced in Version

2.5 (beta)

Protyotype and Arguments
int GetCurMap()

GetCurScreen

Retrieves the number of the current screen within the current map.

Introduced in Version

2.5 (beta)

Protyotype and Arguments
int GetCurScreen()

Two examples:

int theCurrentScreen = Game->GetCurScreen();
if(Game->GetCurScreen==04);

GetMapFlag

As with CurMapFlag, but retrieves the miscellaneous flags of any map, not just the current one. This function is undefined if map is less than 1 or greater than the maximum map number of your quest, or if screen is greater than 135. Note: Screen numbers in ZQuest are usually displayed in hexadecimal.

Introduced in Version

2.5 (beta)

Removed in Version

2.5 (beta, build 712, replaced by GetScreenState)

Prototype and Arguments
bool GetMapFlag(int map, int screen, int flag)
  • int map: The map to inspect.
  • int screen: The screen in the specified map whose flags should be inspected.
  • int flag: Use the MF_ constants in std.zh for the flag parameter.

GetScreenD

Retrieves the value of a D[] element on the given screen of the current dmap.

Introduced in Version

2.5 (beta)

Prototype and Arguments
float GetScreenD(int screen, int reg)
  • int screen: The screen whose D[] array should be inspected.
  • int reg: The index of the D[] element to return.

GetScreenState

Retrieves the miscellaneous states/flags of any screen in the specified map.

Introduced in Version

2.5 (beta, build 712)

Prototype and Arguments
bool GetScreenState(int map, int screen, int flag)
  • int map: the number of the map containing the screen of interest. The return value of this function is undefined if map is less than 1 or greater than the maximum map number of your quest.
  • int screen: the screen whose states/flags should be inspected. The return value of this function is undefined if screen is greater than 135.
  • int flag: The state/flag whose value should be returned. Use the ST_ constants in std.zh .

SetScreenState

Sets the miscellaneous states/flags of any screen in the specified map.

Introduced in Version

2.5 (beta, build 712)

Prototype and Arguments
void SetScreenState(int map, int screen, int flag, bool value)
  • int map: the number of the map containing the screen of interest. The return value of this function is undefined if map is less than 1 or greater than the maximum map number of your quest.
  • int screen: the screen whose states/flags should be inspected. The return value of this function is undefined if screen is greater than 135.
  • int flag: The state/flag whose value should be returned. Use the ST_ constants in std.zh .
  • bool value: true to set the state/flag, false to clear it.

LoadItemClass

Retrieves the itemclass pointer corresponding to the given item family.

Prototype and Arguments
itemclass LoadItemClass(int family)
  • int family: The item family whose itemclass pointer should be returned. Use the IC_ constants in std.zh as values.

PlaySound

Plays one of the quest's sound effects. Use the SFX_ constants in std.zh as values of soundid.

Introduced in Version

2.5 (beta)

Prototype and Arguments
void PlaySound(int soundid)
  • int soundid: The sound to play. Use the SFX_ constants in std.zh as values.

PlayMidi

void PlayMIDI(int MIDIid)

* Changes the current screen MIDI to MIDIid.
* Will revert to the DMap (or screen) MIDI upon leaving the screen.
void PlayMidi(int midiid)
  • int midiid: The midi to play.

SetMapFlag

Sets the miscellaneous states/flags of any screen in the specified map. Superceeded by SetScreenState.

Introduced in Version

2.5 (beta)

Removed in Version

2.5 (beta, build 712, replaced by SetScreenState)

Prototype and Arguments
void SetMapFlag(int map, int screen, int flag, bool value)
  • int map: the number of the map containing the screen of interest. The return value of this function is undefined if map is less than 1 or greater than the maximum map number of your quest.
  • int screen: the screen whose states/flags should be inspected. The return value of this function is undefined if screen is greater than 135.
  • int flag: The state/flag whose value should be returned. Use the MF_ constants in std.zh .
  • bool value: true to set the state/flag, false to clear it.

SetScreenD

Sets the value of the given D[] element on the given screen of the current dmap.

Introduced in Version

2.5 (beta)

Prototype and Arguments
void SetScreenD(int screen, int reg, float value)
  • int screen: the screen whose D[] array to access.
  • int reg: the index of the D[] array that should be set.
  • float value: the value to write to D[reg].

GetComboData

Returns a particular combo reference from anywhere in the game world, based on map (NOT DMap), screen number, and position.

Introduced in Version

2.5 (beta, build 712)

Prototype and Arguments
int GetComboData(int map, int screen, int position)
  • int map: the map containing the screen and combo of interest.
  • int screen: the screen number of the screen in the specified map; should be between 0 and 135 (0x87) inclusive.
  • int position: the position of the combo in the screen; should be between 0 and 175 (0xAF) inclusive.

SetComboData

Sets a particular combo reference anywhere in the game world, based on map (NOT DMap), screen number, and position.

Introduced in Version

2.5 (beta, build 712)

Prototype and Arguments
void SetComboData(int map, int screen, int position, int value)
  • int map: the map containing the screen and combo of interest.
  • int screen: the screen number of the screen in the specified map; should be between 0 and 135 (0x87) inclusive.
  • int position: the position of the combo in the screen; should be between 0 and 175 (0xAF) inclusive.
  • int value: the ID of the new combo, which will replace the old combo.

GetComboCSet

Returns a particular combo's CSet from anywhere in the game world, based on map (NOT DMap), screen number, and position.

Introduced in Version

2.5 (beta, build 712)

Prototype and Arguments
int GetComboCSet(int map, int screen, int position)
  • int map: the map containing the screen and combo of interest.
  • int screen: the screen number of the screen in the specified map; should be between 0 and 135 (0x87) inclusive.
  • int position: the position of the combo in the screen; should be between 0 and 175 (0xAF) inclusive.

SetComboCSet

Sets a particular combo's CSet anywhere in the game world, based on map (NOT DMap), screen number, and position.

Introduced in Version

2.5 (beta, build 712)

Prototype and Arguments
void SetComboCSet(int map, int screen, int position, int value)
  • int map: the map containing the screen and combo of interest.
  • int screen: the screen number of the screen in the specified map; should be between 0 and 135 (0x87) inclusive.
  • int position: the position of the combo in the screen; should be between 0 and 175 (0xAF) inclusive.
  • int value: the CSet to assign to the combo.

GetComboFlag

Returns a particular combo's secret flag from anywhere in the game world, based on map (NOT DMap), screen number, and position.

Introduced in Version

2.5 (beta, build 712)

Prototype and Arguments
int GetComboFlag(int map, int screen, int position)
  • int map: the map containing the screen and combo of interest.
  • int screen: the screen number of the screen in the specified map; should be between 0 and 135 (0x87) inclusive.
  • int position: the position of the combo in the screen; should be between 0 and 175 (0xAF) inclusive.

SetComboFlag

Sets a particular combo's secret flag anywhere in the game world, based on map (NOT DMap), screen number, and position.

Introduced in Version

2.5 (beta, build 712)

Prototype and Arguments
void SetComboFlag(int map, int screen, int position, int value)
  • int map: the map containing the screen and combo of interest.
  • int screen: the screen number of the screen in the specified map; should be between 0 and 135 (0x87) inclusive.
  • int position: the position of the combo in the screen; should be between 0 and 175 (0xAF) inclusive.
  • int value: the flag value to assign to the combo. Use the CF_ constants in std.zh.

GetComboType

Returns a particular combo's type from anywhere in the game world, based on map (NOT DMap), screen number, and position.

Introduced in Version

2.5 (beta, build 712)

Prototype and Arguments
int GetComboType(int map, int screen, int position)
  • int map: the map containing the screen and combo of interest.
  • int screen: the screen number of the screen in the specified map; should be between 0 and 135 (0x87) inclusive.
  • int position: the position of the combo in the screen; should be between 0 and 175 (0xAF) inclusive.

SetComboType

Sets a particular combo's type anywhere in the game world, based on map (NOT DMap), screen number, and position. Note that you are grabbing an actual combo attribute as referenced by the combo on screen you're referring to, which means that setting this attribute will affect all references to this combo throughout the quest.

Introduced in Version

2.5 (beta, build 712)

Prototype and Arguments
void SetComboType(int map, int screen, int position, int value)
  • int map: the map containing the screen and combo of interest.
  • int screen: the screen number of the screen in the specified map; should be between 0 and 135 (0x87) inclusive.
  • int position: the position of the combo in the screen; should be between 0 and 175 (0xAF) inclusive.
  • int value: Use the CT_ constants in std.zh.

GetComboInherentFlag

Returns a particular combo's inherent flag from anywhere in the game world, based on map (NOT DMap), screen number, and position.

Introduced in Version

2.5 (beta, build 712)

Prototype and Arguments
int GetComboInherentFlag(int map, int screen, int position)
  • int map: the map containing the screen and combo of interest.
  • int screen: the screen number of the screen in the specified map; should be between 0 and 135 (0x87) inclusive.
  • int position: the position of the combo in the screen; should be between 0 and 175 (0xAF) inclusive.

SetComboInherentFlag

Sets a particular combo's inherent flag anywhere in the game world, based on map (NOT DMap), screen number, and position. Note that you are grabbing an actual combo attribute as referenced by the combo on screen you're referring to, which means that setting this attribute will affect all references to this combo throughout the quest.

Introduced in Version

2.5 (beta, build 712)

Prototype and Arguments
void SetComboInherentFlag(int map, int screen, int position, int value)
  • int map: the map containing the screen and combo of interest.
  • int screen: the screen number of the screen in the specified map; should be between 0 and 135 (0x87) inclusive.
  • int position: the position of the combo in the screen; should be between 0 and 175 (0xAF) inclusive.
  • int value: the flag value to assign to the combo. Use the CF_ constants in std.zh.

GetComboSolid

Returns a particular combo's solidity flag (walkability) from anywhere in the game world, based on map (NOT DMap), screen number, and position. Also see determining combo walkability.

Introduced in Version

2.5 (beta, build 712)

Prototype and Arguments
int GetComboSolid(int map, int screen, int position)
  • int map: the map containing the screen and combo of interest.
  • int screen: the screen number of the screen in the specified map; should be between 0 and 135 (0x87) inclusive.
  • int position: the position of the combo in the screen; should be between 0 and 175 (0xAF) inclusive.

SetComboSolid

Sets a particular combo's solidity (or walkability) anywhere in the game world, based on map (NOT DMap), screen number, and position. Note that you are grabbing an actual combo attribute as referenced by the combo on screen you're referring to, which means that setting this attribute will affect all references to this combo throughout the quest. Also see determining combo walkability.

Introduced in Version

2.5 (beta, build 712)

Prototype and Arguments
void SetComboSolid(int map, int screen, int position, int value)
  • int map: the map containing the screen and combo of interest.
  • int screen: the screen number of the screen in the specified map; should be between 0 and 135 (0x87) inclusive.
  • int position: the position of the combo in the screen; should be between 0 and 175 (0xAF) inclusive.
  • int value: the walkability pattern for the combo. See determining combo walkability.

Properties

int Cheat

The current cheat level of the quest player.

int ContinueDMap

The dmap containing the screen that will be used when Link dies and continues.

int ContinueScreen

The screen in the continue dmap (see ContinueDMap below) that will be used when Link dies and continues.

int Counter[]

The current value of the game counters. Use the CR_ constants in std.zh to index into this array.

bool CurMapFlag[]

An array of miscellaneous flags data associated with the current map. Use the MF_ constants in std.zh as indices into this array.

Introduced in Version
2.5 (beta)
Removed in Version
2.5 (beta, build 712, replaced by State[])

int DCounter[]

The current value of the game drain counters. Use the CR_ constants in std.zh to index into this array.

int Generic[]

An array of miscellaneous game values, such as number of heart containers and magic drain rate. Use the GEN_ constants in std.zh to index into this array.

int GuyCount[]

The number of NPCs (enemies and guys) on screen i of this map, where i is the index used to access this array.

bool HasPlayed

This value is true if the current quest session was loaded from a saved game, false if the quest was started fresh.

int LItems[]

The level items of level i currently under the posession of the player, where i is the index used to access this array. Each element of this array consists of flags ORed (|) together; use the LI_ constants in std.zh to set or compare these values.

int LKeys[]

The number of level keys of level i currently under the possession of the player, where i is the index used to access this array.

int MCounter[]

The current maximum value of the game counters. Use the CR_ constants in std.zh to index into this array.

int NumDeaths

The number of times Link has perished during this quest.

bool State[]

An array of miscellaneous flags data associated with the current screen. Use the ST_ constants in std.zh as indices into this array.

int Time

Returns the time elapsed in this quest, in 60ths of a second. The return value is undefined if TimeValid is false (see below).

bool TimeValid

True if the elapsed quest time can be determined for the current quest.