# Last Attacker
Grammar — Last unit that attacked unit
Flags —Native
|Function
Returns the unit who last attacked the specified unit.
# Arguments
unit
— Unit
Returns — unit
native unit AILastAttacker(unit u);
# Related
Category: AI Advanced / Tactical / Functions
- Same Command —
bool
— AISameCommand - Last Attacker —
unit
— AILastAttacker - Last Attack —
int
— AILastAttack - Get Wants To Move Status —
bool
— AIControlWantsToMove - Is Ignored By Wave —
bool
— AIIsIgnoredByWave - Is In Combat —
bool
— AIUnitIsInCombat - Get Cloaked Attacker —
point
— AIGetCloakedAttacker - Get Best Target Point On Group —
point
— AIBestTargetPoint - Find Units —
unitgroup
— AIFindUnits - Get Default Combat Priority —
unit
— AIDefaultCombatPriority - Combat Diff Flag Special High Priority —
bool
— AICombatDiffFlagCatSpecialHighPrio - Combat Diff Flag Splash High Priority —
bool
— AICombatDiffFlagCatSplashHighPrio - Combat Diff Flag Timed Low Priority —
bool
— AICombatDiffFlagCatTimedLowPrio - Combat Diff Flag Workers Normal Priority —
bool
— AICombatDiffFlagCatWorkersNormalPrio - Combat Diff Flag Sort Buildings Priority —
bool
— AICombatDiffFlagCatSortBuildingsPrio - Combat Diff Flag Healers —
bool
— AICombatDiffFlagTieBreakHealers - Combat Diff Flag Low Health —
bool
— AICombatDiffFlagTieBreakLowHP - Combat Diff Flag Bonus Damage —
bool
— AICombatDiffFlagTieBreakBonusDamage - Combat Diff Flag Injured —
bool
— AICombatDiffFlagTieBreakInjured - Combat Diff Flag Detector —
bool
— AICombatDiffFlagTieBreakDetector - Combat Diff Flag Siege Range —
bool
— AICombatDiffFlagTieBreakRange - Does Unit Have Tactical Disabled —
bool
— AIIsTacticalDisabled
# Examples
campaigns/swarm.sc2campaign — base.sc2maps/maps/campaign/swarm/zchar03.sc2map/MapScript.galaxy:451
libSwaC_gf_AttachReticleEffectAndTextTagOnUnit(libSwaC_ge_CampaginReticleType_ZergEnemy, libSwaC_ge_CampaginReticleSize_Large, null, lp_uNIT, "Ref_Center");
lv_reticle = libNtve_gf_ActorLastCreated();
while (!(((AILastAttacker(lp_uNIT) != null) || (UnitIsAlive(lp_uNIT) == false)))) {
Wait(0.3, c_timeGame);
}
campaigns/swarm.sc2campaign — base.sc2maps/maps/campaign/swarm/zexpedition02.sc2map/MapScript.galaxy:2288
lv_shuttle = gv_shuttleUnit;
libSwaC_gf_AttachReticleEffectAndTextTagOnUnit(libSwaC_ge_CampaginReticleType_ZergEnemy, libSwaC_ge_CampaginReticleSize_Large, null, lv_shuttle, "Ref_Center");
while (!((AILastAttacker(lv_shuttle) != null))) {
Wait(1.0, c_timeGame);
}
campaigns/swarm.sc2campaign — base.sc2maps/maps/campaign/swarm/zhybrid02.sc2map/MapScript.galaxy:1030
}
lv_lastAttacker = AILastAttacker(lp_hybrid);
if ((gv_aIHybridAttacker[lv_indexHybrid] != null) && (UnitIsAlive(gv_aIHybridAttacker[lv_indexHybrid]) == true)) {
if ((lv_lastAttacker != null) && (UnitIsAlive(lv_lastAttacker) == true) && ((FixedToInt(GameGetMissionTime()) - AILastAttack(lp_hybrid)) < 5)) {
campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/zchar03.sc2map — MapScript.galaxy:451
libSwaC_gf_AttachReticleEffectAndTextTagOnUnit(libSwaC_ge_CampaginReticleType_ZergEnemy, libSwaC_ge_CampaginReticleSize_Large, null, lp_uNIT, "Ref_Center");
lv_reticle = libNtve_gf_ActorLastCreated();
while (!(((AILastAttacker(lp_uNIT) != null) || (UnitIsAlive(lp_uNIT) == false)))) {
Wait(0.3, c_timeGame);
}
campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/zexpedition02.sc2map — MapScript.galaxy:2288
lv_shuttle = gv_shuttleUnit;
libSwaC_gf_AttachReticleEffectAndTextTagOnUnit(libSwaC_ge_CampaginReticleType_ZergEnemy, libSwaC_ge_CampaginReticleSize_Large, null, lv_shuttle, "Ref_Center");
while (!((AILastAttacker(lv_shuttle) != null))) {
Wait(1.0, c_timeGame);
}
campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/zhybrid02.sc2map — MapScript.galaxy:1030
}
lv_lastAttacker = AILastAttacker(lp_hybrid);
if ((gv_aIHybridAttacker[lv_indexHybrid] != null) && (UnitIsAlive(gv_aIHybridAttacker[lv_indexHybrid]) == true)) {
if ((lv_lastAttacker != null) && (UnitIsAlive(lv_lastAttacker) == true) && ((FixedToInt(GameGetMissionTime()) - AILastAttack(lp_hybrid)) < 5)) {
campaigns/void.sc2campaign — base.sc2maps/maps/campaign/void/pkorhal02.sc2map/MapScript.galaxy:439
// Implementation
while ((UnitIsAlive(lp_hybrid) == true) && (libVCMI_gf_GameIsOver() == false)) {
lv_lastAttacker = AILastAttacker(lp_hybrid);
lv_enemyGroup9 = UnitGroupAlliance(UnitGetOwner(lp_hybrid), c_unitAllianceEnemy, RegionCircle(UnitGetPosition(lp_hybrid), 9.0), UnitFilter(0, 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile) | (1 << c_targetFilterBuried), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterInvulnerable - 32))), 0);
if ((UnitCheckAbilCmdState(lp_hybrid, AbilityCommand("HybridDominatorVoidPlasmaBlast", 0), c_cmdStateCooldown) == false)) {
campaigns/void.sc2campaign — base.sc2maps/maps/campaign/void/ptaldarim02.sc2map/MapScript.galaxy:937
// Implementation
while ((UnitIsAlive(lp_hybrid) == true) && (libVCMI_gf_GameIsOver() == false)) {
lv_lastAttacker = AILastAttacker(lp_hybrid);
lv_enemyGroup9 = UnitGroupAlliance(UnitGetOwner(lp_hybrid), c_unitAllianceEnemy, RegionCircle(UnitGetPosition(lp_hybrid), 9.0), UnitFilter(0, 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile) | (1 << c_targetFilterBuried), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterInvulnerable - 32))), 0);
if ((UnitCheckAbilCmdState(lp_hybrid, AbilityCommand("HybridDominatorVoidPlasmaBlast", 0), c_cmdStateCooldown) == false)) {
campaigns/void.sc2campaign — base.sc2maps/maps/campaign/void/pulnar03.sc2map/MapScript.galaxy:873
AISetUnitScriptControlled(lp_hybrid, false);
while ((UnitIsAlive(lp_hybrid) == true) && (libVCMI_gf_GameIsOver() == false)) {
lv_lastAttacker = AILastAttacker(lp_hybrid);
lv_enemyGroup9 = UnitGroupAlliance(UnitGetOwner(lp_hybrid), c_unitAllianceEnemy, RegionCircle(UnitGetPosition(lp_hybrid), 9.0), UnitFilter(0, 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile) | (1 << c_targetFilterBuried), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterInvulnerable - 32))), 0);
if ((UnitCheckAbilCmdState(lp_hybrid, AbilityCommand("HybridDominatorVoidPlasmaBlast", 0), c_cmdStateCooldown) == false)) {
campaigns/void.sc2campaign — base.sc2maps/maps/campaign/void/sc2epilogue01.sc2map/MapScript.galaxy:4927
while ((libVCMI_gf_GameIsOver() == false)) {
if ((libVCMI_gf_PlayerInCinematicModeCampaign() == false) && (UnitIsAlive(gv_stukov) == true)) {
lv_lastAttacker = AILastAttacker(gv_stukov);
lv_candidates = gf_EnemiesWithinStukovRange(gv_stukov, 10.0, UnitFilter(0, 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))));
auto436C441D_g = lv_candidates;
campaigns/void.sc2campaign — base.sc2maps/maps/campaign/void/sc2epilogue01.sc2map/MapScript.galaxy:5147
while ((libVCMI_gf_GameIsOver() == false)) {
if ((libVCMI_gf_PlayerInCinematicModeCampaign() == false) && (UnitIsAlive(gv_kerrigan) == true)) {
lv_lastAttacker = AILastAttacker(gv_kerrigan);
lv_candidates = gf_EnemiesWithinKerriganRange(gv_kerrigan, 10.0, UnitFilter(0, 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))));
auto5C87A617_g = lv_candidates;
campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/pkorhal02.sc2map — MapScript.galaxy:439
// Implementation
while ((UnitIsAlive(lp_hybrid) == true) && (libVCMI_gf_GameIsOver() == false)) {
lv_lastAttacker = AILastAttacker(lp_hybrid);
lv_enemyGroup9 = UnitGroupAlliance(UnitGetOwner(lp_hybrid), c_unitAllianceEnemy, RegionCircle(UnitGetPosition(lp_hybrid), 9.0), UnitFilter(0, 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile) | (1 << c_targetFilterBuried), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterInvulnerable - 32))), 0);
if ((UnitCheckAbilCmdState(lp_hybrid, AbilityCommand("HybridDominatorVoidPlasmaBlast", 0), c_cmdStateCooldown) == false)) {
campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/ptaldarim02.sc2map — MapScript.galaxy:937
// Implementation
while ((UnitIsAlive(lp_hybrid) == true) && (libVCMI_gf_GameIsOver() == false)) {
lv_lastAttacker = AILastAttacker(lp_hybrid);
lv_enemyGroup9 = UnitGroupAlliance(UnitGetOwner(lp_hybrid), c_unitAllianceEnemy, RegionCircle(UnitGetPosition(lp_hybrid), 9.0), UnitFilter(0, 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile) | (1 << c_targetFilterBuried), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterInvulnerable - 32))), 0);
if ((UnitCheckAbilCmdState(lp_hybrid, AbilityCommand("HybridDominatorVoidPlasmaBlast", 0), c_cmdStateCooldown) == false)) {
campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/pulnar03.sc2map — MapScript.galaxy:873
AISetUnitScriptControlled(lp_hybrid, false);
while ((UnitIsAlive(lp_hybrid) == true) && (libVCMI_gf_GameIsOver() == false)) {
lv_lastAttacker = AILastAttacker(lp_hybrid);
lv_enemyGroup9 = UnitGroupAlliance(UnitGetOwner(lp_hybrid), c_unitAllianceEnemy, RegionCircle(UnitGetPosition(lp_hybrid), 9.0), UnitFilter(0, 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile) | (1 << c_targetFilterBuried), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterInvulnerable - 32))), 0);
if ((UnitCheckAbilCmdState(lp_hybrid, AbilityCommand("HybridDominatorVoidPlasmaBlast", 0), c_cmdStateCooldown) == false)) {
campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/sc2epilogue01.sc2map — MapScript.galaxy:4927
while ((libVCMI_gf_GameIsOver() == false)) {
if ((libVCMI_gf_PlayerInCinematicModeCampaign() == false) && (UnitIsAlive(gv_stukov) == true)) {
lv_lastAttacker = AILastAttacker(gv_stukov);
lv_candidates = gf_EnemiesWithinStukovRange(gv_stukov, 10.0, UnitFilter(0, 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))));
auto436C441D_g = lv_candidates;
campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void/sc2epilogue01.sc2map — MapScript.galaxy:5147
while ((libVCMI_gf_GameIsOver() == false)) {
if ((libVCMI_gf_PlayerInCinematicModeCampaign() == false) && (UnitIsAlive(gv_kerrigan) == true)) {
lv_lastAttacker = AILastAttacker(gv_kerrigan);
lv_candidates = gf_EnemiesWithinKerriganRange(gv_kerrigan, 10.0, UnitFilter(0, 0, (1 << c_targetFilterStructure) | (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))));
auto5C87A617_g = lv_candidates;
mods/starcoop/starcoop.sc2mod — base.sc2data/LibCOMI.galaxy:13153
lv_attackWaveUnitIter = UnitGroupUnitFromEnd(autoADEF27AE_g, autoADEF27AE_u);
if (lv_attackWaveUnitIter == null) { break; }
lv_lastAttacker = AILastAttacker(lv_attackWaveUnitIter);
if ((lv_lastAttacker != null) && (UnitFilterMatch(lv_lastAttacker, UnitGetOwner(lv_attackWaveUnitIter), UnitFilter((1 << c_targetFilterCloaked), 0, (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)))) == true)) {
libCOMI_gv_cM_CoopAI_AIDetection_AttackWaveAddDetection = true;