mod

package
v0.1.133 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 28 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mod writes Modlock mods in Go. A mod registers its handlers in an init function; modlock-host compiles the module to a sandbox inside the game server and calls the handlers on the server's frame thread, one at a time.

package main

import "github.com/paralin/modlock/mod"

func init() {
	mod.Command("hello", func(p mod.Player, args string) {
		p.Chat("Hello from Go!")
	})
}

func main() {}

Build it with:

GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o hello.wasm

The calls into the game and their types are generated from the schema in host.gen.go.

Index

Constants

View Source
const (
	// ButtonAttack is the primary fire button.
	ButtonAttack uint64 = 1
	// ButtonJump is the jump key, Space by default (IN_MANTLE). Blocking it
	// stops the native jump and mantle; the jumping client still predicts
	// the jump and is corrected.
	ButtonJump uint64 = 1 << 48
	// ButtonCrouch is the crouch key, Ctrl by default.
	ButtonCrouch uint64 = 1 << 2
	// ButtonDash is the dash key, Shift by default.
	ButtonDash uint64 = 1 << 16
	// ButtonUse is the interact key.
	ButtonUse uint64 = 1 << 5
	// ButtonAltFire is the zoom and alternate fire button, right mouse by
	// default.
	ButtonAltFire uint64 = 1 << 11
	// ButtonReload is the reload key.
	ButtonReload uint64 = 1 << 13
	// ButtonMelee is the light melee key, Q by default.
	ButtonMelee uint64 = 1 << 32
	// ButtonAbility1 to ButtonAbility3 are the hero's first three ability
	// keys.
	ButtonAbility1 uint64 = 1 << 33
	ButtonAbility2 uint64 = 1 << 34
	ButtonAbility3 uint64 = 1 << 35
	// ButtonUltimate is the hero's ultimate ability key, the fourth.
	ButtonUltimate uint64 = 1 << 36
	// ButtonItem1 to ButtonItem4 are the hero's four active item keys.
	ButtonItem1 uint64 = 1 << 37
	ButtonItem2 uint64 = 1 << 38
	ButtonItem3 uint64 = 1 << 39
	ButtonItem4 uint64 = 1 << 40
	// ButtonParry is the melee parry button.
	ButtonParry uint64 = 1 << 42
	// ButtonSpecNext to ButtonSpecToggleTeam are the buttons a player's client
	// sends in place of the others while they spectate, with no hero of their
	// own in play: ButtonSpecNext and ButtonSpecPrev cycle the watched player,
	// ButtonSpecMode changes the camera mode, and ButtonSpecToggleTeam is the
	// jump key, Space by default.
	ButtonSpecNext       uint64 = 1 << 49
	ButtonSpecPrev       uint64 = 1 << 50
	ButtonSpecMode       uint64 = 1 << 51
	ButtonSpecToggleTeam uint64 = 1 << 52
)

Button bits name inputs for BlockInput, WatchInput and Player.Press.

View Source
const (
	// LayerSolid is the world and solid objects.
	LayerSolid uint64 = 1 << 0
	// LayerHitbox is the hit boxes of heroes and units.
	LayerHitbox uint64 = 1 << 1
	// LayerTrigger is invisible volumes that react to touch.
	LayerTrigger uint64 = 1 << 2
	// LayerPlayerClip is walls that only stop heroes.
	LayerPlayerClip uint64 = 1 << 4
	// LayerPlayer is player-controlled heroes.
	LayerPlayer uint64 = 1 << 18
	// LayerNpc is units that are not players.
	LayerNpc uint64 = 1 << 19
	// LayerStaticLevel is the map's built geometry, foliage included.
	LayerStaticLevel uint64 = 1 << 30
	// LayerHero, LayerTrooper and LayerBuilding are those units' bodies.
	LayerHero     uint64 = 1 << 37
	LayerTrooper  uint64 = 1 << 38
	LayerBuilding uint64 = 1 << 40
)

Layer bits name collision layers for Trace.

View Source
const (
	// ScreenEffectKilled is the death treatment.
	ScreenEffectKilled = effectspb.ScreenEffect_SCREEN_EFFECT_KILLED
	// ScreenEffectBlack fades the view to black.
	ScreenEffectBlack = effectspb.ScreenEffect_SCREEN_EFFECT_BLACK
	// ScreenEffectBlinded is the blind treatment.
	ScreenEffectBlinded = effectspb.ScreenEffect_SCREEN_EFFECT_BLINDED
	// ScreenEffectDarkness is Drifter's darkness view.
	ScreenEffectDarkness = effectspb.ScreenEffect_SCREEN_EFFECT_DARKNESS
	// ScreenEffectMatchIntro is the match start treatment.
	ScreenEffectMatchIntro = effectspb.ScreenEffect_SCREEN_EFFECT_MATCH_INTRO
)

The values of ScreenEffect.

View Source
const (
	// FieldTypeBool is one byte read as a boolean.
	FieldTypeBool = fieldspb.FieldType_FIELD_TYPE_BOOL
	// FieldTypeInt8 through FIELD_TYPE_UINT32 are integers read as numbers.
	FieldTypeInt8   = fieldspb.FieldType_FIELD_TYPE_INT8
	FieldTypeInt16  = fieldspb.FieldType_FIELD_TYPE_INT16
	FieldTypeInt32  = fieldspb.FieldType_FIELD_TYPE_INT32
	FieldTypeUint8  = fieldspb.FieldType_FIELD_TYPE_UINT8
	FieldTypeUint16 = fieldspb.FieldType_FIELD_TYPE_UINT16
	FieldTypeUint32 = fieldspb.FieldType_FIELD_TYPE_UINT32
	// FieldTypeInt64 and FIELD_TYPE_UINT64 are 64-bit integers.
	FieldTypeInt64  = fieldspb.FieldType_FIELD_TYPE_INT64
	FieldTypeUint64 = fieldspb.FieldType_FIELD_TYPE_UINT64
	// FieldTypeFloat32 and FIELD_TYPE_FLOAT64 are floating point numbers.
	FieldTypeFloat32 = fieldspb.FieldType_FIELD_TYPE_FLOAT32
	FieldTypeFloat64 = fieldspb.FieldType_FIELD_TYPE_FLOAT64
	// FieldTypeVector is three floats, such as a position or angles.
	FieldTypeVector = fieldspb.FieldType_FIELD_TYPE_VECTOR
	// FieldTypeHandle is an entity handle, read as a number.
	FieldTypeHandle = fieldspb.FieldType_FIELD_TYPE_HANDLE
	// FieldTypeString is a string the field points to.
	FieldTypeString = fieldspb.FieldType_FIELD_TYPE_STRING
)

The values of FieldType.

View Source
const (
	// PickupKindUrn is the soul urn, which its carrier delivers.
	PickupKindUrn = entitiespb.PickupKind_PICKUP_KIND_URN
	// PickupKindMovementBuff is the movement speed buff.
	PickupKindMovementBuff = entitiespb.PickupKind_PICKUP_KIND_MOVEMENT_BUFF
)

The values of PickupKind.

View Source
const (
	// ControllerStreamNone means no client streams the player's controllers
	// yet: none is linked, the link dropped, or the client has not answered
	// the watch. A mod sees no controllers, and the player needs the client
	// running.
	ControllerStreamNone = controllerspb.ControllerStream_CONTROLLER_STREAM_NONE
	// ControllerStreamLive means frames arrive and the game has focus.
	ControllerStreamLive = controllerspb.ControllerStream_CONTROLLER_STREAM_LIVE
	// ControllerStreamUnfocused means frames arrive while the player's game
	// window does not have focus. The controllers are listed with nothing held
	// and every axis at rest.
	ControllerStreamUnfocused = controllerspb.ControllerStream_CONTROLLER_STREAM_UNFOCUSED
	// ControllerStreamStale means the stream is linked but no frame arrived
	// within its deadline. The controllers keep their last state, so a short
	// gap does not cut a held throttle; the mod decides what a long one means.
	ControllerStreamStale = controllerspb.ControllerStream_CONTROLLER_STREAM_STALE
	// ControllerStreamOpening means the client answered and is starting its
	// reader. Starting can wait on a system prompt that controls access to
	// input devices, so an opening that lasts is the player's cue to allow it.
	ControllerStreamOpening = controllerspb.ControllerStream_CONTROLLER_STREAM_OPENING
	// ControllerStreamUnavailable means the client answered but cannot read
	// controllers on this PC, for the reason PlayerControllers gives, such as
	// SDL3 failing to load. The client tries again on the next watch.
	ControllerStreamUnavailable = controllerspb.ControllerStream_CONTROLLER_STREAM_UNAVAILABLE
)

The values of ControllerStream.

View Source
const (
	// GamepadButtonSouth is the bottom face button.
	GamepadButtonSouth = controllerspb.GamepadButton_GAMEPAD_BUTTON_SOUTH
	// GamepadButtonEast is the right face button.
	GamepadButtonEast = controllerspb.GamepadButton_GAMEPAD_BUTTON_EAST
	// GamepadButtonWest is the left face button.
	GamepadButtonWest = controllerspb.GamepadButton_GAMEPAD_BUTTON_WEST
	// GamepadButtonNorth is the top face button.
	GamepadButtonNorth = controllerspb.GamepadButton_GAMEPAD_BUTTON_NORTH
	// GamepadButtonBack is the View, Select or Share button.
	GamepadButtonBack = controllerspb.GamepadButton_GAMEPAD_BUTTON_BACK
	// GamepadButtonGuide is the Xbox, PS or Home button.
	GamepadButtonGuide = controllerspb.GamepadButton_GAMEPAD_BUTTON_GUIDE
	// GamepadButtonStart is the Menu, Start or Options button.
	GamepadButtonStart = controllerspb.GamepadButton_GAMEPAD_BUTTON_START
	// GamepadButtonLeftStick is the left stick pressed in.
	GamepadButtonLeftStick = controllerspb.GamepadButton_GAMEPAD_BUTTON_LEFT_STICK
	// GamepadButtonRightStick is the right stick pressed in.
	GamepadButtonRightStick = controllerspb.GamepadButton_GAMEPAD_BUTTON_RIGHT_STICK
	// GamepadButtonLeftShoulder is the left bumper.
	GamepadButtonLeftShoulder = controllerspb.GamepadButton_GAMEPAD_BUTTON_LEFT_SHOULDER
	// GamepadButtonRightShoulder is the right bumper.
	GamepadButtonRightShoulder = controllerspb.GamepadButton_GAMEPAD_BUTTON_RIGHT_SHOULDER
	// GamepadButtonDpadUp is the directional pad's up.
	GamepadButtonDpadUp = controllerspb.GamepadButton_GAMEPAD_BUTTON_DPAD_UP
	// GamepadButtonDpadDown is the directional pad's down.
	GamepadButtonDpadDown = controllerspb.GamepadButton_GAMEPAD_BUTTON_DPAD_DOWN
	// GamepadButtonDpadLeft is the directional pad's left.
	GamepadButtonDpadLeft = controllerspb.GamepadButton_GAMEPAD_BUTTON_DPAD_LEFT
	// GamepadButtonDpadRight is the directional pad's right.
	GamepadButtonDpadRight = controllerspb.GamepadButton_GAMEPAD_BUTTON_DPAD_RIGHT
	// GamepadButtonMisc is the extra button some pads have, such as the
	// Xbox Share button or the PlayStation microphone button.
	GamepadButtonMisc = controllerspb.GamepadButton_GAMEPAD_BUTTON_MISC
	// GamepadButtonTouchpad is the PlayStation touchpad pressed.
	GamepadButtonTouchpad = controllerspb.GamepadButton_GAMEPAD_BUTTON_TOUCHPAD
)

The values of GamepadButton.

View Source
const (
	// CommandAxisForward is forwardmove.
	CommandAxisForward = controllerspb.CommandAxis_COMMAND_AXIS_FORWARD
	// CommandAxisLeft is leftmove.
	CommandAxisLeft = controllerspb.CommandAxis_COMMAND_AXIS_LEFT
	// CommandAxisUp is upmove.
	CommandAxisUp = controllerspb.CommandAxis_COMMAND_AXIS_UP
	// CommandAxisRoll is the roll of viewangles, its z component.
	CommandAxisRoll = controllerspb.CommandAxis_COMMAND_AXIS_ROLL
)

The values of CommandAxis.

View Source
const (
	// GamepadAxisLeftX and the others are Gamepad's fields of that name.
	GamepadAxisLeftX        = controllerspb.GamepadAxis_GAMEPAD_AXIS_LEFT_X
	GamepadAxisLeftY        = controllerspb.GamepadAxis_GAMEPAD_AXIS_LEFT_Y
	GamepadAxisRightX       = controllerspb.GamepadAxis_GAMEPAD_AXIS_RIGHT_X
	GamepadAxisRightY       = controllerspb.GamepadAxis_GAMEPAD_AXIS_RIGHT_Y
	GamepadAxisLeftTrigger  = controllerspb.GamepadAxis_GAMEPAD_AXIS_LEFT_TRIGGER
	GamepadAxisRightTrigger = controllerspb.GamepadAxis_GAMEPAD_AXIS_RIGHT_TRIGGER
)

The values of GamepadAxis.

View Source
const (
	// ThresholdDirectionAbove holds the button at or above the threshold.
	ThresholdDirectionAbove = controllerspb.ThresholdDirection_THRESHOLD_DIRECTION_ABOVE
	// ThresholdDirectionBelow holds the button at or below the threshold.
	ThresholdDirectionBelow = controllerspb.ThresholdDirection_THRESHOLD_DIRECTION_BELOW
)

The values of ThresholdDirection.

The values of MovementAction.

View Source
const (
	// PickupCollected is a pickup, such as a healing bat, completing its
	// collection by this hero: on touch, or when its vacuum reaches the hero.
	InteractionKindPickupCollected = movementpb.InteractionKind_INTERACTION_KIND_PICKUP_COLLECTED
	// PropBroken is a breakable prop, such as a crate, the game says this hero
	// broke.
	InteractionKindPropBroken = movementpb.InteractionKind_INTERACTION_KIND_PROP_BROKEN
)

The values of InteractionKind.

The values of Lane.

View Source
const (
	// TextAlignLeft starts the text at its position.
	TextAlignLeft = objectspb.TextAlign_TEXT_ALIGN_LEFT
	// TextAlignCenter centers the text on its position.
	TextAlignCenter = objectspb.TextAlign_TEXT_ALIGN_CENTER
	// TextAlignRight ends the text at its position.
	TextAlignRight = objectspb.TextAlign_TEXT_ALIGN_RIGHT
)

The values of TextAlign.

View Source
const (
	// TextVerticalAlignBottom stands the text on its position.
	TextVerticalAlignBottom = objectspb.TextVerticalAlign_TEXT_VERTICAL_ALIGN_BOTTOM
	// TextVerticalAlignCenter centers the text on its position.
	TextVerticalAlignCenter = objectspb.TextVerticalAlign_TEXT_VERTICAL_ALIGN_CENTER
	// TextVerticalAlignTop hangs the text from its position.
	TextVerticalAlignTop = objectspb.TextVerticalAlign_TEXT_VERTICAL_ALIGN_TOP
)

The values of TextVerticalAlign.

View Source
const (
	// ConvarMissNone is a query the client answered with the value.
	ConvarMissNone = playerspb.ConvarMiss_CONVAR_MISS_NONE
	// ConvarMissTimeout is a query that waited out its timeout. A reply the
	// host cannot read ends this way too, since it names no query.
	ConvarMissTimeout = playerspb.ConvarMiss_CONVAR_MISS_TIMEOUT
	// ConvarMissLeft is a query whose player disconnected before the answer
	// arrived, or whose slot another player took.
	ConvarMissLeft = playerspb.ConvarMiss_CONVAR_MISS_LEFT
	// ConvarMissRefused is a query the client answered without a value: it
	// has no such variable, the name is a command, or the variable is protected.
	ConvarMissRefused = playerspb.ConvarMiss_CONVAR_MISS_REFUSED
	// ConvarMissUnavailable is a query the host could not send, as when the
	// player is a bot or not fully connected, or this game build cannot read
	// answers. The libraries report it when StartConvarQuery fails.
	ConvarMissUnavailable = playerspb.ConvarMiss_CONVAR_MISS_UNAVAILABLE
)

The values of ConvarMiss.

