Jazz2::Scripting namespace

Scripting-related classes, compiled only if WITH_ANGELSCRIPT.

Namespaces

namespace Legacy
Legacy JJ2+ definitions.

Classes

class CScriptArray
AngelScript array
class CScriptDictionary
AngelScript dictionary
class CScriptDictValue
AngelScript dictionary value
class CScriptHandle
AngelScript reference handle
class LevelScriptLoader
Binds an AngelScript script file to LevelHandler and executes the script.
class ScriptActorWrapper
Wraps a scripted actor, forwarding engine callbacks to the AngelScript object.
class ScriptCollectibleWrapper
Wraps a scripted collectible actor, forwarding engine callbacks to the AngelScript object.
class ScriptLoader
Generic AngelScript script loader with #include and #pragma directive support.
class ScriptPlayerWrapper
Wraps a player actor for access from AngelScript.

Enums

enum class DrawType { WeaponAmmo, Health, Lives, PlayerTimer, Score, GameModeHUD }
Specifies a part to be drawn in LevelScriptLoader::OnDraw().
enum class ScriptContextType { Unknown, AlreadyIncluded, Legacy, Standard }
Script context type.
enum class ScriptBuildResult { Success = asSUCCESS, InvalidConfiguration = asINVALID_CONFIGURATION, BuildFailed = asERROR, BuildInProgress = asBUILD_IN_PROGRESS, InitGlobalVarsFailed = asINIT_GLOBAL_VARS_FAILED, NotSupported = asNOT_SUPPORTED, ModuleIsInUse = asMODULE_IS_IN_USE }
Result of ScriptLoader::Build().

Typedefs

using dictKey_t = String
using dictMap_t = HashMap<dictKey_t, CScriptDictValue>

Functions

