Entity class that includes stats/status system. Note: We're assuming something with stats is also movable!

Hierarchy

Constructors

Properties

Accessors

Methods

addAiType addDelay addMilestone addReferenceId addTag addTamedCreature animateAttack animateBumpTowards applyTravelingEffects attack autoScaleStats burn calculateDamageAmount calculateEquipmentStats calculateStats calculateVoyageInfo canCombatTides canDespawn canInspect canInteract canMoveToTile canSailAway canSailTo canSeeObject canSeePosition canSeeTile canSwapWith canUpdateOutsideFov cancelResting capReputation capStatTimers causeStatus changeZ checkForGather checkForGatherFire checkForStill checkForTargetInRange checkForWell checkOnLoadMilestones checkUnder clearTileCache closeContainerDialogs confirmInteract createItemInInventory createMessageManager createNoteManager createQuestManager createSkillManager damage damageByInteractingWith damageRandomEquipment discoverRecipe discoverVulnOrResist equip extinguishTorches findPathToPort fireSootheCheck generateWeightCapacity getActions getActiveStatuses getApplicableStatusEffects getAsHuman getAttack getBarteringBonus getBurnDamage getCombatStrength getConsumeBonus getCraftingDifficulty getDamage getDamageModifier getData getDefaultAiType getDefaultCustomization getDefaultEquipment getDefaultInteraction getDefaultInventory getDefaultName getDescription getDiscoveredVulnsAndResists getEquipEffect getEquipSlotForItem getEquippedItem getEquippedItems getGameOptions getGameOptionsBeforeModifiers getGreeting getInspectionId getInsulation getJumpTile getMaxHealth getMaxWeight getMoveType getMovementDelay getMovementIntent getMovementPoint getMovementProgress getName getProducedTemperature getPublicContainer getQualityBonus getRegistrarId getReputation getReputationChangeOnDeath getReputationMultiplier getScaledWeight getSimplifiedCumulativeAttack getSkillBonus getStaminaDelay getStatus getStatuses getWeightOrStaminaMovementPenalty getWeightStatus hasData hasDelay hasDiscoveredVulnOrResist hasStatus hasTag hasTalkedTo hasWalkPath healthSyncCheck humansVisible hurtHands incrementIslandTickCount initializeStats interact isAlreadyInteracting isDead isDualWielding isGhost isHost isHostile isLocalPlayer isNearby isOffHandDisabled isOnFire isResting isRestingCancelled isServer isSwimming isValid isWaiting isWithinHumanBounds kill loadOnIsland loadUi makeHostile move moveTo moveToIsland moveToIslandId moveToIslandPosition moveTowardsIsland notifyItem notifyStat onDie onMoveComplete onMovementCompleted onNoInput onSetStatChangeTimer onSkillGain onStaminaUseChanged onStatChange onStatusEffectChanged overrideNextMovement passTurn postMove processInput queueSoundEffect queueSoundEffectInFront rangeAction refreshStatusEffects removeAiType removeData removeTag removeTamedCreature resetDefense resetMovementIntent resetStatTimers runActions runCommonProcesses setCachedTile setData setFromPosition setHumansWithinBound setMoveType setMoving setName setOptions setPosition setStatChangeTimerIgnoreDifficultyOptions setStatus setTamedCreatureEnemy setVehicle setWalkPath setZ skipNextMovement skipNextUpdate spawn staminaReduction staminaSyncCheck startResting statGain swimAndSootheCheck talkTo tick tickStatuses toString trampleFire unequip unequipAll update updateDirection updateMovementIntent updateRender updateReputation updateReputationForAttackingWithTamedCreature updateStatsAndAttributes updateStrength updateSwimming updateTablesAndWeight updateTile updateVehicle updateView updateWeight getNameTranslation getRegistrarId setRegistrarId

Constructors

Properties

_description?: unknown
_movementTime?: {
    end: number;
    start: number;
}

Type declaration

  • end: number
  • start: number
