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
- func BlockInput(buttons uint64) error
- func CallService(service, method string, payload []byte) ([]byte, error)
- func ClearMap() error
- func Command(name string, handler func(p Player, args string))
- func CreateEntity(options *EntityOptions) (uint32, error)
- func Damage(options *HitOptions) error
- func EmitSound(entity uint32, sound string) error
- func EncodeSpot(s *Spot) ([]byte, error)
- func FindEntities(className string) ([]uint32, error)
- func FireInput(entity uint32, input string, value any, activator *uint32) (bool, error)
- func HoldMatchClock(seconds *float32) error
- func HoldModifierState(entity uint32, state string, active *bool) error
- func HoldReload(held bool) error
- func Log(args ...any)
- func MatchClock() (float32, error)
- func ModifierState(entity uint32, state string) (bool, error)
- func MoveEntity(entity uint32, position *Vector, facing *Angles, velocity *Vector) error
- func OnDamage(handler func(hit *DamageEvent) *DamageResult)
- func OnDamaged(handler func(hit *DamagedEvent))
- func OnFrame(handler func(f *FrameEvent))
- func OnImpact(handler func(impact *ImpactEvent))
- func OnInput(handler func(p Player, pressed, released uint64))
- func OnLanded(handler func(landing *LandedEvent))
- func OnLaunch(handler func(projectile *LaunchEvent))
- func OnNpcsRestored(handler func(err error))
- func OnRestored(handler func(p Player, err error))
- func OnSettingChanged(handler func(p Player, key, value string))
- func OnStart(handler func(args []string))
- func OnWorld(handler func(mapName string))
- func Pause(paused bool) error
- func Precache(options *PrecacheOptions) error
- func ReadField(entity uint32, className, field string, kind FieldType) (any, error)
- func ReadFieldList(entity uint32, className, field string, kind FieldType) ([]any, error)
- func RemapInput(from, to uint64, repeat *bool) error
- func RemoveEntities(className string) (int32, error)
- func RemoveEntity(entity uint32) (bool, error)
- func RestoreNpcs(npcs []*NpcTarget) error
- func Serve(service string, handler Service)
- func ServerCommand(command string) error
- func StartRift(position *Vector) error
- func WatchInput(buttons uint64) error
- func WatchProjectiles(options *ProjectileOptions) error
- func WriteField(entity uint32, className, field string, kind FieldType, value any) error
- func WriteFieldList(entity uint32, className, field string, kind FieldType, values []any) error
- type Ability
- type AbilityOptions
- type Angles
- type BotOptions
- type BotOptionsHeroId
- type BotOptionsHeroName
- type CommandEvent
- type CommandResult
- type Connection
- type DamageEvent
- type DamageResult
- type DamagedEvent
- type EntityClassName
- type EntityOptions
- type EquipmentTarget
- type FieldType
- type FieldWrite
- type FogOptions
- type FrameEvent
- type HeroTarget
- type HitOptions
- type ImpactEvent
- type InputEvent
- type KeyValue
- type LandedEvent
- type LaunchEvent
- type LoadedSpot
- func (l *LoadedSpot) At(entity uint32) *Placed
- func (l *LoadedSpot) Bounce(movement []*MovementSample)
- func (l *LoadedSpot) Clear()
- func (l *LoadedSpot) Objects() []*Placed
- func (l *LoadedSpot) Place(object *SpotObject) (*Placed, error)
- func (l *LoadedSpot) Remove(placed *Placed)
- func (l *LoadedSpot) Spot() *Spot
- type ModelOptions
- type MovementAction
- type MovementCommand
- type MovementSample
- type Npc
- type NpcOptions
- type NpcState
- type NpcTarget
- type NpcsRestoredEvent
- type ParticleOptions
- type ParticlePoint
- type Pawn
- type Pickup
- type PickupKind
- type Placed
- type Player
- func (p Player) Abilities() ([]*Ability, error)
- func (p Player) AddMetric(name string, value float64, label *string) error
- func (p Player) AdjustSouls(delta int32, silent *bool) error
- func (p Player) Announce(title, text string) error
- func (p Player) BlockInput(buttons uint64) error
- func (p Player) Buttons() (uint64, error)
- func (p Player) CenterText(text string) error
- func (p Player) Chat(text string) error
- func (p Player) ClearItems() error
- func (p Player) ClearScreenEffect(effect ScreenEffect) error
- func (p Player) Freeze(frozen *bool) error
- func (p Player) GiveItem(item string) error
- func (p Player) GiveModifier(modifier string, seconds float32) error
- func (p Player) Heal(amount int32) error
- func (p Player) HoldModifier(modifier string, active *bool) error
- func (p Player) Kill() error
- func (p Player) Move(position *Vector, facing *Angles, velocity *Vector) error
- func (p Player) Pawn() (*Pawn, error)
- func (p Player) Press(buttons uint64) error
- func (p Player) RefreshAbility(ability string) error
- func (p Player) RemoveBot() error
- func (p Player) ReplaceAbility(index uint32, ability string) error
- func (p Player) ResetHero(souls int32) error
- func (p Player) Respawn() error
- func (p Player) RestoreHero(target *HeroTarget) error
- func (p Player) RestoreStamina() error
- func (p Player) ScreenEffect(effect ScreenEffect, timing *ScreenTiming) error
- func (p Player) SelectHero(hero any, team int32) (uint32, error)
- func (p Player) SetAbility(options *AbilityOptions) error
- func (p Player) SetSetting(key, value string) error
- func (p Player) SetStamina(stamina float32) error
- func (p Player) SetVelocity(velocity *Vector) error
- func (p Player) Setting(key string) (string, error)
- func (p Player) SettingNumber(key string) (float64, error)
- func (p Player) SettingOn(key string) (bool, error)
- func (p Player) Sound(sound string) error
- func (p Player) Spectate() error
- func (p Player) StartingSouls(souls int32) error
- func (p Player) Steer(steering *Steering) error
- func (p Player) Teleport(position *Vector, facing *Angles, velocity *Vector) error
- func (p Player) Unwatch() error
- func (p Player) Watch(target uint32) error
- func (p Player) WatchMovement(watch bool) error
- type PrecacheOptions
- type ProjectileOptions
- type RestoredEvent
- type RiftState
- type Score
- type ScreenEffect
- type ScreenTiming
- type Service
- type ServiceCall
- type ServiceReply
- type SettingChangedEvent
- type Spot
- type SpotObject
- type StartEvent
- type StartResult
- type Steering
- type TextOptions
- type TimerTarget
- type TraceHit
- type TraceOptions
- type UiPressEvent
- type Vector
- type WorldEvent
- type WorldObject
Constants ¶
const ( // ButtonAttack is the primary fire button. ButtonAttack uint64 = 1 // ButtonUse is the interact key. ButtonUse uint64 = 1 << 5 // ButtonMelee is the light melee button. ButtonMelee uint64 = 1 << 11 // ButtonReload is the reload key. ButtonReload uint64 = 1 << 13 // ButtonAbility1 to ButtonAbility3 are the hero's first three ability // keys. ButtonAbility1 uint64 = 1 << 33 ButtonAbility2 uint64 = 1 << 34 ButtonAbility3 uint64 = 1 << 35 // ButtonParry is the melee parry button. ButtonParry uint64 = 1 << 42 )
Button bits name inputs for BlockInput, WatchInput and Player.Press.
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 // LayerWorldGeometry is the map's static geometry. LayerWorldGeometry uint64 = 1 << 14 // LayerPlayer is player-controlled heroes. LayerPlayer uint64 = 1 << 18 // LayerNpc is units that are not players. LayerNpc uint64 = 1 << 19 // 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.
const ( MovementActionLanded = wasm.MovementAction_MOVEMENT_ACTION_LANDED MovementActionZiplineAttached = wasm.MovementAction_MOVEMENT_ACTION_ZIPLINE_ATTACHED MovementActionGroundDash = wasm.MovementAction_MOVEMENT_ACTION_GROUND_DASH MovementActionSlide = wasm.MovementAction_MOVEMENT_ACTION_SLIDE MovementActionBouncePad = wasm.MovementAction_MOVEMENT_ACTION_BOUNCE_PAD MovementActionDashJump = wasm.MovementAction_MOVEMENT_ACTION_DASH_JUMP MovementActionAirJump = wasm.MovementAction_MOVEMENT_ACTION_AIR_JUMP MovementActionWallJump = wasm.MovementAction_MOVEMENT_ACTION_WALL_JUMP MovementActionAirDash = wasm.MovementAction_MOVEMENT_ACTION_AIR_DASH MovementActionMeleeStarted = wasm.MovementAction_MOVEMENT_ACTION_MELEE_STARTED // AbilityExecuted is any ability the hero cast. MovementActionAbilityExecuted = wasm.MovementAction_MOVEMENT_ACTION_ABILITY_EXECUTED )
The values of MovementAction.
const ( // ScreenEffectKilled is the death treatment. ScreenEffectKilled = wasm.ScreenEffect_SCREEN_EFFECT_KILLED // ScreenEffectBlack fades the view to black. ScreenEffectBlack = wasm.ScreenEffect_SCREEN_EFFECT_BLACK // ScreenEffectBlinded is the blind treatment. ScreenEffectBlinded = wasm.ScreenEffect_SCREEN_EFFECT_BLINDED // ScreenEffectDarkness is Drifter's darkness view. ScreenEffectDarkness = wasm.ScreenEffect_SCREEN_EFFECT_DARKNESS // ScreenEffectMatchIntro is the match start treatment. ScreenEffectMatchIntro = wasm.ScreenEffect_SCREEN_EFFECT_MATCH_INTRO )
The values of ScreenEffect.
const ( // FieldTypeBool is one byte read as a boolean. FieldTypeBool = wasm.FieldType_FIELD_TYPE_BOOL // FieldTypeInt8 through FIELD_TYPE_UINT32 are integers read as numbers. FieldTypeInt8 = wasm.FieldType_FIELD_TYPE_INT8 FieldTypeInt16 = wasm.FieldType_FIELD_TYPE_INT16 FieldTypeInt32 = wasm.FieldType_FIELD_TYPE_INT32 FieldTypeUint8 = wasm.FieldType_FIELD_TYPE_UINT8 FieldTypeUint16 = wasm.FieldType_FIELD_TYPE_UINT16 FieldTypeUint32 = wasm.FieldType_FIELD_TYPE_UINT32 // FieldTypeInt64 and FIELD_TYPE_UINT64 are 64-bit integers. FieldTypeInt64 = wasm.FieldType_FIELD_TYPE_INT64 FieldTypeUint64 = wasm.FieldType_FIELD_TYPE_UINT64 // FieldTypeFloat32 and FIELD_TYPE_FLOAT64 are floating point numbers. FieldTypeFloat32 = wasm.FieldType_FIELD_TYPE_FLOAT32 FieldTypeFloat64 = wasm.FieldType_FIELD_TYPE_FLOAT64 // FieldTypeVector is three floats, such as a position or angles. FieldTypeVector = wasm.FieldType_FIELD_TYPE_VECTOR // FieldTypeHandle is an entity handle, read as a number. FieldTypeHandle = wasm.FieldType_FIELD_TYPE_HANDLE // FieldTypeString is a string the field points to. FieldTypeString = wasm.FieldType_FIELD_TYPE_STRING )
The values of FieldType.
const ( // PickupKindUrn is the soul urn, which its carrier delivers. PickupKindUrn = wasm.PickupKind_PICKUP_KIND_URN // PickupKindMovementBuff is the movement speed buff. PickupKindMovementBuff = wasm.PickupKind_PICKUP_KIND_MOVEMENT_BUFF )
The values of PickupKind.
Variables ¶
This section is empty.
Functions ¶
func BlockInput ¶
BlockInput withholds buttons from every player's hero until called again. Stopping the mod releases them.
func CallService ¶
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 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 ¶
Command calls handler when a player types /name in chat. The handler 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 any 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.
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 EncodeSpot ¶
EncodeSpot returns the spot document. Equal spots encode to equal bytes; positions and angles keep single precision.
func FindEntities ¶ added in v0.1.3
FindEntities returns the handle of every live entity of a class, such as zip_line_node.
func FireInput ¶ added in v0.1.1
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.
func HoldMatchClock ¶
HoldMatchClock keeps the match time at seconds every frame until called again; omitted seconds let it run.
func HoldModifierState ¶
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
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 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 ¶
MatchClock returns the match time in seconds that the scoreboard shows.
func ModifierState ¶
ModifierState reports whether an entity has a modifier state, such as MODIFIER_STATE_PARRY_ACTIVE.
func MoveEntity ¶
MoveEntity places any entity, such as a projectile, and replaces its facing and motion when given.
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 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 ¶
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 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 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 OnRestored ¶
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 ¶
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 OnStart ¶
func OnStart(handler func(args []string))
OnStart calls handler once when the server starts the mod, with the arguments that follow -- on the modlock-host command line.
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 ¶
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.
func ReadField ¶
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.
func ReadFieldList ¶ added in v0.1.3
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 RemapInput ¶
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 ¶
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
RemoveEntity takes an entity the mod created out of the world without rewards. It reports false when the entity was already gone.
func RestoreNpcs ¶
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 ¶
Serve answers the host's calls to service with handler. Registering a service again replaces its handler.
func ServerCommand ¶
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.
func WatchInput ¶
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 ¶
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 fields cannot be written. A write to the match's state sends all of it, so players already in the match see the change.
Types ¶
type AbilityOptions ¶
type AbilityOptions = wasm.AbilityOptions
AbilityOptions changes one ability of a player's hero.
type BotOptionsHeroId ¶
type BotOptionsHeroId = wasm.BotOptions_HeroId
BotOptionsHeroId sets BotOptions.Hero to HeroId.
type BotOptionsHeroName ¶
type BotOptionsHeroName = wasm.BotOptions_HeroName
BotOptionsHeroName sets BotOptions.Hero to HeroName.
type CommandEvent ¶
type CommandEvent = wasm.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 = wasm.CommandResult
CommandResult answers whether the mod handled a command.
type Connection ¶
type Connection = wasm.Connection
Connection is one occupied player slot.
func Players ¶
func Players() ([]*Connection, error)
Players lists the occupied player slots in slot order.
type DamageEvent ¶
type DamageEvent = wasm.DamageEvent
DamageEvent is one hit before the game applies it. Handles are zero when the game names no such entity.
type DamageResult ¶
type DamageResult = wasm.DamageResult
DamageResult answers a DamageEvent. An empty result lets the hit through.
type DamagedEvent ¶
type DamagedEvent = wasm.DamagedEvent
DamagedEvent reports one hit the game applied.
type EntityClassName ¶ added in v0.1.1
type EntityClassName = wasm.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 = wasm.EntityOptions
EntityOptions describes an entity to create.
type EquipmentTarget ¶
type EquipmentTarget = wasm.EquipmentTarget
EquipmentTarget is one ability or item a HeroTarget gives the hero.
type FieldWrite ¶ added in v0.1.1
type FieldWrite = wasm.FieldWrite
FieldWrite writes one schema field of an entity the host creates.
type FogOptions ¶
type FogOptions = wasm.FogOptions
FogOptions describes an oriented box of tinted fog.
type HeroTarget ¶
type HeroTarget = wasm.HeroTarget
HeroTarget is the state RestoreHero gives one hero. Omitted parts keep the hero's own.
type ImpactEvent ¶
type ImpactEvent = wasm.ImpactEvent
ImpactEvent is a watched projectile striking something.
type InputEvent ¶
type InputEvent = wasm.InputEvent
InputEvent is one player's watched buttons that went down or up.
type LaunchEvent ¶
type LaunchEvent = wasm.LaunchEvent
LaunchEvent is a watched projectile's first frame.
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) 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.
type ModelOptions ¶
type ModelOptions = wasm.ModelOptions
ModelOptions describes a model placed in the world.
type MovementAction ¶
type MovementAction = wasm.MovementAction
MovementAction is a movement fact the game announced for a hero.
type MovementCommand ¶ added in v0.1.1
type MovementCommand = wasm.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 = wasm.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 ¶
Move places the unit and sets its velocity, which drives its walk animation. It reports false once the unit is gone.
type NpcOptions ¶
type NpcOptions = wasm.NpcOptions
NpcOptions describes a unit that is not a player, such as a trooper.
type NpcsRestoredEvent ¶
type NpcsRestoredEvent = wasm.NpcsRestoredEvent
NpcsRestoredEvent reports how a RestoreNpcs ended.
type ParticleOptions ¶
type ParticleOptions = wasm.ParticleOptions
ParticleOptions describes a particle effect.
type ParticlePoint ¶
type ParticlePoint = wasm.ParticlePoint
ParticlePoint places one control point of a particle effect.
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.
type PickupKind ¶
type PickupKind = wasm.PickupKind
PickupKind is a kind of item players collect by walking over it.
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 {
// Slot identifies the player on the server.
Slot int32
}
Player addresses one connected player by their server slot.
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 (Player) Abilities ¶
Abilities lists the abilities of the player's hero in the hero's order, or none without a live hero.
func (Player) AddMetric ¶
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) AdjustSouls ¶
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) BlockInput ¶
BlockInput withholds buttons from the player's hero until called again, on top of the block on everyone. Zero releases the player.
func (Player) Buttons ¶
Buttons returns the buttons a player holds, as Buttons bits, while the player is alive or dead.
func (Player) CenterText ¶
CenterText shows text in the middle of the player's screen until it is replaced. Empty text clears it.
func (Player) ClearItems ¶
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) Freeze ¶
Freeze holds the player's hero in place, without input or damage, until it is released. Stopping the mod releases it.
func (Player) GiveItem ¶
GiveItem gives the hero an item, enabled and free. A hero that owns it keeps its one copy.
func (Player) GiveModifier ¶
GiveModifier gives the hero an ability's modifier, named "<ability>/<modifier>", for seconds, as if the hero's own ability applied it; a hero without that ability applies it with its first ability. The game may end it sooner, as invisibility ends on a shot.
func (Player) HoldModifier ¶
HoldModifier keeps an ability's modifier, named "<ability>/<modifier>", on the hero with no expiry, giving it back whenever the game removes it or the hero returns. The hero must own the ability or item. 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.
func (Player) Move ¶ added in v0.1.1
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) Press ¶
Press presses buttons at the player's next input, even through a block. A bot presses them as a player would.
func (Player) RefreshAbility ¶
RefreshAbility ends the cooldown of the hero's ability named ability, such as citadel_ability_melee_parry.
func (Player) ReplaceAbility ¶
ReplaceAbility puts the ability named ability, untrained, in the hero's ability slot index, as Ability.slot, removing the ability there.
func (Player) ResetHero ¶ added in v0.1.3
ResetHero rebuilds the player's hero as it first spawned, without items, ability upgrades, levels or ability points, holding souls.
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.
func (Player) RestoreStamina ¶
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) SelectHero ¶
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.
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 ¶
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
SetStamina sets the player's stamina, as Pawn.stamina reads it. The game regenerates it as usual afterwards.
func (Player) SetVelocity ¶
SetVelocity replaces the motion of a player's hero without moving it.
func (Player) Setting ¶
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 ¶
SettingNumber returns the player's value of a number setting the manifest declares.
func (Player) SettingOn ¶
SettingOn returns the player's value of a switch setting the manifest declares.
func (Player) Sound ¶
Sound plays a game sound event, such as Damage.Send.Crit, on the player's hero.
func (Player) Spectate ¶ added in v0.1.1
Spectate moves the player to the spectators, without a hero. The player watches until a hero selection seats them again.
func (Player) StartingSouls ¶
StartingSouls sets the souls the player's hero spawns with.
func (Player) Steer ¶ added in v0.1.1
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 counting once; a Steer without one releases the hero.
func (Player) Teleport ¶
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) Unwatch ¶ added in v0.1.3
Unwatch returns a player watching from their hero back to it. Stopping the mod returns every such player.
func (Player) Watch ¶ added in v0.1.2
Watch points the player's camera at a hero, through the hero's own view, as the game's spectator camera follows it. A spectator watches through their spectator camera, once it exists. A player with a hero watches while the hero stays where it stands, keeping its level, souls and items, until Unwatch returns them to it.
func (Player) WatchMovement ¶
WatchMovement adds a player's hero to the movement samples of each Frame event on a new tick, or removes it.
type PrecacheOptions ¶
type PrecacheOptions = wasm.PrecacheOptions
PrecacheOptions names what the next world loads ahead of use.
type ProjectileOptions ¶
type ProjectileOptions = wasm.ProjectileOptions
ProjectileOptions selects the projectiles a mod watches.
type RestoredEvent ¶
type RestoredEvent = wasm.RestoredEvent
RestoredEvent reports how a RestoreHero ended.
type RiftState ¶
RiftState is the Rift objective's timing as the game holds it. Times are game times in seconds, or zero when unset.
type Score ¶ added in v0.1.3
Score is one player's scoreboard counters since the match began, as the game counts them.
type ScreenEffect ¶
type ScreenEffect = wasm.ScreenEffect
ScreenEffect is a stock full-screen view effect.
type ScreenTiming ¶
type ScreenTiming = wasm.ScreenTiming
ScreenTiming is a screen effect's timing in seconds.
type Service ¶
Service answers calls to one service the mod serves: the method's name and payload in, the answer out.
type ServiceCall ¶
type ServiceCall = wasm.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 SettingChangedEvent ¶
type SettingChangedEvent = wasm.SettingChangedEvent
SettingChangedEvent is one player's new value of one setting.
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.
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 = wasm.StartEvent
StartEvent describes the server the mod starts in.
type StartResult ¶
type StartResult = wasm.StartResult
StartResult declares which events the mod consumes.
type Steering ¶ added in v0.1.1
Steering is one recorded movement command and the pose its step ends on.
type TextOptions ¶
type TextOptions = wasm.TextOptions
TextOptions describes text that floats in the world.
type TimerTarget ¶
type TimerTarget = wasm.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 ¶
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 = wasm.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 UiPressEvent ¶
type UiPressEvent = wasm.UiPressEvent
UiPressEvent reports a press on a button in a player's interface.
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; 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, as traces report it.
func (WorldObject) Move ¶
func (w WorldObject) Move(position *Vector, facing *Angles) error
Move places the object at position, turning it to facing.
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.
Source Files
¶
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. |