auto getCustomSetID(std::uint8_t index) -> std::uint32_t
Returns the ANIM::Set value of a custom animation set.
void Unimplemented(const char* sourceName)
Logs that a script called a function that isn't implemented, with where it called it from.
auto OpenScriptFile(StringView path) -> std::unique_ptr<Death::IO::Stream>
Opens a file a script names, from the content or the directory of the original game.
auto IsScriptFileNameSafe(StringView filename) -> bool
Returns whether a file name a script gives stays inside the data directory of the game.
auto get_sinTable(std::uint32_t angle) -> float
Returns the sine of the given table angle.
auto get_cosTable(std::uint32_t angle) -> float
Returns the cosine of the given table angle.
auto RandWord32() -> std::uint32_t
Returns a random 32-bit word.
auto unixTimeSec() -> std::uint64_t
Returns the current Unix time in seconds.
auto unixTimeMs() -> std::uint64_t
Returns the current Unix time in milliseconds.
auto jjRegexIsValid(const String& expression) -> bool
Returns whether the given regular expression is valid.
auto jjRegexMatch(const String& text, const String& expression, bool ignoreCase) -> bool
Returns whether the text fully matches the regular expression.
auto jjRegexMatchWithResults(const String& text, const String& expression, CScriptArray& results, bool ignoreCase) -> bool
Returns whether the text fully matches the regular expression, outputting captured groups.
auto jjRegexSearch(const String& text, const String& expression, bool ignoreCase) -> bool
Returns whether the regular expression is found anywhere in the text.
auto jjRegexSearchWithResults(const String& text, const String& expression, CScriptArray& results, bool ignoreCase) -> bool
Returns whether the regular expression is found anywhere in the text, outputting captured groups.
auto jjRegexReplace(const String& text, const String& expression, const String& replacement, bool ignoreCase) -> String
Returns the text with regular expression matches replaced.
auto GetFPS() -> std::int32_t
Returns the current frames per second.
auto isAdmin() -> bool
Returns whether the local player is a server administrator.
auto getLevelFileName() -> String
Returns the file name of the current level.
auto getCurrLevelName() -> String
Returns the title of the current level.
void setCurrLevelName(const String& in)
Sets the title of the current level.
auto get_jjTilesetFileName() -> String
Returns the file name of the tile set used by the current level.
auto get_gameState() -> std::int32_t partially supported
Returns the state of the multiplayer game.
auto getBorderWidth() -> std::int32_t partially supported
Returns the width of the black border on the left and right side of each subscreen.
auto getBorderHeight() -> std::int32_t partially supported
Returns the height of the black border on the top and bottom side of each subscreen.
auto getSplitscreenType() -> bool partially supported
Whether the screen is split vertically when there are exactly two local players.
auto setSplitscreenType(bool value) -> bool partially supported
Sets whether the screen is split vertically.
auto get_teamScore(std::int32_t color) -> std::int32_t
Returns the current score of a team in team-based game modes.
auto GetMaxHealth() -> std::int32_t
Returns the highest health a player can have.
auto GetStartHealth() -> std::int32_t
Returns the health a player starts with.
auto getEnabledTeam(std::uint8_t team) -> bool
Whether a team is enabled in the current game.
auto getKeyDown(std::uint8_t key) -> bool
Whether a key or a mouse button is currently held down.
auto getCursorX() -> std::int32_t
Returns the horizontal position of the mouse cursor.
auto getCursorY() -> std::int32_t
Returns the vertical position of the mouse cursor.
auto mlleSetup() -> bool
Finishes setting up a level made in an extended level editor.
void mlleSpawnOffgrids()
Spawns the objects placed off the tile grid.
void mlleSpawnOffgridsLocal()
Spawns the objects placed off the tile grid, for local players only.
auto mlleGetLayer(const String& name) -> Legacy::jjLAYER*
Returns the layer of the given name, or null if the level has no such layer.
void jjSetFadeColors(std::uint8_t red, std::uint8_t green, std::uint8_t blue)
Sets the fade color of the textured background.
void jjSetFadeColorsFromPalette(std::uint8_t paletteColorID)
Sets the fade color of the textured background to the color of a palette entry.
void jjSetFadeColorsFromPalcolor(jjPALCOLOR color)
Sets the fade color of the textured background.
auto jjGetFadeColors() -> jjPALCOLOR
Returns the fade color of the textured background, see jjSetFadeColors().
void jjUpdateTexturedBG()
Redraws the textured background from the tiles of its layer.
auto get_jjTexturedBGTexture() -> std::int32_t
Returns the texture of the textured background.
auto set_jjTexturedBGTexture(std::int32_t texture) -> std::int32_t
Sets the texture of the textured background.
auto get_jjTexturedBGStyle() -> std::int32_t
Returns the effect the textured background is drawn with.
auto set_jjTexturedBGStyle(std::int32_t style) -> std::int32_t
Sets the effect the textured background is drawn with.
auto get_jjTexturedBGUsed() -> bool
Whether jjLayers[8] is drawn textured.
auto set_jjTexturedBGUsed(bool used) -> bool
Sets whether jjLayers[8] is drawn textured.
auto get_jjTexturedBGStars() -> bool
Whether the textured background shows stars.
auto set_jjTexturedBGStars(bool used) -> bool
Sets whether the textured background shows stars.
auto get_jjTexturedBGFadePositionX() -> float
Returns the horizontal fade position of the textured background.
auto set_jjTexturedBGFadePositionX(float value) -> float
Sets the horizontal fade position of the textured background.
auto get_jjTexturedBGFadePositionY() -> float
Returns the vertical fade position of the textured background.
auto set_jjTexturedBGFadePositionY(float value) -> float
Sets the vertical fade position of the textured background.
auto getUseLayer8Speeds() -> bool
Whether layer 8 moves by its own speeds.
auto setUseLayer8Speeds(bool value) -> bool
Sets whether layer 8 moves by its own speeds.
auto jjGetStaticTile(std::uint16_t tileID) -> std::uint16_t partially supported
Returns the frame an animated tile currently shows.
auto jjTileGet(std::uint8_t layer, std::int32_t xTile, std::int32_t yTile) -> std::uint16_t
Returns the tile at a position in tiles in one of the original layers.
auto jjTileSet(std::uint8_t layer, std::int32_t xTile, std::int32_t yTile, std::uint16_t newTile) -> std::uint16_t
Changes the tile at a position in tiles in one of the original layers.
void jjGenerateSettableTileArea(std::uint8_t layer, std::int32_t xTile, std::int32_t yTile, std::int32_t width, std::int32_t height)
Prepares a rectangular area of one of the original layers for jjTileSet().
auto jjMaskedPixel(std::int32_t xPixel, std::int32_t yPixel) -> bool
Returns whether a pixel of the sprite layer is solid.
auto jjMaskedPixelLayer(std::int32_t xPixel, std::int32_t yPixel, std::uint8_t layer) -> bool partially supported
Returns whether a pixel is solid, see jjMaskedPixel().
auto jjMaskedHLine(std::int32_t xPixel, std::int32_t lineLength, std::int32_t yPixel) -> bool
Returns whether any pixel of a horizontal line in the sprite layer is solid.
auto jjMaskedHLineLayer(std::int32_t xPixel, std::int32_t lineLength, std::int32_t yPixel, std::uint8_t layer) -> bool partially supported
Returns whether any pixel of a horizontal line is solid, see jjMaskedHLine().
auto jjMaskedVLine(std::int32_t xPixel, std::int32_t yPixel, std::int32_t lineLength) -> bool
Returns whether any pixel of a vertical line in the sprite layer is solid.
auto jjMaskedVLineLayer(std::int32_t xPixel, std::int32_t yPixel, std::int32_t lineLength, std::uint8_t layer) -> bool partially supported
Returns whether any pixel of a vertical line is solid, see jjMaskedVLine().
auto jjMaskedTopVLine(std::int32_t xPixel, std::int32_t yPixel, std::int32_t lineLength) -> std::int32_t
Returns where the topmost solid pixel of a vertical line in the sprite layer is.
auto jjMaskedTopVLineLayer(std::int32_t xPixel, std::int32_t yPixel, std::int32_t lineLength, std::uint8_t layer) -> std::int32_t partially supported
Returns where the topmost solid pixel of a vertical line is, see jjMaskedTopVLine().
auto GetEvent(std::uint16_t tx, std::uint16_t ty) -> std::int32_t
Returns the event ID placed on a tile of the sprite layer.
auto GetEventParamWrapper(std::uint16_t tx, std::uint16_t ty, std::int32_t offset, std::int32_t length) -> std::int32_t partially supported
Returns one parameter of the event placed on a tile.
void SetEventByte(std::uint16_t tx, std::uint16_t ty, std::uint8_t newEventId) partially supported
Replaces the event placed on a tile.
void SetEventParam(std::uint16_t tx, std::uint16_t ty, int8_t offset, std::int8_t length, std::int32_t newValue) partially supported
Changes one parameter of the event placed on a tile.
auto GetTileType(std::uint16_t tile) -> std::int8_t partially supported
Returns the type of a tile, indexed by tile ID.
auto SetTileType(std::uint16_t tile, std::uint16_t value) -> std::int8_t
Sets the type of a tile, indexed by tile ID.
auto GetTileIs32Bit(std::uint16_t tile) -> bool
Whether a tile uses 32-bit colors, indexed by tile ID.
auto get_jjObjects(std::int32_t index) -> jjOBJ*
Returns all objects of the level, indexed by object ID.
auto get_jjObjectPresets(std::int8_t id) -> jjOBJ*
Returns the templates of new objects, indexed by event ID.
void jjAddParticleTileExplosion(std::uint16_t xTile, std::uint16_t yTile, std::uint16_t tile, bool collapseSceneryStyle) partially supported
Breaks a tile into falling pieces, like destroyed scenery.
void jjAddParticlePixelExplosion(float xPixel, float yPixel, int curFrame, int direction, int mode) partially supported
Bursts a sprite frame into pixel particles.
auto GetParticle(std::int32_t index) -> jjPARTICLE*
Returns all particles of the level, indexed from 0 to 1023.
auto AddParticle(std::int32_t particleType) -> jjPARTICLE*
Creates a new particle.
auto get_jjPlayerCount() -> std::int32_t partially supported
Returns the number of players in the level.
auto get_jjLocalPlayerCount() -> std::int32_t
Returns the number of local players.
auto get_jjP() -> jjPLAYER*
Returns the current player.
auto get_jjPlayers(std::uint8_t index) -> jjPLAYER*
Returns the player with the given jjPLAYER::playerID.
auto get_jjLocalPlayers(std::uint8_t index) -> jjPLAYER*
Returns the local player with the given index.
auto get_jjWEAPON(int index) -> jjWEAPON*
Returns the options of the given weapon.
auto get_jjCHARACTER(int index) -> jjCHARACTER*
Returns the profile of the given character.
void playSample(float xPixel, float yPixel, std::int32_t sample, std::int32_t volume, std::int32_t frequency)
Plays a sound sample at a position in the level.
auto playLoopedSample(float xPixel, float yPixel, std::int32_t sample, std::int32_t channel, std::int32_t volume, std::int32_t frequency) -> std::int32_t
Plays a looping sound sample at a position in the level and returns its channel.
void playPrioritySample(std::int32_t sample)
Plays a sound sample at full volume regardless of where the players are.
auto isSampleLoaded(std::int32_t sample) -> bool
Returns whether a sound sample is available to play.
auto loadSample(std::int32_t sample, const String& filename) -> bool
Loads a sound sample from a file and returns whether it succeeded.
void jjSetModPosition(std::int32_t order, std::int32_t row, bool reset) partially supported
Jumps to a row of a position in the order list of the playing module music.
void jjSlideModChannelVolume(std::int32_t channel, float volume, std::int32_t milliseconds) partially supported
Gradually changes the volume of a channel of the playing module music.
auto jjGetModOrder() -> std::int32_t
Returns the current position in the order list of the playing module music.
auto jjGetModRow() -> std::int32_t
Returns the current row of the playing module music.
auto jjGetModTempo() -> std::int32_t
Returns the tempo of the playing module music, in beats per minute.
void jjSetModTempo(std::uint8_t tempo) partially supported
Sets the tempo of the playing module music, until the module sets another one.
auto jjGetModSpeed() -> std::int32_t
Returns the speed (ticks per row) of the playing module music.
void jjSetModSpeed(std::uint8_t speed) partially supported
Sets the speed (ticks per row) of the playing module music, until the module sets another one.
void RegisterArray(asIScriptEngine* engine)
Registers array type to AngelScript engine.
void RegisterDictionary(asIScriptEngine* engine)
Registers dictionary type to AngelScript engine.
void RegisterImGuiBindings(asIScriptEngine* engine)
Registers ImGui bindings to AngelScript engine.
void RegisterMath(asIScriptEngine* engine)
Registers vec2/vec3/vec4/vec2i/vec3i/vec4i/Color types to AngelScript engine.
void RegisterRef(asIScriptEngine* engine)
Registers ref type to AngelScript engine.
void RegisterString(asIScriptEngine* engine)
Registers Death::Containers::String as string type to AngelScript engine.
void RegisterStringUtils(asIScriptEngine* engine)
Registers string::split() and join(), which need the array type registered first.
void RegisterArray(asIScriptEngine* engine)
Registers array type to AngelScript engine.
void RegisterDictionary(asIScriptEngine* engine)
Registers dictionary type to AngelScript engine.
void RegisterRef(asIScriptEngine* engine)
Registers ref type to AngelScript engine.

