Commands
The Command System provides a framework for processing administrative and testing commands within the game server.
The system uses reflection to automatically discover and register command protocols, allowing for easy addition of new commands without manual registration.
Command Structure
Commands follow the format: [group] [command] [parameters]
- Group: Command category (e.g., "mod", "sb", "debug")
- Command: Specific action within the group
- Parameters: Optional arguments for the command
Creating Command Protocols
Command protocols are classes that inherit from CommandProtocol and define a group of related commands.
Basic Protocol Structure
internal class CommandModifyProtocol : CommandProtocol {
internal override string Group { get; set; } = "mod";
[Command("levelup")]
[AuthRequired(AuthLevel.QualityAssurance)]
[Alias("lvlup")]
private void LevelUpCommand() {
var newLevel = (byte)(Context.Character.MagicSchoolBehavior.Level + 1);
if (newLevel > MagicLevelsConfig.MaxLevel) {
InformSenderClient($"Cannot exceed max level ({MagicLevelsConfig.MaxLevel}).");
return;
}
var msg = new CHARACTER_103_PROTOCOL.MSG_LEVELUP() { NewLevel = newLevel };
Context.SessionActor.Tell(msg, null);
}
}internal class CommandModifyProtocol : CommandProtocol {
internal override string Group { get; set; } = "mod";
[Command("levelup")]
[AuthRequired(AuthLevel.QualityAssurance)]
[Alias("lvlup")]
private void LevelUpCommand() {
var newLevel = (byte)(Context.Character.MagicSchoolBehavior.Level + 1);
if (newLevel > MagicLevelsConfig.MaxLevel) {
InformSenderClient($"Cannot exceed max level ({MagicLevelsConfig.MaxLevel}).");
return;
}
var msg = new CHARACTER_103_PROTOCOL.MSG_LEVELUP() { NewLevel = newLevel };
Context.SessionActor.Tell(msg, null);
}
}Command Attributes
[Command("name")]
Defines the command name that players will type. This is the primary identifier for the command.
[Command("levelup")]
private void LevelUpCommand() { }[Command("levelup")]
private void LevelUpCommand() { }[Alias("alias1", "alias2")]
Provides alternative names for the same command. Useful for shortcuts or common variations.
[Command("levelup")]
[Alias("lvlup", "level-up")]
private void LevelUpCommand() { }[Command("levelup")]
[Alias("lvlup", "level-up")]
private void LevelUpCommand() { }[AuthRequired(AuthLevel)]
Restricts command access based on player authority level. Available levels:
AuthLevel.QualityAssurance- QA testersAuthLevel.Developer- Developers (debug builds only)AuthLevel.Administrator- Server administrators
[Command("speed")]
[AuthRequired(AuthLevel.QualityAssurance)]
private void SetSpeedCommand(string speedMultiplier) { }[Command("speed")]
[AuthRequired(AuthLevel.QualityAssurance)]
private void SetSpeedCommand(string speedMultiplier) { }[Remainder] Parameter Attribute
Combines all remaining command arguments into a single string parameter. Useful for commands that accept text with spaces.
[Command("announce")]
private void AnnounceCommand([Remainder] string message) {
// message contains all text after "announce"
}[Command("announce")]
private void AnnounceCommand([Remainder] string message) {
// message contains all text after "announce"
}Command Groups
Sub-Groups Structure
Commands are organized into logical groups based on functionality:
Modify Commands (mod)
- Character modification (level, speed, stats)
- Quick testing adjustments
- Development utilities
Spellbook Commands (sb)
- Spell learning and management
- Deck manipulation
- Magic school operations
Quest Commands (quest)
offer,grant,forcegrant- show a quest's offer dialog, or start a quest through the normal accept pathlist,info,show- list active quests and goals, or show one quest's goals and progresscompletegoal,completegoalfor,complete- complete the current goal or a whole quest throughQuestServiceremove- remove a quest (active or completed) and clear its registry entries so it can be offered again- The commands only send a
MSG_QUESTCOMMANDto the session;QuestServiceruns the action through its normal goal, quest and removal paths. The server does not know which quest the client tracks, so commands without a name use the only active quest.
DynaMod Commands (dynamod)
- Listing, setting, toggling and removing the character's dynamic mods
Debug Commands (debug)
- System information retrieval
- Position and state debugging
- Technical diagnostics
Cheat Commands (cheat)
win- instantly end the current duel as a player victorycinematic- toggle instant spell cinematics for the player's own duels (effects still resolve; only the cinematic pacing collapses)nofizzle- toggle spell fizzling off for the player's own casts (the accuracy roll always succeeds; dispel wards still apply)
Command Context
The CommandContext provides access to execution environment:
private void ExampleCommand() {
var character = Context.Character; // Player's Wizard object
var account = Context.Account; // Player's Account object
var sessionActor = Context.SessionActor; // Player's SessionActor reference
var charObject = Context.CharacterObject; // Player's game object
// Send message to client
InformSenderClient("Command executed successfully.");
}private void ExampleCommand() {
var character = Context.Character; // Player's Wizard object
var account = Context.Account; // Player's Account object
var sessionActor = Context.SessionActor; // Player's SessionActor reference
var charObject = Context.CharacterObject; // Player's game object
// Send message to client
InformSenderClient("Command executed successfully.");
}Parameter Handling
Commands automatically parse and validate parameters:
[Command("teleport")]
private void TeleportCommand(string zoneName, string location = "Start") {
// zoneName is required, location defaults to "Start"
}
[Command("give")]
private void GiveItemCommand(string itemId, string quantity) {
if (!uint.TryParse(itemId, out var itemIdUint)) {
InformSenderClient("Invalid item ID.");
return;
}
// Process command with validated parameters
}[Command("teleport")]
private void TeleportCommand(string zoneName, string location = "Start") {
// zoneName is required, location defaults to "Start"
}
[Command("give")]
private void GiveItemCommand(string itemId, string quantity) {
if (!uint.TryParse(itemId, out var itemIdUint)) {
InformSenderClient("Invalid item ID.");
return;
}
// Process command with validated parameters
}
Imlight