Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Player

Hierarchy

Implements

Index

Constructors

Properties

Accessors

Methods

Object literals

Constructors

constructor

  • new Player(identifier?: undefined | string): Player
  • Parameters

    • Optional identifier: undefined | string

    Returns Player

Properties

absentLastUsedTime

absentLastUsedTime: number = 0

anim

anim: number

attackAnimationEndTime

attackAnimationEndTime: number | undefined

attackAnimationType

attackAnimationType: DamageType | undefined

containerSortInfo

containerSortInfo: Record<string, IContainerSortInfo>

crafted

crafted: Record<number, ICrafted>

customization

customization: ICustomizations

deathBy

deathBy: ISerializedTranslation = Translation.message(Message.Mysteriously).serialize()

defense

defense: PlayerDefense = new PlayerDefense(0, 0)

defenses

defenses: number[] = []

dialogContainerInfo

dialogContainerInfo: Record<number, IDialogInfo>

dialogInfo

dialogInfo: Record<string, IDialogInfo>

Optional displayCreature

displayCreature: CreatureType

Readonly entityType

entityType: Player = EntityType.Player

Readonly equipEffects

equipEffects: Map<EquipEffect, [LightSource, number] | [Telescopy, number, number]> = new Map<EquipEffect, EquipEffects>()

equipped

equipped: Record<number, number>

event

exploredMap

exploredMap: IExploreMap[] | undefined

facingDirection

facingDirection: Cardinal | None

finishedMovingClientside

finishedMovingClientside: boolean = false

fromX

fromX: number

Not guaranteed to be synced between the server and client for Player entities

fromY

fromY: number

Not guaranteed to be synced between the server and client for Player entities

handToUse

handToUse: EquipType | undefined = EquipType.LeftHand

hintSeen

hintSeen: boolean[] = []

id

id: number

identifier

identifier: string

isConnecting

isConnecting: boolean = false

isMoving

isMoving: boolean = false

isMovingClientside

isMovingClientside: boolean = false

lastAttackedBy

lastAttackedBy: Human | Creature | undefined

lastIslandId

lastIslandId: string = DEFAULT_ISLAND_ID

messages

messages: MessageManager

milestoneModifiers

milestoneModifiers: Set<Milestone> = new Set<Milestone>()

moveType

moveType: MoveType | undefined

movementCompleteZ

movementCompleteZ: number | undefined = undefined

movementFinishTime

movementFinishTime: number = 0

movementProgress

movementProgress: number = 1

name

name: string

nextMoveDirection

nextMoveDirection: Cardinal | None | undefined

nextMoveTime

nextMoveTime: number = 0

nextX

nextX: number = -1

nextY

nextY: number = -1

notes

options

options: IOptions = Objects.deepClone(SaveDataGlobal.defaultOptions)

properties

properties: IProperties | undefined

quests

quests: QuestManager

quickSlotInfo

quickSlotInfo: IQuickSlotInfo[] = []

realTimeTickActionDelay

realTimeTickActionDelay: number = 0

Optional referenceId

referenceId: undefined | number

Optional renamed

renamed: string | ISerializedTranslation

restData

restData: IRestData | undefined

revealedItems

revealedItems: Record<number, boolean>

score

score: number = 0

shouldApplyTravelingEffects

shouldApplyTravelingEffects: boolean | number = true

skill

skill: SkillManager = new SkillManager(this, {id: () => this.id,getSkillGainMultiplier: (...args) => this.getSkillGainMultiplier(...args),canSkillGain: (...args) => this.canSkillGain(...args),onSkillGain: (...args) => this.onSkillGain(...args),})

spawnPoint

spawnPoint: IVector3 = {} as IVector3

Readonly stat

stat: Stats<this> = new Stats(this)

state

state: PlayerState = PlayerState.None

stats

stats: IStats

status

status: IStatus

stopNextMovement

stopNextMovement: boolean

swimming

swimming: boolean = false

tamedCreatures

tamedCreatures: Map<string, number[]> = new Map()

traveled

