Multiplayer reference
The authority rule every state change asks, and the commands a client sends to the server with the relay that carries and applies them. For how to use it, see Multiplayer.
IVtCommandRelay
Interface.
Per-unit transport seam for player intents. A predicting client’s modules hand a VtCommand to the relay on the same unit instead of changing state; the relay sends it to the authority, which calls VtCommandRelay.Apply on its own copy of the unit.
Scripting API
| Member | Description |
|---|---|
void Send(in VtCommand command) |
Send command to the authority for this unit. |
VtCommand
Serializable struct.
One player intent that a predicting client sends to the authority: talk to an NPC, use an item, accept a quest, place a building. Built by the module that received the call and carried through IVtCommandRelay; applied on the authority by VtCommandRelay.Apply, which re-validates everything with the authority’s own state.
Inspector fields
| Field | Type | Default | Description |
|---|---|---|---|
Kind (kind) |
VtCommandKind | Interact |
What the player wants to do. |
Id (id) |
string |
Empty | Id of the definition the command is about: item, quest, recipe or buildable. Also a player, mail or slot area id. |
Index (index) |
int |
0 | Secondary number: an equipment slot, a dialogue answer index, a targeting mode or a count. |
Point (point) |
Vector3 |
(0, 0, 0) | World point for walking, ground-targeted item use and building placement. |
Rotation (rotation) |
Quaternion |
— | Placement rotation of a building. |
Target (target) |
GameObject |
None | Scene object the command acts on: the NPC or item to interact with, the crafting station, the building to demolish, the unit to attack or throw an item at. |
Text (text) |
string |
Empty | Free text: a chat line, a guild name, a mail as JSON. |
Id 2 (id2) |
string |
Empty | Second id: the target area of a slot move. |
Index 2 (index2) |
int |
0 | Second number: the target slot of a slot move, the targeting mode of a slot use. |
Count (count) |
int |
0 | How many items to move or drop, 0 for the whole stack. |
Scripting API
| Member | Description |
|---|---|
static VtCommand MoveSlot(VtInventorySlotRef from, VtInventorySlotRef to, int count) |
Move count items from one inventory slot to another, 0 for the whole stack. |
static VtCommand SelectHeldSlot(int index) |
Hold the item in slot index of the held-slot area, -1 for none. |
static VtCommand DropSlot(VtInventorySlotRef slot, int count) |
Drop count items from a slot to the ground, 0 for the whole stack. |
static VtCommand QuickMoveSlot(VtInventorySlotRef from) |
Send a slot’s stack to where it belongs, such as from the bag to the bar. |
static VtCommand UseSlot(VtInventorySlotRef slot, in VtAbilityTargetData targetData) |
Use the item in a slot at the given target. |
static VtCommand Interact(GameObject target) |
Talk to an NPC or pick up a world item. |
static VtCommand UseItem(VtItemDefinition item, in VtAbilityTargetData targetData) |
Use a consumable from the bag at the given target. |
static VtCommand Equip(VtItemDefinition item, VtEquipmentSlot slot) |
Equip an item into a slot. |
static VtCommand Unequip(VtEquipmentSlot slot) |
Take off the item in a slot. |
static VtCommand AcceptQuest(VtQuestDefinition quest) |
Accept a quest. |
static VtCommand AbandonQuest(VtQuestDefinition quest) |
Abandon a quest. |
static VtCommand TurnInQuest(VtQuestDefinition quest) |
Turn in a completed quest. |
static VtCommand DialogueChoose(int answerIndex) |
Pick the dialogue answer at answerIndex. |
static VtCommand DialogueContinue() |
Advance past a plain dialogue line. |
static VtCommand DialogueEnd() |
Close the conversation. |
static VtCommand Craft(VtRecipeDefinition recipe, VtCraftingStation station) |
Craft a recipe, at station or by hand when it is null. |
static VtCommand CancelCraft() |
Cancel the craft in progress. |
static VtCommand Build(VtBuildableDefinition buildable, Vector3 position, Quaternion rotation) |
Place a building at a position and rotation. |
static VtCommand Demolish(VtUnit building) |
Demolish a placed building. |
static VtCommand MoveTo(Vector3 destination, bool acceptPartialPath = false) |
Walk to destination. acceptPartialPath walks as far as possible when the point cannot be reached. |
static VtCommand Engage(IVtAttackable target) |
Chase and auto-attack a target. |
static VtCommand Stop() |
Stop moving, drop the target and interrupt the cast. |
static VtCommand Order(VtOrderKind order, Vector3 point, GameObject target) |
Give an order: order toward point, or at target for an attack. |
static VtCommand Buy(VtItemDefinition item, int count, VtVendor vendor) |
Buy count of an item from a vendor. |
static VtCommand Sell(VtItemDefinition item, int count, VtVendor vendor) |
Sell count of an item to a vendor. |
static VtCommand Respawn() |
Come back to life after the respawn delay. |
static VtCommand LearnTalent(VtTalentDefinition talent) |
Learn the next rank of a talent. |
static VtCommand SpendAttributePoint(VtAttributeDefinition attribute) |
Put one attribute point into an attribute. |
static VtCommand ResetProgression() |
Refund every talent rank and attribute point. |
static VtCommand PartyInvite(VtUnit target) |
Invite a unit to the party. |
static VtCommand PartyAccept() |
Accept the pending party invite. |
static VtCommand PartyDecline() |
Decline the pending party invite. |
static VtCommand PartyLeave() |
Leave the party. |
static VtCommand PartyKick(VtUnit member) |
Remove a member from the party. |
static VtCommand PartyPromote(VtUnit member) |
Hand party leadership to a member. |
static VtCommand PartySetLootRule(VtPartyLootRule rule) |
Change the party’s loot rule. |
static VtCommand SummonDismiss(VtSummon summon) |
Dismiss one of the unit’s summons. |
static VtCommand SummonDismissAll() |
Dismiss every summon the unit controls. |
static VtCommand SummonSetStance(VtCompanionStance stance) |
Set the stance of the unit’s companions. |
static VtCommand ChatSend(VtChatChannel channel, string text, string whisperTo) |
Send a chat line on a channel. whisperTo is the recipient of a whisper, otherwise null. |
static VtCommand ChatIgnore(string playerId) |
Ignore a player in chat. |
static VtCommand ChatUnignore(string playerId) |
Stop ignoring a player in chat. |
static VtCommand GuildCreate(string guildName, string tag) |
Found a guild with a name and a tag. |
static VtCommand GuildInvite(string playerNameOrId) |
Invite a player to the guild, by name or id. |
static VtCommand GuildAccept() |
Accept the pending guild invite. |
static VtCommand GuildDecline() |
Decline the pending guild invite. |
static VtCommand GuildLeave() |
Leave the guild. |
static VtCommand GuildKick(string memberPlayerId) |
Remove a member from the guild. |
static VtCommand GuildPromote(string memberPlayerId) |
Promote a guild member one rank. |
static VtCommand GuildDemote(string memberPlayerId) |
Demote a guild member one rank. |
static VtCommand GuildTransfer(string memberPlayerId) |
Hand guild leadership to a member. |
static VtCommand GuildSetMotd(string text) |
Set the guild’s message of the day. |
static VtCommand GuildDisband() |
Disband the guild. |
static VtCommand FriendRequest(string playerNameOrId) |
Send a friend request to a player, by name or id. |
static VtCommand FriendAccept(string fromPlayerId) |
Accept a friend request. |
static VtCommand FriendDecline(string fromPlayerId) |
Decline a friend request. |
static VtCommand FriendCancel(string toPlayerId) |
Withdraw a friend request you sent. |
static VtCommand FriendRemove(string friendPlayerId) |
End a friendship. |
static VtCommand MailSend(VtMailDraft draft) |
Send a mail. |
static VtCommand MailTake(string mailId) |
Take a mail’s attachments. |
static VtCommand MailRead(string mailId) |
Mark a mail read. |
static VtCommand MailDelete(string mailId) |
Delete a mail. |
static VtCommand MailReturn(string mailId) |
Return a mail to its sender. |
static VtCommand Unlock(VtUnlockDefinition unlock) |
Buy an unlock. |
static VtCommand StashDepositItem(VtSharedStash stash, VtItemDefinition item, int count) |
Move count of an item from the bag into a shared stash. |
static VtCommand StashDepositCurrency(VtSharedStash stash, VtCurrencyDefinition currency, int amount) |
Move amount of a currency from the wallet into a shared stash. |
static VtCommand StashDepositAll(VtSharedStash stash) |
Move the whole bag and wallet into a shared stash. |
static VtCommand StashDepositAll(VtSharedStash stash, VtStashDepositFilter filter) |
Deposit the part of the bag and wallet that filter picks. The tags travel by id in text. |
static VtCommand EquipFromInventory(VtItemDefinition item, VtEquipmentSlot slot = VtEquipmentSlot.None) |
Wear an item from the bag, putting what it replaces back. VtEquipmentSlot.None uses the item’s own slot. |
static VtCommand UnequipToInventory(VtEquipmentSlot slot) |
Take off the item in a slot into the bag. |
VtAuthority
Static class.
Who may change a unit’s state in this process. Every mutator in the package asks here first. Single-player answers VtAuthorityLevel.Authoritative for everything; a networked game installs ResolveFn at bootstrap to answer per unit.
Scripting API
| Member | Description |
|---|---|
static Func<Component, VtAuthorityLevel> ResolveFn { get; set; } |
The rule a networked game installs at bootstrap. Input is a component on the unit in question; return how much this process may change it. Null restores the single-player default, where everything is authoritative. |
static Func<Component, bool> IsLocalFn { get; set; } |
Yes-or-no form of ResolveFn: true maps to VtAuthorityLevel.Authoritative, false to VtAuthorityLevel.Replica. A networked game that wants owner-side prediction sets ResolveFn instead. |
static VtAuthorityLevel Level(Component c) |
How much this process may change the unit that owns c. |
static bool IsAuthoritative(Component c) |
True when this process owns the truth for the unit. Gate everything that must never be applied provisionally. |
static bool IsLocal(Component c) |
True when this process may at least predict for the unit: the authority or the owning client. Gate movement, cast bars, cooldowns and resource costs. |
static bool IsPredicting(Component c) |
True when this process is the owning client of the unit and not its authority: changes must be forwarded. |
VtCommandRelay
Static class.
The two halves of a forwarded intent. Predicting clients call Forward from inside the module method the player invoked; the authority calls Apply when the command arrives and the module re-validates with its own state. Gameplay code calls neither: it calls log.Accept(quest) or inventory.TryUseItem(item) and the module does the rest. Your IVtCommandRelay calls Apply on arrival.
Scripting API
| Member | Description |
|---|---|
static Func<float> Clock { get; set; } |
Clock the rate limiter reads, in seconds. The default is real time, so a paused game does not bank commands; null restores it. |
static event Action<VtUnit, VtCommand, bool> OnApplied |
Fires on the authority after a command was applied, with the outcome. Useful for logging. |
static event Action<VtUnit, VtCommand> OnRateLimited |
Fires on the authority when a command was dropped because the unit sent more than VtTuning.maxCommandsPerSecond allows. Count these per client to kick a flooder. |
static void ResetRateLimits() |
Forget every unit’s command budget, for example on a new match. |
static bool Forward(Component sender, in VtCommand command) |
Hand command to the IVtCommandRelay on the unit that owns sender. Returns false, and warns once per unit, when no relay is attached. |
static bool Apply(VtUnit unit, in VtCommand command, VtDefinitionCatalog catalog = null) |
Run command on the authority’s copy of unit. Ids resolve through catalog or the shared Definition Catalog. Returns whether the module accepted it. |
VtAuthorityLevel
Enum.
How much this process may change a unit’s state. Resolved per component by VtAuthority.Level.
| Value | Description |
|---|---|
Replica |
Read-only mirror. Nothing here changes state; replication writes it. |
Predicting |
The owning client of its own unit. May apply provisional changes the authority will confirm or overwrite: movement, cast bars, cooldowns and resource costs. Everything else forwards a command and waits for replication. |
Authoritative |
Owns the truth. Single-player, the co-op host, or a dedicated server. |
Enums
VtCommandKind
The kinds of intent a client can send. See VtCommand.
| Value | Description |
|---|---|
Interact |
Talk to an NPC or pick up a world item. target is the object. |
UseItem |
Use a consumable. id is the item, index the targeting mode, point and target the target. |
Equip |
Equip an item. id is the item, index the slot. |
Unequip |
Unequip a slot. index is the slot. |
AcceptQuest |
Accept a quest. id is the quest. |
AbandonQuest |
Abandon a quest. id is the quest. |
TurnInQuest |
Turn in a quest. id is the quest. |
DialogueChoose |
Pick a dialogue answer. index is the choice index. |
DialogueContinue |
Advance past a plain dialogue line. |
DialogueEnd |
Close the conversation. |
Craft |
Craft a recipe. id is the recipe, target the station or null. |
CancelCraft |
Cancel the craft in progress. |
Build |
Place a building. id is the buildable, point and rotation the pose. |
Demolish |
Demolish a placed building. target is the building. |
MoveTo |
Walk to a point. point is the destination, index 1 to accept a partial path. |
Engage |
Chase and auto-attack a hostile. target is the unit. |
Stop |
Stop moving, drop the target and interrupt the cast. |
Buy |
Buy from a vendor. id is the item, index the count, target the vendor. |
Sell |
Sell to a vendor. id is the item, index the count, target the vendor. |
Respawn |
Come back to life after the respawn delay. |
LearnTalent |
Learn the next rank of a talent. id is the talent. |
SpendAttributePoint |
Put one attribute point into an attribute. id is the attribute’s save id. |
ResetProgression |
Refund every talent rank and attribute point. |
PartyInvite |
Invite a unit to the party. target is the invitee. |
PartyAccept |
Accept the pending party invite. |
PartyDecline |
Decline the pending party invite. |
PartyLeave |
Leave the party. |
PartyKick |
Remove a member. target is the member. |
PartyPromote |
Hand leadership over. target is the new leader. |
PartySetLootRule |
Change the party’s loot rule. index is the rule. |
SummonDismiss |
Dismiss one of the unit’s summons. target is the summon. |
SummonDismissAll |
Dismiss every summon the unit controls. |
SummonSetStance |
Set the stance of the unit’s companions. index is the stance. |
ChatSend |
Send a chat line. index is the channel, text the line, id the whisper target. |
ChatIgnore |
Ignore a player in chat. id is the player id. |
ChatUnignore |
Stop ignoring a player. id is the player id. |
GuildCreate |
Found a guild. text is the name, id the tag. |
GuildInvite |
Invite a player to the guild. id is the player name or id. |
GuildAccept |
Accept the pending guild invite. |
GuildDecline |
Decline the pending guild invite. |
GuildLeave |
Leave the guild. |
GuildKick |
Remove a member. id is the member’s player id. |
GuildPromote |
Promote a member. id is the member’s player id. |
GuildDemote |
Demote a member. id is the member’s player id. |
GuildTransfer |
Hand over leadership. id is the member’s player id. |
GuildSetMotd |
Set the message of the day. text is the message. |
GuildDisband |
Disband the guild. |
FriendRequest |
Send a friend request. id is the player name or id. |
FriendAccept |
Accept a friend request. id is the requester’s player id. |
FriendDecline |
Decline a friend request. id is the requester’s player id. |
FriendCancel |
Withdraw a sent friend request. id is the recipient’s player id. |
FriendRemove |
End a friendship. id is the friend’s player id. |
MailSend |
Send a mail. text is the draft as JSON. |
MailTake |
Take a mail’s attachments. id is the mail id. |
MailRead |
Mark a mail read. id is the mail id. |
MailDelete |
Delete a mail. id is the mail id. |
MailReturn |
Return a mail to its sender. id is the mail id. |
Order |
Give a unit an order. index is the VtOrderKind, point the destination, target the object to attack. |
Unlock |
Buy an unlock. id is the unlock id. |
StashDepositItem |
Move items into a shared stash. target is the stash, id the item id, index the count. |
StashDepositCurrency |
Move currency into a shared stash. target is the stash, id the currency id, index the amount. |
StashDepositAll |
Move the unit’s whole bag and wallet into a shared stash. target is the stash. |
EquipFromInventory |
Wear an item from the bag, putting what it replaces back. id is the item id, index the VtEquipmentSlot or VtEquipmentSlot.None for the item’s own slot. |
UnequipToInventory |
Take off an item into the bag. index is the VtEquipmentSlot. |
MoveSlot |
Move items between inventory slots. id/index is the source slot, id2/index2 the target, count how many (0 = the whole stack). |
QuickMoveSlot |
Send a slot’s stack where it belongs. id/index is the slot. |
UseSlot |
Use the item in a slot. id/index is the slot, index2 the targeting mode, point or target as for UseItem. |
SelectHeldSlot |
Hold the item in a slot of the VtUnitHeldSlot area. index is the slot, -1 for none. |
DropSlot |
Drop items from a slot to the ground. id/index is the slot, count how many (0 = the whole stack). |
VtEquipmentSlot
The set of equipment slots an item can occupy on a unit. Used as the key for the slot map on VtUnitEquipment and as the source-id suffix when equipped items push their modifiers / attributes / traits ("equipment_<slot>").
| Value | Description |
|---|---|
None |
Inventory-only / non-equippable. Potions, materials, quest items. |
Head |
Helm / hat / hood. |
Chest |
Chestpiece / robe / breastplate. |
Legs |
Leg armor / pants / greaves. |
Feet |
Boots / sandals / sabatons. |
Hands |
Gloves / gauntlets / bracers. |
MainHand |
Primary weapon. 2H weapons occupy this slot and block OffHand. |
OffHand |
Off-hand weapon, shield, or focus. Auto-unequipped when a 2H is equipped to MainHand. |
Neck |
Necklace / amulet / pendant. |
Ring1 |
First ring slot. Members of the Ring family. |
Ring2 |
Second ring slot. Members of the Ring family. |
Trinket1 |
First trinket slot. Members of the Trinket family. |
Trinket2 |
Second trinket slot. Members of the Trinket family. |
Back |
Worn on the back: backpack, cloak, quiver. |
VtOrderKind
An order a unit with VtUnitOrders carries out.
| Value | Description |
|---|---|
Idle |
No order. The unit attacks hostile units that come inside its aggro range. |
Move |
Walk to a point and ignore enemies on the way. |
AttackMove |
Walk to a point and fight every hostile unit met on the way. |
Attack |
Attack one target until it dies. |
HoldPosition |
Stay in place and attack only what is within attack range. |
Stop |
Stop moving and fighting, then go idle. Given as an order, never held. |
VtPartyLootRule
Who may pick up items that drop from a kill made by a party member. Serialized as int; append-only.
| Value | Description |
|---|---|
FreeForAll |
Anyone may pick up the drop. |
PartyReserved |
For VtTuning.lootReserveSeconds only the killer’s party may pick up the drop; after that anyone may. |
VtCompanionStance
How a VtCompanionAi fights.
| Value | Description |
|---|---|
Passive |
Follows the owner and never attacks. |
Defensive |
Attacks what the owner attacks and whatever hurts the owner or the companion. |
Aggressive |
Like Defensive, and also attacks hostiles that come inside its aggro range. |
VtChatChannel
Where a chat message goes. Serialized as int; append-only.
| Value | Description |
|---|---|
Say |
Players within VtTuning.chatSayRange of the sender. |
Yell |
Players within VtTuning.chatYellRange of the sender. |
Party |
The sender’s party. |
Guild |
The sender’s guild. Needs the guild module. |
Whisper |
One player by name or id, echoed to the sender. |
System |
Server announcements. Players cannot send on it. |
Npc |
Lines spoken by non-player units, such as boss yells. Players cannot send on it. |