Enum documentation

enum class Jazz2::Scripting::DrawType

Specifies a part to be drawn in LevelScriptLoader::OnDraw().

Identifies an individual HUD element a script may override or augment while drawing, such as the weapon ammo, health, lives, player timer, score or the game mode specific overlay. It is passed to the draw callback so the script can render or customize that particular part.

enum class Jazz2::Scripting::ScriptContextType

Script context type.

Identifies the dialect of a loaded script part as it is processed, distinguishing legacy JJ2+ compatible scripts from standard Jazz² Resurrection scripts, as well as parts that are unsupported or were already included. It is reported per file and may be refined by #pragma directives.

Enumerators
Unknown

Unknown/unsupported script part.

AlreadyIncluded

Already included script part.

Legacy

Legacy (JJ2+ compatible) script part.

Standard

Standard (Jazz² Resurrection compatible) script part.

enum class Jazz2::Scripting::ScriptBuildResult

Result of ScriptLoader::Build().

Reports the outcome of compiling the main script module, mirroring the underlying AngelScript return codes for success and the various failure conditions such as an invalid engine configuration, a failed build, a build already in progress or missing compiler support.

Enumerators
Success

The engine succeeded.

InvalidConfiguration

The engine configuration is invalid.

BuildFailed

The script failed to build.

