Jazz2::Scripting::Legacy::jjPLAYER class

A player in the level.

Primary script interface to a player, wrapping an engine Actors::Player and mirroring the original JJ2+ jjPLAYER. Exposes position, speed, health, lives, score, weapons/ammo, the active character and a large set of state queries and actions (freeze, morph, sugar rush, warps, etc.). The level loader owns one backing instance per player (see LevelScriptLoader::GetPlayerBackingStore), reached from script via jjPlayers.

Constructors, destructors, conversion operators

jjPLAYER(LevelScriptLoader* levelScripts, Actors::Player* player)
Creates a new instance wrapping the given engine player.
~jjPLAYER()

Public functions

auto operator=(const jjPLAYER& o) -> jjPLAYER&
auto get_score() const -> std::int32_t
Returns the player's score.
auto set_score(std::int32_t value) -> std::int32_t
Sets the player's score.
auto get_scoreDisplayed() const -> std::int32_t
Returns the score currently shown on the HUD.
auto set_scoreDisplayed(std::int32_t value) -> std::int32_t
Sets the score currently shown on the HUD.
auto setScore(std::int32_t value) -> std::int32_t
Sets the player's score.
auto get_xPos() const -> float
Returns the horizontal position in pixels.
auto set_xPos(float value) -> float
Sets the horizontal position in pixels.
auto get_yPos() const -> float
Returns the vertical position in pixels.
auto set_yPos(float value) -> float
Sets the vertical position in pixels.
auto get_xAcc() const -> float
Returns the horizontal acceleration.
auto set_xAcc(float value) -> float
Sets the horizontal acceleration.
auto get_yAcc() const -> float
Returns the vertical acceleration.
auto set_yAcc(float value) -> float
Sets the vertical acceleration.
auto get_xOrg() const -> float
Returns the original (spawn) horizontal position.
auto set_xOrg(float value) -> float
Sets the original (spawn) horizontal position.
auto get_yOrg() const -> float
Returns the original (spawn) vertical position.
auto set_yOrg(float value) -> float
Sets the original (spawn) vertical position.
auto get_xSpeed() -> float
Returns the horizontal speed.
auto set_xSpeed(float value) -> float
Sets the horizontal speed.
auto get_ySpeed() -> float
Returns the vertical speed.
auto set_ySpeed(float value) -> float
Sets the vertical speed.
void freeze(bool frozen)
Freezes or unfreezes the player.
auto get_currTile() -> std::int32_t
Returns the tile the player currently occupies.
auto startSugarRush(std::int32_t time) -> bool
Starts a sugar rush lasting the given number of ticks.
auto get_health() const -> std::int8_t
Returns the player's health.
auto set_health(std::int8_t value) -> std::int8_t
Sets the player's health.
auto get_fastfire() const -> std::int32_t
Returns the player's fast-fire level.
auto set_fastfire(std::int32_t value) -> std::int32_t
Sets the player's fast-fire level.
auto get_currWeapon() const -> std::int8_t
Returns the currently selected weapon.
auto set_currWeapon(std::int8_t value) -> std::int8_t
Sets the currently selected weapon.
auto get_invincibility() const -> std::int32_t
Returns the remaining invincibility duration.
auto set_invincibility(std::int32_t value) -> std::int32_t
Sets the remaining invincibility duration.
auto get_blink() const -> std::int32_t
Returns the remaining blink (post-hit flicker) duration.
auto set_blink(std::int32_t value) -> std::int32_t
Sets the remaining blink (post-hit flicker) duration.
auto extendInvincibility(std::int32_t duration) -> std::int32_t
Extends the player's invincibility by the given duration.
auto get_food() const -> std::int32_t
Returns the player's food count.
auto set_food(std::int32_t value) -> std::int32_t
Sets the player's food count.
auto get_coins() const -> std::int32_t
Returns the player's coin count.
auto set_coins(std::int32_t value) -> std::int32_t
Sets the player's coin count.
auto testForCoins(std::int32_t numberOfCoins) -> bool
Spends the given number of coins if the player has enough.
auto get_gems(std::uint32_t type) const -> std::int32_t
Returns the player's gem count of the given type.
auto set_gems(std::uint32_t type, std::int32_t value) -> std::int32_t
Sets the player's gem count of the given type.
auto testForGems(std::int32_t numberOfGems, std::uint32_t type) -> bool
Spends the given number of gems of a type if the player has enough.
auto get_shieldType() const -> std::int32_t
Returns the active shield type.
auto set_shieldType(std::int32_t value) -> std::int32_t
Sets the active shield type.
auto get_shieldTime() const -> std::int32_t
Returns the remaining shield duration.
auto set_shieldTime(std::int32_t value) -> std::int32_t
Sets the remaining shield duration.
auto get_rolling() const -> std::int32_t
Returns the remaining roll duration.
auto set_rolling(std::int32_t value) -> std::int32_t
Sets the remaining roll duration.
auto get_playerID() const -> std::int8_t
Returns the player's id.
auto get_localPlayerID() const -> std::int32_t
Returns the player's local id.
auto get_running() const -> bool
Returns whether the player is running.
auto set_running(bool value) -> bool
Sets whether the player is running.
auto get_stoned() -> std::int32_t
Returns the remaining stoned (dizzy) duration.
auto set_stoned(std::int32_t value) -> std::int32_t
Sets the remaining stoned (dizzy) duration.
void suckerTube(std::int32_t xSpeed, std::int32_t ySpeed, bool center, bool noclip, bool trigSample)
Moves the player through a sucker tube at the given speed.
void poleSpin(float xSpeed, float ySpeed, std::uint32_t delay)
Spins the player off a pole at the given speed.
void spring(float xSpeed, float ySpeed, bool keepZeroSpeeds, bool sample)
Bounces the player off a spring at the given speed.
auto get_isConnecting() const -> bool
Returns whether the player is still connecting.
auto get_isIdle() const -> bool
Returns whether the player is idle.
auto get_isOut() const -> bool
Returns whether the player is out of the game.
auto get_isSpectating() const -> bool
Returns whether the player is spectating.
auto get_isInGame() const -> bool
Returns whether the player is currently in the game.
auto get_name() const -> String
Returns the player's display name.
auto get_nameUnformatted() const -> String
Returns the player's name without formatting codes.
auto setName(const String& name) -> bool
Sets the player's display name.
auto get_light() const -> std::int8_t
Returns the brightness of the light around the player.
auto set_light(std::int8_t value) -> std::int8_t
Sets the brightness of the light around the player.
auto get_fur() const -> std::uint32_t
Returns the packed fur (recolor) value.
auto set_fur(std::uint32_t value) -> std::uint32_t
Sets the packed fur (recolor) value.
void getFur(std::uint8_t& a, std::uint8_t& b, std::uint8_t& c, std::uint8_t& d) const
Outputs the player's four fur (recolor) palette indices.
void setFur(std::uint8_t a, std::uint8_t b, std::uint8_t c, std::uint8_t d)
Sets the player's four fur (recolor) palette indices.
auto get_noFire() const -> bool
Returns whether the player is prevented from firing.
auto set_noFire(bool value) -> bool
Sets whether the player is prevented from firing.
auto get_antiGrav() const -> bool
Returns whether anti-gravity is active.
auto set_antiGrav(bool value) -> bool
Sets whether anti-gravity is active.
auto get_invisibility() const -> bool
Returns whether the player is invisible.
auto set_invisibility(bool value) -> bool
Sets whether the player is invisible.
auto get_noclipMode() const -> bool
Returns whether noclip mode is active.
auto set_noclipMode(bool value) -> bool
Sets whether noclip mode is active.
auto get_lighting() const -> std::uint8_t
Returns the player's lighting level.
auto set_lighting(std::uint8_t value) -> std::uint8_t
Sets the player's lighting level.
auto resetLight() -> std::uint8_t
Resets the player's lighting to the default level.
auto get_playerKeyLeftPressed() -> bool
Returns whether the left key is pressed.
auto get_playerKeyRightPressed() -> bool
Returns whether the right key is pressed.
auto get_playerKeyUpPressed() -> bool
Returns whether the up key is pressed.
auto get_playerKeyDownPressed() -> bool
Returns whether the down key is pressed.
auto get_playerKeyFirePressed() -> bool
Returns whether the fire key is pressed.
auto get_playerKeySelectPressed() -> bool
Returns whether the weapon-select key is pressed.
auto get_playerKeyJumpPressed() -> bool
Returns whether the jump key is pressed.
auto get_playerKeyRunPressed() -> bool
Returns whether the run key is pressed.
void set_playerKeyLeftPressed(bool value)
Sets whether the left key is pressed.
void set_playerKeyRightPressed(bool value)
Sets whether the right key is pressed.
void set_playerKeyUpPressed(bool value)
Sets whether the up key is pressed.
void set_playerKeyDownPressed(bool value)
Sets whether the down key is pressed.
void set_playerKeyFirePressed(bool value)
Sets whether the fire key is pressed.
void set_playerKeySelectPressed(bool value)
Sets whether the weapon-select key is pressed.
void set_playerKeyJumpPressed(bool value)
Sets whether the jump key is pressed.
void set_playerKeyRunPressed(bool value)
Sets whether the run key is pressed.
auto get_powerup(std::uint8_t index) -> bool
Returns whether the player has the powerup for the given weapon.
auto set_powerup(std::uint8_t index, bool value) -> bool
Sets whether the player has the powerup for the given weapon.
auto get_ammo(std::uint8_t index) const -> std::int32_t
Returns the ammo count for the given weapon.
auto set_ammo(std::uint8_t index, std::int32_t value) -> std::int32_t
Sets the ammo count for the given weapon.
auto offsetPosition(std::int32_t xPixels, std::int32_t yPixels) -> bool
Moves the player by the given pixel offset.
auto warpToTile(std::int32_t xTile, std::int32_t yTile, bool fast) -> bool
Warps the player to the given tile coordinates.
auto warpToID(std::uint8_t warpID, bool fast) -> bool
Warps the player to the warp target with the given id.
auto morph(bool rabbitsOnly, bool morphEffect) -> std::uint32_t
Morphs the player into a random character.
auto morphTo(std::uint32_t charNew, bool morphEffect) -> std::uint32_t
Morphs the player into the given character.
auto revertMorph(bool morphEffect) -> std::uint32_t
Reverts the player to the original character.
auto get_charCurr() const -> std::uint32_t
Returns the player's current character.
void kill()
Kills the player.
auto hurt(std::int8_t damage, bool forceHurt, jjPLAYER* attacker) -> bool
Damages the player and returns whether the hit was applied.
auto get_timerState() const -> std::uint32_t
Returns the state of the player's timer.
auto get_timerPersists() const -> bool
Returns whether the timer persists across levels.
auto set_timerPersists(bool value) -> bool
Sets whether the timer persists across levels.
auto timerStart(std::int32_t ticks, bool startPaused) -> std::uint32_t
Starts the player's timer for the given number of ticks.
auto timerPause() -> std::uint32_t
Pauses the player's timer.
auto timerResume() -> std::uint32_t
Resumes the player's timer.
auto timerStop() -> std::uint32_t
Stops the player's timer.
auto get_timerTime() const -> std::int32_t
Returns the time remaining on the player's timer.
auto set_timerTime(std::int32_t value) -> std::int32_t
Sets the time remaining on the player's timer.
void timerFunction(const String& functionName)
Sets the script function called when the timer ends, by name.
void timerFunctionPtr(void* function)
Sets the script function called when the timer ends, by pointer.
void timerFunctionFuncPtr(void* function)
Sets the script function called when the timer ends, by function pointer.
auto activateBoss(bool activate) -> bool
Activates or deactivates the player's boss.
auto limitXScroll(std::uint16_t left, std::uint16_t width) -> bool
Limits horizontal camera scrolling to the given region.
void cameraFreezeFF(float xPixel, float yPixel, bool centered, bool instant)
Freezes the camera at the given fixed position.
void cameraFreezeBF(bool xUnfreeze, float yPixel, bool centered, bool instant)
Freezes the camera, leaving the horizontal axis tracking the player.
void cameraFreezeFB(float xPixel, bool yUnfreeze, bool centered, bool instant)
Freezes the camera, leaving the vertical axis tracking the player.
void cameraFreezeBB(bool xUnfreeze, bool yUnfreeze, bool centered, bool instant)
Freezes the camera, leaving both axes optionally tracking the player.
void cameraUnfreeze(bool instant)
Unfreezes the camera.
void showText(const String& text, std::uint32_t size)
Shows the given text to the player.
void showTextByID(std::uint32_t textID, std::uint32_t offset, std::uint32_t size)
Shows a string from the level text bank to the player.
auto get_fly() const -> std::uint32_t
Returns the remaining fly (airboard) duration.
auto set_fly(std::uint32_t value) -> std::uint32_t
Sets the remaining fly (airboard) duration.
auto fireBulletDirection(std::uint8_t gun, bool depleteAmmo, bool requireAmmo, std::uint32_t direction) -> std::int32_t
Fires a bullet in the given direction and returns the new bullet's id.
auto fireBulletAngle(std::uint8_t gun, bool depleteAmmo, bool requireAmmo, float angle) -> std::int32_t
Fires a bullet at the given angle and returns the new bullet's id.
auto get_cameraX() const -> float
Returns the camera's horizontal position.
auto get_cameraY() const -> float
Returns the camera's vertical position.
auto get_deaths() const -> std::int32_t
Returns the number of times the player has died.
auto get_isJailed() const -> bool
Returns whether the player is jailed.
auto get_isZombie() const -> bool
Returns whether the player is a zombie.
auto get_lrsLives() const -> std::int32_t
Returns the player's remaining lives in last-rabbit-standing mode.
auto get_roasts() const -> std::int32_t
Returns the number of players this player has roasted.
auto get_laps() const -> std::int32_t
Returns the number of laps the player has completed.
auto get_lapTimeCurrent() const -> std::int32_t
Returns the elapsed time of the current lap.
auto get_lapTimes(std::uint32_t index) const -> std::int32_t
Returns the recorded time of the lap at the given index.
auto get_lapTimeBest() const -> std::int32_t
Returns the player's best lap time.
auto get_isAdmin() const -> bool
Returns whether the player is a server administrator.
auto hasPrivilege(const String& privilege, std::uint32_t moduleID) const -> bool
Returns whether the player holds the given privilege.
auto doesCollide(const jjOBJ* object, bool always) const -> bool
Returns whether the player collides with the given object.
auto getObjectHitForce(const jjOBJ& target) const -> std::int32_t
Returns the force with which the player would hit the given object.
auto objectHit(jjOBJ* target, std::int32_t force, std::uint32_t playerHandling) -> bool
Handles the player hitting the target object.
auto isEnemy(const jjPLAYER* victim) const -> bool
Returns whether the given player is an enemy of this player.