View Source
const (
	DisconnectReasonShutdown                             = playerspb.DisconnectReason_DISCONNECT_REASON_SHUTDOWN
	DisconnectReasonDisconnectByUser                     = playerspb.DisconnectReason_DISCONNECT_REASON_DISCONNECT_BY_USER
	DisconnectReasonDisconnectByServer                   = playerspb.DisconnectReason_DISCONNECT_REASON_DISCONNECT_BY_SERVER
	DisconnectReasonLost                                 = playerspb.DisconnectReason_DISCONNECT_REASON_LOST
	DisconnectReasonOverflow                             = playerspb.DisconnectReason_DISCONNECT_REASON_OVERFLOW
	DisconnectReasonSteamBanned                          = playerspb.DisconnectReason_DISCONNECT_REASON_STEAM_BANNED
	DisconnectReasonSteamInuse                           = playerspb.DisconnectReason_DISCONNECT_REASON_STEAM_INUSE
	DisconnectReasonSteamTicket                          = playerspb.DisconnectReason_DISCONNECT_REASON_STEAM_TICKET
	DisconnectReasonSteamLogon                           = playerspb.DisconnectReason_DISCONNECT_REASON_STEAM_LOGON
	DisconnectReasonSteamAuthcancelled                   = playerspb.DisconnectReason_DISCONNECT_REASON_STEAM_AUTHCANCELLED
	DisconnectReasonSteamAuthalreadyused                 = playerspb.DisconnectReason_DISCONNECT_REASON_STEAM_AUTHALREADYUSED
	DisconnectReasonSteamAuthinvalid                     = playerspb.DisconnectReason_DISCONNECT_REASON_STEAM_AUTHINVALID
	DisconnectReasonSteamVacbanstate                     = playerspb.DisconnectReason_DISCONNECT_REASON_STEAM_VACBANSTATE
	DisconnectReasonSteamLoggedInElsewhere               = playerspb.DisconnectReason_DISCONNECT_REASON_STEAM_LOGGED_IN_ELSEWHERE
	DisconnectReasonSteamVacCheckTimedout                = playerspb.DisconnectReason_DISCONNECT_REASON_STEAM_VAC_CHECK_TIMEDOUT
	DisconnectReasonSteamDropped                         = playerspb.DisconnectReason_DISCONNECT_REASON_STEAM_DROPPED
	DisconnectReasonSteamOwnership                       = playerspb.DisconnectReason_DISCONNECT_REASON_STEAM_OWNERSHIP
	DisconnectReasonServerinfoOverflow                   = playerspb.DisconnectReason_DISCONNECT_REASON_SERVERINFO_OVERFLOW
	DisconnectReasonTickmsgOverflow                      = playerspb.DisconnectReason_DISCONNECT_REASON_TICKMSG_OVERFLOW
	DisconnectReasonStringtablemsgOverflow               = playerspb.DisconnectReason_DISCONNECT_REASON_STRINGTABLEMSG_OVERFLOW
	DisconnectReasonDeltaentmsgOverflow                  = playerspb.DisconnectReason_DISCONNECT_REASON_DELTAENTMSG_OVERFLOW
	DisconnectReasonTempentmsgOverflow                   = playerspb.DisconnectReason_DISCONNECT_REASON_TEMPENTMSG_OVERFLOW
	DisconnectReasonSoundsmsgOverflow                    = playerspb.DisconnectReason_DISCONNECT_REASON_SOUNDSMSG_OVERFLOW
	DisconnectReasonSnapshotoverflow                     = playerspb.DisconnectReason_DISCONNECT_REASON_SNAPSHOTOVERFLOW
	DisconnectReasonSnapshoterror                        = playerspb.DisconnectReason_DISCONNECT_REASON_SNAPSHOTERROR
	DisconnectReasonReliableoverflow                     = playerspb.DisconnectReason_DISCONNECT_REASON_RELIABLEOVERFLOW
	DisconnectReasonBaddeltatick                         = playerspb.DisconnectReason_DISCONNECT_REASON_BADDELTATICK
	DisconnectReasonNomoresplits                         = playerspb.DisconnectReason_DISCONNECT_REASON_NOMORESPLITS
	DisconnectReasonTimedout                             = playerspb.DisconnectReason_DISCONNECT_REASON_TIMEDOUT
	DisconnectReasonDisconnected                         = playerspb.DisconnectReason_DISCONNECT_REASON_DISCONNECTED
	DisconnectReasonLeavingsplit                         = playerspb.DisconnectReason_DISCONNECT_REASON_LEAVINGSPLIT
	DisconnectReasonDifferentclasstables                 = playerspb.DisconnectReason_DISCONNECT_REASON_DIFFERENTCLASSTABLES
	DisconnectReasonBadrelaypassword                     = playerspb.DisconnectReason_DISCONNECT_REASON_BADRELAYPASSWORD
	DisconnectReasonBadspectatorpassword                 = playerspb.DisconnectReason_DISCONNECT_REASON_BADSPECTATORPASSWORD
	DisconnectReasonHltvrestricted                       = playerspb.DisconnectReason_DISCONNECT_REASON_HLTVRESTRICTED
	DisconnectReasonNospectators                         = playerspb.DisconnectReason_DISCONNECT_REASON_NOSPECTATORS
	DisconnectReasonHltvunavailable                      = playerspb.DisconnectReason_DISCONNECT_REASON_HLTVUNAVAILABLE
	DisconnectReasonHltvstop                             = playerspb.DisconnectReason_DISCONNECT_REASON_HLTVSTOP
	DisconnectReasonKicked                               = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED
	DisconnectReasonBanadded                             = playerspb.DisconnectReason_DISCONNECT_REASON_BANADDED
	DisconnectReasonKickbanadded                         = playerspb.DisconnectReason_DISCONNECT_REASON_KICKBANADDED
	DisconnectReasonHltvdirect                           = playerspb.DisconnectReason_DISCONNECT_REASON_HLTVDIRECT
	DisconnectReasonPureserverClientextra                = playerspb.DisconnectReason_DISCONNECT_REASON_PURESERVER_CLIENTEXTRA
	DisconnectReasonPureserverMismatch                   = playerspb.DisconnectReason_DISCONNECT_REASON_PURESERVER_MISMATCH
	DisconnectReasonUsercmd                              = playerspb.DisconnectReason_DISCONNECT_REASON_USERCMD
	DisconnectReasonRejectedByGame                       = playerspb.DisconnectReason_DISCONNECT_REASON_REJECTED_BY_GAME
	DisconnectReasonMessageParseError                    = playerspb.DisconnectReason_DISCONNECT_REASON_MESSAGE_PARSE_ERROR
	DisconnectReasonInvalidMessageError                  = playerspb.DisconnectReason_DISCONNECT_REASON_INVALID_MESSAGE_ERROR
	DisconnectReasonBadServerPassword                    = playerspb.DisconnectReason_DISCONNECT_REASON_BAD_SERVER_PASSWORD
	DisconnectReasonDirectConnectReservation             = playerspb.DisconnectReason_DISCONNECT_REASON_DIRECT_CONNECT_RESERVATION
	DisconnectReasonConnectionFailure                    = playerspb.DisconnectReason_DISCONNECT_REASON_CONNECTION_FAILURE
	DisconnectReasonNoPeerGroupHandlers                  = playerspb.DisconnectReason_DISCONNECT_REASON_NO_PEER_GROUP_HANDLERS
	DisconnectReasonReconnection                         = playerspb.DisconnectReason_DISCONNECT_REASON_RECONNECTION
	DisconnectReasonLoopshutdown                         = playerspb.DisconnectReason_DISCONNECT_REASON_LOOPSHUTDOWN
	DisconnectReasonLoopdeactivate                       = playerspb.DisconnectReason_DISCONNECT_REASON_LOOPDEACTIVATE
	DisconnectReasonHostEndgame                          = playerspb.DisconnectReason_DISCONNECT_REASON_HOST_ENDGAME
	DisconnectReasonLoopLevelloadActivate                = playerspb.DisconnectReason_DISCONNECT_REASON_LOOP_LEVELLOAD_ACTIVATE
	DisconnectReasonCreateServerFailed                   = playerspb.DisconnectReason_DISCONNECT_REASON_CREATE_SERVER_FAILED
	DisconnectReasonExiting                              = playerspb.DisconnectReason_DISCONNECT_REASON_EXITING
	DisconnectReasonRequestHoststateIdle                 = playerspb.DisconnectReason_DISCONNECT_REASON_REQUEST_HOSTSTATE_IDLE
	DisconnectReasonRequestHoststateHltvrelay            = playerspb.DisconnectReason_DISCONNECT_REASON_REQUEST_HOSTSTATE_HLTVRELAY
	DisconnectReasonClientConsistencyFail                = playerspb.DisconnectReason_DISCONNECT_REASON_CLIENT_CONSISTENCY_FAIL
	DisconnectReasonClientUnableToCrcMap                 = playerspb.DisconnectReason_DISCONNECT_REASON_CLIENT_UNABLE_TO_CRC_MAP
	DisconnectReasonClientNoMap                          = playerspb.DisconnectReason_DISCONNECT_REASON_CLIENT_NO_MAP
	DisconnectReasonClientDifferentMap                   = playerspb.DisconnectReason_DISCONNECT_REASON_CLIENT_DIFFERENT_MAP
	DisconnectReasonServerRequiresSteam                  = playerspb.DisconnectReason_DISCONNECT_REASON_SERVER_REQUIRES_STEAM
	DisconnectReasonSteamDenyMisc                        = playerspb.DisconnectReason_DISCONNECT_REASON_STEAM_DENY_MISC
	DisconnectReasonSteamDenyBadAntiCheat                = playerspb.DisconnectReason_DISCONNECT_REASON_STEAM_DENY_BAD_ANTI_CHEAT
	DisconnectReasonServerShutdown                       = playerspb.DisconnectReason_DISCONNECT_REASON_SERVER_SHUTDOWN
	DisconnectReasonReplayIncompatible                   = playerspb.DisconnectReason_DISCONNECT_REASON_REPLAY_INCOMPATIBLE
	DisconnectReasonConnectRequestTimedout               = playerspb.DisconnectReason_DISCONNECT_REASON_CONNECT_REQUEST_TIMEDOUT
	DisconnectReasonServerIncompatible                   = playerspb.DisconnectReason_DISCONNECT_REASON_SERVER_INCOMPATIBLE
	DisconnectReasonLocalproblemManyrelays               = playerspb.DisconnectReason_DISCONNECT_REASON_LOCALPROBLEM_MANYRELAYS
	DisconnectReasonLocalproblemHostedserverprimaryrelay = playerspb.DisconnectReason_DISCONNECT_REASON_LOCALPROBLEM_HOSTEDSERVERPRIMARYRELAY
	DisconnectReasonLocalproblemNetworkconfig            = playerspb.DisconnectReason_DISCONNECT_REASON_LOCALPROBLEM_NETWORKCONFIG
	DisconnectReasonLocalproblemOther                    = playerspb.DisconnectReason_DISCONNECT_REASON_LOCALPROBLEM_OTHER
	DisconnectReasonRemoteTimeout                        = playerspb.DisconnectReason_DISCONNECT_REASON_REMOTE_TIMEOUT
	DisconnectReasonRemoteTimeoutConnecting              = playerspb.DisconnectReason_DISCONNECT_REASON_REMOTE_TIMEOUT_CONNECTING
	DisconnectReasonRemoteOther                          = playerspb.DisconnectReason_DISCONNECT_REASON_REMOTE_OTHER
	DisconnectReasonRemoteBadcrypt                       = playerspb.DisconnectReason_DISCONNECT_REASON_REMOTE_BADCRYPT
	DisconnectReasonRemoteCertnottrusted                 = playerspb.DisconnectReason_DISCONNECT_REASON_REMOTE_CERTNOTTRUSTED
	DisconnectReasonUnusual                              = playerspb.DisconnectReason_DISCONNECT_REASON_UNUSUAL
	DisconnectReasonInternalError                        = playerspb.DisconnectReason_DISCONNECT_REASON_INTERNAL_ERROR
	DisconnectReasonRejectBadchallenge                   = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_BADCHALLENGE
	DisconnectReasonRejectNolobby                        = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_NOLOBBY
	DisconnectReasonRejectBackgroundMap                  = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_BACKGROUND_MAP
	DisconnectReasonRejectSinglePlayer                   = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_SINGLE_PLAYER
	DisconnectReasonRejectHiddenGame                     = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_HIDDEN_GAME
	DisconnectReasonRejectLanrestrict                    = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_LANRESTRICT
	DisconnectReasonRejectBadpassword                    = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_BADPASSWORD
	DisconnectReasonRejectServerfull                     = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_SERVERFULL
	DisconnectReasonRejectInvalidreservation             = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_INVALIDRESERVATION
	DisconnectReasonRejectFailedchannel                  = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_FAILEDCHANNEL
	DisconnectReasonRejectConnectFromLobby               = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_CONNECT_FROM_LOBBY
	DisconnectReasonRejectReservedForLobby               = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_RESERVED_FOR_LOBBY
	DisconnectReasonRejectInvalidkeylength               = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_INVALIDKEYLENGTH
	DisconnectReasonRejectOldprotocol                    = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_OLDPROTOCOL
	DisconnectReasonRejectNewprotocol                    = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_NEWPROTOCOL
	DisconnectReasonRejectInvalidconnection              = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_INVALIDCONNECTION
	DisconnectReasonRejectInvalidcertlen                 = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_INVALIDCERTLEN
	DisconnectReasonRejectInvalidsteamcertlen            = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_INVALIDSTEAMCERTLEN
	DisconnectReasonRejectSteam                          = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_STEAM
	DisconnectReasonRejectServerauthdisabled             = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_SERVERAUTHDISABLED
	DisconnectReasonRejectServercdkeyauthinvalid         = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_SERVERCDKEYAUTHINVALID
	DisconnectReasonRejectBanned                         = playerspb.DisconnectReason_DISCONNECT_REASON_REJECT_BANNED
	DisconnectReasonKickedTeamkilling                    = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED_TEAMKILLING
	DisconnectReasonKickedTkStart                        = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED_TK_START
	DisconnectReasonKickedUntrustedaccount               = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED_UNTRUSTEDACCOUNT
	DisconnectReasonKickedConvictedaccount               = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED_CONVICTEDACCOUNT
	DisconnectReasonKickedCompetitivecooldown            = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED_COMPETITIVECOOLDOWN
	DisconnectReasonKickedTeamhurting                    = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED_TEAMHURTING
	DisconnectReasonKickedHostagekilling                 = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED_HOSTAGEKILLING
	DisconnectReasonKickedVotedoff                       = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED_VOTEDOFF
	DisconnectReasonKickedIdle                           = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED_IDLE
	DisconnectReasonKickedSuicide                        = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED_SUICIDE
	DisconnectReasonKickedNosteamlogin                   = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED_NOSTEAMLOGIN
	DisconnectReasonKickedNosteamticket                  = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED_NOSTEAMTICKET
	DisconnectReasonKickedInputautomation                = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED_INPUTAUTOMATION
	DisconnectReasonKickedVacnetabnormalbehavior         = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED_VACNETABNORMALBEHAVIOR
	DisconnectReasonKickedInsecureclient                 = playerspb.DisconnectReason_DISCONNECT_REASON_KICKED_INSECURECLIENT
)

The values of DisconnectReason.

View Source
const (
	// ModRoleUnspecified is no role.
	ModRoleUnspecified = playerspb.ModRole_MOD_ROLE_UNSPECIFIED
	// ModRoleDeveloper builds the mod.
	ModRoleDeveloper = playerspb.ModRole_MOD_ROLE_DEVELOPER
	// ModRoleTester tries the mod's unfinished features.
	ModRoleTester = playerspb.ModRole_MOD_ROLE_TESTER
)

The values of ModRole.

View Source
const (
	// CameraParamDistance is how far behind the hero the camera sits.
	CameraParamDistance = playerspb.CameraParam_CAMERA_PARAM_DISTANCE
	// CameraParamFieldOfView is the view's field of view in degrees.
	CameraParamFieldOfView = playerspb.CameraParam_CAMERA_PARAM_FIELD_OF_VIEW
	// CameraParamTarget is the position the camera follows.
	CameraParamTarget = playerspb.CameraParam_CAMERA_PARAM_TARGET
	// CameraParamVerticalOffset raises the camera.
	CameraParamVerticalOffset = playerspb.CameraParam_CAMERA_PARAM_VERTICAL_OFFSET
	// CameraParamHorizontalOffset moves the camera to the side.
	CameraParamHorizontalOffset = playerspb.CameraParam_CAMERA_PARAM_HORIZONTAL_OFFSET
)

The values of CameraParam.

View Source
const (
	// GameActionScoreboard holds the game's Tab screen while it is held.
	GameActionScoreboard = uipb.GameAction_GAME_ACTION_SCOREBOARD
	// GameActionExtraInfo shows the HUD's detail view while it is held. The
	// game reports it only as the gDetailView class on its HUD panels.
	GameActionExtraInfo = uipb.GameAction_GAME_ACTION_EXTRA_INFO
)

The values of GameAction.

View Source
const (
	// ActionPhasePressed starts a press.
	ActionPhasePressed = uipb.ActionPhase_ACTION_PHASE_PRESSED
	// ActionPhaseReleased ends a press as the player let go.
	ActionPhaseReleased = uipb.ActionPhase_ACTION_PHASE_RELEASED
	// ActionPhaseCancelled ends a press before the player let go, as a stock
	// overlay took the player's input or the screen lost the HUD. The release
	// that follows sends nothing.
	ActionPhaseCancelled = uipb.ActionPhase_ACTION_PHASE_CANCELLED
	// ActionPhaseMoved reports where a range's handles stand while the
	// player still holds one, at most ten times a second. A game action never
	// moves.
	ActionPhaseMoved = uipb.ActionPhase_ACTION_PHASE_MOVED
)

The values of ActionPhase.

View Source
const (
	// OverlayNone means the game has the player's input.
	OverlayNone = uipb.Overlay_OVERLAY_NONE
	// OverlayChat is the chat box, open for typing.
	OverlayChat = uipb.Overlay_OVERLAY_CHAT
	// OverlayShop is the item shop.
	OverlayShop = uipb.Overlay_OVERLAY_SHOP
	// OverlayBuilds is the build editor.
	OverlayBuilds = uipb.Overlay_OVERLAY_BUILDS
	// OverlayItemDraft is the item draft's choice.
	OverlayItemDraft = uipb.Overlay_OVERLAY_ITEM_DRAFT
	// OverlayPopup is a stock popup, such as a confirmation.
	OverlayPopup = uipb.Overlay_OVERLAY_POPUP
	// OverlayEscapeMenu is the escape menu, which pauses a local game.
	OverlayEscapeMenu = uipb.Overlay_OVERLAY_ESCAPE_MENU
)

The values of Overlay.

View Source
const (
	// TooLarge is a document longer than 262,144 UTF-8 bytes.
	DocumentFailureTooLarge = uipb.DocumentFailure_DOCUMENT_FAILURE_TOO_LARGE
	// Expired is a transfer that did not finish within its deadline: 20
	// seconds and one more for each 14,400 bytes the document declares.
	DocumentFailureExpired = uipb.DocumentFailure_DOCUMENT_FAILURE_EXPIRED
	// Cancelled is a transfer the player stopped, as by closing its menu.
	DocumentFailureCancelled = uipb.DocumentFailure_DOCUMENT_FAILURE_CANCELLED
	// Malformed is a transfer whose frames were missing, out of order, or
	// not text.
	DocumentFailureMalformed = uipb.DocumentFailure_DOCUMENT_FAILURE_MALFORMED
)

The values of DocumentFailure.

View Source
const (
	// PingKindMap is a ping on a place, a unit or the minimap.
	PingKindMap = wasmpb.PingKind_PING_KIND_MAP
	// PingKindWheel is a line from the comms wheel or a quick ping key.
	PingKindWheel = wasmpb.PingKind_PING_KIND_WHEEL
	// PingKindQuickResponse answers another player's ping.
	PingKindQuickResponse = wasmpb.PingKind_PING_KIND_QUICK_RESPONSE
	// PingKindAbility pings one of the player's abilities or items.
	PingKindAbility = wasmpb.PingKind_PING_KIND_ABILITY
)