BuildInProgress

Another thread is currently building.

InitGlobalVarsFailed

It was not possible to initialize at least one of the global variables.

NotSupported

Compiler support is disabled in the engine.

ModuleIsInUse

The code in the module is still being used and and cannot be removed.

Typedef documentation

typedef String Jazz2::Scripting::dictKey_t

typedef HashMap<dictKey_t, CScriptDictValue> Jazz2::Scripting::dictMap_t

Function documentation

std::uint32_t Jazz2::Scripting::getCustomSetID(std::uint8_t index)

Returns the ANIM::Set value of a custom animation set.

The custom sets follow the sets of the original game; index selects one of them.

void Jazz2::Scripting::Unimplemented(const char* sourceName)

Logs that a script called a function that isn't implemented, with where it called it from.

std::unique_ptr<Death::IO::Stream> Jazz2::Scripting::OpenScriptFile(StringView path)

Opens a file a script names, from the content or the directory of the original game.

bool Jazz2::Scripting::IsScriptFileNameSafe(StringView filename)

Returns whether a file name a script gives stays inside the data directory of the game.

float Jazz2::Scripting::get_sinTable(std::uint32_t angle)

Returns the sine of the given table angle.

float Jazz2::Scripting::get_cosTable(std::uint32_t angle)

Returns the cosine of the given table angle.

std::uint32_t Jazz2::Scripting::RandWord32()

Returns a random 32-bit word.

std::uint64_t Jazz2::Scripting::unixTimeSec()

Returns the current Unix time in seconds.

std::uint64_t Jazz2::Scripting::unixTimeMs()

Returns the current Unix time in milliseconds.

bool Jazz2::Scripting::jjRegexIsValid(const String& expression)

Returns whether the given regular expression is valid.

bool Jazz2::Scripting::jjRegexMatch(const String& text, const String& expression, bool ignoreCase)

Returns whether the text fully matches the regular expression.

bool Jazz2::Scripting::jjRegexMatchWithResults(const String& text, const String& expression, CScriptArray& results, bool ignoreCase)

Returns whether the text fully matches the regular expression, outputting captured groups.

bool Jazz2::Scripting::jjRegexSearch(const String& text, const String& expression, bool ignoreCase)

Returns whether the regular expression is found anywhere in the text.

bool Jazz2::Scripting::jjRegexSearchWithResults(const String& text, const String& expression, CScriptArray& results, bool ignoreCase)

Returns whether the regular expression is found anywhere in the text, outputting captured groups.

String Jazz2::Scripting::jjRegexReplace(const String& text, const String& expression, const String& replacement, bool ignoreCase)

Returns the text with regular expression matches replaced.

std::int32_t Jazz2::Scripting::GetFPS()

Returns the current frames per second.

bool Jazz2::Scripting::isAdmin()

Returns whether the local player is a server administrator.

String Jazz2::Scripting::getLevelFileName()

Returns the file name of the current level.

Only the name with the .j2l extension appended, e.g. castle1.j2l, without any directories. This is the name the original file had, not the episode path the game uses internally.

String Jazz2::Scripting::getCurrLevelName()

Returns the title of the current level.

The name shown to players, e.g. on the loading screen. Scripts may assign a new title.

void Jazz2::Scripting::setCurrLevelName(const String& in)