ai: AiType
allowSmartMovementClientside?: boolean
anim: number = 0
attackAnimationTime?: IMovementTime
attackAnimationType?: DamageType
cachedMovementPenalty?: number
crafted: Record<number, ICrafted> = {}
customization: ICustomizations
deathBy: ISerializedTranslation = ...
defense: default = ...
defenses: number[] = []
direction: default = Vector2.ZERO

undefined = Vector2.ZERO for this

equipEffects: Map<EquipEffect, EquipEffects> = ...
equippedOffHandDisabled?: default
equippedReferences: Map<EquipType, default> = ...
facingDirection: East | North | West | South = Direction.South

undefined = Direction.None for this

flyingDelay?: number
fromX: number = 0

Note: This might not be a whole number.

fromY: number = 0

Note: This might not be a whole number.

gameOptionsCached?: IGameOptionsPlayer
handEquippedToLast: MainHand | OffHand = EquipType.OffHand
id: number
identifier: string
interactions?: Map<string, Set<number>>
inventory: IContainer = ...
isConnecting: boolean = false
isMoving?: boolean

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

isMovingSuppressVehicleClientside: boolean = false

Flag that will prevent a humans vehicle from showing up until the movement finishews

isPlayerLike: boolean = false
islandId: `${number},${number}`
lastAttackedByReference?: Reference
manualTickActionDelay?: number
messages: IMessageManager
milestonesCollection: GameplayModifiersCollection<default, Milestone, MilestoneModifierInstance<any>, [default<number>?]> = ...
moveType?: MoveType
movementCompleteZ?: number

Only used for Human entities

movementIntent: IMovementIntent = {}
movingClientside: MovingClientSide = MovingClientSide.NoInput

The state of what the client thinks is happening to this entity (regarding movement)

movingOptions?: IMoveToOptions
nextMoveDirection?: None | East | North | West | South
nextMoveTime: number = 0
options: Readonly<IOptions> = ...
preventRendering?: boolean
realTimeTickActionDelay: number = 0
referenceId?: number

