# Unit Behavior
Grammar — unit behavior index
Flags —Native
|Function
Returns the behavior at the specified index on the specified unit.
# Arguments
unit
— Unitint
— Index
Returns — string
<gamelink::Behavior>
native string UnitBehaviorGet(unit inUnit, int inIndex);
# Related
Category: Behavior / Basic
- Remove Behaviors By Category —
void
— UnitBehaviorRemoveCategory - Remove Behavior (Player) —
void
— UnitBehaviorRemovePlayer - Remove Behavior —
void
— UnitBehaviorRemove - Add Behavior (Player) —
void
— UnitBehaviorAddPlayer - Add Behavior —
void
— UnitBehaviorAdd - Set Behavior Count —
void
— libNtve_gf_SetBehaviorCount - Number Of Behaviors On Unit —
int
— UnitBehaviorCountAll - Unit Behavior —
string
<gamelink::Behavior> — UnitBehaviorGet - Unit Has Behavior —
bool
— UnitHasBehavior2 - Unit Has Behavior (Enabled) —
bool
— UnitHasBehavior - Unit Behavior Enabled —
bool
— UnitBehaviorEnabled - Stack Count Of Behavior On Unit —
int
— UnitBehaviorCount - Behavior Has Flag —
bool
— UnitBehaviorHasFlag - Transfer Behavior —
void
— UnitBehaviorTransfer - Set Unit Behavior Duration —
void
— UnitBehaviorSetDuration - Set Unit Behavior Duration Remaining —
void
— UnitBehaviorSetDurationRemaining - Duration Remaining Of Behavior On Unit —
fixed
— UnitBehaviorDuration - Duration Of Behavior On Unit —
fixed
— UnitBehaviorDurationTotal - Set Unit Behavior Spawn Count —
void
— UnitBehaviorSpawn - Unit Behavior Effect Player —
int
— UnitBehaviorEffectPlayer - Unit Behavior Effect Unit —
unit
— UnitBehaviorEffectUnit - Set Unit Behavior User Data —
void
— UnitBehaviorEffectTreeSetUserData - User Data Of Behavior On Unit —
fixed
— UnitBehaviorEffectTreeUserData - User Data Of Behavior On Unit Exists —
bool
— UnitBehaviorEffectTreeUserDataExists - Unit Behavior Changes —
void
— TriggerAddEventUnitBehaviorChange - Unit Behavior Changes From Category —
void
— TriggerAddEventUnitBehaviorChangeFromCategory - Triggering Behavior —
string
<gamelink::Behavior> — EventUnitBehavior - Triggering Behavior Change —
int
<preset::BehaviorChange> — EventUnitBehaviorChange - Unit Behavior Damage Modify Remaining —
fixed
— UnitBehaviorDamageModifyRemaining - Unit Behavior Damage Modify Limit —
fixed
— UnitBehaviorDamageModifyLimit - For Each Behavior On Unit — macro
# Examples
mods/heroesdata.stormmod — base.stormdata/TriggerLibs/GameLib.galaxy:11730
lv_itBehavior = 1;
for ( ; lv_itBehavior <= auto70A8A24D_ae ; lv_itBehavior += 1 ) {
if ((UnitBehaviorHasCategoryFlag(UnitBehaviorGet(lv_itHeroUnit, lv_itBehavior), c_behaviorCategoryQuest) == true)) {
lv_removedBehavior = UnitBehaviorGet(lv_itHeroUnit, lv_itBehavior);
UnitBehaviorRemove(lv_itHeroUnit, lv_removedBehavior, 1);
mods/heroesdata.stormmod — base.stormdata/TriggerLibs/GameLib.galaxy:11731
for ( ; lv_itBehavior <= auto70A8A24D_ae ; lv_itBehavior += 1 ) {
if ((UnitBehaviorHasCategoryFlag(UnitBehaviorGet(lv_itHeroUnit, lv_itBehavior), c_behaviorCategoryQuest) == true)) {
lv_removedBehavior = UnitBehaviorGet(lv_itHeroUnit, lv_itBehavior);
UnitBehaviorRemove(lv_itHeroUnit, lv_removedBehavior, 1);
UnitBehaviorAdd(lv_itHeroUnit, lv_removedBehavior, lv_itHeroUnit, 1);
mods/heroesdata.stormmod — base.stormdata/TriggerLibs/HeroesLib.galaxy:2953
lv_itBehavior = UnitBehaviorCountAll(lp_targetUnit);
for ( ; ( (auto6DC7FEE5_ai >= 0 && lv_itBehavior <= auto6DC7FEE5_ae) || (auto6DC7FEE5_ai < 0 && lv_itBehavior >= auto6DC7FEE5_ae) ) ; lv_itBehavior += auto6DC7FEE5_ai ) {
lv_behavior = UnitBehaviorGet(lp_targetUnit, lv_itBehavior);
if ((CatalogFieldValueGetAsInt(c_gameCatalogBehavior, lv_behavior, "BehaviorFlags[" + IntToString(0) + "]", c_playerAny) != 1)) {
lv_behaviorsToBeRemovedCount += 1;
mods/heroesdata.stormmod — base.stormdata/TriggerLibs/SupportLib.galaxy:1711
lv_itBehavior = 1;
for ( ; ( (auto4FF55E2E_ai >= 0 && lv_itBehavior <= auto4FF55E2E_ae) || (auto4FF55E2E_ai < 0 && lv_itBehavior >= auto4FF55E2E_ae) ) ; lv_itBehavior += auto4FF55E2E_ai ) {
lv_tokenBehavior = UnitBehaviorGet(lv_itSelectedUnit, lv_itBehavior);
if ((CatalogFieldValueGet(c_gameCatalogBehavior, lv_tokenBehavior, "BehaviorCategories[" + IntToString(c_behaviorCategoryQuest) + "]", lp_player) == "1") && (lv_tokenBehavior != "AlarakSadismToken")) {
lv_tokensToAdd = lp_count;
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:3535
autoE98657EB_u = lp_parent;
autoE98657EB_i = 1;
for ( ; autoE98657EB_i <= UnitBehaviorCountAll(autoE98657EB_u) ; autoE98657EB_i += BoolToInt(lv_b == UnitBehaviorGet(autoE98657EB_u, autoE98657EB_i)) ) {
lv_b = UnitBehaviorGet(autoE98657EB_u, autoE98657EB_i);
lv_bstackcount = UnitBehaviorCount(lp_parent, lv_b);
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:3536
autoE98657EB_i = 1;
for ( ; autoE98657EB_i <= UnitBehaviorCountAll(autoE98657EB_u) ; autoE98657EB_i += BoolToInt(lv_b == UnitBehaviorGet(autoE98657EB_u, autoE98657EB_i)) ) {
lv_b = UnitBehaviorGet(autoE98657EB_u, autoE98657EB_i);
lv_bstackcount = UnitBehaviorCount(lp_parent, lv_b);
if ((CatalogFieldValueGetAsInt(c_gameCatalogBehavior, lv_b, "BehaviorCategories[" + IntToString(c_unitBehaviorFlagFast) + "]", c_playerAny) == 1)) {
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMU.galaxy:1666
lv_behaviorIndex = 1;
for ( ; ( (auto85BE7A0C_ai >= 0 && lv_behaviorIndex <= auto85BE7A0C_ae) || (auto85BE7A0C_ai < 0 && lv_behaviorIndex >= auto85BE7A0C_ae) ) ; lv_behaviorIndex += auto85BE7A0C_ai ) {
if (((UnitBehaviorGet(lp_killer, lv_behaviorIndex) == "") || (CatalogEntryScope(c_gameCatalogBehavior, UnitBehaviorGet(lp_killer, lv_behaviorIndex)) != "CBehaviorBuff"))) {
continue;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMU.galaxy:1666
lv_behaviorIndex = 1;
for ( ; ( (auto85BE7A0C_ai >= 0 && lv_behaviorIndex <= auto85BE7A0C_ae) || (auto85BE7A0C_ai < 0 && lv_behaviorIndex >= auto85BE7A0C_ae) ) ; lv_behaviorIndex += auto85BE7A0C_ai ) {
if (((UnitBehaviorGet(lp_killer, lv_behaviorIndex) == "") || (CatalogEntryScope(c_gameCatalogBehavior, UnitBehaviorGet(lp_killer, lv_behaviorIndex)) != "CBehaviorBuff"))) {
continue;
}
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMU.galaxy:1670
}
lv_creditor = CatalogFieldValueGet(c_gameCatalogBehavior, UnitBehaviorGet(lp_killer, lv_behaviorIndex), "KillCredit.Value", c_playerAny);
if ((lv_creditor != "Unknown")) {
auto09043CCB_val = lv_creditor;
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMU.galaxy:1690
else {
}
lv_actualKiller = UnitBehaviorEffectUnit(lp_killer, UnitBehaviorGet(lp_killer, lv_behaviorIndex), lv_creditorEffectUnit, 0);
break;
}
mods/warcoop/warclassicsystem.sc2mod — base.sc2data/TriggerLibs/WarClassicSystem.galaxy:494
lv_i = 1;
for ( ; ( (autoCFB9FEA6_ai >= 0 && lv_i <= autoCFB9FEA6_ae) || (autoCFB9FEA6_ai < 0 && lv_i >= autoCFB9FEA6_ae) ) ; lv_i += autoCFB9FEA6_ai ) {
lv_itBuff = UnitBehaviorGet(lv_caster, lv_i);
lv_itStack = UnitBehaviorCount(lv_caster, lv_itBuff);
lv_itStackExist = UnitBehaviorCount(lv_target, lv_itBuff);
mods/warcoop/warclassicsystem.sc2mod — base.sc2data/TriggerLibs/WarClassicSystem.galaxy:502
lv_i = 1;
for ( ; ( (auto8D9AF44D_ai >= 0 && lv_i <= auto8D9AF44D_ae) || (auto8D9AF44D_ai < 0 && lv_i >= auto8D9AF44D_ae) ) ; lv_i += auto8D9AF44D_ai ) {
lv_itBuff = UnitBehaviorGet(lv_caster, lv_i);
if ((CatalogEntryScope(c_gameCatalogBehavior, lv_itBuff) == "CBehaviorAttribute")) {
lv_itStack = UnitGetAttributePoint(lp_source, lv_itBuff, true);
mods/warcoop/warclassicsystem.sc2mod — base.sc2data/TriggerLibs/WarClassicSystem.galaxy:1349
auto37CC6DB9_u = lv_u;
auto37CC6DB9_i = 1;
for ( ; auto37CC6DB9_i <= UnitBehaviorCountAll(auto37CC6DB9_u) ; auto37CC6DB9_i += BoolToInt(lv_itBehavior == UnitBehaviorGet(auto37CC6DB9_u, auto37CC6DB9_i)) ) {
lv_itBehavior = UnitBehaviorGet(auto37CC6DB9_u, auto37CC6DB9_i);
if ((CatalogEntryScope(c_gameCatalogBehavior, lv_itBehavior) == "CBehaviorUnitTracker")) {
mods/warcoop/warclassicsystem.sc2mod — base.sc2data/TriggerLibs/WarClassicSystem.galaxy:1350
auto37CC6DB9_i = 1;
for ( ; auto37CC6DB9_i <= UnitBehaviorCountAll(auto37CC6DB9_u) ; auto37CC6DB9_i += BoolToInt(lv_itBehavior == UnitBehaviorGet(auto37CC6DB9_u, auto37CC6DB9_i)) ) {
lv_itBehavior = UnitBehaviorGet(auto37CC6DB9_u, auto37CC6DB9_i);
if ((CatalogEntryScope(c_gameCatalogBehavior, lv_itBehavior) == "CBehaviorUnitTracker")) {
lv_ug = UnitGetTrackedUnitGroup(lv_u, lv_itBehavior);