Sets the title of the current level.

String Jazz2::Scripting::get_jjTilesetFileName()

Returns the file name of the tile set used by the current level.

If the level combines several tile sets, the first one is returned. Empty if the level has no tile map.

std::int32_t Jazz2::Scripting::get_gameState()

Returns the state of the multiplayer game.

GAME::STARTED without a multiplayer round. In multiplayer GAME::PREGAME before the round starts, GAME::STARTED or GAME::OVERTIME while it runs, GAME::STOPPED after it.

std::int32_t Jazz2::Scripting::getBorderWidth()

Returns the width of the black border on the left and right side of each subscreen.

The value is the size of one border, not of both together.

std::int32_t Jazz2::Scripting::getBorderHeight()

Returns the height of the black border on the top and bottom side of each subscreen.

bool Jazz2::Scripting::getSplitscreenType()

Whether the screen is split vertically when there are exactly two local players.

bool Jazz2::Scripting::setSplitscreenType(bool value)

Sets whether the screen is split vertically.

std::int32_t Jazz2::Scripting::get_teamScore(std::int32_t color)

Returns the current score of a team in team-based game modes.

Indexed by TEAM::Color, 0 outside of multiplayer. A client knows the score the server sent last.

std::int32_t Jazz2::Scripting::GetMaxHealth()

Returns the highest health a player can have.

Taken from the first player, 5 if there is no player yet.

std::int32_t Jazz2::Scripting::GetStartHealth()

Returns the health a player starts with.

Players always start at full health, so this is the same value as jjMaxHealth.

bool Jazz2::Scripting::getEnabledTeam(std::uint8_t team)

Whether a team is enabled in the current game.

Indexed by TEAM::Color, the teams of the team game mode in multiplayer, none otherwise.

bool Jazz2::Scripting::getKeyDown(std::uint8_t key)

Whether a key or a mouse button is currently held down.

Indexed by Windows virtual-key codes, e.g. 0x41 for A or 0x20 for Space. Codes 1, 2, 4, 5 and 6 are the left, right, middle and the two extra mouse buttons. Codes 0x10, 0x11 and 0x12 match Shift, Ctrl and Alt on either side. Keys without a counterpart are never reported as held.

std::int32_t Jazz2::Scripting::getCursorX()

Returns the horizontal position of the mouse cursor.

In pixels of the game view, measured from its left edge, so it stays consistent with drawing even when the window is scaled. Add jjPLAYER::cameraX to get a position in the level.

std::int32_t Jazz2::Scripting::getCursorY()

Returns the vertical position of the mouse cursor.

In pixels of the game view, measured from its top edge. Add jjPLAYER::cameraY to get a position in the level.

bool Jazz2::Scripting::mlleSetup()

Finishes setting up a level made in an extended level editor.

The layers, the palette, the edited tiles and the like are already part of the level when it's converted, so this only recolors the sprites the level asks for. Always returns true.

void Jazz2::Scripting::mlleSpawnOffgrids()

Spawns the objects placed off the tile grid.

Has no effect, these objects are already placed when the level is converted.

void Jazz2::Scripting::mlleSpawnOffgridsLocal()

Spawns the objects placed off the tile grid, for local players only.

Has no effect, these objects are already placed when the level is converted.

Legacy::jjLAYER* Jazz2::Scripting::mlleGetLayer(const String& name)

Returns the layer of the given name, or null if the level has no such layer.

void Jazz2::Scripting::jjSetFadeColors(std::uint8_t red, std::uint8_t green, std::uint8_t blue)

Sets the fade color of the textured background.

The same as calling setFadeColor() on warpHorizon of the textured background layer, which is jjLayers[8], or if that layer isn't textured but another one is, the farthest textured layer.

void Jazz2::Scripting::jjSetFadeColorsFromPalette(std::uint8_t paletteColorID)

Sets the fade color of the textured background to the color of a palette entry.

The default, 207, is the last color of the gradient most textures use.

void Jazz2::Scripting::jjSetFadeColorsFromPalcolor(jjPALCOLOR color)

Sets the fade color of the textured background.

jjPALCOLOR Jazz2::Scripting::jjGetFadeColors()

Returns the fade color of the textured background, see jjSetFadeColors().

void Jazz2::Scripting::jjUpdateTexturedBG()

Redraws the textured background from the tiles of its layer.

Changes to textured layers are applied automatically, so this is never needed.

std::int32_t Jazz2::Scripting::get_jjTexturedBGTexture()

Returns the texture of the textured background.

A shortcut for jjLAYER::texture of the textured background layer, see jjSetFadeColors() for which layer that is.

std::int32_t Jazz2::Scripting::set_jjTexturedBGTexture(std::int32_t texture)

Sets the texture of the textured background.

std::int32_t Jazz2::Scripting::get_jjTexturedBGStyle()

Returns the effect the textured background is drawn with.

A shortcut for jjLAYER::textureStyle of the textured background layer, see jjSetFadeColors() for which layer that is.

std::int32_t Jazz2::Scripting::set_jjTexturedBGStyle(std::int32_t style)