traveled: boolean = false

turns

turns: number = 1

vehicleItemId

vehicleItemId: number | undefined

walkPath

walkPath: IWalkPath | undefined

walkSoundCounter

walkSoundCounter: number = 4

x

x: number

y

y: number

z

z: number

Accessors

asCreature

  • get asCreature(): undefined

asEntity

asHuman

asNPC

  • get asNPC(): undefined
  • Returns undefined

asPlayer

clientStore

  • Returns IClientStore

Methods

addDelay

  • addDelay(delay: number, replace?: undefined | false | true, addStaminaDelay?: undefined | false | true): void
  • Parameters

    • delay: number
    • Optional replace: undefined | false | true
    • Optional addStaminaDelay: undefined | false | true

    Returns void

addMilestone

  • addMilestone(milestone: Milestone, data?: undefined | number, update?: boolean): void
  • Parameters

    • milestone: Milestone
    • Optional data: undefined | number
    • Default value update: boolean = false

    Returns void

addProperty

  • addProperty(property: Property, value: any): void

animateAttack

  • animateAttack(damageType: DamageType[] | undefined): void

animateBumpTowards

  • animateBumpTowards(x: number, y: number): void
  • Faces the target and animates a bump into effect

    Parameters

    • x: number
    • y: number

    Returns void

applyTravelingEffects

  • applyTravelingEffects(sailToCivilization?: undefined | false | true): void
  • Applies traveling effects to the player Includes stat loss & item damages

    Parameters

    • Optional sailToCivilization: undefined | false | true

    Returns void

burn

  • burn(fireType: FireType, skipMessage?: boolean, skipParry?: undefined | false | true, equipType?: EquipType, fromCombat?: undefined | false | true): number | undefined
  • Burn the player

    Parameters

    • fireType: FireType
    • Default value skipMessage: boolean = false
    • Optional skipParry: undefined | false | true
    • Optional equipType: EquipType
    • Optional fromCombat: undefined | false | true

    Returns number | undefined

calculateEquipmentStats

  • calculateEquipmentStats(): void

Protected calculateStats

  • calculateStats(): void

canJump

  • canJump(): boolean

canSeeObject

canSeePosition

  • canSeePosition(type: CanASeeBType, tileX: number, tileY: number, tileZ: number): boolean

Protected canSkillGain

  • canSkillGain(): boolean

cancelResting

causeStatus

changeId

  • changeId(id: number): void
  • Parameters

    • id: number

    Returns void

checkForGather

  • checkForGather(): Doodad | undefined
  • Returns Doodad | undefined

checkForGatherFire

checkForStill

  • checkForStill(withWater?: undefined | false | true, isLit?: undefined | false | true): boolean
  • Check if there is a still in front of the player.

    Parameters

    • Optional withWater: undefined | false | true

      Check if the still has water in it?

    • Optional isLit: undefined | false | true

      Check if the still is lit?

    Returns boolean

checkForTargetInRange

  • checkForTargetInRange(range: number, includePlayers?: undefined | false | true): IMobCheck

checkForWell

  • checkForWell(): boolean
  • Returns boolean

checkReputationMilestones

  • checkReputationMilestones(): void
  • Returns void

checkSkillMilestones

  • checkSkillMilestones(): void
  • Returns void

checkTravelMilestones

  • checkTravelMilestones(): void
  • Returns void

checkUnder

createItemInInventory

damage

  • damage(damageInfoOrAmount: IDamageInfo | number): number | undefined
  • damage(damageInfoOrAmount: IDamageInfo | number, damageMessage?: Message | Translation, soundDelay?: undefined | number, causesBlood?: undefined | false | true): number | undefined

damageByInteractingWith

damageRandomEquipment

  • damageRandomEquipment(): void

discoverRecipe

  • discoverRecipe(recipeType: ItemType, crafted?: ICrafted, discoveredClientSide?: undefined | false | true): void
  • Parameters

    • recipeType: ItemType
    • Default value crafted: ICrafted = { newUnlock: true, unlockTime: Date.now() }
    • Optional discoveredClientSide: undefined | false | true

    Returns void