Public variables

float jumpStrength
Strength of the player's jump.
std::int8_t frozen
Number of frames the player remains frozen.
std::int32_t warpID
Id of the warp the player is using.
std::int32_t lives
Number of remaining lives.
std::int32_t bossNumber
Index of the boss assigned to the player.
std::int32_t boss
Object id of the player's boss.
bool bossActive
Whether the player's boss is active.
std::int8_t direction
Facing direction of the player.
std::int32_t platform
Object id of the platform the player is standing on.
std::int32_t flag
Capture-the-flag flag state.
std::int32_t clientID
Network client id of the player.
bool team
Team the player belongs to.
std::int32_t specialJump
Remaining special-jump duration.
std::int32_t buttstomp
Remaining buttstomp duration.
std::int32_t helicopter
Remaining helicopter (copter) duration.
std::int32_t helicopterElapsed
Elapsed helicopter (copter) time.
std::int32_t specialMove
Active special move.
std::int32_t idle
Number of frames the player has been idle.
bool isLocal
Whether the player is local to this client.
bool isActive
Whether the player is currently active.
std::uint32_t charOrig
The player's original character.
std::int32_t subscreenX
Horizontal position of the player's split-screen subscreen.
std::int32_t subscreenY
Vertical position of the player's split-screen subscreen.
std::uint32_t charCurr
The player's current character.
std::uint16_t curAnim
Current animation index.
std::uint32_t curFrame
Current sprite frame index.
std::uint8_t frameID
Current frame id within the animation.