Sets the effect the textured background is drawn with.

bool Jazz2::Scripting::get_jjTexturedBGUsed()

Whether jjLayers[8] is drawn textured.

true if its jjLAYER::textureSurface is anything but SURFACE::UNTEXTURED. Setting true on an untextured layer changes it to SURFACE::LEGACY, setting false to SURFACE::UNTEXTURED.

bool Jazz2::Scripting::set_jjTexturedBGUsed(bool used)

Sets whether jjLayers[8] is drawn textured.

bool Jazz2::Scripting::get_jjTexturedBGStars()

Whether the textured background shows stars.

A shortcut for warpHorizon.stars of the textured background layer, see jjSetFadeColors() for which layer that is. The other styles use this value as their own parameter, see jjLAYER::warpHorizon.

bool Jazz2::Scripting::set_jjTexturedBGStars(bool used)

Sets whether the textured background shows stars.

float Jazz2::Scripting::get_jjTexturedBGFadePositionX()

Returns the horizontal fade position of the textured background.

A fraction of the view, 0.5 being the middle. A shortcut for the fade position of the textured background layer, see jjSetFadeColors() for which layer that is.

float Jazz2::Scripting::set_jjTexturedBGFadePositionX(float value)

Sets the horizontal fade position of the textured background.

float Jazz2::Scripting::get_jjTexturedBGFadePositionY()

Returns the vertical fade position of the textured background.

See jjTexturedBGFadePositionX.

float Jazz2::Scripting::set_jjTexturedBGFadePositionY(float value)

Sets the vertical fade position of the textured background.

bool Jazz2::Scripting::getUseLayer8Speeds()

Whether layer 8 moves by its own speeds.

When false, layer 8 stays fixed to the screen as with LAYERSPEEDMODEL::LAYER8. Only has an effect if layer 8 uses LAYERSPEEDMODEL::LAYER8 on both axes when the level starts.

bool Jazz2::Scripting::setUseLayer8Speeds(bool value)

Sets whether layer 8 moves by its own speeds.

std::uint16_t Jazz2::Scripting::jjGetStaticTile(std::uint16_t tileID)

Returns the frame an animated tile currently shows.

A tile that isn't animated is returned as it is.

std::uint16_t Jazz2::Scripting::jjTileGet(std::uint8_t layer, std::int32_t xTile, std::int32_t yTile)

Returns the tile at a position in tiles in one of the original layers.

A shortcut for jjLayers[layer].tileGet().

std::uint16_t Jazz2::Scripting::jjTileSet(std::uint8_t layer, std::int32_t xTile, std::int32_t yTile, std::uint16_t newTile)

Changes the tile at a position in tiles in one of the original layers.

A shortcut for jjLayers[layer].tileSet(). Returns newTile, or 0 if the layer or the position is invalid.

void Jazz2::Scripting::jjGenerateSettableTileArea(std::uint8_t layer, std::int32_t xTile, std::int32_t yTile, std::int32_t width, std::int32_t height)

Prepares a rectangular area of one of the original layers for jjTileSet().

Has no effect, every tile can already be changed on its own.

bool Jazz2::Scripting::jjMaskedPixel(std::int32_t xPixel, std::int32_t yPixel)

Returns whether a pixel of the sprite layer is solid.

Coordinates are in pixels. When a solid pixel is found, jjEventAtLastMaskedPixel is set to the event of its tile.

bool Jazz2::Scripting::jjMaskedPixelLayer(std::int32_t xPixel, std::int32_t yPixel, std::uint8_t layer)

Returns whether a pixel is solid, see jjMaskedPixel().

bool Jazz2::Scripting::jjMaskedHLine(std::int32_t xPixel, std::int32_t lineLength, std::int32_t yPixel)

Returns whether any pixel of a horizontal line in the sprite layer is solid.

The line starts at xPixel,yPixel and is lineLength pixels long to the right. Returns false if lineLength isn't positive. Sets jjEventAtLastMaskedPixel like jjMaskedPixel().

bool Jazz2::Scripting::jjMaskedHLineLayer(std::int32_t xPixel, std::int32_t lineLength, std::int32_t yPixel, std::uint8_t layer)

Returns whether any pixel of a horizontal line is solid, see jjMaskedHLine().

bool Jazz2::Scripting::jjMaskedVLine(std::int32_t xPixel, std::int32_t yPixel, std::int32_t lineLength)

Returns whether any pixel of a vertical line in the sprite layer is solid.

The line starts at xPixel,yPixel and is lineLength pixels long downwards. Returns false if lineLength isn't positive. Sets jjEventAtLastMaskedPixel like jjMaskedPixel().

bool Jazz2::Scripting::jjMaskedVLineLayer(std::int32_t xPixel, std::int32_t yPixel, std::int32_t lineLength, std::uint8_t layer)

Returns whether any pixel of a vertical line is solid, see jjMaskedVLine().

std::int32_t Jazz2::Scripting::jjMaskedTopVLine(std::int32_t xPixel, std::int32_t yPixel, std::int32_t lineLength)