equip

  • equip(item: Item, slot: EquipType, internal?: boolean, switchingHands?: boolean): boolean
  • Parameters

    • item: Item
    • slot: EquipType
    • Default value internal: boolean = false
    • Default value switchingHands: boolean = false

    Returns boolean

extinguishTorches

  • extinguishTorches(): void

faceDirection

  • faceDirection(direction: Cardinal | None, turnDelay?: undefined | number): boolean
  • Returns true if the player changed their facing direction.

    Parameters

    • direction: Cardinal | None
    • Optional turnDelay: undefined | number

    Returns boolean

getActiveStatuses

getAndSwitchHandToUse

  • getAndSwitchHandToUse(): EquipType | undefined

Protected getApplicableStatusEffects

getAsHuman

getBarteringBonus

  • getBarteringBonus(baseCredits: number): number
  • Returns the bartering bonus for a given credit value

    Parameters

    • baseCredits: number

    Returns number

Protected getBaseStatBonuses

  • getBaseStatBonuses(): {} & {}

getBurnDamage

  • getBurnDamage(fireType: FireType, skipParry?: undefined | false | true, equipType?: EquipType): number

getConsumeBonus

  • getConsumeBonus(item: Item | undefined, skillUse?: SkillType): number

getCraftingDifficulty

getDamage

getDamageModifier

  • getDamageModifier(): number

getDefaultCarveTool

  • getDefaultCarveTool(_player: Player): Item | undefined
  • Parameters

    Returns Item | undefined

getDialogInfo

  • getDialogInfo(dialogIndex: string | number): IDialogInfo
  • Parameters

    • dialogIndex: string | number

    Returns IDialogInfo

getDisplayCreature

getEquipEffect

getEquipSlotForItem

getEquippedItem

getEquippedItems

  • getEquippedItems(): Item[]

getFacingPoint

getFacingTile

getGameOptions

getGameOptionsBeforeModifiers

getInspectionId

  • getInspectionId(): string

getInsulation

getMaxHealth

  • getMaxHealth(): number
  • Gets the max health of the player.

    Returns the result of the "getMaxHealth" event, or the max in Stat.Health, if the result of the hook is undefined.

    Returns number

getMaxWeight

  • getMaxWeight(): number
  • Gets the strength of the player.

    Returns the result of Hook.GetPlayerStrength, or the max in Stat.Health, if the result of the hook is undefined.

    Used internally for Stat.Weight.max

    Returns number

getMoveType

getMovementFinishTime

  • getMovementFinishTime(timeStamp: number): number

getMovementIntent

getMovementPoint

  • getMovementPoint(timeStamp: number): IVector2

getMovementProgress

  • getMovementProgress(): number

getName

getNextPosition

  • Returns IVector3

getPoint

getProducedTemperature

  • getProducedTemperature(): number | undefined

getProperty

  • getProperty<T>(property: Property): T | undefined

getReputation

  • getReputation(): number

Protected getSkillGainMultiplier

  • getSkillGainMultiplier(skillType: SkillType): number

getStaminaDelay

  • getStaminaDelay(staminaToStartAddingDelayAt?: number): number
  • Gets a stamina penalty delay to be used for slowed actions and movement.

    Parameters

    • Default value staminaToStartAddingDelayAt: number = STAMINA_LOW_PENALTY_START

      Stat value where delays start getting added from.

    Returns number

getStatus

  • Returns the handler for this status effect, whether or not this entity currently has the effect.

    Type parameters

    Parameters

    Returns undefined | S

getStatuses

getTile

getTileUpdateType

getWeightOrStaminaMovementPenalty

  • getWeightOrStaminaMovementPenalty(): number
  • Returns number

getWeightStatus

  • Returns WeightStatus

hasDelay

  • hasDelay(): boolean

hasHandToUse

  • hasHandToUse(): boolean

hasProperty

  • hasProperty(property: Property): boolean

hasStatus

  • Returns whether the entity has the given StatusType

    Parameters

    Returns boolean