The values of PingKind.

View Source
const (
	// ServiceFailureNone is an answered call.
	ServiceFailureNone = wasmpb.ServiceFailure_SERVICE_FAILURE_NONE
	// ServiceFailureRefused is a call the service answered with an error.
	ServiceFailureRefused = wasmpb.ServiceFailure_SERVICE_FAILURE_REFUSED
	// ServiceFailureTimeout is a call that waited out its timeout.
	ServiceFailureTimeout = wasmpb.ServiceFailure_SERVICE_FAILURE_TIMEOUT
	// ServiceFailureUnavailable is a call to a service nobody provides
	// here, or one more than the host keeps waiting for a mod.
	ServiceFailureUnavailable = wasmpb.ServiceFailure_SERVICE_FAILURE_UNAVAILABLE
)

The values of ServiceFailure.

View Source
const AnyHero = "any"

AnyHero is the Want.Hero that keeps the hero a member has, or else seats them on a random released hero.

View Source
const EntityCameraSettleSeconds = 6

EntityCameraSettleSeconds is how long an entity camera takes to settle after it opens. The game client blends into intro_camera from a snapshot of the opening view for about five seconds, interpolating pitch, yaw and roll as wrapped angles, so an orientation that crosses 180 degrees of roll, or passes over the top in pitch, during the blend swings the view the wrong way and stalls it. Hold the camera clear of those crossings, such as level, for this long after OpenEntityCamera; from then on any orientation renders exactly.

View Source
const HideoutHeroConvar = "citadel_hideout_hero_id"

HideoutHeroConvar is the client console variable that holds the hero a player last chose in their hideout, the one the game's hero picker starts on.

Variables

View Source
var ErrPlayerLeft = errors.New("persist: the player left; their Player no longer names a connection")

ErrPlayerLeft refuses a persist call for a Player whose connection has left the server, such as one a mod kept after the player went. The slot may hold another player by then, whose record the call must not reach.

View Source
var Heroes = []Hero{
	{Name: "hero_atlas", ID: 6, Title: "Abrams", Portrait: "file://{images}/heroes/bull_sm.psd"},
	{Name: "hero_fencer", ID: 77, Title: "Apollo", Portrait: "file://{images}/heroes/fencer_sm.psd"},
	{Name: "hero_baba", ID: 88, Title: "Baba", Portrait: "file://{images}/heroes/baba_sm.psd"},
	{Name: "hero_bebop", ID: 15, Title: "Bebop", Portrait: "file://{images}/heroes/bebop_sm.psd"},
	{Name: "hero_punkgoat", ID: 72, Title: "Billy", Portrait: "file://{images}/heroes/punkgoat_sm.psd"},
	{Name: "hero_nano", ID: 16, Title: "Calico", Portrait: "file://{images}/heroes/nano_sm.psd"},
	{Name: "hero_unicorn", ID: 81, Title: "Celeste", Portrait: "file://{images}/heroes/unicorn_sm.psd"},
	{Name: "hero_deadpack", ID: 78, Title: "Deadman Danny", Portrait: "file://{images}/heroes/deadpack_sm.psd"},
	{Name: "hero_drifter", ID: 64, Title: "Drifter", Portrait: "file://{images}/heroes/drifter_sm.psd"},
	{Name: "hero_dynamo", ID: 11, Title: "Dynamo", Portrait: "file://{images}/heroes/sumo_sm.psd"},
	{Name: "hero_necro", ID: 76, Title: "Graves", Portrait: "file://{images}/heroes/necro_sm.psd"},
	{Name: "hero_orion", ID: 17, Title: "Grey Talon", Portrait: "file://{images}/heroes/archer_sm.psd"},
	{Name: "hero_haze", ID: 13, Title: "Haze", Portrait: "file://{images}/heroes/haze_sm.psd"},
	{Name: "hero_astro", ID: 14, Title: "Holliday", Portrait: "file://{images}/heroes/astro_sm.psd"},
	{Name: "hero_inferno", ID: 1, Title: "Infernus", Portrait: "file://{images}/heroes/inferno_sm.psd"},
	{Name: "hero_tengu", ID: 20, Title: "Ivy", Portrait: "file://{images}/heroes/tengu_sm.psd"},
	{Name: "hero_kelvin", ID: 12, Title: "Kelvin", Portrait: "file://{images}/heroes/kelvin_sm.psd"},
	{Name: "hero_ghost", ID: 4, Title: "Lady Geist", Portrait: "file://{images}/heroes/spectre_sm.psd"},
	{Name: "hero_lash", ID: 31, Title: "Lash", Portrait: "file://{images}/heroes/lash_sm.psd"},
	{Name: "hero_forge", ID: 8, Title: "McGinnis", Portrait: "file://{images}/heroes/engineer_sm.psd"},
	{Name: "hero_vampirebat", ID: 63, Title: "Mina", Portrait: "file://{images}/heroes/vampirebat_sm.psd"},
	{Name: "hero_mirage", ID: 52, Title: "Mirage", Portrait: "file://{images}/heroes/mirage_sm.psd"},
	{Name: "hero_krill", ID: 18, Title: "Mo & Krill", Portrait: "file://{images}/heroes/digger_sm.psd"},
	{Name: "hero_nurse", ID: 87, Title: "Nurse Harrow", Portrait: "file://{images}/heroes/nurse_sm.psd"},
	{Name: "hero_bookworm", ID: 67, Title: "Paige", Portrait: "file://{images}/heroes/bookworm_sm.psd"},
	{Name: "hero_chrono", ID: 10, Title: "Paradox", Portrait: "file://{images}/heroes/chrono_sm.psd"},
	{Name: "hero_synth", ID: 50, Title: "Pocket", Portrait: "file://{images}/heroes/synth_sm.psd"},
	{Name: "hero_ratking", ID: 84, Title: "Rat King", Portrait: "file://{images}/heroes/ratking_sm.psd"},
	{Name: "hero_familiar", ID: 79, Title: "Rem", Portrait: "file://{images}/heroes/familiar_sm.psd"},
	{Name: "hero_gigawatt", ID: 2, Title: "Seven", Portrait: "file://{images}/heroes/gigawatt_sm.psd"},
	{Name: "hero_shiv", ID: 19, Title: "Shiv", Portrait: "file://{images}/heroes/shiv_sm.psd"},
	{Name: "hero_werewolf", ID: 80, Title: "Silver", Portrait: "file://{images}/heroes/werewolf_sm.psd"},
	{Name: "hero_magician", ID: 60, Title: "Sinclair", Portrait: "file://{images}/heroes/magician_sm.psd"},
	{Name: "hero_chessmaster", ID: 85, Title: "Solomon", Portrait: "file://{images}/heroes/chessmaster_sm.psd"},
	{Name: "hero_doorman", ID: 69, Title: "The Doorman", Portrait: "file://{images}/heroes/doorman_sm.psd"},
	{Name: "hero_priest", ID: 65, Title: "Venator", Portrait: "file://{images}/heroes/priest_sm.psd"},
	{Name: "hero_frank", ID: 66, Title: "Victor", Portrait: "file://{images}/heroes/frank_sm.psd"},
	{Name: "hero_hornet", ID: 3, Title: "Vindicta", Portrait: "file://{images}/heroes/hornet_sm.png"},
	{Name: "hero_artist", ID: 86, Title: "Violet", Portrait: "file://{images}/heroes/artist_sm.psd"},
	{Name: "hero_viscous", ID: 35, Title: "Viscous", Portrait: "file://{images}/heroes/viscous_sm.psd"},
	{Name: "hero_viper", ID: 58, Title: "Vyper", Portrait: "file://{images}/heroes/kali_sm.psd"},
	{Name: "hero_warden", ID: 25, Title: "Warden", Portrait: "file://{images}/heroes/warden_sm.psd"},
	{Name: "hero_wraith", ID: 7, Title: "Wraith", Portrait: "file://{images}/heroes/wraith_sm.psd"},
	{Name: "hero_yamato", ID: 27, Title: "Yamato", Portrait: "file://{images}/heroes/yamato_sm.psd"},
}

Heroes lists every released hero alphabetically by title, with the game's name, fixed id and small portrait for each. The table follows the game's hero data; a hero the game adds or releases joins it in a Modlock release.

Functions

func AdjustSound added in v0.1.77

func AdjustSound(id uint32, volume, pitch *float32) error

AdjustSound changes the volume or pitch of a sound Sound or EmitSound started, while it plays.

func ApplyUi added in v0.1.79

func ApplyUi(p Player, change *uipb.Change) error

ApplyUi sends one change to the interface the player sees. Package ui builds the changes; a mod draws with ui.Show rather than calling this.

func BlockInput

func BlockInput(buttons uint64) error

BlockInput withholds buttons from every player's hero until called again, and the spectator buttons from a spectating player's commands. Stopping the mod releases them.

func CallService

func CallService(service, method string, payload []byte) ([]byte, error)

CallService calls method of a service the host provides outside Modlock, such as a game mode's match, and returns the service's answer. The service defines the payload's encoding.

func CallServiceLater added in v0.1.86

func CallServiceLater(service, method string, payload []byte, timeout time.Duration, done func(reply []byte, err error))

CallServiceLater calls method of a service the host provides and returns at once; done runs in a later frame with the answer, or with a *ServiceError when the service refused, the call waited past timeout or nobody provides the service. A zero timeout waits the host's longest, 30 seconds. done runs exactly once while the mod runs; calls still waiting when the mod stops end with it.

func ClearMap

func ClearMap() error

ClearMap removes the map's own units and objectives, such as troopers, guardians and walkers, so a mode can use the map as an arena.

func Command

func Command(name string, handler func(p Player, args string))

Command calls handler when a player types /name in chat. The handler runs with the next server frame, before the frame handlers, and receives the text after the name, trimmed of surrounding spaces. Registering a name again replaces its handler.

func CreateEntity added in v0.1.1

func CreateEntity(options *EntityOptions) (uint32, error)

CreateEntity creates an entity the server knows by its designer name, such as npc_trooper_boss or prop_dynamic, with spawn key values and fields written before it spawns. The world removes it when the world ends; stopping the mod removes it too. It refuses an ability, item or weapon, which only a hero holds: GiveItem and ReplaceAbility give one. It refuses a class that runs console lines or loads scripts or entities past a mod's checks, such as point_servercommand, and key values that name a console line or a script, such as vscripts.

func Damage

func Damage(options *HitOptions) error

Damage deals a hit as the game would. The mod's Damage events do not include its own hits.

func EmitSound

func EmitSound(entity uint32, sound string, options *SoundOptions) (uint32, error)

EmitSound plays one game sound on any entity, such as a projectile, and returns its ID. Volume and pitch scale the sound, and listeners limit who hears it.

func EncodeSpot

func EncodeSpot(s *Spot) ([]byte, error)

EncodeSpot returns the spot document. Equal spots encode to equal bytes; positions and angles keep single precision.

func EntityName added in v0.1.57

func EntityName(entity uint32) (string, error)

EntityName returns a live entity's name, the targetname a map or a spawn key value gave it, or an empty name for an unnamed entity.

func FindEntities added in v0.1.3

func FindEntities(className string) ([]uint32, error)

FindEntities returns the handle of every live entity of a class, such as zip_line_node.

func FindEntitiesByName added in v0.1.57

func FindEntitiesByName(name string) ([]uint32, error)

FindEntitiesByName returns the handle of every live entity with a name, the targetname a map or the targetname key value of CreateEntity gave it.

func FireInput added in v0.1.1

func FireInput(entity uint32, input string, value any, activator *uint32) (bool, error)

FireInput sends an input to a live entity, as a map's output would, such as Skin with the integer 1. The value must have the type the input reads. It reports false once the entity is gone. It refuses AddOutput and the script inputs on every entity, and any input to an entity of a class CreateEntity refuses.

func GiveEntityModifier added in v0.1.78

func GiveEntityModifier(entity uint32, modifier string, seconds float32) error

GiveEntityModifier gives a live entity, such as Npc.entity or Pawn.entity, a modifier for seconds. An ability's modifier, named "<ability>/<modifier>", resolves its parent ability subclass even when the entity owns no abilities.

func HandedOff added in v0.1.51

func HandedOff() (string, error)

HandedOff returns the game's handoff state, or empty.

func Handoff added in v0.1.51

func Handoff(text string) error

Handoff replaces the handoff state for the game: what the running build hands the next build when the mod reloads, such as which round it plays. It lasts only through a reload of the mod in the same game, such as an update, whose new build reads it back with HandedOff. The host holds it in memory and never writes it to disk, so it ends when the mod stops or the server restarts. The host refuses state past 64 KiB.

func HideCues

func HideCues(rules []*CueRule) error

HideCues replaces the mod's cue rules: each keeps the particle or sound it names from its viewers until called again, while the event that caused the cue still resolves. Stopping the mod shows every cue again.

func HoldEntityModifier added in v0.1.78

func HoldEntityModifier(entity uint32, modifier string, active *bool) error

HoldEntityModifier keeps a modifier, named as GiveModifier names it, on a live entity with no expiry, giving it back whenever the game removes it while the entity lives. The hold ends with the entity or when active is false. Releasing leaves the entity's current modifier; the mod stopping removes it.

func HoldMatchClock

func HoldMatchClock(seconds *float32) error

HoldMatchClock keeps the match time at seconds every frame until called again; omitted seconds let it run.

func HoldModifierState

func HoldModifierState(entity uint32, state string, active *bool) error

HoldModifierState holds a modifier state, such as MODIFIER_STATE_FRIENDLY_FIRE_ENABLED, on an entity while the mod runs, or releases the hold. The hold ends with the entity.

func HoldReload added in v0.1.2

func HoldReload(held bool) error

HoldReload keeps the running build through a reload while held is true, such as while a player is partway through something a new build would lose. A reload that arrives meanwhile waits, and the newest one applies on the first frame after the mod releases the hold. A new build starts without a hold.

func ItemID added in v0.1.79

func ItemID(name string) uint32

ItemID returns the game's id for an item or ability name, such as "upgrade_magic_shield": MurmurHash2 of the name's bytes, seeded with its length, as the game hashes it.

func KillEntity added in v0.1.72

func KillEntity(options *KillOptions) error

KillEntity forces a hero or unit to die, optionally crediting an attacker. Already dead victims succeed without another death or reward.

func Log

func Log(args ...any)

Log writes one line to the server log under the mod's name. Arguments are formatted as by fmt.Sprint.

func MatchClock

func MatchClock() (float32, error)

MatchClock returns the match time in seconds that the scoreboard shows.

func ModifierState

func ModifierState(entity uint32, state string) (bool, error)

ModifierState reports whether an entity has a modifier state, such as MODIFIER_STATE_PARRY_ACTIVE.

func MoveEntity

func MoveEntity(entity uint32, position *Vector, facing *Angles, velocity *Vector) error

MoveEntity places any entity, such as a projectile, and replaces its facing and motion when given. Without a position it leaves the entity where it is, so a velocity alone steers a body the physics simulates, such as a prop_physics, which carries the motion on against the world.

func OnAbilityCast added in v0.1.83

func OnAbilityCast(handler func(cast *AbilityCastEvent))

OnAbilityCast calls handler after each ability the game executes, before the next frame: a hero's abilities and the items a player activates, at the moment the cast takes effect.

func OnChat added in v0.1.50

func OnChat(handler func(line *ChatEvent))

OnChat calls handler with each chat line a player writes, commands included, on the next server frame.

func OnDamage

func OnDamage(handler func(hit *DamageEvent) *DamageResult)

OnDamage calls handler before each hit lands, so it can block the hit or change its damage by returning a result; nil lets the hit through. Later handlers see the earlier ones' amount.

func OnDamaged

func OnDamaged(handler func(hit *DamagedEvent))

OnDamaged calls handler on the frame after each hit lands.

func OnFrame

func OnFrame(handler func(f *FrameEvent))

OnFrame calls handler once per server frame.

func OnHeal added in v0.1.84

func OnHeal(handler func(heal *HealEvent))

OnHeal calls handler after each heal, before the next frame: health a hero or unit regained at once from an ability, an item or lifesteal. Regeneration calls nothing, including what abilities such as Siphon Life restore as regeneration, and neither do the mod's own heal and a heal at full health. The heal names the entity healed, the healer and ability when the game names them, and the player of each: a slot of -1 is a unit's, or no one's.

func OnImpact

func OnImpact(handler func(impact *ImpactEvent))

OnImpact calls handler when a watched projectile strikes something, inside the game's impact: its calls apply before the game continues.

func OnInput

func OnInput(handler func(p Player, pressed, released uint64))

OnInput calls handler with the watched buttons a player pressed and released, as Button bits, before the next frame. A button is held from its press until its release.

func OnKill added in v0.1.83

func OnKill(handler func(kill *KillEvent))

OnKill calls handler after each hit that kills a hero or a unit, before the next frame. The kill names both entities and the player of each: a slot of -1 is a unit's, or a hazard's for the attacker.

func OnLanded

func OnLanded(handler func(landing *LandedEvent))

OnLanded calls handler when a hero lands under the manifest's QuakeWorld movement, before the next frame.

func OnLaunch

func OnLaunch(handler func(projectile *LaunchEvent))

OnLaunch calls handler with each watched projectile's first frame, before the next frame. WatchProjectiles names the projectiles.

func OnLevelChange added in v0.1.84

func OnLevelChange(handler func(change *LevelEvent))

OnLevelChange calls handler as each hero reaches a new level, before the next frame.

func OnMelee added in v0.1.84

func OnMelee(handler func(swing *MeleeEvent))

OnMelee calls handler after each melee swing, before the next frame, with whether it was heavy and the entities it struck, none for a miss.

func OnModifierEvent added in v0.1.83

func OnModifierEvent(name string, handler func(event *ModifierFiredEvent))

OnModifierEvent calls handler each time the game fires the modifier event with this EModifierEvent name, such as ABILITY_CAST_STARTED, PARRY_SUCCESS or PLAYER_RESPAWNED, before the next frame. Register before the mod starts. A name the running game lacks is logged once and never fires.

func OnNpcsRestored

