# Last Attacker

Grammar — Last unit that attacked unit
FlagsNative | Function

Returns the unit who last attacked the specified unit.

# Arguments

  • unit — Unit

Returns — unit

native unit AILastAttacker(unit u);

Category: AI Advanced / Tactical / Functions

# Examples

campaigns/swarm.sc2campaignbase.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.sc2campaignbase.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.sc2campaignbase.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.sc2mapMapScript.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.sc2mapMapScript.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.sc2mapMapScript.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.sc2campaignbase.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.sc2campaignbase.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.sc2campaignbase.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.sc2campaignbase.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.sc2campaignbase.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.sc2mapMapScript.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.sc2mapMapScript.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.sc2mapMapScript.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.sc2mapMapScript.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.sc2mapMapScript.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.sc2modbase.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;