Do not use this property directly, instead use `game.references.getReference()

renamed?: string | ISerializedTranslation
respawnPoint: undefined | IVector4
restData: undefined | IRestData
score: number = 0
seen: number
shouldSkipNextMovement?: true
shouldSkipNextUpdate?: true
skill: default
stat: default<default> = ...
state: PlayerState = PlayerState.None
stats: IStats
status: IStatus
swimming: boolean = false
talked?: Map<string, number>
tamedCreatures: Map<`${number},${number}`, Set<number>> = ...
ticksSpent: Map<`${number},${number}`, number> = ...
turns: number = 1
type: NPCType
vehicleItemReference: undefined | default
walkPath?: IWalkPath
walkSoundCounter: number = 4
weightCapacity: number
x: number
y: number
registrarId: number

Accessors

  • get asCorpse(): undefined
  • Returns undefined

  • get asCreature(): undefined
  • Returns undefined

  • get asDoodad(): undefined
  • Returns undefined

  • get asEntity(): default<DescriptionType, TypeType, TagType, unknown>
  • Returns default<DescriptionType, TypeType, TagType, unknown>

  • get asEntityMovable(): default<DescriptionType, TypeType, TagType, unknown>
  • Returns default<DescriptionType, TypeType, TagType, unknown>

  • get asEntityWithStats(): default<DescriptionType, TypeType, TagType>
  • Returns default<DescriptionType, TypeType, TagType>

  • get asHuman(): default<number>
  • Returns default<number>

  • get asItem(): undefined
  • Returns undefined

  • get asLocalPlayer(): undefined
  • Returns undefined

  • get asMerchant(): undefined | default
  • Returns undefined | default

  • get asNPC(): default
  • Returns default

  • get asPlayer(): undefined
  • Returns undefined

  • get asShipper(): undefined | default
  • Returns undefined | default

  • get asTileEvent(): undefined
  • Returns undefined

  • get constructorFunction(): typeof default
  • Returns typeof default

  • get description(): undefined | DescriptionType
  • Get the entities description

    Returns undefined | DescriptionType

  • get entityType(): NPC
  • Returns NPC

  • get facingTile(): default
  • Regular entities don't have a direction so this will be the same as getTile()

    Returns default

  • get isFlying(): boolean
  • Returns boolean

  • get island(): default
  • Returns default

  • get point(): IVector3
  • Location of the entity on the world. Parent classes will probably mark this as always defined

    Returns IVector3

  • get reference(): undefined | Reference
  • Returns undefined | Reference

  • get tile(): default
  • Tile the entity is on in the world. Parent classes will probably mark this as always defined

    Returns default

  • get tilesAround(): undefined | default[]
  • Returns undefined | default[]

Methods

  • Parameters

    Returns void

  • Parameters

    • delay: number
    • Optional replace: boolean
    • Optional addStaminaDelay: boolean

    Returns void

  • Returns void

  • Adds a referenceId to the entity if it doesn't already have one

    Returns void

  • Parameters

    • tag: unknown

    Returns void

  • Parameters

    Returns void

  • Faces the target and animates a bump into effect

    Parameters

    Returns void

  • Applies traveling effects to the player

    • Loses stamina, hunger, and thirst
    • Damages spyglass, golden sextant, and boat if it's being used
    • Decays items in the player's inventory

    Parameters

    Returns void

  • Returns boolean

  • Returns void

  • Burn the player

    Parameters

    • fireType: FireType
    • skipMessage: boolean = false
    • Optional skipParry: boolean
    • Optional equipType: EquipType
    • Optional fromCombat: boolean
    • level: number = 1

    Returns undefined | number

  • Returns void

  • Override in npcs for custom logic

    Returns

    True if the npc can despawn due to not being seen for a while

    Returns boolean

  • Parameters

    Returns boolean

  • Parameters

    Returns 0 | -1 | -2 | -3 | -4 | -5 | -6

  • Parameters

    • x: number
    • y: number

    Returns boolean

  • Parameters

    • type: CanASeeBType
    • islandId: `${number},${number}`
    • x: number
    • y: number
    • z: number
    • Optional fieldOfView: default
    • Optional customRadius: number

    Returns boolean

  • Allow swapping with npcs

    Parameters

    • human: default<number>
    • source: undefined | string

    Returns boolean

  • Override in npcs for custom logic

    Returns

    True if an npc can move / attack / do other things while not in anyones field of view

    Returns boolean

  • Returns void

  • Stop stat timers when they would kill

    Returns void

  • Parameters

    • toZ: number
    • fromZ: number

    Returns undefined | boolean | void

  • Check if there is a still in front of the player.

    Parameters

    • Optional withWater: boolean

      Check if the still has water in it?

    • Optional isLit: boolean

      Check if the still is lit?

    Returns boolean

  • Parameters

    • range: number
    • Optional includePlayers: boolean

    Returns IMobCheck

  • Returns boolean

  • Returns void

  • Closes container dialogs

    Returns void

  • Parameters

    • human: default<number>
    • Optional interactType: number

    Returns Promise<boolean>

  • Parameters

    Returns undefined | number

  • Deprecated

    provide a full IDamageInfo object yourself you lazy fiend

    Parameters

    • damageInfoOrAmount: number | IDamageInfo
    • Optional damageMessage: default | default
    • Optional soundDelay: number
    • Optional causesBlood: boolean
    • Optional statusEffect: default

    Returns undefined | number

  • Parameters

    • recipeType: ItemType
    • crafted: ICrafted = ...
    • Optional discoveredClientSide: boolean

    Returns void

  • Parameters

    Returns boolean

  • Extinguishes all torches the player is holding.

    Returns void

  • Parameters

    • portId: number
    • Optional options: Partial<{
          requireBoat: boolean;
          startReversed: boolean;
      }>

    Returns undefined | default[]

  • Chance to stop frostbite when next to a fire

    Returns void

  • Sets the default weightCapacity of an NPC (based on their equipment and starting items).

    Returns void

  • The actions available to use with this npc

    Returns undefined | ActionType[]

  • Returns the bartering bonus for a given credit value

    Parameters

    • baseCredits: number

    Returns number

  • Parameters

    Returns number

  • Returns number

  • Returns number

  • Gets a data

    Returns

    Data value or undefined if it wasn't found

    Type Parameters

    • T

    Parameters

    • key: string

      Data key

    Returns undefined | T

  • The ai type

    Returns AiType

  • The customizations of the npc - called when created

    Returns ICustomizations

  • The equip the npc spawns with - called for every equip type when the npc is created

    Parameters

    Returns undefined | default | ItemType

  • Returns undefined | number

  • Items the npc should spawn with - called when created This is in addition to the equipment

    Returns (default | ItemType)[]

  • The name of the npc - called when created

    Returns default

  • Called when filling out the entities description for the first time

    Returns void

  • Parameters

    • Optional includeDisabled: true

    Returns default[]

  • Parameters

    • human: default<number>
    • timeSinceLastChat: number | false

      The time it's been since the human last chatted with this NPC, or false if it's the first time.

    Returns undefined | default

  • Returns string

  • Gets the insulation of this object.

    Insulation is a decimal number from 0 to 1.

    • An insulation of 0 means that the temperature inside this object is equivalent to the temperature outside.
    • An insulation of 1 means that no temperature inside this object is emitted to the outside tiles — it is a completely separate temperature "biome".
    • Values in between change how much of the temperatures are produced/used on either side.

    Parameters

    Returns 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.

    Parameters

    • withBonus: boolean = true

    Returns 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

  • Returns number

  • Gets movement progress and moves the state machine forward when the movement is completed

    Parameters

    • timeStamp: number

    Returns number

  • Gets the temperature produced by this object. Positive values are "heat", negative values are "cold". Refer to the values of the Temperature enum to see the possible range. If this method is not implemented, or it returns undefined, Temperature.Neutral is used.

    Returns undefined | number

  • Returns undefined | IContainer

  • Parameters

    Returns number

  • Returns number

  • Returns number

  • The reputation change when the npc dies

    Returns number

  • Multiply the reputation amount with whatever is set via milestone modifiers or custom game options for this player.

    Returns

    A number or undefined if a reputation number was not passed.

    Parameters

    • reputation: undefined | number

      A number or undefined to be mutiplied.

    Returns undefined | number

  • Gets this human's current carried weight, scaled down to what it would be without any weight bonuses applied

    Returns number

  • Gets a stamina penalty delay to be used for slowed actions and movement.

    Parameters

    • staminaToStartAddingDelayAt: number = STAMINA_LOW_PENALTY_START

      Stat value where delays start getting added from.

    Returns number

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

    Type Parameters

    Parameters

    Returns undefined | S

  • Generator for status effects on the entity.

    Returns default[]

  • Check if a data was set

    Returns

    True if the data exists, false if it doesn't

    Parameters

    • key: string

      Data key

    Returns boolean

  • Returns boolean

  • Returns whether the entity has the given StatusType

    Parameters

    Returns number

  • Parameters

    • tag: unknown

    Returns boolean

  • Returns

    The time since the NPC was last talked to, or false if the human has never talked to the NPC.

    Parameters

    Returns number | false

  • Returns boolean

  • Parameters

    • reason: string

    Returns void

  • Parameters

    Returns boolean

  • Initialize stats

    Returns void

  • Parameters

    • human: default<number>
    • Optional interactType: number

    Returns boolean

  • Returns boolean

  • Returns boolean

  • Returns boolean

  • Returns boolean

  • Returns boolean

  • Returns boolean

  • Parameters

    • entity: default<unknown, number, unknown, unknown>

    Returns boolean

  • Returns boolean

  • Returns boolean

  • Returns boolean

  • Returns true if this is the special dedicated server player

    Returns boolean

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

    Returns boolean

  • Returns boolean

  • Returns boolean

  • Checks if the entity is within the viewport bounds of one or more humans

    Returns boolean

  • Returns boolean

  • Loads ui. Should only be called if this player is local

    Returns void

  • Returns void

  • Returns boolean

  • Moves this player to another island

    Parameters

    Returns Promise<void>

  • Returns void

  • Returns void

  • Note: The noInput event would be emitted before moveComplete. Ordering is done via EmitHumanEventPacket

    Returns void

  • Parameters

    • skill: SkillType
    • fromValue: number
    • toValue: number
    • mod: number

    Returns void

  • Event handler for when resting begins, weight changes, or strength changes.

    Returns void

  • 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

  • Event handler for when a status effect is applied or removed.

    Parameters

    Returns void

  • Returns void

  • Parameters

    • type: SfxType
    • Optional delay: number
    • Optional speed: number

    Returns void

  • Parameters

    • type: SfxType
    • Optional delay: number
    • Optional speed: number

    Returns void

  • Parameters

    Returns {
        actionRange: number;
        bonusRange: number;
        mobCheck: IMobCheck;
    }

    • actionRange: number
    • bonusRange: number
    • mobCheck: IMobCheck
  • Returns void

  • Removes an AiType from an NPC.

    Parameters

    • ai: AiType

      The AiType to remove from the NPC.

    Returns void

  • Removes a data

    Returns

    True when the data is removed. False if the key wasn't set

    Parameters

    • key: string

      Data key

    Returns boolean

  • Parameters

    • tag: unknown

    Returns void

  • Parameters

    • Optional skipStatChangedEvent: boolean

    Returns void

  • Returns void

  • Override in npcs for custom logic

    Returns

    True if the npc is doing something that would prevent it from attacking/moving

    Returns boolean

  • Parameters

    Returns boolean

  • Sets a data

    Rturns

    The value

    Type Parameters

    • T

    Parameters

    • key: string

      Data key

    • value: T

      Data value

    Returns T

  • Parameters

    • fromX: number = ...
    • fromY: number = ...

    Returns void

  • Parameters

    • fromX: number
    • fromY: number
    • Optional toZ: number
    • Optional options: IMoveToOptions

    Returns void

  • Sets whether the entity has the given StatusType. Emits EntityEvent.StatusChange.

    Parameters

    • status: StatusType

      The status to change

    • level: number | boolean

      Whether the entity will have the status.
      If given false/0, removes the status. If given true/1+, raises the status to the given level.

    • reason: StatusEffectChangeReason

      The reason for the change

    Returns boolean

  • Parameters

    • item: undefined | default
    • Optional extinguishTorches: boolean

    Returns boolean

  • Parameters

    • z: number
    • allowCancelation: boolean = true
    • effects: boolean = true

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

    • updateFlowField: boolean = true

    Returns boolean

  • Skips the next movement for this creature / npc

    Returns void

  • Skips the next update for this creature / npc

    Returns void

  • Creates inventory, equips items, and scales stats

    Returns void

  • Parameters

    • Optional skill: SkillType
    • Optional level: number

    Returns void

  • Parameters

    • reason: string

    Returns void

  • Returns void

  • Greets a human, if necessary, and sets the NPC as having been talked to them on the current turn.

    Returns

    The time since the NPC was last talked to, or false if the human has never talked to the NPC.

    Parameters

    Returns number | false

  • Ticks a player

    Returns

    True if the game should tick after this

    Parameters

    • Optional isPassTurn: boolean
    • Optional turnType: TurnTypeFlag

    Returns boolean

  • Updates caused by status effects such as bleeding, poison, and burns.

    Returns void

  • Returns string

  • Parameters

    Returns void

  • Unequips an item. Note: This is safe to call even if the item isn't equipped. it'll do nothing in that case.

    Parameters

    • item: default
    • internal: boolean = false
    • skipMessage: boolean = false
    • skipRevertItem: boolean = false

    Returns void

  • Returns void

  • Returns void

  • Faces the target tile

    Parameters

    • tile: default
    • Optional updateVehicleDirection: boolean

    Returns void

  • Parameters

    • reputation: number

    Returns 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

  • Returns void

  • Parameters

    • source: string

    Returns void

  • Called when the entity is about to move to another tile. This should update relevant properties on the tile and return true

    Returns

    False to block the move

    Parameters

    • fromTile: default

      Tile the entity was on

    • toTile: default

      Tile the entity is moving onto

    Returns boolean

  • Returns void

  • Parameters

    • source: string

    Returns void

  • Returns number

  • Parameters

    • id: number

    Returns void

Generated using TypeDoc