func OnNpcsRestored(handler func(err error))

OnNpcsRestored calls handler when RestoreNpcs ends: err is nil once the map holds every target, or says why it does not.

func OnParry added in v0.1.84

func OnParry(handler func(parry *ParryEvent))

OnParry calls handler after each parry that catches a melee swing, before the next frame, naming the hero that parried and the attacker it caught.

func OnPing added in v0.1.100

func OnPing(handler func(ping *PingEvent) *PingResult)

OnPing calls handler with each ping a player sends, from the comms wheel, a quick ping key, the map or an ability, before anyone sees it, so it can block the ping or mute its voice line. A blocked ping reaches nobody, the sender included: no marker, sound, voice line or chat line. The players a handler lists in MuteVoice, by slot, get the ping without its voice line. The handler runs inside the server's ping, so it decides at once and defers other work to a frame.

func OnPlayerAway added in v0.1.101

func OnPlayerAway(handler func(away *PlayerAwayEvent))

OnPlayerAway calls handler once each time a joined human's client disconnects while the server holds their seat. They have not left: their hero and controller stay in the game, and OnPlayerReturn follows if they come back, so keep their seat as it stands rather than clear it.

func OnPlayerJoin added in v0.1.72

func OnPlayerJoin(handler func(joined *PlayerJoinedEvent))

OnPlayerJoin calls handler once for each player the mod serves when they are ready: a human who finished joining, a bot once added, and at start each player already in the game.

func OnPlayerLeave added in v0.1.72

func OnPlayerLeave(handler func(left *PlayerLeftEvent))

OnPlayerLeave calls handler once for each joined player who leaves the mod, with the reason the server dropped them when it gave one. A seat ends, and its player leaves, when a bot is removed, a human is kicked or released by the program that runs the host, or a human stays away past the game's limit; a human who only disconnects is away first. The slot and hero still read during the call, and afterwards Modlock kills the hero, keeps it down and takes the controller off its team, so the mod need not clear them. A player the mod stops serving leaves too, with Disconnected false.

func OnPlayerReturn added in v0.1.101

func OnPlayerReturn(handler func(returned *PlayerReturnedEvent))

OnPlayerReturn calls handler once each time an away player reconnects to their seat and finishes joining again, with the same Player, generation and hero they left.

func OnPlayers added in v0.1.79

func OnPlayers(handler func(players []*Connection))

OnPlayers calls handler with each player list the host reports, before the event it arrives with. A slot whose generation changed holds a new connection.

func OnRestored

func OnRestored(handler func(p Player, err error))

OnRestored calls handler when a player's Player.RestoreHero ends: err is nil once the target held for a second, or says why it did not.

func OnSettingChanged

func OnSettingChanged(handler func(p Player, key, value string))

OnSettingChanged calls handler when a player's setting changes outside the mod, such as on the player's profile. The mod's own Player.SetSetting calls do not reach it.

func OnSpawn added in v0.1.79

func OnSpawn(handler func(player Player, pawn *Pawn))

OnSpawn calls handler each time a player's hero enters play: their first hero after joining, and each respawn. The player has a hero to move, equip and read from then on, which OnPlayerJoin does not promise. The library hears it from the game's PLAYER_RESPAWNED event, before the frame handlers run.

func OnStart

func OnStart(handler func(args []string))

OnStart calls handler once when the server starts the mod, with the words after -- on the modlock dev or play command line.

func OnUiAction

func OnUiAction(handler func(event *UiActionEvent))

OnUiAction calls handler with each phase of a game action the root of a player's interface follows, with the next server frame. Package ui registers it to run the followers' handlers.

func OnUiDocument

func OnUiDocument(handler func(event *UiDocumentEvent))

OnUiDocument calls handler with the end of each submission from a player's document input, with the next server frame: the whole document, or why it did not arrive.

func OnUiInput added in v0.1.79

func OnUiInput(handler func(event *UiInputEvent))

OnUiInput calls handler with each change a player makes to an input in the mod's interface, with the next server frame. Package ui registers it to run the inputs' handlers.

func OnUiOverlay

func OnUiOverlay(handler func(event *UiOverlayEvent))

OnUiOverlay calls handler with each stock overlay that takes or gives back the input of a player whose interface root follows overlays, with the next server frame. Package ui registers it to run the followers' handlers.

func OnUiPlacement

func OnUiPlacement(handler func(event *UiPlacementEvent))

OnUiPlacement calls handler with each placement of the interface of a player whose interface root follows placement, with the next server frame. Package ui registers it to run the followers' handlers.

func OnUiPress added in v0.1.79

func OnUiPress(handler func(event *UiPressEvent))

OnUiPress calls handler with each press a player makes in the mod's interface, with the next server frame: a button's, or a layout's with the action its bound panel or its script names. Package ui registers it to run the buttons' and the bindings' handlers.

func OnUiWindow

func OnUiWindow(handler func(event *UiWindowEvent))

OnUiWindow calls handler with each run of a list's rows a player's screen asks the mod to show, with the next server frame. Package ui registers it to draw the window it asks for.

func OnWorld

func OnWorld(handler func(mapName string))

OnWorld calls handler with the map's name each time a world loads, and at start when one already has. Objects and bots from an earlier world are gone by then.

func Pause

func Pause(paused bool) error

Pause stops or resumes the game clock, as the pause command would. Stopping the mod resumes it.

func Precache

func Precache(options *PrecacheOptions) error

Precache loads heroes and resources with the next world. Call it during start, before the first world loads; a call after that, such as from a reload, prepares only the world after the next map change. Name every hero whose abilities ReplaceAbility gives, with their particles.

func PushEntity added in v0.1.31

func PushEntity(entity uint32, velocity, spin *Vector) error

PushEntity adds a velocity and an angular velocity to any entity. On a body the physics simulates, such as a prop_physics, it acts like an impulse that the simulation carries on.

func ReadBoard added in v0.1.73

func ReadBoard(query *BoardQuery, viewer *Connection, done func(*BoardPage, error))

ReadBoard reads the board and optional live viewer on a later frame.

func ReadField

func ReadField(entity uint32, className, field string, kind FieldType) (any, error)

ReadField reads one schema field of a live entity, such as the int32 m_iHealth of CBaseEntity. The host finds the field by name, so it survives game updates that move it, and refuses an entity that is not of the named class or a subclass. The match's state, such as the gold of each team or the winning team, is a field of CCitadelGameRules, which the citadel_gamerules entity reads. The parts of an entity's model that its body component holds read through the entity too: CGameSceneNode, and for a model entity CSkeletonInstance and CModelState, such as the uint64 m_MeshGroupMask of CModelState that chooses which mesh groups draw.

func ReadFieldList added in v0.1.3

func ReadFieldList(entity uint32, className, field string, kind FieldType) ([]any, error)

ReadFieldList reads a field that holds a list, such as the m_vecBannedHeroes of CCitadelGameRules. The type is the type of one element: a number, a handle, a boolean or a vector. A list of structures cannot be read.

func ReadFile added in v0.1.13

func ReadFile(path string) (*string, error)

ReadFile reads one of the mod's files: the host's copy, which the mod wrote or the server's operator placed, else the one the mod ships under data/. A file in neither reads as unset. Names that leave the mod's directories are refused.

func ReadFileBytes added in v0.1.94

func ReadFileBytes(path string) ([]byte, error)

ReadFileBytes reads one of the mod's files from the same places as ReadFile, as bytes that need not be text, such as a packed table the mod views in place. A file in neither reads as unset. The host reads the whole file during the call.

func ReadModifierField added in v0.1.17

func ReadModifierField(entity uint32, modifier, className, field string, kind FieldType) (any, error)

ReadModifierField reads one schema field of a modifier the entity holds, such as the int32 m_nCameraLevel of CCitadel_Modifier_OrbitCamera on a pawn holding modifier_citadel_orbit_camera. The answer holds no value while the entity lacks the modifier. The host cannot check the modifier's class, so a wrong class reads the wrong bytes, though never past readable memory.

func RemapInput

func RemapInput(from, to uint64, repeat *bool) error

RemapInput makes the from buttons act as the to buttons for every player's hero until called again; from reads as up. With repeat, a held from button uses the to ability again as soon as it is ready. A zero from stops remapping, and stopping the mod does too. BlockInput applies after the remap.

func RemoveEntities

func RemoveEntities(className string) (int32, error)

RemoveEntities removes every entity of a class, such as npc_trooper, without rewards, and returns how many it removed.

func RemoveEntity added in v0.1.1

func RemoveEntity(entity uint32) (bool, error)

RemoveEntity takes an entity the mod created out of the world without rewards. It reports false when the entity was already gone.

func ReportMatch added in v0.1.73

func ReportMatch(report *MatchReport, done func(error))

ReportMatch reports the places of enrolled players together. Done receives acceptance or refusal on a later frame. Each place carries a connection.

func ReportScore added in v0.1.88

func ReportScore(player *ScoreConnection, report *ScoreReport, done func(error))

ReportScore reports an enrolled player's score. Done receives acceptance or refusal on a later frame. Key distinguishes rounds within the game.

func RestoreNpcs

func RestoreNpcs(npcs []*NpcTarget) error

RestoreNpcs replaces the map's lane units and objectives with targets over the next frames. Units of these classes not in the list are removed, structures that match are kept, and moving units are spawned again in place. An NpcsRestored event reports when every target stands as its own unit, or why not. A new call replaces the running one.

func Serve

func Serve(service string, handler Service)

Serve answers the host's calls to service with handler. Registering a service again replaces its handler.

func ServerCommand

func ServerCommand(command string) error

ServerCommand runs one line at the server console, as if typed there. A line that sets a variable may set a development-only or cheat-protected one. A line that reaches the engine's controls for files, logging, the network or the process, or stores a command to run later, is refused with the name of the command.

func SetFreeForAll added in v0.1.4

func SetFreeForAll(enabled bool) error

SetFreeForAll turns free-for-all on or off for the running mod, over the Manifest's free_for_all default. While on, the host seats each new player on the smaller team with no team screen, holds friendly fire on every hero, makes teammates enemies to abilities, projectiles and target checks, and ignores changeteam commands. The stock hero picker does not open for a seated player, so the mod gives each seated player whose pawn has hero 0 a hero with SelectHero. Turning it off releases the friendly fire holds and restores stock team relations; players keep their teams. Clients still draw teammates as allies.

func SetOrbitCamera added in v0.1.8

func SetOrbitCamera(player Player, enabled bool) error

SetOrbitCamera gives the player's hero the hideout's orbit camera, zoomed with the wheel, or returns the normal camera. The hideout HUD replaces the game HUD while it is on.

The pawn's networked m_bInHideoutZone moves its client to the hideout view, and the wheel zooms only while the pawn holds MODIFIER_STATE_HIDEOUT_ZONE, since the server ignores orbit_camera_in and orbit_camera_out without it.

func SetRespawnDelay added in v0.1.82

func SetRespawnDelay(delay time.Duration)

SetRespawnDelay brings every fallen hero back after delay, in place of the game's own respawn time. Zero leaves fallen heroes to the game again.

func SetTeamSeating added in v0.1.28

func SetTeamSeating(enabled bool) error

SetTeamSeating turns team seating on or off for the running mod. While on, the host seats each player who joins with no team on the smaller team with no team screen; friendly fire and changeteam stay as the game has them. The stock hero picker does not open for a seated player, so the mod gives each seated player whose pawn has hero 0 a hero with SelectHero. Free-for-all seats players this way whatever this says. Turning it off leaves players on their teams.

func ShowEntityOnlyTo added in v0.1.4

func ShowEntityOnlyTo(entity uint32, players []int32) error

ShowEntityOnlyTo sends an entity the mod created only to the players with the listed server slots; every other client drops it, or never receives it when the call follows its creation in the same frame. With no players no client receives it. The list replaces any earlier one. A player who leaves is taken off every list, so whoever joins in their slot does not receive the entity. The rule holds for an entity created with TransmitAlways too, but not for entities parented to it, which need their own call. Removing the entity, the world ending or the mod stopping drops the rule.

func ShowEntityToAll added in v0.1.4

func ShowEntityToAll(entity uint32) error

ShowEntityToAll sends an entity the mod created to every player the game would send it to again, undoing ShowEntityOnlyTo.

func SilenceVoice added in v0.1.77

func SilenceVoice(concepts []string) error

SilenceVoice keeps every hero from speaking the named voice concepts, until called again. A hero still hears the game's other sounds. Stopping the mod lets them speak; a name the game does not know fails the call and the known ones still apply.

func StartRift

func StartRift(position *Vector) error

StartRift opens the Rift objective at position now.

func StartServiceCall added in v0.1.86

func StartServiceCall(service, method string, payload []byte, timeoutMilliseconds uint32) (uint64, error)

StartServiceCall calls method of a service the host provides and returns at once with a number; the answer arrives in a later frame as a ServiceReplied event carrying that number. Every call ends once: with the reply, the service's refusal, a timeout or no provider at all. A service nobody provides is never asked. The host waits at most 30 seconds, or the call's shorter timeout, and drops the mod's waiting calls when the mod stops or reloads. A service that answers at once answers this way too, in the next frame.

func StopSound added in v0.1.77

func StopSound(id uint32) error

StopSound stops a sound Sound or EmitSound started. A sound that already ended is not an error.

func WatchInput

func WatchInput(buttons uint64) error

WatchInput replaces the buttons whose presses and releases arrive as Input events. Watching does not withhold a press; block it with BlockInput.

func WatchProjectiles

func WatchProjectiles(options *ProjectileOptions) error

WatchProjectiles reports the projectiles with these designer names, such as rocket_launcher_rocket_projectile, in Launch and Impact events. A new call replaces the list; an empty list stops watching.

func WriteField

func WriteField(entity uint32, className, field string, kind FieldType, value any) error

WriteField writes one schema field of a live entity and sends the change to the players. The value takes the form ReadField returns for the type. Text goes only to a symbol field (string_t, such as the m_DialogXMLName of a point_clientui_world_panel), with {addon} replaced by the mod's content addon as in an entity's key values; a CUtlString field owns its text and cannot be written. A write to the match's state sends all of it, so players already in the match see the change, and a write to a model part, as ReadField names them, sends the entity. A client builds a client UI entity's panel only when it creates the entity, so a write to m_DialogXMLName sends every client a full update on the next frame, which creates every entity again; the players' game stalls briefly, so write a layout when it changes, not every frame. It refuses the fields that name a console line or a script, such as m_iszPrivateVScripts, here and among the fields CreateEntity writes before spawn.

func WriteFieldList added in v0.1.3

func WriteFieldList(entity uint32, className, field string, kind FieldType, values []any) error

WriteFieldList replaces the elements of a list field and sends the change to the players, growing the list when it holds fewer elements than the new ones.

func WriteFile added in v0.1.13

func WriteFile(path, text string) error

WriteFile replaces one of the mod's files in the host's copy, which outlives a restart and an update of the mod; the files the mod ships stay as they are. The write is whole or not at all, and the host refuses one past its quota of 4 MiB per mod. A host that keeps no files refuses every write.

Types

type Ability

type Ability = abilitiespb.Ability

Ability is one ability a hero owns.

type AbilityCastEvent added in v0.1.83

type AbilityCastEvent = abilitiespb.AbilityCastEvent

AbilityCastEvent reports one ability the game executed: the moment the cast takes effect, after any cast time, for a hero's abilities and the items a player activates.

type AbilityOptions

type AbilityOptions = abilitiespb.AbilityOptions

AbilityOptions changes one ability of a player's hero.

type ActionPhase

type ActionPhase = uipb.ActionPhase

ActionPhase is where a press stands: of a game action, or of a range's handle.

type Angles

type Angles = geometrypb.EulerAngles

Angles is a rotation in degrees.

type AxisBinding

type AxisBinding = controllerspb.AxisBinding

AxisBinding drives one command axis from one device axis: a raw axis or an axis of the gamepad layer. Exactly one of Raw and Gamepad is set; an entry with neither or both is ignored.

type AxisThreshold

type AxisThreshold = controllerspb.AxisThreshold

AxisThreshold reads an axis as a button, as a radio transmitter's two- and three-position switches report themselves as axes. The button goes down when the axis reaches the threshold from the released side, and up only once the axis has gone back past the threshold by the hysteresis, so noise around the threshold never toggles it.

type BoardPage added in v0.1.73

type BoardPage = scorespb.BoardPage

BoardPage is a page of standings and the requested viewer's own row.

type BoardQuery added in v0.1.73

type BoardQuery = scorespb.BoardQuery

BoardQuery selects a page of a board and optionally a viewer.

type BotOptions

type BotOptions = playerspb.BotOptions

BotOptions describes a bot player.

type BotOptionsHeroId

type BotOptionsHeroId = playerspb.BotOptions_HeroId

BotOptionsHeroId sets BotOptions.Hero to HeroId.

type BotOptionsHeroName

type BotOptionsHeroName = playerspb.BotOptions_HeroName

BotOptionsHeroName sets BotOptions.Hero to HeroName.

type BotPolicy added in v0.1.79

type BotPolicy int

BotPolicy is what a Cast does with a bot.

const (
	// BotsSkip leaves bots out of the cast.
	BotsSkip BotPolicy = iota
	// BotsJoin makes a bot a member as a human is.
	BotsJoin
	// BotsKick asks the server to remove each bot, once per connection.
	BotsKick
)

type Bounds

type Bounds = uipb.Bounds

Bounds is a box on a player's screen in layout units, the units of a style's pixels, measured from the screen's top left corner. The screen is 1080 layout units tall at every resolution.

type BuildCategory added in v0.1.47

type BuildCategory = abilitiespb.BuildCategory

BuildCategory is one named group of a build's items.

func HeroBuild added in v0.1.47

func HeroBuild(hero string) ([]*BuildCategory, error)

HeroBuild reads a hero's recommended build from the host's game data: its categories of items in buying order. Items the game does not define are left out, so every item returned is one GiveItem accepts. A hero without a build answers with no categories. The call needs a loaded world.

type BuildItem added in v0.1.47

type BuildItem = abilitiespb.BuildItem

BuildItem is one item of a build.

type ButtonBinding

type ButtonBinding = controllerspb.ButtonBinding

ButtonBinding holds command button bits while one device input is held: a raw button, a gamepad button, an axis past a threshold or a hat direction. Exactly one source is set; an entry with none or several is ignored.

