# Set Unit Custom Value
Grammar — Set u custom value index to val
Flags —Native
|Action
Sets a unit’s custom value. This is an arbitrary property that can be recalled using “Custom Value Of Unit”.
# Arguments
unit
— Unitint
— Indexfixed
— Value
Returns — void
native void UnitSetCustomValue(
unit inUnit,
int inIndex,
fixed inVal,
);
# Related
Category: Unit / Basic
- [F] —
void
— Unit Show Kill Display — ( UnitShowKillDisplay ) - [F] —
bool
— Unit Can Path To Point — ( UnitPathableToPoint ) - [F] —
bool
— Unit Can Path To Unit — ( UnitPathableToUnit ) - [F] —
void
— Create Units With Default Facing — ( libNtve_gf_CreateUnitsWithDefaultFacing ) - [F] —
void
— Create Units With Point Facing — ( libNtve_gf_CreateUnitsAtPoint2 ) - [F] —
unitgroup
— Create Units Facing Angle — ( UnitCreate ) - [F] —
unitgroup
— Create Units Facing Point — ( libNtve_gf_UnitCreateFacingPoint ) - [F] —
unit
— Last Created Unit — ( UnitLastCreated ) - [F] —
unitgroup
— Last Created Units — ( UnitLastCreatedGroup ) - [F] —
unit
— Original Caster Of Unit — ( UnitGetOriginalCaster ) - [F] —
string
[ gamelink::Effect ] — Effect That Created Unit — ( UnitGetOriginalEffect ) - [F] —
void
— Replace Unit — ( libNtve_gf_ReplaceUnit ) - [F] —
unit
— Last Replaced Unit — ( libNtve_gf_LastReplacedUnit ) - [F] —
void
— Change Owner — ( UnitSetOwner ) - [F] —
void
— Unit Owner Changes — ( TriggerAddEventUnitChangeOwner ) - [F] —
int
— Old Unit Owner — ( EventUnitOwnerOld ) - [F] —
int
— New Unit Owner — ( EventUnitOwnerNew ) - [F] —
void
— Rescue Unit — ( libNtve_gf_RescueUnit ) - [F] —
void
— Rescue Unit Group — ( libNtve_gf_RescueUnit2 ) - [F] —
void
— Kill Unit — ( UnitKill ) - [F] —
void
— Revive Unit — ( UnitRevive ) - [F] —
void
— Remove Unit — ( UnitRemove ) - [F] —
int
— Owner Of Unit — ( UnitGetOwner ) - [F] —
bool
— Unit Is Alive — ( UnitIsAlive ) - [F] —
bool
— Unit Is Valid — ( UnitIsValid ) - [F] —
bool
— Unit Group Is Dead — ( libNtve_gf_UnitGroupIsDead ) - [F] —
void
— Move Unit Instantly — ( UnitSetPosition ) - [F] —
void
— Make Unit Face Angle — ( UnitSetFacing ) - [F] —
void
— Make Unit Face Point — ( libNtve_gf_MakeUnitFacePoint ) - [F] —
point
— Position Of Unit — ( UnitGetPosition ) - [F] —
point
— Goal Position Of Unit — ( UnitGetGoalPosition ) - [F] —
fixed
— Facing Angle Of Unit — ( UnitGetFacing ) - [F] —
void
— Pause/Unpause Unit — ( libNtve_gf_PauseUnit ) - [F] —
void
— Pause/Unpause All Units — ( UnitPauseAll ) - [F] —
void
— Sleep/WakeUp Unit — ( libNtve_gf_SleepUnit ) - [F] —
void
— Show/Hide Unit — ( libNtve_gf_ShowHideUnit ) - [F] —
void
— Share Vision of Unit — ( libNtve_gf_ShareVisionofUnit ) - [F] —
bool
— Unit Is Paused — ( libNtve_gf_UnitIsPaused ) - [F] —
bool
— Unit Is Sleepiing — ( libNtve_gf_UnitIsSleepiing ) - [F] —
bool
— Unit Is Hidden — ( libNtve_gf_UnitIsHidden ) - [F] —
bool
— Unit Is Visible To Player — ( libNtve_gf_UnitIsVisibleToPlayer ) - [F] —
void
— Set Unit Custom Value — ( UnitSetCustomValue ) - [F] —
fixed
— Custom Value Of Unit — ( UnitGetCustomValue ) - [F] —
void
— Unit Enters/Leaves Region — ( TriggerAddEventUnitRegion ) - [F] —
region
— Triggering Region — ( EventUnitRegion ) - [F] —
void
— Unit Enters/Leaves Point — ( TriggerAddEventUnitRangePoint ) - [F] —
void
— Unit Enters/Leaves Range Of Unit — ( TriggerAddEventUnitRange ) - [F] —
unit
— Triggering Range Unit — ( EventUnitRangeUnit ) - [F] —
bool
— Unit In Region — ( libNtve_gf_UnitInRegion ) - [F] —
unit
— Triggering Unit — ( EventUnit ) - [F] —
void
— Load Unit Model — ( UnitLoadModel ) - [F] —
void
— Unload Unit Model — ( UnitUnloadModel ) - [F] —
unit
— Agent Of Player For Unit — ( UnitAgent ) - [F] —
void
— Change Empty Unit Variables In Events — ( UnitEventSetNullVariableInvalid ) - [F] —
text
— Name of Unit — ( UnitGetName ) - [F] —
int
— Ideal Harvester Count — ( UnitIdealWorkerCount ) - [F] —
int
— Current Harvester Count — ( UnitCurrentWorkerCount )
# Examples
# campaigns/liberty.sc2campaign
// L6349
UnitSetCustomValue(lv_plane, 0, 1.0)
// L2233
UnitSetCustomValue(auto2248E752_var, 0, 21.0)
// L2241
UnitSetCustomValue(autoF40515E8_var, 0, 21.0)
// L2249
UnitSetCustomValue(auto8267D447_var, 0, 21.0)
// L2257
UnitSetCustomValue(autoE2AC6924_var, 0, 21.0)
// L2500
UnitSetCustomValue(lv_pickedUnit, 0, IntToFixed((lv_customIntValueOfUnit - 1)))
// L2507
UnitSetCustomValue(lv_pickedUnit, 0, IntToFixed((lv_customIntValueOfUnit - 1)))
// L3724
UnitSetCustomValue(EventUnit(), 0, 0.0)
// L3731
UnitSetCustomValue(autoE914C699_var, 0, 0.0)
// L3736
UnitSetCustomValue(EventUnit(), 0, 100.0)
// L3749
UnitSetCustomValue(EventUnit(), 0, 0.0)
// L332
UnitSetCustomValue(lp_attackedStructure, 0, gv_nightDefenderCooldown)
// L1456
UnitSetCustomValue(EventUnit(), 0, (UnitGetCustomValue(EventUnit(), 0) + 1.0))
// L1836
UnitSetCustomValue(autoE55A534E_var, 2, IntToFixed(lv_i))
// L2007
UnitSetCustomValue(gv_infestableStructure[lv_index], 0, (UnitGetCustomValue(gv_infestableStructure[lv_index], 0) - 1.0))
// L2845
UnitSetCustomValue(EventUnitProgressUnit(), 1, 1.0)
// L2853
UnitSetCustomValue(EventUnitProgressUnit(), 1, 1.0)
// L362
UnitSetCustomValue(gv_infestationVirophageUnit[lp_colonyIndex], 1, IntToFixed(lp_colonyIndex))
// L632
UnitSetCustomValue(UnitCargoLastCreated(), 1, IntToFixed(lp_colonyIndex))
// L796
UnitSetCustomValue(UnitLastCreated(), (ge_UnitData_udEggType), IntToFixed((lp_type)))
// L797
UnitSetCustomValue(UnitLastCreated(), (ge_UnitData_udEggScale), gv_eGG_SIZE_BASE)
// L798
UnitSetCustomValue(UnitLastCreated(), (ge_UnitData_udEggColony), IntToFixed(lp_colonyIndex))
// L1510
UnitSetCustomValue(gv_infestationVirophageUnit[lv_colonyIndex], 1, IntToFixed(lv_colonyIndex))
// L2080
UnitSetCustomValue(autoB51C2030_var, (ge_UnitData_udEggScale), lv_eggScale)
// L571
UnitSetCustomValue(UnitLastCreated(), 0, IntToFixed(lv_currentTarget))
// L600
UnitSetCustomValue(UnitLastCreated(), 0, IntToFixed(lv_currentTarget))
// L1922
UnitSetCustomValue(UnitLastCreated(), 0, IntToFixed(lv_initialCustomValue))
// L2150
UnitSetCustomValue(auto499A4BF2_var, 0, (UnitGetCustomValue(auto499A4BF2_var, 0) + 1.0))
// L3297
UnitSetCustomValue(auto5F63F107_var, 0, 2.0)
// L1218
UnitSetCustomValue(UnitFromId(2), 1, UnitGetPropertyFixed(UnitFromId(2), c_unitPropLifeMax, c_unitPropNormal))
// L4412
UnitSetCustomValue(EventUnit(), 1, UnitGetPropertyFixed(EventUnit(), c_unitPropLife, c_unitPropCurrent))
// L5739
UnitSetCustomValue(lv_door, 0, (UnitGetCustomValue(lv_door, 0) + 1.0))
// L1081
UnitSetCustomValue(autoB474868C_var, 1, 99.0)
// L1088
UnitSetCustomValue(autoA6654341_var, 1, 99.0)
// L1363
UnitSetCustomValue(autoC0A4CB95_var, 0, 99.0)
// L1449
UnitSetCustomValue(UnitLastCreated(), 1, 99.0)
// L1459
UnitSetCustomValue(UnitLastCreated(), 1, 99.0)
// L1469
UnitSetCustomValue(UnitLastCreated(), 1, 99.0)
// L1479
UnitSetCustomValue(UnitLastCreated(), 1, 99.0)
// L1489
UnitSetCustomValue(UnitLastCreated(), 1, 99.0)
// L1499
UnitSetCustomValue(UnitLastCreated(), 1, 99.0)
// L1509
UnitSetCustomValue(UnitLastCreated(), 1, 99.0)
// L2555
UnitSetCustomValue(lv_scientist, 0, 1.0)
// L2615
UnitSetCustomValue(lv_scientist, 0, 1.0)
// L2671
UnitSetCustomValue(lv_scientist, 0, 1.0)
// L2727
UnitSetCustomValue(lv_scientist, 0, 1.0)
// L2775
UnitSetCustomValue(lv_scientist, 0, 0.0)
// L9754
UnitSetCustomValue(lv_egg, 0, 1.0)
// L2443
UnitSetCustomValue(lp_unit, (ge_CustomDataIndex_CustomDataIndexClickableRoom), IntToFixed((lp_room)))
// L2493
UnitSetCustomValue(lp_unit, (ge_CustomDataIndex_CustomDataIndexClickableLock), lv_value)
// L9566
UnitSetCustomValue(lp_unit, (ge_CustomDataIndex_CustomDataIndexFlashingData), IntToFixed(gv_hotspots_FlashingTextTagCount))
// L9854
UnitSetCustomValue(lp_unit, (ge_CustomDataIndex_CustomDataIndexFlashingData), 0.0)
// L1175
UnitSetCustomValue(lv_u, 0, 1.0)
// L1236
UnitSetCustomValue(lv_u, 1, PointGetX(UnitGetPosition(lv_u)))
// L1237
UnitSetCustomValue(lv_u, 2, PointGetY(UnitGetPosition(lv_u)))
// L325
UnitSetCustomValue(lv_harvestingProbe, 2, IntToFixed(lv_targetTerrazineIndex))
// L326
UnitSetCustomValue(lv_harvestingProbe, 3, IntToFixed(lp_secondaryRegionSearchIndex))
// L787
UnitSetCustomValue(UnitFromId(34), 0, 1.0)
// L789
UnitSetCustomValue(UnitFromId(70), 0, 2.0)
// L791
UnitSetCustomValue(UnitFromId(78), 0, 3.0)
// L793
UnitSetCustomValue(UnitFromId(35), 0, 4.0)
// L795
UnitSetCustomValue(UnitFromId(24), 0, 5.0)
// L797
UnitSetCustomValue(UnitFromId(81), 0, 6.0)
// L799
UnitSetCustomValue(UnitFromId(27), 0, 7.0)
// L801
UnitSetCustomValue(UnitFromId(30), 0, 8.0)
// L770
UnitSetCustomValue(autoA878FA45_var, 0, DistanceBetweenPoints(UnitGetPosition(autoA878FA45_var), PointFromId(1140)))
// L771
UnitSetCustomValue(autoA878FA45_var, 1, AngleBetweenPoints(PointFromId(1140), UnitGetPosition(autoA878FA45_var)))
// L2406
UnitSetCustomValue(auto395C2B50_var, 0, PointGetX(UnitGetPosition(auto395C2B50_var)))
// L2407
UnitSetCustomValue(auto395C2B50_var, 1, PointGetY(UnitGetPosition(auto395C2B50_var)))
// L2419
UnitSetCustomValue(auto67BD9FEE_var, 0, PointGetX(lv_randomPoint))
// L2420
UnitSetCustomValue(auto67BD9FEE_var, 1, PointGetY(lv_randomPoint))
// L2653
UnitSetCustomValue(auto1BE7B4F4_var, 0, PointGetX(UnitGetPosition(auto1BE7B4F4_var)))
// L2654
UnitSetCustomValue(auto1BE7B4F4_var, 1, PointGetY(UnitGetPosition(auto1BE7B4F4_var)))
// L2666
UnitSetCustomValue(auto0F10452F_var, 0, PointGetX(lv_randomPoint))
// L2667
UnitSetCustomValue(auto0F10452F_var, 1, PointGetY(lv_randomPoint))
// L2492
UnitSetCustomValue(lv_tempSpineCrawler, 0, 2.0)
// L2758
UnitSetCustomValue(EventUnit(), 0, PointGetX(lv_randomPoint))
// L2759
UnitSetCustomValue(EventUnit(), 1, PointGetY(lv_randomPoint))
// L2798
UnitSetCustomValue(autoB111683E_var, 0, PointGetX(lv_randomPoint))
// L2799
UnitSetCustomValue(autoB111683E_var, 1, PointGetY(lv_randomPoint))
// L800
UnitSetCustomValue(UnitFromId(317), 0, (UnitGetCustomValue(UnitFromId(317), 0) + 1.0))
// L1064
UnitSetCustomValue(gv_siegeTankDropship, 0, (UnitGetCustomValue(gv_siegeTankDropship, 0) + 1.0))
// L3655
UnitSetCustomValue(EventUnit(), 0, 2.0)
// L3666
UnitSetCustomValue(EventUnit(), 0, 0.0)
// L3736
UnitSetCustomValue(lv_transferUnit, 0, 2.0)
// L3746
UnitSetCustomValue(lv_transferUnit, 0, 0.0)
// L3815
UnitSetCustomValue(lv_transferUnit, 0, 2.0)
// L3825
UnitSetCustomValue(lv_transferUnit, 0, 0.0)
// L824
UnitSetCustomValue(lv_u, 0, PointGetX(UnitGetPosition(lv_u)))
// L825
UnitSetCustomValue(lv_u, 1, PointGetY(UnitGetPosition(lv_u)))
// L2438
UnitSetCustomValue(autoDAD5E4FA_var, 0, IntToFixed(UnitGroupCount(UnitGroupAlliance(gv_pLAYER_02_ScriptedTOSS, c_unitAllianceEnemy, RegionCircle(UnitGetPosition(autoDAD5E4FA_var), 2.0), UnitFilter(0, 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterRawResource) | (1 << c_targetFilterMissile) | (1 << c_targetFilterDestructible), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterInvulnerable - 32)) | (1 << (c_targetFilterBenign - 32))), 0), c_unitCountAlive)))
// L6796
UnitSetCustomValue(auto074C9372_var, 0, PointGetX(lv_randomSpot))
// L6797
UnitSetCustomValue(auto074C9372_var, 1, PointGetY(lv_randomSpot))
// L6811
UnitSetCustomValue(auto4771A35A_var, 0, PointGetX(lv_randomSpot))
// L6812
UnitSetCustomValue(auto4771A35A_var, 1, PointGetY(lv_randomSpot))
// L6884
UnitSetCustomValue(UnitLastCreated(), 0, PointGetX(lv_randomSpot))
// L6885
UnitSetCustomValue(UnitLastCreated(), 1, PointGetY(lv_randomSpot))
// L5699
UnitSetCustomValue(UnitLastCreated(), 0, 1.0)
// L5704
UnitSetCustomValue(UnitLastCreated(), 0, 2.0)
// L5709
UnitSetCustomValue(UnitLastCreated(), 0, 3.0)