-
Notifications
You must be signed in to change notification settings - Fork 0
GetStormElement (with id)
koliva8245 edited this page Jun 25, 2026
·
5 revisions
Example of getting a single xml element with an id of AmazonBlindingLight:
<CAbilEffectTarget id="AmazonBlindingLight">
...
<Effect value="AmazonBlindingLightInitialSet" />
<Flags index="ClearLastMoveTarget" value="1" />
<Flags index="RangeUseCasterRadius" value="0" />
<Flags index="RequireTargetVision" value="0" />
<Cost>
<Vital index="Energy" value="50" />
<Cooldown TimeUse="15" />
</Cost>
...
</CAbilEffectTarget>
HeroesData heroesData = heroesXmlLoader.HeroesData;
// get the dataObjectType for CAbilEffectTarget
// string? dataObjectType = heroesData.GetDataObjectTypeByElementType("CAbilEffectTarget"); // abil
// better to just hardcode the dataObjectType than to call GetDataObjectTypeByElementType
StormElement? amazonBlindingLightElement = heroesData.GetStormElement("abil", "AmazonBlindingLight");
// AmazonBlindingLightInitialSet
string? effectValue = amazonBlindingLightElement.DataValues.GetElementDataAt("Effect").Value.GetString();
StormElementData flagData = amazonBlindingLightElement.DataValues.GetElementDataAt("Flags");
// ClearLastMoveTarget, RangeUseCasterRadius, RequireTargetVision
IEnumerable<string> flagIndexes = flagData.GetElementDataIndexes();
// 1, 0, 0
foreach (string flagIndex in flagIndexes)
{
StormElementData flagElementData = flagData.GetElementDataAt(flagIndex);
string value = flagElementData.Value.GetString();
}
StormElementData costElement = amazonBlindingLightElement.DataValues.GetElementDataAt("Cost");
// 50
int costEnergyValue = costElement
.GetElementDataAt("Vital")
.GetElementDataAt("Energy")
.Value.GetInt();
// 15
int costCooldownTimeUseValue = costElement
.GetElementDataAt("Cooldown")
.GetElementDataAt("TimeUse")
.Value.GetInt();