type CameraApproach added in v0.1.8

type CameraApproach = playerspb.CameraApproach

CameraApproach moves a param toward a value.

type CameraHold added in v0.1.8

type CameraHold = playerspb.CameraHold

CameraHold keeps a param where it is.

type CameraLag added in v0.1.8

type CameraLag = playerspb.CameraLag

CameraLag lets a param trail its usual value.

type CameraLerp added in v0.1.8

type CameraLerp = playerspb.CameraLerp

CameraLerp moves a param from one value to another over a time.

type CameraOptions added in v0.1.8

type CameraOptions = playerspb.CameraOptions

CameraOptions adds one operation to a player's camera.

type CameraParam added in v0.1.8

type CameraParam = playerspb.CameraParam

CameraParam is one value of the camera that follows a hero, which the game's abilities move as Mirage's Tornado pulls the camera back.

type CameraSpring added in v0.1.8

type CameraSpring = playerspb.CameraSpring

CameraSpring pulls a param toward a value.

type Cast added in v0.1.79

type Cast[M any] struct {
	// contains filtered or unexported fields
}

Cast tracks a mode's players: one member of type M for each human who finished joining, made by the mode's Join and ended by its Leave. Members are keyed by slot and connection generation, so a reconnect is a leave and a join. Cast tracks joins and leaves from host player events and settles them on the next Frame; on frames with no membership changes it does not scan the player list.

A member may carry a Want: to sit on a hero and team, and to respawn after a delay when their hero falls. A human whose want leaves the hero free still gets one if the game leaves them on a team without a hero, since nothing else would seat them. Each frame Cast compares the desired state with the member's current hero, retries applying differences at most once per second, and stops once they match. Failed or dropped assignments are retried rather than reported as errors.

Each frame costs one pawn read per member, which the mode reads back with Pawn instead of querying the game again.

func NewCast added in v0.1.79

func NewCast[M any](options CastOptions[M]) *Cast[M]

NewCast returns a Cast that answers players coming and going with options. It settles the player list the host last reported on its first Frame.

func (*Cast[M]) Frame added in v0.1.79

func (c *Cast[M]) Frame(seconds float64)

Frame settles the joins and leaves reported since the last frame, reads each member's hero, and retries applying any desired state that has not taken effect yet at most once per second. seconds is the game clock, as FrameEvent.TimeSeconds reports it.

func (*Cast[M]) Get added in v0.1.79

func (c *Cast[M]) Get(p Player) (M, bool)

Get returns the member in the player's slot, and false when there is none.

func (*Cast[M]) Members added in v0.1.79

func (c *Cast[M]) Members() []M

Members lists the members in the order they joined.

func (*Cast[M]) Pawn added in v0.1.79

func (c *Cast[M]) Pawn(p Player) *Pawn

Pawn returns the member's hero as Cast read it this frame, or nil.

func (*Cast[M]) Size added in v0.1.79

func (c *Cast[M]) Size() int

Size returns the number of members.

type CastOptions added in v0.1.79

type CastOptions[M any] struct {
	// Join makes the member for a player who finished joining. It is required.
	Join func(connection *Connection) M
	// Leave ends a member whose connection left the slot, or nil.
	Leave func(member M, connection *Connection)
	// Want is what every member wants. WantOf replaces it when set.
	Want Want
	// WantOf returns what one member wants now; nil uses Want. Cast calls it
	// for each member on most frames, so a want follows the member's own state
	// and the function should be cheap.
	WantOf func(member M) Want
	// Bots says what Cast does with a bot; BotsSkip is the default.
	Bots BotPolicy
}

CastOptions are a mode's answers to its players coming and going.

type ChatEvent added in v0.1.50

type ChatEvent = wasmpb.ChatEvent

ChatEvent carries one chat line as the server accepted it, commands included.

type CommandAxis

type CommandAxis = controllerspb.CommandAxis

CommandAxis names one analog field of the player's user command (CBaseUserCmdPB) that a command binding can drive.

type CommandBinding

type CommandBinding = controllerspb.CommandBinding

CommandBinding maps one device's inputs to the fields of the player's user commands. The player's client applies it to each state it reads and hands the result to its host application, which may carry it in the commands the game sends, so the server receives the device's input with each command instead of a round trip later. Modlock itself writes nothing into the game.

type CommandEvent

type CommandEvent = wasmpb.CommandEvent

CommandEvent carries one command line from a player: a chat line that starts with a slash (or ".", "+" or "-"), without that prefix, or a console command the server received.

type CommandResult

type CommandResult = wasmpb.CommandResult

CommandResult answers whether the mod handled a command.

type Connection

type Connection = playerspb.Connection

Connection is one occupied player slot.

func ConnectionOfSteamID added in v0.1.82

func ConnectionOfSteamID(steamID uint64) *Connection

ConnectionOfSteamID returns the connection of the account with a Steam ID, or nil when it is not connected. Its GetPlayer is the slot of the Player to call.

func Players

func Players() ([]*Connection, error)

Players lists the occupied player slots in slot order. It answers from the roster the host last reported, and asks the host until a report arrives.

type Controller

type Controller = controllerspb.Controller

Controller is one device as a mod reads it.

type ControllerInfo

type ControllerInfo = controllerspb.ControllerInfo

ControllerInfo describes one device a client reads.

type ControllerState

type ControllerState = controllerspb.ControllerState

ControllerState is one device's inputs, the raw joystick layer always and the gamepad layer when SDL knows the device.

type ControllerStream

type ControllerStream = controllerspb.ControllerStream

ControllerStream is the state of the stream that brings one player's controllers to the host, as a mod reads it.

type ConvarAnsweredEvent

type ConvarAnsweredEvent = playerspb.ConvarAnsweredEvent

ConvarAnsweredEvent ends one StartConvarQuery.

type ConvarMiss

type ConvarMiss = playerspb.ConvarMiss

ConvarMiss says why a console variable query ended without a value.

type CueRule

type CueRule = effectspb.CueRule

CueRule keeps one particle or sound the server starts from chosen players. The event that caused the cue still resolves; only who sees or hears it changes. A cue a player's own client predicts, such as their own parry, never comes from the server, so no rule reaches it.

type DamageEvent

type DamageEvent = combatpb.DamageEvent

DamageEvent is one hit before the game applies it. Handles are zero when the game names no such entity.

type DamageResult

type DamageResult = combatpb.DamageResult

DamageResult answers a DamageEvent. An empty result lets the hit through.

type DamagedEvent

type DamagedEvent = combatpb.DamagedEvent

DamagedEvent reports one hit the game applied.

type DisconnectReason added in v0.1.72

type DisconnectReason = playerspb.DisconnectReason

DisconnectReason is why the server dropped a connection, numbered as the game's ENetworkDisconnectionReason.

type DocumentDelivered

type DocumentDelivered = uipb.DocumentDelivered

DocumentDelivered is a submission that arrived whole.

type DocumentFailed

type DocumentFailed = uipb.DocumentFailed

DocumentFailed is a submission that ended without its document.

type DocumentFailure

type DocumentFailure = uipb.DocumentFailure

DocumentFailure says why a document input's submission did not arrive.

type DriveCommand added in v0.1.8

type DriveCommand = movementpb.DriveCommand

DriveCommand is a player's controls for one tick and the ticks after it.

type EntityCamera

type EntityCamera struct {
	// contains filtered or unexported fields
}

EntityCamera drives one player's 6-DOF point_camera override while keeping their living hero active.

func OpenEntityCamera

func OpenEntityCamera(player Player, opts EntityCameraOptions) (*EntityCamera, error)

OpenEntityCamera gives player's living hero a per-player 6-DOF point_camera view, through Player.OpenEntityCamera, that preserves full 360-degree roll and over-the-top pitch loops while keeping the player on their living hero. The server sends the player what is visible from the camera rather than from the hero. A player has one entity camera: opening another moves it, and Stop closes whichever is open. While the camera is active the stock client skips its third-person look polling, so mouse and right-stick look do not update view angles.

func (*EntityCamera) Entity

func (c *EntityCamera) Entity() uint32

Entity returns the player's primary point_camera entity handle.

func (*EntityCamera) Move

func (c *EntityCamera) Move(position Vector, facing Angles) error

Move places the camera at position and facing, preserving full roll.

func (*EntityCamera) SetFOV

func (c *EntityCamera) SetFOV(fov float32) error

SetFOV updates the camera's horizontal field of view in degrees.

func (*EntityCamera) Stop

func (c *EntityCamera) Stop() error

Stop closes the camera and returns the player to their hero.

type EntityCameraOptions

type EntityCameraOptions struct {
	Position Vector
	Facing   Angles
	// FOV is the horizontal field of view in degrees; zero uses 90.
	FOV float32
	// ZNear and ZFar override clipping planes when non-zero.
	ZNear float32
	ZFar  float32
	// Smooth blends in from the hero over 0.5s instead of cutting on frame 1.
	Smooth bool
	// KeepControls keeps the movement keys and the left stick's forward and
	// left axes reaching movement samples while the camera is open, which the
	// stock camera-override modifier otherwise freezes, as for a cinematic.
	KeepControls bool
}

EntityCameraOptions configures a player's 6-DOF point_camera override.

type EntityClassName added in v0.1.1

type EntityClassName = entitiespb.EntityClassName

EntityClassName names one entity's class two ways.

func EntityClass added in v0.1.1

func EntityClass(entity uint32) (*EntityClassName, error)

EntityClass returns a live entity's schema class, such as CCitadelPlayerPawn, whose fields ReadField reads, and its designer name.

type EntityOptions added in v0.1.1

type EntityOptions = entitiespb.EntityOptions

EntityOptions describes an entity to create.

type EntityPlacement added in v0.1.21

type EntityPlacement = entitiespb.EntityPlacement

EntityPlacement is an entity's place in the world.

func EntityPosition added in v0.1.21

func EntityPosition(entity uint32) (*EntityPlacement, error)

EntityPosition returns where a live entity stands, its absolute origin and angles, as MoveEntity places it, and its velocity. Any entity with a place in the world has one, such as one of the map's boxes.

type EquipmentTarget

type EquipmentTarget = playerspb.EquipmentTarget

EquipmentTarget is one ability or item a HeroTarget gives the hero.

type FieldType

type FieldType = fieldspb.FieldType

FieldType is how ReadField and WriteField interpret a field's storage.

type FieldWrite added in v0.1.1

type FieldWrite = fieldspb.FieldWrite

FieldWrite writes one schema field of an entity the host creates.

type FogOptions

type FogOptions = objectspb.FogOptions

FogOptions describes an oriented box of tinted fog.

type FrameEvent

type FrameEvent = wasmpb.FrameEvent

FrameEvent identifies one server frame.

type GameAction

type GameAction = uipb.GameAction

GameAction is one of the game's own bound actions a mod may follow.

type Gamepad

type Gamepad = controllerspb.Gamepad

Gamepad is a device's gamepad layer, with named sticks, triggers and buttons, for a device whose layout SDL knows.

type GamepadAxis

type GamepadAxis = controllerspb.GamepadAxis

GamepadAxis names one axis of the gamepad layout, as Gamepad carries it.

type GamepadButton

type GamepadButton = controllerspb.GamepadButton

GamepadButton names one button of the gamepad layout, by position as SDL names them: South is A on an Xbox controller and Cross on a PlayStation one.

type HatPosition

type HatPosition = controllerspb.HatPosition

HatPosition reads a hat as a button, held while the hat points any of the directions its mask names.

type HealEvent added in v0.1.84

type HealEvent = combatpb.HealEvent

HealEvent reports health an ability, item or lifesteal restored at once to a hero or unit. Regeneration reports none, including what abilities such as Siphon Life restore as regeneration, and neither do Modlock's own heal and a heal at full health.

type Hero added in v0.1.79

type Hero struct {
	// Name is the game's name for the hero, as SelectHero takes it.
	Name string
	// ID is the hero's fixed id, as Pawn.Hero reports it.
	ID uint32
	// Title is the hero's name as players read it.
	Title string
	// Portrait is the hero's small stock portrait, as an image's src.
	Portrait string
}

Hero is one released hero: its game name, such as "hero_atlas", the title players read and its fixed id.

func FindHero added in v0.1.79

func FindHero(typed string) (Hero, bool)

FindHero matches what a player typed, such as "geist", "Lady Geist" or "hero_ghost", to a hero: an exact game name or title first, then the first title that starts with or contains it.

func HeroNamed added in v0.1.79

func HeroNamed(name string) (Hero, bool)

HeroNamed returns the released hero that name names exactly: its game name, such as "hero_nano", that name without "hero_", such as "nano", or its title in any case, with or without spaces and punctuation, such as "Calico" or "ladygeist". Unlike FindHero it matches no part of a name, so a misspelled name finds no hero rather than another one. Returns false when name names no released hero.

type HeroTarget

type HeroTarget = playerspb.HeroTarget

HeroTarget is the state RestoreHero gives one hero. Omitted parts keep the hero's own.

type HitOptions

type HitOptions = combatpb.HitOptions

HitOptions describes damage the mod deals.

type ImpactEvent

type ImpactEvent = combatpb.ImpactEvent

ImpactEvent is a watched projectile striking something.

type InputEvent

type InputEvent = wasmpb.InputEvent

InputEvent is one player's watched buttons that went down or up.

type Interaction added in v0.1.68

type Interaction = movementpb.Interaction

Interaction is one completed interaction with a map object.

type InteractionKind added in v0.1.68

type InteractionKind = movementpb.InteractionKind

InteractionKind names how a hero completed an interaction with a map object.

type KeyValue added in v0.1.1

type KeyValue = entitiespb.KeyValue

KeyValue is one spawn key value.

type KillEvent added in v0.1.83

type KillEvent = combatpb.KillEvent

KillEvent reports one hero or unit that a hit killed.

type KillOptions added in v0.1.72

type KillOptions = combatpb.KillOptions

KillOptions forces a hero or unit's death through the game's damage path.

type LandedEvent

type LandedEvent = movementpb.LandedEvent

LandedEvent is one hero landing.

type Lane added in v0.1.67

type Lane = movementpb.Lane

Lane is one of the map's lanes, numbered as the game numbers them. The three-lane map has yellow, blue and purple ziplines and no green.

type LaunchEvent

type LaunchEvent = combatpb.LaunchEvent

LaunchEvent is a watched projectile's first frame.

type LevelEvent added in v0.1.84

type LevelEvent = combatpb.LevelEvent

LevelEvent reports a hero reaching a new level.

type LoadedSpot

type LoadedSpot struct {
	Map string
	// contains filtered or unexported fields
}

LoadedSpot is a spot standing in the world, in placement order.

func LoadSpot

func LoadSpot(s *Spot) *LoadedSpot

LoadSpot places every object of s and returns it standing. Objects the game cannot place are skipped with a log line; the rest load.

func (*LoadedSpot) At

func (l *LoadedSpot) At(entity uint32) *Placed

At returns the placed object whose entity a trace hit, or nil.

func (*LoadedSpot) Bounce

func (l *LoadedSpot) Bounce(movement []*MovementSample)

Bounce launches each sampled hero who stands on a bouncing object. A mode calls it with each frame's movement samples, for the heroes it watches.

func (*LoadedSpot) Clear

func (l *LoadedSpot) Clear()

Clear removes every placed object.

func (*LoadedSpot) Objects

func (l *LoadedSpot) Objects() []*Placed

Objects returns the placed objects in placement order.

func (*LoadedSpot) Place

func (l *LoadedSpot) Place(object *SpotObject) (*Placed, error)

Place spawns object as a solid model and adds it to the spot. A model the game cannot place logs why and returns the error.

func (*LoadedSpot) Remove

func (l *LoadedSpot) Remove(placed *Placed)

Remove takes a placed object out of the world and the spot.

func (*LoadedSpot) Spot

func (l *LoadedSpot) Spot() *Spot

Spot returns the spot as it stands.

type MatchPlace added in v0.1.88

type MatchPlace = scorespb.Place

MatchPlace names an enrolled participant and their finishing place.

type MatchReport added in v0.1.73

type MatchReport = scorespb.MatchReport

MatchReport reports one match's places to a board.

type Measured

type Measured = uipb.Measured

Measured is the bounds of the node a tree names with measure.

type MeleeEvent added in v0.1.84

type MeleeEvent = combatpb.MeleeEvent

MeleeEvent reports one melee swing as the game resolves it.

type ModRole added in v0.1.53

type ModRole = playerspb.ModRole

ModRole is what a player is to the running mods.

type ModelOptions

type ModelOptions = objectspb.ModelOptions

ModelOptions describes a model placed in the world.

type Modifier added in v0.1.80

type Modifier = abilitiespb.Modifier

Modifier is one modifier an entity holds, as the game keeps it.

func Modifiers added in v0.1.80

func Modifiers(entity uint32) ([]*Modifier, error)

Modifiers lists every modifier an entity holds, such as the stun a hero's ultimate keeps on its target, with its name, class, caster, ability, age, time left and stacks. An entity that holds none answers an empty list.

type ModifierFiredEvent added in v0.1.83

type ModifierFiredEvent = combatpb.ModifierFiredEvent

ModifierFiredEvent reports one of the game's modifier events the mod watches, with the entities the game fired it with. Which of them an event fills depends on the event.

type MovementAction

type MovementAction = movementpb.MovementAction

MovementAction is a movement fact the game announced for a hero.

type MovementCommand added in v0.1.1

type MovementCommand = movementpb.MovementCommand

MovementCommand is the movement a player commanded over one tick. The server runs a player's commands as they arrive, so a tick may run several or none: every press among them is kept once, and a tick that ran none holds the last buttons without pressing them again.

type MovementSample

type MovementSample = movementpb.MovementSample

MovementSample is one watched hero's movement on one tick, as the game keeps it. A hero whose position, velocity or ground the game does not provide has no sample; another field the game did not provide is absent or zero.

type Npc

type Npc struct {
	// Entity is the unit's entity handle, as damage events report it.
	Entity uint32
}

Npc is one unit the mod spawned.

func SpawnNpc

func SpawnNpc(options *NpcOptions) (Npc, error)