hasTamedCreature

  • hasTamedCreature(creature: Creature): boolean
  • Parameters

    Returns boolean

hasWalkPath

  • hasWalkPath(): boolean
  • Returns boolean

healthSyncCheck

  • healthSyncCheck(reason: string): void
  • Parameters

    • reason: string

    Returns void

hurtHands

  • Parameters

    Returns boolean

isExploredClientSide

  • isExploredClientSide(x: number, y: number, z: number): boolean
  • Check if a position is marked as explored Only use this clientside

    Parameters

    • x: number
    • y: number
    • z: number

    Returns boolean

isFacingCarvableTile

  • isFacingCarvableTile(): boolean
  • Returns boolean

isGhost

  • isGhost(): boolean

isInFov

  • isInFov(): boolean

isLocalPlayer

  • isLocalPlayer(): boolean

isNearby

  • isNearby(entity: Entity): boolean

isOnFire

isResting

  • isResting(): boolean

isRestingCancelled

  • isRestingCancelled(): boolean

isServer

  • isServer(): boolean
  • Returns boolean

isSwimming

  • isSwimming(): boolean
  • Gets if the human is swimming (and not on a boat)

    Returns boolean

kill

  • kill(): void
  • Returns void

markAsExplored

  • markAsExplored(points: IVector2[]): any
  • Parameters

    Returns any

moveTo

  • moveTo(): boolean
  • deprecated

    Do not call this with players.

    Returns boolean

notifyItem

notifyStat

onNoInput

  • onNoInput(): void
  • Returns void

Protected onSetStatChangeTimer

  • Applies stat change timer multipliers from game difficulty options

    Parameters

    Returns false | undefined

Protected onSkillGain

  • onSkillGain(skill: SkillType, mod: number): void

Protected onStatChange

  • Event handler for EntityEvent.StatChanged. Handles special functionality when stats are increased:

    1. When resting & stamina is full, resting will be cancelled.
    2. Health is sync-checked.
    3. When hunger > maximum, damage will be dealt, stamina will be decreased, and a message will be displayed.
    4. When thirst > maximum, damage will be dealt, stamina will be decreased, and a message will be displayed.

    Parameters

    Returns void

Protected onStatusEffectChanged

  • onStatusEffectChanged(status: StatusType, has: boolean): void
  • Event handler for when a status effect is applied or removed.

    Parameters

    Returns void

onUnserialized

  • onUnserialized(): void

passTurn

  • Parameters

    Returns void

processInput

  • This is only ran on the server

    Parameters

    • timeStamp: number

    Returns IMovementIntent | undefined

queueSoundEffect

  • queueSoundEffect(type: SfxType, delay?: number, speed?: number, noPosition?: boolean): void
  • Parameters

    • type: SfxType
    • Default value delay: number = 0
    • Default value speed: number = 1
    • Default value noPosition: boolean = false

    Returns void

queueSoundEffectInFront

  • queueSoundEffectInFront(type: SfxType, delay?: number, speed?: number, noPosition?: boolean): void
  • Parameters

    • type: SfxType
    • Default value delay: number = 0
    • Default value speed: number = 1
    • Default value noPosition: boolean = false

    Returns void

removeProperty

  • removeProperty(property: Property): boolean

Protected resetDefense

  • resetDefense(skipStatChangedEvent?: undefined | false | true): void
  • Parameters

    • Optional skipStatChangedEvent: undefined | false | true

    Returns void

resetMovementStates

  • resetMovementStates(): void
  • Returns void

resetStatTimers

  • resetStatTimers(): void

respawn

  • respawn(): void
  • Returns void

revealItem

  • Parameters

    Returns void

setInFov

  • setInFov(inFov: boolean): void
  • Parameters

    • inFov: boolean

    Returns void

setMoveType

setOptions

setPaddling

  • setPaddling(paddling: boolean, itemId: number, extinguishTorches?: undefined | false | true): boolean
  • Parameters

    • paddling: boolean
    • itemId: number
    • Optional extinguishTorches: undefined | false | true

    Returns boolean

