# Last Replaced Unit

Grammar — Last replaced unit
FlagsFunction

Returns the last replacement unit created via “Replace Unit”.

Returns — unit

unit libNtve_gf_LastReplacedUnit();

Category: Unit / Basic

# Examples

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/evolution/zevolutionhydralisk.sc2map/MapScript.galaxy:1230

        if ((UnitGetType(UnitGroupLoopCurrent()) == "HydraliskBurrowed")) {
            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Hydralisk", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphHydraliskToHydraliskImpaler", 0)), c_orderQueueReplace);
        }

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/evolution/zevolutionhydralisk.sc2map/MapScript.galaxy:1231

            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Hydralisk", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphHydraliskToHydraliskImpaler", 0)), c_orderQueueReplace);
        }
        else {

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/evolution/zevolutionmutalisk.sc2map/MapScript.galaxy:961

            if ((TriggerIsEnabled(gt_ObjectiveCollectBroodLordEssenceComplete) == false)) {
                libNtve_gf_ReplaceUnit(EventUnit(), "MutaliskBroodlord", libNtve_ge_ReplaceUnitOptions_NewUnitssMax);
                UnitGroupAdd(gv_mutaliskGroup, libNtve_gf_LastReplacedUnit());
            }
            else {

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/evolution/zevolutionmutalisk.sc2map/MapScript.galaxy:4209

    for ( ; !UnitGroupLoopDone() ; UnitGroupLoopStep() ) {
        libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Viper", libNtve_ge_ReplaceUnitOptions_NewUnitssMax);
        UnitGroupAdd(gv_viperGroup, libNtve_gf_LastReplacedUnit());
    }
    UnitGroupLoopEnd();

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/evolution/zevolutionroach.sc2map/MapScript.galaxy:1085

        if ((UnitGetType(UnitGroupLoopCurrent()) == "RoachBurrowed")) {
            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Roach", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphRoachToCorpser", 0)), c_orderQueueReplace);
        }

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/evolution/zevolutionroach.sc2map/MapScript.galaxy:1086

            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Roach", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphRoachToCorpser", 0)), c_orderQueueReplace);
        }
        else {

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/evolution/zevolutionswarmhost.sc2map/MapScript.galaxy:879

        if (((UnitGetType(UnitGroupLoopCurrent()) == "SwarmHostRooted") || (UnitGetType(UnitGroupLoopCurrent()) == "SwarmHostBurrowed"))) {
            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "SwarmHost", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphSwarmHostToSplitA", 0)), c_orderQueueReplace);
        }

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/evolution/zevolutionswarmhost.sc2map/MapScript.galaxy:880

            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "SwarmHost", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphSwarmHostToSplitA", 0)), c_orderQueueReplace);
        }
        else {

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/evolution/zevolutionswarmhost.sc2map/MapScript.galaxy:1624

        if (((UnitGetType(UnitGroupLoopCurrent()) == "SwarmHostRooted") || (UnitGetType(UnitGroupLoopCurrent()) == "SwarmHostBurrowed"))) {
            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "SwarmHost", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphSwarmHostToSplitB", 0)), c_orderQueueReplace);
        }

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/evolution/zevolutionswarmhost.sc2map/MapScript.galaxy:1625

            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "SwarmHost", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphSwarmHostToSplitB", 0)), c_orderQueueReplace);
        }
        else {

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/evolution/zevolutionultralisk.sc2map/MapScript.galaxy:1311

        if ((UnitGetType(UnitGroupLoopCurrent()) == "UltraliskBurrowed")) {
            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Ultralisk", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphUltraliskToNoxious", 0)), c_orderQueueReplace);
        }

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/evolution/zevolutionultralisk.sc2map/MapScript.galaxy:1312

            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Ultralisk", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphUltraliskToNoxious", 0)), c_orderQueueReplace);
        }
        else {

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/evolution/zevolutionultralisk.sc2map/MapScript.galaxy:2130

        if ((UnitGetType(UnitGroupLoopCurrent()) == "UltraliskBurrowed")) {
            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Ultralisk", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphUltraliskToTorrasque", 0)), c_orderQueueReplace);
        }

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/evolution/zevolutionultralisk.sc2map/MapScript.galaxy:2131

            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Ultralisk", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphUltraliskToTorrasque", 0)), c_orderQueueReplace);
        }
        else {

campaigns/swarm.sc2campaignbase.sc2maps/maps/campaign/swarm/zlab01.sc2map/MapScript.galaxy:10698

    UnitIssueOrder(UnitFromId(114), OrderTargetingUnit(AbilityCommand("attack", 0), UnitFromId(515)), c_orderQueueReplace);
    libNtve_gf_ReplaceUnit(gv_mainDoor, "UmojanLabDoorsThinRightLowered", libNtve_ge_ReplaceUnitOptions_OldUnitsRelative);
    gv_mainDoor = libNtve_gf_LastReplacedUnit();
    UIAlertClear(gv_pLAYER_01_USER);
    TriggerExecute(gt_StartAI, true, false);

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/evolution/zevolutionhydralisk.sc2mapMapScript.galaxy:1230

        if ((UnitGetType(UnitGroupLoopCurrent()) == "HydraliskBurrowed")) {
            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Hydralisk", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphHydraliskToHydraliskImpaler", 0)), c_orderQueueReplace);
        }

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/evolution/zevolutionhydralisk.sc2mapMapScript.galaxy:1231

            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Hydralisk", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphHydraliskToHydraliskImpaler", 0)), c_orderQueueReplace);
        }
        else {

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/evolution/zevolutionmutalisk.sc2mapMapScript.galaxy:961

            if ((TriggerIsEnabled(gt_ObjectiveCollectBroodLordEssenceComplete) == false)) {
                libNtve_gf_ReplaceUnit(EventUnit(), "MutaliskBroodlord", libNtve_ge_ReplaceUnitOptions_NewUnitssMax);
                UnitGroupAdd(gv_mutaliskGroup, libNtve_gf_LastReplacedUnit());
            }
            else {

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/evolution/zevolutionmutalisk.sc2mapMapScript.galaxy:4209

    for ( ; !UnitGroupLoopDone() ; UnitGroupLoopStep() ) {
        libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Viper", libNtve_ge_ReplaceUnitOptions_NewUnitssMax);
        UnitGroupAdd(gv_viperGroup, libNtve_gf_LastReplacedUnit());
    }
    UnitGroupLoopEnd();

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/evolution/zevolutionroach.sc2mapMapScript.galaxy:1085

        if ((UnitGetType(UnitGroupLoopCurrent()) == "RoachBurrowed")) {
            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Roach", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphRoachToCorpser", 0)), c_orderQueueReplace);
        }

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/evolution/zevolutionroach.sc2mapMapScript.galaxy:1086

            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Roach", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphRoachToCorpser", 0)), c_orderQueueReplace);
        }
        else {

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/evolution/zevolutionswarmhost.sc2mapMapScript.galaxy:879

        if (((UnitGetType(UnitGroupLoopCurrent()) == "SwarmHostRooted") || (UnitGetType(UnitGroupLoopCurrent()) == "SwarmHostBurrowed"))) {
            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "SwarmHost", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphSwarmHostToSplitA", 0)), c_orderQueueReplace);
        }

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/evolution/zevolutionswarmhost.sc2mapMapScript.galaxy:880

            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "SwarmHost", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphSwarmHostToSplitA", 0)), c_orderQueueReplace);
        }
        else {

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/evolution/zevolutionswarmhost.sc2mapMapScript.galaxy:1624

        if (((UnitGetType(UnitGroupLoopCurrent()) == "SwarmHostRooted") || (UnitGetType(UnitGroupLoopCurrent()) == "SwarmHostBurrowed"))) {
            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "SwarmHost", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphSwarmHostToSplitB", 0)), c_orderQueueReplace);
        }

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/evolution/zevolutionswarmhost.sc2mapMapScript.galaxy:1625

            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "SwarmHost", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphSwarmHostToSplitB", 0)), c_orderQueueReplace);
        }
        else {

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/evolution/zevolutionultralisk.sc2mapMapScript.galaxy:1311

        if ((UnitGetType(UnitGroupLoopCurrent()) == "UltraliskBurrowed")) {
            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Ultralisk", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphUltraliskToNoxious", 0)), c_orderQueueReplace);
        }

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/evolution/zevolutionultralisk.sc2mapMapScript.galaxy:1312

            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Ultralisk", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphUltraliskToNoxious", 0)), c_orderQueueReplace);
        }
        else {

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/evolution/zevolutionultralisk.sc2mapMapScript.galaxy:2130

        if ((UnitGetType(UnitGroupLoopCurrent()) == "UltraliskBurrowed")) {
            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Ultralisk", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphUltraliskToTorrasque", 0)), c_orderQueueReplace);
        }

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/evolution/zevolutionultralisk.sc2mapMapScript.galaxy:2131

            libNtve_gf_ReplaceUnit(UnitGroupLoopCurrent(), "Ultralisk", 1);
            libNtve_gf_MakeUnitUncommandable(libNtve_gf_LastReplacedUnit(), true);
            UnitIssueOrder(libNtve_gf_LastReplacedUnit(), Order(AbilityCommand("MorphUltraliskToTorrasque", 0)), c_orderQueueReplace);
        }
        else {

campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign/swarm/zlab01.sc2mapMapScript.galaxy:10698

    UnitIssueOrder(UnitFromId(114), OrderTargetingUnit(AbilityCommand("attack", 0), UnitFromId(515)), c_orderQueueReplace);
    libNtve_gf_ReplaceUnit(gv_mainDoor, "UmojanLabDoorsThinRightLowered", libNtve_ge_ReplaceUnitOptions_OldUnitsRelative);
    gv_mainDoor = libNtve_gf_LastReplacedUnit();
    UIAlertClear(gv_pLAYER_01_USER);
    TriggerExecute(gt_StartAI, true, false);

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:26485

        if (auto8B4AE5B8_var == null) { break; }
        libNtve_gf_ReplaceUnit(auto8B4AE5B8_var, "TychusResearchCenterUnlocked", libNtve_ge_ReplaceUnitOptions_OldUnitsRelative);
        libNtve_gf_CopyUnitControlGroups(auto8B4AE5B8_var, libNtve_gf_LastReplacedUnit());
        UnitCreateEffectUnit(auto8B4AE5B8_var, "TychusResearchCenterCopyRally", libNtve_gf_LastReplacedUnit());
        libCOUI_gv_cU_TychusSquadBar = libNtve_gf_LastReplacedUnit();

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:26486

        libNtve_gf_ReplaceUnit(auto8B4AE5B8_var, "TychusResearchCenterUnlocked", libNtve_ge_ReplaceUnitOptions_OldUnitsRelative);
        libNtve_gf_CopyUnitControlGroups(auto8B4AE5B8_var, libNtve_gf_LastReplacedUnit());
        UnitCreateEffectUnit(auto8B4AE5B8_var, "TychusResearchCenterCopyRally", libNtve_gf_LastReplacedUnit());
        libCOUI_gv_cU_TychusSquadBar = libNtve_gf_LastReplacedUnit();
        if ((UnitIsSelected(auto8B4AE5B8_var, UnitGetOwner(libCOMI_gf_EventTychusHero())) == true)) {

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:26487

        libNtve_gf_CopyUnitControlGroups(auto8B4AE5B8_var, libNtve_gf_LastReplacedUnit());
        UnitCreateEffectUnit(auto8B4AE5B8_var, "TychusResearchCenterCopyRally", libNtve_gf_LastReplacedUnit());
        libCOUI_gv_cU_TychusSquadBar = libNtve_gf_LastReplacedUnit();
        if ((UnitIsSelected(auto8B4AE5B8_var, UnitGetOwner(libCOMI_gf_EventTychusHero())) == true)) {
            UnitSelect(libNtve_gf_LastReplacedUnit(), UnitGetOwner(libCOMI_gf_EventTychusHero()), true);

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:26489

        libCOUI_gv_cU_TychusSquadBar = libNtve_gf_LastReplacedUnit();
        if ((UnitIsSelected(auto8B4AE5B8_var, UnitGetOwner(libCOMI_gf_EventTychusHero())) == true)) {
            UnitSelect(libNtve_gf_LastReplacedUnit(), UnitGetOwner(libCOMI_gf_EventTychusHero()), true);
        }

mods/starcoop/starcoop.sc2modbase.sc2data/LibCOMI.galaxy:26492

        }

        libCOUI_gf_CU_TychusSetBarUnit(libNtve_gf_LastReplacedUnit());
    }
    DialogControlSetAnimationState(libCOUI_gv_cU_TychusSquadUnitFrames[0], PlayerGroupAll(), "TrainingState", "NotTraining");