SpawnNpc adds a unit that is not a player, such as a trooper, as CreateEntity does, then sets its health and lane. It thinks from the next frame. The world removes it when the world ends; stopping the mod removes it too.

func (Npc) Move

func (n Npc) Move(position *Vector, facing *Angles, velocity *Vector) (bool, error)

Move places the unit and sets its velocity, which drives its walk animation. It sets the pose without a teleport, which would reset the unit's animation, so a mode can steer its units every frame. It reports false once the unit is gone.

func (Npc) Read

func (n Npc) Read() (*NpcState, error)

Read returns the unit's state, or nothing once it is gone.

func (Npc) Remove

func (n Npc) Remove() (bool, error)

Remove takes a unit the mod spawned out of the world without rewards. It reports false when the unit was already gone.

func (Npc) SetHealth

func (n Npc) SetHealth(health int32, maxHealth *int32) (bool, error)

SetHealth sets the unit's health, and its maximum when given. It reports false once the unit is gone.

type NpcOptions

type NpcOptions = npcspb.NpcOptions

NpcOptions describes a unit that is not a player, such as a trooper.

type NpcState

type NpcState = npcspb.NpcState

NpcState is a unit's state this frame.

type NpcTarget

type NpcTarget = npcspb.NpcTarget

NpcTarget is one unit or objective RestoreNpcs places, as replays record it.

type NpcsRestoredEvent

type NpcsRestoredEvent = npcspb.NpcsRestoredEvent

NpcsRestoredEvent reports how a RestoreNpcs ended.

type Overlay

type Overlay = uipb.Overlay

Overlay names the stock interface that holds the player's input. When several are open, the renderer names the first of chat, the shop, the build editor, the item draft, a popup and the escape menu.

type ParryEvent added in v0.1.84

type ParryEvent = combatpb.ParryEvent

ParryEvent reports a parry that caught a melee swing.

type ParticleAnchor added in v0.1.8

type ParticleAnchor = objectspb.ParticleAnchor

ParticleAnchor ties one control point of a particle effect to an entity.

type ParticleOptions

type ParticleOptions = objectspb.ParticleOptions

ParticleOptions describes a particle effect.

type ParticlePoint

type ParticlePoint = objectspb.ParticlePoint

ParticlePoint places one control point of a particle effect.

type Pawn

type Pawn = playerspb.Pawn

Pawn is one player's pawn this frame: their hero, or the game's placeholder before a hero is selected.

type PersistOp added in v0.1.86

type PersistOp = persistpb.Op

PersistOp is one change to one field of a record.

func PersistAdd added in v0.1.86

func PersistAdd(field string, n float64) *PersistOp

PersistAdd adds n to a count or number field; a count takes only a whole number from zero up.

func PersistInsert added in v0.1.86

func PersistInsert(field, tag string) *PersistOp

PersistInsert adds tag to a tags field.

func PersistMax added in v0.1.86

func PersistMax(field string, n float64) *PersistOp

PersistMax raises a number or max field to n when n is higher.

func PersistMin added in v0.1.86

func PersistMin(field string, n float64) *PersistOp

PersistMin lowers a number field to n when n is lower.

func PersistRemove added in v0.1.86

func PersistRemove(field, tag string) *PersistOp

PersistRemove takes tag from a tags field.

func PersistSetNumber added in v0.1.86

func PersistSetNumber(field string, n float64) *PersistOp

PersistSetNumber sets a count or number field to n.

func PersistSetText added in v0.1.86

func PersistSetText(field, text string) *PersistOp

PersistSetText sets a string field to text.

type PersistRecord added in v0.1.86

type PersistRecord = persistpb.Record

PersistRecord is one player's record of a type the manifest declares under persist: each field written so far, by name.

type Pickup

type Pickup struct {
	// Entity is the pickup's entity handle.
	Entity uint32
}

Pickup is one pickup the mod placed.

func CreatePickup

func CreatePickup(kind PickupKind, position *Vector) (Pickup, error)

CreatePickup places an urn, which a hero carries once collected, or a movement buff. Stopping the mod removes it.

func (Pickup) Present

func (p Pickup) Present() (bool, error)

Present reports whether the pickup still lies in the world, uncollected.

func (Pickup) Remove

func (p Pickup) Remove() (bool, error)

Remove takes the pickup out of the world. It reports false when a player had collected it.

type PickupKind

type PickupKind = entitiespb.PickupKind

PickupKind is a kind of item players collect by walking over it.

type PingEvent added in v0.1.100

type PingEvent = wasmpb.PingEvent

PingEvent carries one ping a player sent, before anyone sees it.

type PingKind added in v0.1.100

type PingKind = wasmpb.PingKind

PingKind is how a player pinged.

type PingResult added in v0.1.100

type PingResult = wasmpb.PingResult

PingResult answers a Ping event.

type Placed

type Placed struct {
	Object *SpotObject
	World  WorldObject
	// Entity is the model's entity handle, as traces report it.
	Entity uint32
}

Placed is one spot object standing in the world.

type Player

type Player struct {
	// contains filtered or unexported fields
}

Player addresses one connected player by their server slot. Two Players are equal only when they name the same connection: a person who takes a slot another left gets a different Player, so a map keyed by Player never hands the newcomer the entry of the one who left. PlayerOf makes one; the zero Player names nobody.

func AddBot

func AddBot(options *BotOptions) (Player, error)

AddBot adds a bot player and returns it. The bot leaves when the world ends or the mod stops.

func PlayerOf added in v0.1.84

func PlayerOf(slot int32) Player

PlayerOf returns the Player of the connection that holds slot now, equal to every other Player made for that connection.

func (Player) Abilities

func (p Player) Abilities() ([]*Ability, error)

Abilities lists the abilities of the player's hero in the hero's order, or none without a live hero.

func (Player) AddMetric

func (p Player) AddMetric(name string, value float64, label *string) error

AddMetric adds to the player's total of a metric the manifest declares. The host keeps each player's totals in memory and hands them on once, when the player leaves or the mod stops; a bot keeps none.

func (Player) AdjustAbilityPoints added in v0.1.74

func (p Player) AdjustAbilityPoints(points, unlocks int32) error

AdjustAbilityPoints gives the player ability points and ability unlocks, or takes them when negative, as Pawn.ability_points and Pawn.ability_unlocks read them. A spend larger than the player holds fails and spends nothing.

func (Player) AdjustSouls

func (p Player) AdjustSouls(delta int32, silent *bool) error

AdjustSouls gives the player delta souls, or takes them when delta is negative. A spend larger than the player's souls fails and spends nothing. Silent skips the pickup's sound and number.

func (Player) Announce

func (p Player) Announce(title, text string) error

Announce shows a game announcement with a title to the player.

func (Player) BlockInput

func (p Player) BlockInput(buttons uint64) error

BlockInput withholds buttons from the player's hero until called again, and the spectator buttons from their commands while they spectate, on top of the block on everyone. Zero releases the player.

func (Player) Buttons

func (p Player) Buttons() (uint64, error)

Buttons returns the buttons a player holds, as Buttons bits, while the player is alive or dead.

func (Player) BuyItem added in v0.1.76

func (p Player) BuyItem(item string, imbue, source *uint32) error

BuyItem buys an item for the hero as the shop does, under the shop's own rules and for the souls it charges, or fails and charges nothing when the shop refuses, as away from the shop or without the souls. With imbue, an imbuing item strengthens whatever ability the hero holds in that slot, 0 to 3, including one ReplaceAbility put there, which the game's own buydependentitem refuses; the call fails, buying nothing, when the ability does not accept it.

func (Player) CenterText

func (p Player) CenterText(text string) error

CenterText shows text in the middle of the player's screen until it is replaced. Empty text clears it.

func (Player) ChangeTeam added in v0.1.39

func (p Player) ChangeTeam(team int32) error

ChangeTeam moves the player's hero, living or dead, to team 2 or 3 where it stands, for a human or a bot alike. The hero keeps its hero, abilities, items and health, and the player keeps their connection; a dead hero respawns on its new team, on its timer or through Respawn. A living hero moved inside the other team's base dies to the base's defense. A player without a hero joins a team through SelectHero instead.

func (Player) Chat

func (p Player) Chat(text string) error

Chat sends a server chat line to the player.

func (Player) ClearCamera added in v0.1.8

func (p Player) ClearCamera(context *string) error

ClearCamera removes a context's camera operations from the player's camera, or every operation, and the camera returns to its usual place.

func (Player) ClearItems

func (p Player) ClearItems() error

ClearItems removes every item the player's hero owns.

func (Player) ClearScreenEffect

func (p Player) ClearScreenEffect(effect ScreenEffect) error

ClearScreenEffect ends every running instance of effect on the player's view.

func (Player) Connection added in v0.1.82

func (p Player) Connection() *Connection

Connection returns the player's connection: their name, Steam ID, whether they are a bot and whether they finished joining. It returns nil when nobody holds the slot.

func (Player) Drive added in v0.1.8

func (p Player) Drive(command *DriveCommand) error

Drive gives a bot the controls a player has, where it looks, the movement axes and the buttons, as its input on every tick until the next Drive replaces it. The game runs that input as a player's own, so the hero accelerates, turns, jumps, dashes, slides and casts with its own movement and animation; the bot's own brain no longer moves it. Presses count once. A Drive without a command returns the bot to its brain.

func (Player) FreeCamera added in v0.1.8

func (p Player) FreeCamera(position *Vector, facing *Angles) error

FreeCamera lets the player fly their camera from a position, with the movement keys and the mouse, as the game's roaming spectator camera does. A player with a living hero leaves it where it stands, keeping its level, souls and items, until Unwatch returns them to it.

func (Player) Freeze

func (p Player) Freeze(frozen *bool) error

Freeze holds the player's hero in place, without input or damage, until it is released. Stopping the mod releases it.

func (Player) GetRecord added in v0.1.86

func (p Player) GetRecord(recordType string, done func(*PersistRecord, error))

GetRecord reads the player's record of recordType over the host's persist service; done runs in a later frame with the record, empty for one never written, or the error that refused the read. A Player kept after its player left is refused at once with ErrPlayerLeft.

func (Player) GiveItem

func (p Player) GiveItem(item string, imbue *uint32) error

GiveItem gives the hero an item, enabled and free. A hero that owns it keeps its one copy. With imbue, an imbuing item strengthens the hero's ability in that slot, 0 to 3, as the shop asks when one is bought; the call fails, granting nothing, when the ability does not accept it.

func (Player) GiveModifier

func (p Player) GiveModifier(modifier string, seconds float32) error

GiveModifier gives the hero a modifier for seconds. An ability's modifier, named "<ability>/<modifier>", comes as if the hero's own ability applied it; a hero without that ability, or a modifier named on its own, such as Street Brawl's zipline boost modifier_street_brawl_round_start_zipline_boost, applies it with the hero's first ability. The game may end it sooner, as invisibility ends on a shot.

func (Player) HandedOff added in v0.1.51

func (p Player) HandedOff() (string, error)

HandedOff returns the player's handoff state, or empty.

func (Player) Handoff added in v0.1.51

func (p Player) Handoff(text string) error

Handoff replaces the handoff state for the player, such as the panels their HUD shows. It lasts only through a reload of the mod in the same game, in memory, as the game's does, and ends early when the player leaves; only that player reads it back, and a bot keeps none.

func (Player) Heal

func (p Player) Heal(amount int32) error

Heal restores health to the player's hero, up to its maximum.

func (Player) HoldModifier

func (p Player) HoldModifier(modifier string, active *bool) error

HoldModifier keeps a modifier, named as GiveModifier names it, on the hero with no expiry, giving it back whenever the game removes it or the hero returns. Every hero that gains the modifier from the same ability keeps it until the hold ends. Releasing leaves the hero's current modifier until it dies; the mod stopping removes it.

func (Player) Kill

func (p Player) Kill() error

Kill kills a player's hero, crediting no one.

func (Player) Move added in v0.1.1

func (p Player) Move(position *Vector, facing *Angles, velocity *Vector) error

Move carries the player's hero to a position as continuous motion, as a recording plays back. Unlike Teleport it keeps the hero's animated model drawn when repeated every tick, and leaves the camera alone.

func (Player) MoveCamera added in v0.1.8

func (p Player) MoveCamera(options *CameraOptions) error

MoveCamera adds one operation to the player's camera, as the game's abilities pull it back, widen its view or swing it to a point. Operations run alongside the game's own until they end or ClearCamera removes them.

func (Player) MoveEntityCamera

func (p Player) MoveEntityCamera(position *Vector, facing *Angles, fov *float32) error

MoveEntityCamera changes the place, facing or field of view of the player's open entity camera, and the player receives what is visible from its new place. It fails when none is open.

func (Player) OpenEntityCamera

func (p Player) OpenEntityCamera(position *Vector, facing *Angles, fov, zNear, zFar *float32, blend, keepControls *bool) (uint32, error)

OpenEntityCamera shows the player the world from a camera entity at a pose, with full pitch and roll, while their living hero stays where it stands. The player receives what is visible from the camera, not from the hero. Over an open entity camera it moves that camera; from Watch or FreeCamera it returns the player to their hero first. It returns the camera entity, which only that player receives. The client blends into the camera's angles for about six seconds after it opens, wrapping each angle, so a camera that rolls or pitches past 180 degrees in that time swings the wrong way. Unwatch closes it, as does removing the entity; stopping the mod closes every one.

func (Player) Pawn

func (p Player) Pawn() (*Pawn, error)

Pawn returns the player's pawn this frame: the hero, or the game's placeholder with hero 0 that a player joining on a team holds until a hero is selected. It returns nothing for a spectator and before the game has made a pawn. The pawn's entity changes whenever the game replaces it.

func (Player) PreferredHeroLater

func (p Player) PreferredHeroLater(timeout time.Duration, done func(hero uint32, ok bool))

PreferredHeroLater finds the hero the player last chose in their hideout, as the identifier SelectHero takes, and returns at once. done runs once in a later frame with the hero, or with ok false when the client gave no hero within timeout, so the mod leaves the player to choose. Call it from OnPlayerReturn as well as OnPlayerJoin, because a player who reconnects returns through OnPlayerReturn. A timeout of zero or less waits 10 seconds.

func (Player) Press

func (p Player) Press(buttons uint64) error

Press presses buttons at the player's next input, even through a block. A bot presses them as a player would.

func (Player) QueryConvarLater

func (p Player) QueryConvarLater(name string, timeout time.Duration, done func(value string, miss ConvarMiss))

QueryConvarLater asks the player's client for the value of its console variable name and returns at once. done runs once in a later frame, with the value and ConvarMissNone, or with the miss that says why no value came. A zero timeout waits the host's longest, 30 seconds.

func (Player) RefreshAbility

func (p Player) RefreshAbility(ability string) error

RefreshAbility ends the cooldown of the hero's ability named ability, such as citadel_ability_melee_parry.

func (Player) RemoveBot

func (p Player) RemoveBot() error

RemoveBot removes a bot the mod added.

func (Player) ReplaceAbility

func (p Player) ReplaceAbility(index uint32, ability string, keep *bool) error

ReplaceAbility puts the ability named ability, untrained unless keep carries the old one's progress, in the hero's ability slot index, as Ability.slot, removing the ability there. The game trains and upgrades an ability in slots 0 to 3 by its slot, so a player holds the upgrade key and presses the slot's ability key to spend ability points on it, and training an untrained one costs an ability unlock. A hero change or ResetHero gives the hero its own abilities again, so a mod that keeps a swap replaces again then. An ability from another hero loads its models and particles only if Precache named that hero and those resources before the world loaded; otherwise its first effect stalls the game on a blocking load and the game reports an assertion.

func (Player) ResetHero added in v0.1.3

func (p Player) ResetHero(souls int32) error

ResetHero rebuilds the player's hero as it first spawned, without items, ability upgrades, levels or ability points, holding souls.

func (Player) Respawn

func (p Player) Respawn() error

Respawn revives the player's dead hero. A pawn with hero 0 has no hero to revive; the call fails until SelectHero gives it one.

func (Player) RestoreHero

func (p Player) RestoreHero(target *HeroTarget) error

RestoreHero gives the player's live hero target over the next few seconds: the build first, then health, stamina and pose once it settles, then charges and cooldowns. A Restored event reports when the result has held for a second, or why it could not. A new call replaces the running one. A pawn with hero 0 has no hero to restore; the call fails until SelectHero gives it one.

func (Player) RestoreStamina

func (p Player) RestoreStamina() error

RestoreStamina refills the player's stamina.

func (Player) ScreenEffect

func (p Player) ScreenEffect(effect ScreenEffect, timing *ScreenTiming) error

ScreenEffect plays a full-screen effect on the player's view. Effects of one kind stack. The player's hero must be alive.

func (Player) Seat added in v0.1.82

func (p Player) Seat(seat Seating) bool

Seat gives the player a hero on a team, skipping the game's team and hero screens. Call it as the player joins, in an OnPlayerJoin handler.

The hero spawns on a later frame and triggers OnSpawn. The library retries the assignment until the player is seated, and reapplies it if the player changes hero, so a call made before the game is ready is not lost. Calling Seat again replaces the previous assignment, and the assignment clears when the player leaves. Returns false if the player slot is empty.

func (Player) SelectHero

func (p Player) SelectHero(hero any, team int32) (uint32, error)

SelectHero gives the player a hero on a team, 2 or 3, and returns the hero's identifier as Pawn.hero reports it. The hero appears on a later frame. A hero the player picked through the game's Change Hero wins: the game removes the old hero before it spawns the pick, and a call in that gap, up to 5 seconds, fails and leaves the pick to land.

func (Player) SetAbility

func (p Player) SetAbility(options *AbilityOptions) error

SetAbility changes the upgrades, charges or timers of one of the hero's abilities. An omitted option stays as it is.

func (Player) SetSetting

func (p Player) SetSetting(key, value string) error

SetSetting changes the player's value of a setting the manifest declares. The value follows the player to later games and other mods' servers of the same mod; a bot keeps the defaults.

func (Player) SetStamina added in v0.1.3

func (p Player) SetStamina(stamina float32) error

SetStamina sets the player's stamina, as Pawn.stamina reads it. The game regenerates it as usual afterwards.

func (Player) SetVelocity

func (p Player) SetVelocity(velocity *Vector) error

SetVelocity replaces the motion of a player's hero without moving it.