Returns where the topmost solid pixel of a vertical line in the sprite layer is.

The line starts at xPixel,yPixel and is lineLength pixels long downwards. The result counts from 1, so it's 1 if yPixel itself is solid, and lineLength + 1 if no pixel of the line is. Useful for finding slopes under an object. Sets jjEventAtLastMaskedPixel like jjMaskedPixel().

std::int32_t Jazz2::Scripting::jjMaskedTopVLineLayer(std::int32_t xPixel, std::int32_t yPixel, std::int32_t lineLength, std::uint8_t layer)

Returns where the topmost solid pixel of a vertical line is, see jjMaskedTopVLine().

std::int32_t Jazz2::Scripting::GetEvent(std::uint16_t tx, std::uint16_t ty)

Returns the event ID placed on a tile of the sprite layer.

Tiles are addressed by xTile and yTile. The number uses the event numbering of the original game, so it can be compared with OBJECT::Object and AREA::Area constants.

std::int32_t Jazz2::Scripting::GetEventParamWrapper(std::uint16_t tx, std::uint16_t ty, std::int32_t offset, std::int32_t length)

Returns one parameter of the event placed on a tile.

Parameters
tx
ty
offset Position of the first bit, relative to the first parameter
length Number of bits, negative for a signed value

The parameter is selected the same way the event definitions of the original level editor describe it.

  • length is the bit count of the parameter; a negative value marks a signed parameter.
  • offset is the sum of the absolute lengths of all parameters stored before the requested one, so the first parameter is at offset 0.

An offset of -4 with a length of 2 reads the difficulty bits of the event instead. Returns 0 if the requested bits fall outside the event data.

void Jazz2::Scripting::SetEventByte(std::uint16_t tx, std::uint16_t ty, std::uint8_t newEventId)

Replaces the event placed on a tile.

newEventID is the new event number, e.g. an OBJECT::Object or AREA::Area constant. Only the event ID changes, the parameters already stored on the tile are kept.

void Jazz2::Scripting::SetEventParam(std::uint16_t tx, std::uint16_t ty, int8_t offset, std::int8_t length, std::int32_t newValue)

Changes one parameter of the event placed on a tile.

Parameters
tx
ty
offset Position of the first bit, relative to the first parameter
length Number of bits, negative for a signed value
newValue Value to store

offset and length select the bits exactly as in jjParameterGet(); the new value is truncated to fit them. Objects that already exist may have read their parameters when they were created and won't notice the change, areas that affect the player and objects created later will.

std::int8_t Jazz2::Scripting::GetTileType(std::uint16_t tile)

Returns the type of a tile, indexed by tile ID.

0 is an ordinary tile, 1 translucent, 3 invisible and 5 heat-distorted.

std::int8_t Jazz2::Scripting::SetTileType(std::uint16_t tile, std::uint16_t value)

Sets the type of a tile, indexed by tile ID.

bool Jazz2::Scripting::GetTileIs32Bit(std::uint16_t tile)

Whether a tile uses 32-bit colors, indexed by tile ID.

false for tiles that use palette colors and for empty or undefined tiles.

jjOBJ* Jazz2::Scripting::get_jjObjects(std::int32_t index)

Returns all objects of the level, indexed by object ID.

Slots up to jjObjectCount may hold objects, check jjOBJ::isActive to skip the free ones.

jjOBJ* Jazz2::Scripting::get_jjObjectPresets(std::int8_t id)

Returns the templates of new objects, indexed by event ID.

Every object created from an event starts as a copy of its template, so changing a template (best done in onLevelLoad()) changes all objects of that event created afterward, including their jjOBJ::behavior.

void Jazz2::Scripting::jjAddParticleTileExplosion(std::uint16_t xTile, std::uint16_t yTile, std::uint16_t tile, bool collapseSceneryStyle)

Breaks a tile into falling pieces, like destroyed scenery.

The four quarters of the tile fly apart, or drop with a little drift when collapseSceneryStyle is set, and fall out of the view.

void Jazz2::Scripting::jjAddParticlePixelExplosion(float xPixel, float yPixel, int curFrame, int direction, int mode)

Bursts a sprite frame into pixel particles.

Parameters
xPixel Horizontal position in pixels
yPixel Vertical position in pixels
curFrame Frame to burst, an index of jjAnimFrames
direction Negative to flip the frame horizontally
mode Currently ignored, every mode looks the same

The pieces take the shape of the frame, drawn as it would be at the given position.

jjPARTICLE* Jazz2::Scripting::GetParticle(std::int32_t index)

Returns all particles of the level, indexed from 0 to 1023.

jjPARTICLE* Jazz2::Scripting::AddParticle(std::int32_t particleType)

Creates a new particle.

Parameters
particleType Type of the particle, PARTICLE::INACTIVE is not allowed
Returns The new particle, or null if all particle slots are in use or the type is invalid

The particle starts at position 0, 0 with default values for its type, so at least set its position afterward.

std::int32_t Jazz2::Scripting::get_jjPlayerCount()

