Skip to main content

Heroes

Namespace: DeadworksManaged.Api

Work with Deadlock hero identities, data, and selection.

Heroes Enum

Enum of all Deadlock hero identities. Use HeroTypeExtensions to convert between enum values and string names.

Heroes hero = Heroes.Inferno;

HeroTypeExtensions

Extension methods for the Heroes enum.

MethodReturnsDescription
ToHeroName(Heroes)stringConverts to internal name (e.g. "hero_inferno")
ToDisplayName(Heroes)stringConverts to localized display name (e.g. "Grey Talon" for Orion)
TryParse(string, out Heroes)boolParses name string back to enum
GetHeroData(Heroes)CitadelHeroData?Gets native VData for the hero

Examples

// Enum to string
string name = Heroes.Inferno.ToHeroName(); // "hero_inferno"

// String to enum
if (HeroTypeExtensions.TryParse("hero_inferno", out var hero))
{
Console.WriteLine($"Found hero: {hero}");
}

// Get hero data
var heroData = Heroes.Inferno.GetHeroData();

CitadelHeroData

Wrapper around native CitadelHeroData_t (VData). Obtain via Heroes.GetHeroData().

Properties

PropertyTypeDescription
IsValidboolWhether the hero data pointer is valid
HeroIDintInternal hero ID
DisabledboolWhether hero is disabled
PlayerSelectableboolWhether players can select this hero
InDevelopmentboolWhether hero is still in development
ComplexityintHero complexity rating
NewPlayerRecommendedboolRecommended for new players
AvailableInGameboolComputed — true if selectable, not disabled, not development-only

Methods

MethodReturnsDescription
GetField<T>(ReadOnlySpan<byte> fieldName)TRead any schema field by name at runtime

Hero Selection

Force a player to select a specific hero via CCitadelPlayerController:

controller.SelectHero(Heroes.Inferno);

Random Hero Assignment

var heroes = Enum.GetValues<Heroes>();
var randomHero = heroes[Random.Shared.Next(heroes.Length)];
controller.SelectHero(randomHero);

Precaching Heroes

Heroes must be precached if you're swapping them at runtime. See Precaching.

Deadworks currently automatically precaches all heroes.

See Also