func (Player) Setting

func (p Player) Setting(key string) (string, error)

Setting returns the player's value of a setting the manifest declares: the value they chose, or the setting's default. A bot has the defaults.

func (Player) SettingNumber

func (p Player) SettingNumber(key string) (float64, error)

SettingNumber returns the player's value of a number setting the manifest declares.

func (Player) SettingOn

func (p Player) SettingOn(key string) (bool, error)

SettingOn returns the player's value of a switch setting the manifest declares.

func (Player) SilenceVoice added in v0.1.77

func (p Player) SilenceVoice(concepts []string) error

SilenceVoice keeps the player's hero from speaking the named voice concepts until called again, on top of those silenced for everyone.

func (Player) Slot

func (p Player) Slot() int32

Slot returns the server slot the player holds.

func (Player) Sound

func (p Player) Sound(sound string, options *SoundOptions) (uint32, error)

Sound plays a game sound event, such as Damage.Send.Crit, on the player's hero, and returns its ID. It follows the hero as it moves. Volume and pitch scale the sound, and listeners limit who hears it.

func (Player) Spectate added in v0.1.1

func (p Player) Spectate() error

Spectate moves the player to the spectators, without a hero. The player watches until a hero selection seats them again.

func (Player) StartConvarQuery

func (p Player) StartConvarQuery(name string, timeoutMilliseconds uint32) (uint64, error)

StartConvarQuery asks the player's client for the value of one of its console variables and returns at once with a number; the answer arrives in a later frame as a ConvarAnswered event carrying that number. Every query ends once: with the value, the client's refusal, a timeout or the player's disconnect. Only a fully connected human can be asked. The host waits at most 30 seconds, or the query's shorter timeout, and drops the mod's waiting queries when the mod stops or reloads.

func (Player) StartingSouls

func (p Player) StartingSouls(souls int32) error

StartingSouls sets the souls the player's hero spawns with.

func (Player) Steer added in v0.1.1

func (p Player) Steer(steering *Steering) error

Steer replays a recorded movement command on the player's hero, usually a bot: the game runs the command's buttons and axes, so the hero crouches, slides, jumps and mantles with its own animation, and the step then ends on the recorded pose. The steering stays until the next Steer replaces it, its presses and its pose counting once: on the ticks between, the game's own movement carries the held command on from the pose. A Steer without one releases the hero.

func (Player) StepMovement

func (p Player) StepMovement(state []byte) error

StepMovement hands the player's hero to the step module the manifest's MODEL_STEP movement names, from its next command on, starting from a state block, or with no state returns it to the game's own movement. A hero the module already moves restarts from the new block. When the module traps, runs past its fuel or returns a motion the host refuses, the game's own movement takes the hero back, and StepState says why.

func (Player) StepState

func (p Player) StepState() (any, error)

StepState returns where the hero's step movement stands: the last command the module stepped and the state block after it, or why the module failed. It returns nothing while the game's own movement moves the hero.

func (Player) Teleport

func (p Player) Teleport(position *Vector, facing *Angles, velocity *Vector) error

Teleport moves the player's hero and turns it and the camera. With a velocity it also sets the hero's motion, as a launch, and the camera follows the hero.

func (Player) TrainAbility added in v0.1.76

func (p Player) TrainAbility(slot uint32) error

TrainAbility trains or upgrades whatever ability the hero holds in a slot, 0 to 3, as the player holding the upgrade key and pressing the slot's ability key does: an untrained ability trains for an ability unlock, and a trained one buys its next tier for ability points. It works on an ability ReplaceAbility put there, which the game's own commands for a slot do not reach. When the game refuses, as without an unlock or the points, the call fails and nothing is spent.

func (Player) Unwatch added in v0.1.3

func (p Player) Unwatch() error

Unwatch returns a player watching or flying the free camera from their hero back to it. Stopping the mod returns every such player.

func (Player) UpdateRecord added in v0.1.86

func (p Player) UpdateRecord(recordType string, ops []*PersistOp, key string, done func(record *PersistRecord, repeated bool, err error))

UpdateRecord changes the player's record of recordType by ops, which the host applies all or none, so two servers that update one record at once both land. With a key, such as a round's, an update the host already took is left out and done hears repeated. An update with a PersistAdd needs a key, since a resend without one would count twice; the host refuses it otherwise. done runs in a later frame and may be nil. A Player kept after its player left is refused at once with ErrPlayerLeft, changing nothing.

func (Player) Watch added in v0.1.2

func (p Player) Watch(target uint32, chase *bool) error

Watch points the player's camera at a hero, through the hero's own view or chasing it, as the game's spectator camera follows it. The player's own hero must be dead or removed: while it lives, the client keeps drawing that hero's camera even when Watch succeeds. Use FreeCamera to position the camera while keeping a living hero.

func (Player) WatchControllers

func (p Player) WatchControllers(watch bool, binding *CommandBinding) error

WatchControllers adds a player's controllers to the controller lists of each Frame event, or removes them. The player's client reads the devices only while some mod watches them, and until it answers the player is listed with no stream. A watch may carry a command binding, which the client applies to the player's device for its host application to carry in the player's commands.

func (Player) WatchMovement

func (p Player) WatchMovement(watch bool) error

WatchMovement adds a player's hero to the movement samples of each Frame event on a new tick, or removes it.

func (Player) Zipline added in v0.1.67

func (p Player) Zipline(lane Lane) error

Zipline puts the player's hero on a lane's zipline near the hero, riding it as from the zipline key, with the zipline's intro. It never picks another lane: it fails when the lane has no zipline the hero's team rides on this map, or the hero has no zipline ability. For Street Brawl's fast ride, give the hero modifier_street_brawl_round_start_zipline_boost too.

type PlayerAwayEvent added in v0.1.101

type PlayerAwayEvent = playerspb.PlayerAwayEvent

PlayerAwayEvent reports a joined player whose client disconnected while the server holds their seat. Their controller and hero stay in the game, and the player may return to them.

type PlayerControllers

type PlayerControllers = controllerspb.PlayerControllers

PlayerControllers is one watched player's controllers in a frame.

type PlayerJoinedEvent added in v0.1.72

type PlayerJoinedEvent = playerspb.PlayerJoinedEvent

PlayerJoinedEvent reports a player who joined the mod: a human who finished joining the server, a bot once added, or a player already in the game when the mod starts or begins to serve them.

type PlayerLeftEvent added in v0.1.72

type PlayerLeftEvent = playerspb.PlayerLeftEvent

PlayerLeftEvent reports a player leaving the mod, once for each PlayerJoinedEvent.

type PlayerPawn added in v0.1.100

type PlayerPawn = playerspb.PlayerPawn

PlayerPawn is one player's pawn.

func Pawns added in v0.1.100

func Pawns() ([]*PlayerPawn, error)

Pawns returns every player's pawn this frame in one reply, in slot order, each as Pawn returns it: a mode that reads every hero each frame makes one call instead of one per player. A slot Pawn answers nothing for is left out.

type PlayerReturnedEvent added in v0.1.101

type PlayerReturnedEvent = playerspb.PlayerReturnedEvent

PlayerReturnedEvent reports an away player who reconnected to their seat and finished joining again. The seat, its generation and its hero are the ones they left.

type PlayerScore

type PlayerScore = playerspb.PlayerScore

PlayerScore is one player's scoreboard counters since the match began, as the game counts them.

type PlayersChangedEvent added in v0.1.4

type PlayersChangedEvent = playerspb.PlayersChangedEvent

PlayersChangedEvent holds every player slot with a seat, connected or away, as Players lists them.

type PrecacheOptions

type PrecacheOptions = wasmpb.PrecacheOptions

PrecacheOptions names what the next world loads ahead of use.

type ProjectileOptions

type ProjectileOptions = combatpb.ProjectileOptions

ProjectileOptions selects the projectiles a mod watches.

type RangeEvent

type RangeEvent = uipb.RangeEvent

RangeEvent reports the player's hold on one handle of a range.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry owns ordered callbacks and named command and service handlers. Its zero value accepts registrations. Host entries and registrations run on the same serial frame thread; a Registry does not synchronize callers. Registration during delivery preserves Go range semantics: each range uses its initial length. Deferred chat and UI delivery reads the list at execution.

func (*Registry) AbilityCast

func (h *Registry) AbilityCast(event *AbilityCastEvent) error

AbilityCast runs the cast handlers.

func (*Registry) Chat

func (h *Registry) Chat(event *ChatEvent) error

Chat runs the chat handlers with the next frame, since the line arrives under the same CPU budget as a command.

func (*Registry) Command

func (h *Registry) Command(event *CommandEvent) (*CommandResult, error)

Command runs the handler registered for the command's name and claims the command when one exists.

func (*Registry) Damage

func (h *Registry) Damage(event *DamageEvent) (*DamageResult, error)

Damage chains the hit's amount through the damage handlers, stopping at the first that blocks it.

func (*Registry) Damaged

func (h *Registry) Damaged(event *DamagedEvent) error

Damaged runs the damaged handlers.

func (*Registry) Frame

func (h *Registry) Frame(event *FrameEvent) error

Frame runs frame handlers in registration order.

func (*Registry) Healed

func (h *Registry) Healed(event *HealEvent) error

Healed runs the heal handlers.

func (*Registry) Impact

func (h *Registry) Impact(event *ImpactEvent) error

Impact runs the impact handlers.

func (*Registry) Input

func (h *Registry) Input(event *InputEvent) error

Input runs the input handlers.

func (*Registry) Killed

func (h *Registry) Killed(event *KillEvent) error

Killed runs the kill handlers.

func (*Registry) Landed

func (h *Registry) Landed(event *LandedEvent) error

Landed runs the landing handlers.

func (*Registry) Launch

func (h *Registry) Launch(event *LaunchEvent) error

Launch runs the launch handlers.

func (*Registry) LevelChanged

func (h *Registry) LevelChanged(event *LevelEvent) error

LevelChanged runs the level handlers.

func (*Registry) Melee

func (h *Registry) Melee(event *MeleeEvent) error

Melee runs the melee handlers.

func (*Registry) ModifierFired

func (h *Registry) ModifierFired(event *ModifierFiredEvent) error

ModifierFired runs the handlers of the event's name.

func (*Registry) NpcsRestored

func (h *Registry) NpcsRestored(event *NpcsRestoredEvent) error

NpcsRestored runs the NPC restored handlers.

func (*Registry) OnAbilityCast

func (r *Registry) OnAbilityCast(handler func(cast *AbilityCastEvent))

OnAbilityCast calls handler after each ability the game executes, before the next frame: a hero's abilities and the items a player activates, at the moment the cast takes effect.

func (*Registry) OnChat

func (r *Registry) OnChat(handler func(line *ChatEvent))

OnChat calls handler with each chat line a player writes, commands included, on the next server frame.

func (*Registry) OnDamage

func (r *Registry) OnDamage(handler func(hit *DamageEvent) *DamageResult)

OnDamage calls handler before each hit lands, so it can block the hit or change its damage by returning a result; nil lets the hit through. Later handlers see the earlier ones' amount.

func (*Registry) OnDamaged

func (r *Registry) OnDamaged(handler func(hit *DamagedEvent))

OnDamaged calls handler on the frame after each hit lands.

func (*Registry) OnFrame

func (r *Registry) OnFrame(handler func(f *FrameEvent))

OnFrame calls handler once per server frame.

func (*Registry) OnHeal

func (r *Registry) OnHeal(handler func(heal *HealEvent))

OnHeal calls handler after each heal, before the next frame: health a hero or unit regained at once from an ability, an item or lifesteal. Regeneration calls nothing, including what abilities such as Siphon Life restore as regeneration, and neither do the mod's own heal and a heal at full health. The heal names the entity healed, the healer and ability when the game names them, and the player of each: a slot of -1 is a unit's, or no one's.

func (*Registry) OnImpact

func (r *Registry) OnImpact(handler func(impact *ImpactEvent))

OnImpact calls handler when a watched projectile strikes something, inside the game's impact: its calls apply before the game continues.

func (*Registry) OnInput

func (r *Registry) OnInput(handler func(p Player, pressed, released uint64))

OnInput calls handler with the watched buttons a player pressed and released, as Button bits, before the next frame. A button is held from its press until its release.

func (*Registry) OnKill

func (r *Registry) OnKill(handler func(kill *KillEvent))

OnKill calls handler after each hit that kills a hero or a unit, before the next frame. The kill names both entities and the player of each: a slot of -1 is a unit's, or a hazard's for the attacker.

func (*Registry) OnLanded

func (r *Registry) OnLanded(handler func(landing *LandedEvent))

OnLanded calls handler when a hero lands under the manifest's QuakeWorld movement, before the next frame.

func (*Registry) OnLaunch

func (r *Registry) OnLaunch(handler func(projectile *LaunchEvent))

OnLaunch calls handler with each watched projectile's first frame, before the next frame. WatchProjectiles names the projectiles.

func (*Registry) OnLevelChange

func (r *Registry) OnLevelChange(handler func(change *LevelEvent))

OnLevelChange calls handler as each hero reaches a new level, before the next frame.

func (*Registry) OnMelee

func (r *Registry) OnMelee(handler func(swing *MeleeEvent))

OnMelee calls handler after each melee swing, before the next frame, with whether it was heavy and the entities it struck, none for a miss.

func (*Registry) OnModifierEvent

func (r *Registry) OnModifierEvent(name string, handler func(event *ModifierFiredEvent))

OnModifierEvent calls handler each time the game fires the modifier event with this EModifierEvent name, such as ABILITY_CAST_STARTED, PARRY_SUCCESS or PLAYER_RESPAWNED, before the next frame. Register before the mod starts. A name the running game lacks is logged once and never fires.

func (*Registry) OnNpcsRestored

func (r *Registry) OnNpcsRestored(handler func(err error))

OnNpcsRestored calls handler when RestoreNpcs ends: err is nil once the map holds every target, or says why it does not.

func (*Registry) OnParry

func (r *Registry) OnParry(handler func(parry *ParryEvent))

OnParry calls handler after each parry that catches a melee swing, before the next frame, naming the hero that parried and the attacker it caught.

func (*Registry) OnPing

func (r *Registry) OnPing(handler func(ping *PingEvent) *PingResult)

OnPing calls handler with each ping a player sends, from the comms wheel, a quick ping key, the map or an ability, before anyone sees it, so it can block the ping or mute its voice line. A blocked ping reaches nobody, the sender included: no marker, sound, voice line or chat line. The players a handler lists in MuteVoice, by slot, get the ping without its voice line. The handler runs inside the server's ping, so it decides at once and defers other work to a frame.

func (*Registry) OnPlayerAway

func (r *Registry) OnPlayerAway(handler func(away *PlayerAwayEvent))

OnPlayerAway calls handler once each time a joined human's client disconnects while the server holds their seat. They have not left: their hero and controller stay in the game, and OnPlayerReturn follows if they come back, so keep their seat as it stands rather than clear it.

func (*Registry) OnPlayerJoin

func (r *Registry) OnPlayerJoin(handler func(joined *PlayerJoinedEvent))

OnPlayerJoin calls handler once for each player the mod serves when they are ready: a human who finished joining, a bot once added, and at start each player already in the game.

func (*Registry) OnPlayerLeave

func (r *Registry) OnPlayerLeave(handler func(left *PlayerLeftEvent))

OnPlayerLeave calls handler once for each joined player who leaves the mod, with the reason the server dropped them when it gave one. A seat ends, and its player leaves, when a bot is removed, a human is kicked or released by the program that runs the host, or a human stays away past the game's limit; a human who only disconnects is away first. The slot and hero still read during the call, and afterwards Modlock kills the hero, keeps it down and takes the controller off its team, so the mod need not clear them. A player the mod stops serving leaves too, with Disconnected false.

func (*Registry) OnPlayerReturn

func (r *Registry) OnPlayerReturn(handler func(returned *PlayerReturnedEvent))

OnPlayerReturn calls handler once each time an away player reconnects to their seat and finishes joining again, with the same Player, generation and hero they left.

func (*Registry) OnPlayers

func (r *Registry) OnPlayers(handler func(players []*Connection))

OnPlayers calls handler with each player list the host reports, before the event it arrives with. A slot whose generation changed holds a new connection.

func (*Registry) OnRestored

func (r *Registry) OnRestored(handler func(p Player, err error))

OnRestored calls handler when a player's Player.RestoreHero ends: err is nil once the target held for a second, or says why it did not.

func (*Registry) OnSettingChanged

func (r *Registry) OnSettingChanged(handler func(p Player, key, value string))

OnSettingChanged calls handler when a player's setting changes outside the mod, such as on the player's profile. The mod's own Player.SetSetting calls do not reach it.

func (*Registry) OnSpawn

func (r *Registry) OnSpawn(handler func(Player, *Pawn))

OnSpawn calls handler when the adapter reports a living hero entering play.

func (*Registry) OnStart

func (r *Registry) OnStart(handler func(args []string))

OnStart calls handler once when the server starts the mod, with the words after -- on the modlock dev or play command line.

func (*Registry) OnUiAction

func (r *Registry) OnUiAction(handler func(event *UiActionEvent))

OnUiAction calls handler with each phase of a game action the root of a player's interface follows, with the next server frame. Package ui registers it to run the followers' handlers.

func (*Registry) OnUiDocument

func (r *Registry) OnUiDocument(handler func(event *UiDocumentEvent))

OnUiDocument calls handler with the end of each submission from a player's document input, with the next server frame: the whole document, or why it did not arrive.

func (*Registry) OnUiInput

func (r *Registry) OnUiInput(handler func(event *UiInputEvent))

OnUiInput calls handler with each change a player makes to an input in the mod's interface, with the next server frame. Package ui registers it to run the inputs' handlers.

func (*Registry) OnUiOverlay

func (r *Registry) OnUiOverlay(handler func(event *UiOverlayEvent))

OnUiOverlay calls handler with each stock overlay that takes or gives back the input of a player whose interface root follows overlays, with the next server frame. Package ui registers it to run the followers' handlers.

func (*Registry) OnUiPlacement

func (r *Registry) OnUiPlacement(handler func(event *UiPlacementEvent))

OnUiPlacement calls handler with each placement of the interface of a player whose interface root follows placement, with the next server frame. Package ui registers it to run the followers' handlers.