Returns the number of players in the level.

std::int32_t Jazz2::Scripting::get_jjLocalPlayerCount()

Returns the number of local players.

The players of this machine, none on a server without a player of its own.

jjPLAYER* Jazz2::Scripting::get_jjP()

Returns the current player.

The first local player. Prefer jjLocalPlayers or jjPlayers, which work with more than one player.

jjPLAYER* Jazz2::Scripting::get_jjPlayers(std::uint8_t index)

Returns the player with the given jjPLAYER::playerID.

Never null, an index without a player returns a handle with jjPLAYER::isActive set to false. In multiplayer, the index is the one the server gave the player, the same on every machine.

jjPLAYER* Jazz2::Scripting::get_jjLocalPlayers(std::uint8_t index)

Returns the local player with the given index.

Counts only the players of this machine, from 0 to jjLocalPlayerCount.

jjWEAPON* Jazz2::Scripting::get_jjWEAPON(int index)

Returns the options of the given weapon.

Indexed by a 1-based WEAPON::Weapon number. Other indices return a scratch object whose changes have no effect.

jjCHARACTER* Jazz2::Scripting::get_jjCHARACTER(int index)

Returns the profile of the given character.

Indexed by CHAR::Char. Currently every character shares one placeholder profile whose changes have no effect.

void Jazz2::Scripting::playSample(float xPixel, float yPixel, std::int32_t sample, std::int32_t volume, std::int32_t frequency)

Plays a sound sample at a position in the level.

The position is in level pixels and makes the sound louder or quieter depending on the distance to the players. volume is on a scale where 63 is full volume, 0 is the default of full volume. frequency is the playback rate in Hz, 0 plays the sample at its own rate.

std::int32_t Jazz2::Scripting::playLoopedSample(float xPixel, float yPixel, std::int32_t sample, std::int32_t channel, std::int32_t volume, std::int32_t frequency)

Plays a looping sound sample at a position in the level and returns its channel.

Pass 0 as channel the first time, then the returned channel on every following call, once per game tick for as long as the sound should continue; the sound follows the latest position and stops when the calls stop. Returns 0 if the sample can't be played. volume and frequency work as in jjSample().

void Jazz2::Scripting::playPrioritySample(std::int32_t sample)

Plays a sound sample at full volume regardless of where the players are.

bool Jazz2::Scripting::isSampleLoaded(std::int32_t sample)

Returns whether a sound sample is available to play.

bool Jazz2::Scripting::loadSample(std::int32_t sample, const String& filename)

Loads a sound sample from a file and returns whether it succeeded.

The loaded sound replaces the sample for every later use of that SOUND::Sample value in the script.

void Jazz2::Scripting::jjSetModPosition(std::int32_t order, std::int32_t row, bool reset)

Jumps to a row of a position in the order list of the playing module music.

The jump is heard at once. While the music is paused, it continues from there once it's resumed.

void Jazz2::Scripting::jjSlideModChannelVolume(std::int32_t channel, float volume, std::int32_t milliseconds)

Gradually changes the volume of a channel of the playing module music.

From its current volume to volume (0 to 1) in milliseconds, a new slide of the channel replaces the previous one.

std::int32_t Jazz2::Scripting::jjGetModOrder()

Returns the current position in the order list of the playing module music.

-1 if no module music plays.

std::int32_t Jazz2::Scripting::jjGetModRow()

Returns the current row of the playing module music.

-1 if no module music plays.

std::int32_t Jazz2::Scripting::jjGetModTempo()

Returns the tempo of the playing module music, in beats per minute.

-1 if no module music plays.

void Jazz2::Scripting::jjSetModTempo(std::uint8_t tempo)

Sets the tempo of the playing module music, until the module sets another one.

std::int32_t Jazz2::Scripting::jjGetModSpeed()

Returns the speed (ticks per row) of the playing module music.

-1 if no module music plays.

void Jazz2::Scripting::jjSetModSpeed(std::uint8_t speed)

Sets the speed (ticks per row) of the playing module music, until the module sets another one.

void Jazz2::Scripting::RegisterArray(asIScriptEngine* engine)

Registers array type to AngelScript engine.

void Jazz2::Scripting::RegisterDictionary(asIScriptEngine* engine)

Registers dictionary type to AngelScript engine.

void Jazz2::Scripting::RegisterImGuiBindings(asIScriptEngine* engine)

Registers ImGui bindings to AngelScript engine.

void Jazz2::Scripting::RegisterMath(asIScriptEngine* engine)

Registers vec2/vec3/vec4/vec2i/vec3i/vec4i/Color types to AngelScript engine.

void Jazz2::Scripting::RegisterRef(asIScriptEngine* engine)

Registers ref type to AngelScript engine.

void Jazz2::Scripting::RegisterString(asIScriptEngine* engine)

Registers Death::Containers::String as string type to AngelScript engine.

void Jazz2::Scripting::RegisterStringUtils(asIScriptEngine* engine)

Registers string::split() and join(), which need the array type registered first.