setPosition

setStatChangeTimerIgnoreDifficultyOptions

  • setStatChangeTimerIgnoreDifficultyOptions(stat: Stat | IStat, timer: number, amt?: undefined | number): void
  • Parameters

    • stat: Stat | IStat
    • timer: number
    • Optional amt: undefined | number

    Returns void

setStatus

setTamedCreatureEnemy

  • Parameters

    Returns void

setZ

  • setZ(z: number, effects?: boolean): void
  • Parameters

    • z: number
    • Default value effects: boolean = true

      If true, adds a delay to the player, clears any particles, and updates the view. (Default: true)

    Returns void

setup

  • setup(): void
  • Returns void

setupLoad

  • setupLoad(): void
  • Returns void

showRestInterrupt

  • showRestInterrupt(restType: RestType): void
  • Parameters

    Returns void

staminaReduction

  • staminaReduction(skill?: SkillType, level?: undefined | number): void

startResting

Protected statGain

  • statGain(stat: Stat, bypass: boolean): void
  • Improve one of the core player stats

    Parameters

    • stat: Stat
    • bypass: boolean

    Returns void

Protected swimAndSootheCheck

  • swimAndSootheCheck(): void

tick

  • tick(isPassTurn?: undefined | false | true): void
  • Parameters

    • Optional isPassTurn: undefined | false | true

    Returns void

tickStatuses

  • tickStatuses(): void
  • Updates caused by status effects such as bleeding, poison, and burns.

    Returns void

toString

  • toString(): string

unequip

  • unequip(item: Item, internal?: boolean, skipMessage?: boolean, skipRevertItem?: boolean): void
  • Parameters

    • item: Item
    • Default value internal: boolean = false
    • Default value skipMessage: boolean = false
    • Default value skipRevertItem: boolean = false

    Returns void

unequipAll

  • unequipAll(): void

update

  • update(): void
  • Returns void

updateCraftTable

  • updateCraftTable(adjacentContainers?: IContainer[]): void
  • Parameters

    Returns void

updateDialogInfo

  • updateDialogInfo(dialogIndex: string | number): void
  • Parameters

    • dialogIndex: string | number

    Returns void

updateDismantleTable

  • updateDismantleTable(adjacentContainers?: IContainer[]): void
  • Parameters

    Returns void

updateHandToUse

  • updateHandToUse(): void
  • Ensure handToUse is valid given the players options

    Returns void

updateMovementIntent

  • Parameters

    Returns void

updatePaddling

  • updatePaddling(): void

updateQuickSlotInfo

  • Parameters

    Returns void

updateReputation

  • updateReputation(reputation: number): void

updateStatsAndAttributes

  • updateStatsAndAttributes(): void

updateStrength

  • updateStrength(): void
  • This needs to be called whenever the player's strength requires an update.

    Example usage includes:

    1. When max health changes. Max health is used in calculating the strength.
    2. If a mod is using the GetPlayerStrength hook and the calculation needs to be refreshed.

    Returns void

updateSwimming

  • updateSwimming(): void

updateTables

  • updateTables(deferUpdate?: boolean): void
  • Parameters

    • Default value deferUpdate: boolean = false

    Returns void

updateTablesAndWeight

  • updateTablesAndWeight(source: string, deferTableUpdates?: boolean): void
  • Parameters

    • source: string
    • Default value deferTableUpdates: boolean = false

    Returns void

walkAlongPath

  • walkAlongPath(path: IVector2[] | undefined, force?: undefined | false | true): void
  • Parameters

    • path: IVector2[] | undefined
    • Optional force: undefined | false | true

    Returns void

Static getNameTranslation

Object literals

attackFromEquip

attackFromEquip: object

leftHand

leftHand: number = 0

rightHand

rightHand: number = 0

direction

direction: object

x

x: number = 0

y

y: number = 0

inventory

inventory: object

containedItems

containedItems: Item[] = ([]) as Item[]

Generated using TypeDoc