func (*Registry) OnUiPress

func (r *Registry) OnUiPress(handler func(event *UiPressEvent))

OnUiPress calls handler with each press a player makes in the mod's interface, with the next server frame: a button's, or a layout's with the action its bound panel or its script names. Package ui registers it to run the buttons' and the bindings' handlers.

func (*Registry) OnUiWindow

func (r *Registry) OnUiWindow(handler func(event *UiWindowEvent))

OnUiWindow calls handler with each run of a list's rows a player's screen asks the mod to show, with the next server frame. Package ui registers it to draw the window it asks for.

func (*Registry) OnWorld

func (r *Registry) OnWorld(handler func(mapName string))

OnWorld calls handler with the map's name each time a world loads, and at start when one already has. Objects and bots from an earlier world are gone by then.

func (*Registry) Parried

func (h *Registry) Parried(event *ParryEvent) error

Parried runs the parry handlers.

func (*Registry) Ping

func (h *Registry) Ping(event *PingEvent) (*PingResult, error)

Ping offers the ping to each ping handler, stopping at the first that blocks it; the others add the players they mute its voice line for.

func (*Registry) PlayerAway

func (h *Registry) PlayerAway(event *PlayerAwayEvent) error

PlayerAway runs the away handlers.

func (*Registry) PlayerJoined

func (h *Registry) PlayerJoined(event *PlayerJoinedEvent) error

PlayerJoined runs the join handlers.

func (*Registry) PlayerLeft

func (h *Registry) PlayerLeft(event *PlayerLeftEvent) error

PlayerLeft runs the leave handlers at once, so the leaving player's hero still reads.

func (*Registry) PlayerReturned

func (h *Registry) PlayerReturned(event *PlayerReturnedEvent) error

PlayerReturned runs the return handlers.

func (*Registry) PlayersChanged

func (h *Registry) PlayersChanged(players []*Connection) error

PlayersChanged notifies roster watchers after the adapter publishes the list.

func (*Registry) RegisterCommand

func (r *Registry) RegisterCommand(name string, handler func(p Player, args string))

RegisterCommand calls handler when a player types /name in chat. The handler runs with the next server frame, before the frame handlers, and receives the text after the name, trimmed of surrounding spaces. Registering a name again replaces its handler.

func (*Registry) RegisterService

func (r *Registry) RegisterService(service string, handler Service)

RegisterService answers the host's calls to service with handler. Registering a service again replaces its handler.

func (*Registry) Restored

func (h *Registry) Restored(event *RestoredEvent) error

Restored runs the restored handlers.

func (*Registry) Serve

func (h *Registry) Serve(event *ServiceCall) (*ServiceReply, error)

Serve runs the handler of the called service.

func (*Registry) SettingChanged

func (h *Registry) SettingChanged(event *SettingChangedEvent) error

SettingChanged runs the setting handlers.

func (*Registry) Spawn

func (r *Registry) Spawn(player Player, pawn *Pawn)

Spawn delivers a spawn accepted by the adapter's duplicate filter.

func (*Registry) Start

func (h *Registry) Start(event *StartEvent) (*StartResult, error)

Start runs the start handlers and asks for the events the mod handles.

func (*Registry) UiAction

func (h *Registry) UiAction(event *UiActionEvent) error

UiAction runs the game action handlers with the next frame, as a press does.

func (*Registry) UiDocument

func (h *Registry) UiDocument(event *UiDocumentEvent) error

UiDocument runs the document handlers with the next frame, as a change does.

func (*Registry) UiInput

func (h *Registry) UiInput(event *UiInputEvent) error

UiInput runs the input handlers with the next frame, as a press does.

func (*Registry) UiOverlay

func (h *Registry) UiOverlay(event *UiOverlayEvent) error

UiOverlay runs the overlay handlers with the next frame, as a press does.

func (*Registry) UiPlacement

func (h *Registry) UiPlacement(event *UiPlacementEvent) error

UiPlacement runs the placement handlers with the next frame, as a press does.

func (*Registry) UiPress

func (h *Registry) UiPress(event *UiPressEvent) error

UiPress runs the press handlers with the next frame, since a press arrives under the same CPU budget as a command.

func (*Registry) UiWindow

func (h *Registry) UiWindow(event *UiWindowEvent) error

UiWindow runs the window handlers with the next frame, as a press does.

func (*Registry) World

func (h *Registry) World(event *WorldEvent) error

World runs the world handlers.

type RestoredEvent

type RestoredEvent = playerspb.RestoredEvent

RestoredEvent reports how a RestoreHero ended.

type RiftState

type RiftState = wasmpb.RiftState

RiftState is the Rift objective's timing as the game holds it. Times are game times in seconds, or zero when unset.

func Rift

func Rift() (*RiftState, error)

Rift reads the Rift objective's state.

type ScoreConnection added in v0.1.88

type ScoreConnection = scorespb.ScoreConnection

ScoreConnection is the connection enrolled by BindScorePlayer.

func BindScorePlayer added in v0.1.88

func BindScorePlayer(player *Connection) (*ScoreConnection, error)

BindScorePlayer enrolls a live connection for reporting after it leaves.

type ScoreReport added in v0.1.73

type ScoreReport = scorespb.ScoreReport

ScoreReport reports one enrolled player's result to a board.

type ScreenEffect

type ScreenEffect = effectspb.ScreenEffect

ScreenEffect is a stock full-screen view effect.

type ScreenTiming

type ScreenTiming = effectspb.ScreenTiming

ScreenTiming is a screen effect's timing in seconds.

type Seating added in v0.1.79

type Seating struct {
	// Hero is the hero's name as players know it or as the game does, such as
	// "haze" or "hero_haze", its id as an int or uint32, or AnyHero for the
	// hero the player has or else a random one. Nil is AnyHero.
	Hero any
	// Team is the team, 2 or 3. Zero keeps the player's hero's team or joins
	// the side with fewer heroes.
	Team int32
}

Seating is the hero and team Seat gives one player.

type Service

type Service func(method string, payload []byte) ([]byte, error)

Service answers calls to one service the mod serves: the method's name and payload in, the answer out.

type ServiceCall

type ServiceCall = wasmpb.ServiceCall

ServiceCall calls one method of a service outside Modlock. A host that embeds Modlock provides services of its own, such as a game mode's match, and a mod may serve one to the host. The service and its caller agree on the payload's encoding.

type ServiceError added in v0.1.86

type ServiceError struct {
	// Failure classifies the reason the call ended.
	Failure ServiceFailure
	// Message describes that reason.
	Message string
}

ServiceError ends a started service call without an answer: Failure says why and Message describes it.

func (*ServiceError) Error added in v0.1.86

func (e *ServiceError) Error() string

Error returns the failure's description.

type ServiceFailure added in v0.1.86

type ServiceFailure = wasmpb.ServiceFailure

ServiceFailure says why a service call ended without an answer.

type ServiceRepliedEvent added in v0.1.86

type ServiceRepliedEvent = wasmpb.ServiceRepliedEvent

ServiceRepliedEvent ends one started service call.

type ServiceReply

type ServiceReply = wasmpb.ServiceReply

ServiceReply is a service's answer.

type SettingChangedEvent

type SettingChangedEvent = settingspb.SettingChangedEvent

SettingChangedEvent is one player's new value of one setting.

type SoundOptions added in v0.1.77

type SoundOptions = effectspb.SoundOptions

SoundOptions shape one sound; the zero value plays it to every player as the game made it.

type Spot

type Spot struct {
	Map string
	// Objects are the placed objects in placement order.
	Objects []*SpotObject
}

Spot is a base map and the objects players placed on it. Nothing is compiled: loading a spot spawns each object as a solid model on the map the world already runs.

func DecodeSpot

func DecodeSpot(data []byte) (*Spot, error)

DecodeSpot reads a spot document.

type SpotObject

type SpotObject struct {
	// Model is the model's path, which the mode precached.
	Model    string
	Position *Vector
	Facing   *Angles
	// Scale multiplies the model's size.
	Scale float32
	// Bounce launches a hero who stands on the object upward at this speed,
	// in units per second; zero makes an ordinary object.
	Bounce float32
	// PlacedBy is the Steam ID of the player who placed the object, or zero.
	PlacedBy uint64
}

SpotObject is one solid object placed in a spot.

type StartEvent

type StartEvent = wasmpb.StartEvent

StartEvent describes the server the mod starts in.

type StartResult

type StartResult = wasmpb.StartResult

StartResult declares which events the mod consumes.

type Steering added in v0.1.1

type Steering = movementpb.Steering

Steering is one recorded movement command and the pose its step ends on.

type StepFailed

type StepFailed = movementpb.StepFailed

StepFailed is a hero the step module failed for.

type StepRunning

type StepRunning = movementpb.StepRunning

StepRunning is a hero the step module moves.

type TextAlign added in v0.1.56

type TextAlign = objectspb.TextAlign

TextAlign places text across its position.

type TextOptions

type TextOptions = objectspb.TextOptions

TextOptions describes text that floats in the world.

type TextVerticalAlign added in v0.1.56

type TextVerticalAlign = objectspb.TextVerticalAlign

TextVerticalAlign places text up and down its position.

type ThresholdDirection

type ThresholdDirection = controllerspb.ThresholdDirection

ThresholdDirection says which side of its threshold holds an axis button.

type Timer added in v0.1.4

type Timer struct {
	// contains filtered or unexported fields
}

Timer is one scheduled callback. Time is the game's, so a paused game holds its timers. A tick is 1/64 second.

func After added in v0.1.4

func After(delay time.Duration, fn func()) *Timer

After runs fn once, delay from now.

func Every added in v0.1.4

func Every(interval time.Duration, fn func()) *Timer

Every runs fn each interval, keeping its cadence through a late frame.

func Sequence added in v0.1.4

func Sequence(fn func(run int) (wait time.Duration, again bool)) *Timer

Sequence calls fn on the next frame with the number of times it has run, starting at 1. fn returns the wait before it runs again and true, or false to end the sequence.

func (*Timer) Cancel added in v0.1.4

func (t *Timer) Cancel()

Cancel stops the timer. It does nothing once the timer is finished.

func (*Timer) Finished added in v0.1.4

func (t *Timer) Finished() bool

Finished reports whether the timer ran its last time or was cancelled.

type TimerTarget

type TimerTarget = playerspb.TimerTarget

TimerTarget sets one owned ability's or item's charges and cooldowns. Times are seconds from the moment the host writes them; an omitted start and end mean no timer.

type TraceHit

type TraceHit = combatpb.TraceHit

TraceHit is where a traced line first hit something.

func Trace

func Trace(options *TraceOptions) (*TraceHit, error)

Trace returns where a line first hits something, or nothing when it hits nothing or the world's collision is not ready.

type TraceOptions

type TraceOptions = combatpb.TraceOptions

TraceOptions describes a line to test against the world. Layers are bits of the game's collision layers: bit 0 is solid, 2 trigger, 4 player clip, 18 player and 19 NPC.

type UiActionEvent

type UiActionEvent = uipb.UiActionEvent

UiActionEvent reports one phase of a game action the mod's root follows. Each press reaches the mod once as pressed, then once as released or cancelled.

type UiDocumentEvent

type UiDocumentEvent = uipb.UiDocumentEvent

UiDocumentEvent ends one submission from a player's document input: the whole document, or why it did not arrive.

type UiDocumentEventDelivered

type UiDocumentEventDelivered = uipb.UiDocumentEvent_Delivered

UiDocumentEventDelivered sets UiDocumentEvent.Result to Delivered.

type UiDocumentEventFailed

type UiDocumentEventFailed = uipb.UiDocumentEvent_Failed

UiDocumentEventFailed sets UiDocumentEvent.Result to Failed.

type UiInputEvent added in v0.1.42

type UiInputEvent = uipb.UiInputEvent

UiInputEvent reports a change the player made to an input in their interface, with the value as the host checked it.

type UiInputEventChoice added in v0.1.42

type UiInputEventChoice = uipb.UiInputEvent_Choice

UiInputEventChoice sets UiInputEvent.Value to Choice.

type UiInputEventNumber added in v0.1.42

type UiInputEventNumber = uipb.UiInputEvent_Number

UiInputEventNumber sets UiInputEvent.Value to Number.

type UiInputEventOn added in v0.1.42

type UiInputEventOn = uipb.UiInputEvent_On

UiInputEventOn sets UiInputEvent.Value to On.

type UiInputEventRange

type UiInputEventRange = uipb.UiInputEvent_Range

UiInputEventRange sets UiInputEvent.Value to Range.

type UiInputEventRow

type UiInputEventRow = uipb.UiInputEvent_Row

UiInputEventRow sets UiInputEvent.Value to Row.

type UiInputEventText added in v0.1.42

type UiInputEventText = uipb.UiInputEvent_Text

UiInputEventText sets UiInputEvent.Value to Text.

type UiInputEventWheel added in v0.1.68

type UiInputEventWheel = uipb.UiInputEvent_Wheel

UiInputEventWheel sets UiInputEvent.Value to Wheel.

type UiOverlayEvent

type UiOverlayEvent = uipb.UiOverlayEvent

UiOverlayEvent reports the stock overlay that now holds a player's input, to a mod whose root follows overlays.

type UiPlacementEvent

type UiPlacementEvent = uipb.UiPlacementEvent

UiPlacementEvent reports where a player's screen places a mod's interface, to a mod whose root follows placement. Each event holds the whole placement.

type UiPressEvent

type UiPressEvent = uipb.UiPressEvent

UiPressEvent reports a press on a button in a player's interface, or a press a layout's script sent with an action and a payload.

type UiWindowEvent

type UiWindowEvent = uipb.UiWindowEvent

UiWindowEvent is the run of a list's rows a player's renderer asks for: those near the list's visible box, which it draws as the player scrolls. The mod answers by drawing the list with that window's rows. A list the renderer has not asked about yet shows its first 50 rows.

type Vector

type Vector = geometrypb.Vec3

Vector is a position or direction in the world, in game units.

type Want added in v0.1.79

type Want struct {
	// Hero seats the member on a hero: its name as players know it or as the
	// game does, such as "Calico" or "hero_nano", its id as an int or uint32,
	// or AnyHero for the hero they have or else a random one. Nil leaves the
	// hero free.
	Hero any
	// Team is the team, 2 or 3, to seat the member on. Without one a member
	// keeps their hero's team, or else joins the side with fewer heroes.
	Team int32
	// Respawn is how long a fallen hero waits before Cast asks for it back.
	// Zero leaves a fallen hero to the game.
	Respawn time.Duration
}

Want is what a member's hero should be; each field it leaves at its zero value is free.

type Wheel added in v0.1.68

type Wheel = uipb.Wheel

Wheel reports one wheel step over a slider, anchored to its pointer position.

type WorldEvent

type WorldEvent = wasmpb.WorldEvent

WorldEvent announces a loaded world.

type WorldObject

type WorldObject struct {
	// ID identifies the object among the mod's objects.
	ID uint32
}

WorldObject is one object the mod placed in the world.

func CreateFog

func CreateFog(options *FogOptions) (WorldObject, error)

CreateFog fills a box with tinted fog whose density fades across the box's boundary. Removing the object clears it; moving it moves the box.

func CreateModel

func CreateModel(options *ModelOptions) (WorldObject, error)

CreateModel places a model in the world, solid when the options ask. The world removes it when the world ends; stopping the mod removes it too.

func CreateParticle

func CreateParticle(options *ParticleOptions) (WorldObject, error)

CreateParticle starts a particle effect. Removing the object stops it and lets its end cap play out, unless the mod already stopped it, such as with the DestroyImmediately input; moving it moves the effect.

func CreateText

func CreateText(options *TextOptions) (WorldObject, error)

CreateText places text that floats in the world.

func (WorldObject) Entity

func (w WorldObject) Entity() (uint32, error)

Entity returns the entity handle of a model or particle, as traces report it and particle anchors take it.

func (WorldObject) Move

func (w WorldObject) Move(position *Vector, facing *Angles) error

Move places the object at position, turning it to facing. The physics step pulls a solid model to its new place over one tick, so a model moved each frame strikes physics props such as the Hideout ball with its speed instead of passing through them.

func (WorldObject) Remove

func (w WorldObject) Remove() error

Remove takes the object out of the world.

func (WorldObject) SetHidden added in v0.1.2

func (w WorldObject) SetHidden(player Player, hidden bool) error

SetHidden hides the object from one player or shows it again. Other players still see it. A player who leaves sees every object when they return.

func (WorldObject) SetText

func (w WorldObject) SetText(text string) error

SetText replaces a text object's words.

func (WorldObject) ShowOnlyTo added in v0.1.27

func (w WorldObject) ShowOnlyTo(players []int32) error

ShowOnlyTo sends the object only to the players with the listed server slots; every other client drops it, or never receives it when the call follows its creation in the same frame. With no players no client receives it. The list replaces any earlier one and follows the object when its entity changes. A player who leaves is taken off every list, so whoever joins in their slot does not receive the object. A removed object reaches no client while the engine retires its entity.

func (WorldObject) ShowToAll added in v0.1.27

func (w WorldObject) ShowToAll() error

ShowToAll sends the object to every player again, undoing ShowObjectOnlyTo.

Directories

Path Synopsis
Package console sets the server's console variables and runs its console commands, through values modlock-entitygen generates from the game's console:
Package console sets the server's console variables and runs its console commands, through values modlock-entitygen generates from the game's console:
Package entity reads and writes the fields of live entities, sends them inputs and creates them, through typed classes generated from the game's schema and entity dump by modlock-entitygen.
Package entity reads and writes the fields of live entities, sends them inputs and creates them, through typed classes generated from the game's schema and entity dump by modlock-entitygen.
Package hud draws a mod's HUD in the stock HUD's look, from the tokens in package theme.
Package hud draws a mod's HUD in the stock HUD's look, from the tokens in package theme.
Package theme holds the HUD kit's tokens, each named once: the colors, type scale and sizes the kit's components draw with, and that a mod's own panels can share.
Package theme holds the HUD kit's tokens, each named once: the colors, type scale and sizes the kit's components draw with, and that a mod's own panels can share.
Package ui draws each player's interface from a tree of elements, as struct literals:
Package ui draws each player's interface from a tree of elements, as struct literals:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL