include "TriggerLibs/NativeLib"

include "TriggerLibs/HeroesLib"

include "TriggerLibs/GameLib"

include "TriggerLibs/MapMechanicsLib"

include "TriggerLibs/AILib"

include "TriggerLibs/UILib"

include "TriggerLibs/SoundLib"

include "TriggerLibs/GameDataHelperLib"



include "LibMTOD_h"



//--------------------------------------------------------------------------------------------------

// Library: Towers of Doom

//--------------------------------------------------------------------------------------------------

// External Library Initialization

void libMTOD_InitLibraries () {

    libNtve_InitVariables();

    libCore_InitVariables();

    libGame_InitVariables();

    libMapM_InitVariables();

    libAIAI_InitVariables();

    libUIUI_InitVariables();

    libSond_InitVariables();

    libGDHL_InitVariables();

}



// Variable Initialization

bool libMTOD_InitVariables_completed = false;



void libMTOD_InitVariables () {

    int init_i;

    int init_i1;



    if (libMTOD_InitVariables_completed) {

        return;

    }



    libMTOD_InitVariables_completed = true;



    libMTOD_gv_mMToDOrderBases = UnitGroupEmpty();

    libMTOD_gv_mMToDChaosBases = UnitGroupEmpty();

    libMTOD_gv_mMToDScoringAltarTimer = TimerCreate();

    for (init_i = 0; init_i <= libMTOD_gv_mMToDScoringAltarMaxConfigs_C; init_i += 1) {

        libMTOD_gv_mMToDScoringAltarConfigs[init_i] = PlayerGroupEmpty();

    }

    libMTOD_gv_mMToDScoringAltarRemainingConfigs = PlayerGroupEmpty();

    libMTOD_gv_mMToDScoringAltarRemainingConfigsThreeAltarEvent = PlayerGroupEmpty();

    libMTOD_gv_mMToDObjectivePreviewTimer = TimerCreate();

    libMTOD_gv_mMToDObjectivePreviewDelay_C = 30.0;

    libMTOD_gv_mMToDPhaseTwoTimer = TimerCreate();

    libMTOD_gv_mMToDSixCapDelay_C = 2.0;

    libMTOD_gv_mMToDSixCapTimer = TimerCreate();

    libMTOD_gv_mMToDScalingTimer = TimerCreate();

    for (init_i = 0; init_i <= libCore_gv_bALMaxTeams; init_i += 1) {

        libMTOD_gv_mMToDProtectionTowers[init_i] = UnitGroupEmpty();

    }

    for (init_i = 0; init_i <= libCore_gv_bALMaxPlayers; init_i += 1) {

        libMTOD_gv_mMToDSpiritHealerTextTags[init_i] = c_textTagNone;

    }

    for (init_i = 0; init_i <= libCore_gv_bALMaxPlayers; init_i += 1) {

        libMTOD_gv_mMToDSpiritHealerVOTimers[init_i] = TimerCreate();

    }

    libMTOD_gv_mMToDBanterVariable = true;

    libMTOD_gv_mMToDBanterTimer = TimerCreate();

    libMTOD_gv_mMToDPanels.lv_mainPanel = c_invalidDialogControlId;

    for (init_i1 = 0; init_i1 <= libMTOD_gv_mMToDTownsMaxCount_C; init_i1 += 1) {

        libMTOD_gv_mMToDPanels.lv_townHealth[init_i1].lv_mainTownPanel = c_invalidDialogControlId;

        libMTOD_gv_mMToDPanels.lv_townHealth[init_i1].lv_blueTownPanel = c_invalidDialogControlId;

        libMTOD_gv_mMToDPanels.lv_townHealth[init_i1].lv_blueTownHealth = c_invalidDialogControlId;

        libMTOD_gv_mMToDPanels.lv_townHealth[init_i1].lv_blueTownHealthFrame = c_invalidDialogControlId;

        libMTOD_gv_mMToDPanels.lv_townHealth[init_i1].lv_redTownPanel = c_invalidDialogControlId;

        libMTOD_gv_mMToDPanels.lv_townHealth[init_i1].lv_redTownHealth = c_invalidDialogControlId;

        libMTOD_gv_mMToDPanels.lv_townHealth[init_i1].lv_redTownHealthFrame = c_invalidDialogControlId;

    }

    libMTOD_gv_mMToDPanels.lv_mainHealthPanel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_mainAltarTimerPanel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_altarInfoLabel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_altarLabel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_altarTimerLabel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_mainPotentialShotsPanel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_mainPotentialShotsLabel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_leftPotentialShotsLabel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_rightPotentialShotsLabel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_enemyCaptureNotificationPanel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_enemyCaptureNotificationLabel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_enemyCaptureNotificationTargetLabel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_allyCaptureNotificationPanel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_allyCaptureNotificationLabel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_allyCaptureNotificationTargetLabel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_waygateNotificationPanel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_townUpgradeNotificationPanel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_ravenNotificationPanel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_ravenNotificationLabel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_necroNotificationPanel = c_invalidDialogControlId;

    libMTOD_gv_mMToDPanels.lv_necroNotificationLabel = c_invalidDialogControlId;

}



// Presets

// Functions

void libMTOD_gf_MMToDInitMercs () {

    // Variable Declarations

    int lv_campType;



    // Automatic Variable Declarations

    // Variable Initialization

    lv_campType = (libMapM_ge_JungleCampDefenderTypes_BossCamp1);



    // Implementation

    libMapM_gf_InitializeSapperMercType(libMapM_ge_JungleCampMercTypes_SiegeCamp1, StringExternal("Param/Value/lib_MTOD_1EDBBE28"), libMapM_gv_mercSapperDefaultSpawnTime_C, libMapM_gv_mercSapperDefaultRespawnTime_C);

    libMapM_gv_dataJungleCampDefenderData[lv_campType].lv_campTypeMinimapLabel = StringExternal("Param/Value/lib_MTOD_B7658F40");

    libMapM_gv_dataJungleCampDefenderData[lv_campType].lv_campIsElite = true;

    libMapM_gv_dataJungleCampDefenderData[lv_campType].lv_campIsSoloable = true;

    libMapM_gv_dataJungleCampDefenderData[lv_campType].lv_defendersCoweronDeath = false;

    libMapM_gv_dataJungleCampDefenderData[lv_campType].lv_initialSpawnDelay = libMapM_gv_genericMercBossCampInitialSpawnDelay_C;

    libMapM_gv_dataJungleCampDefenderData[lv_campType].lv_respawnTime = 300.0;

    libMapM_gv_dataJungleCampDefenderData[lv_campType].lv_numberOfCreeps = 1;

    libMapM_gv_dataJungleCampDefenderData[lv_campType].lv_creepUnitTypes[1] = "MercHorsemanDefender";

    libMapM_gv_dataJungleCampDefenderData[lv_campType].lv_xPAwardForCapture = libMTOD_gv_data_XP_GraveGolemCapture_C;

    libMapM_gv_dataJungleCampDefenderData[lv_campType].lv_aIGoalLink = "MercenaryCampGraveGolem";

    libMapM_gv_dataJungleCampMercData[lv_campType].lv_numberOfMinionsSpawned = 0;

    libMapM_gf_DataInitializeScalingDataForDefender(libMapM_ge_JungleCampDefenderTypes_BossCamp1, "HorsemanDefenderScaling");

}



void libMTOD_gf_MMToDUpdateTownState (unit lp_base, int lp_computerPlayer, int lp_stateChange) {

    // Automatic Variable Declarations

    int autoE8E3FF64_val;



    // Implementation

    autoE8E3FF64_val = lp_stateChange;

    if (autoE8E3FF64_val == libMTOD_ge_MMToDTownStateChange_Remove) {

        if ((lp_computerPlayer == libCore_gv_cOMPUTER_TeamOrder)) {

            UnitGroupRemove(libMTOD_gv_mMToDOrderBases, lp_base);

        }

        else {

            UnitGroupRemove(libMTOD_gv_mMToDChaosBases, lp_base);

        }

    }

    else if (autoE8E3FF64_val == libMTOD_ge_MMToDTownStateChange_Add) {

        if ((lp_computerPlayer == libCore_gv_cOMPUTER_TeamOrder)) {

            UnitGroupAdd(libMTOD_gv_mMToDOrderBases, lp_base);

        }

        else {

            UnitGroupAdd(libMTOD_gv_mMToDChaosBases, lp_base);

        }

    }

    else if (autoE8E3FF64_val == libMTOD_ge_MMToDTownStateChange_SwapTeams) {

        if ((lp_computerPlayer == libCore_gv_cOMPUTER_TeamOrder)) {

            UnitGroupAdd(libMTOD_gv_mMToDOrderBases, lp_base);

            UnitGroupRemove(libMTOD_gv_mMToDChaosBases, lp_base);

        }

        else {

            UnitGroupAdd(libMTOD_gv_mMToDChaosBases, lp_base);

            UnitGroupRemove(libMTOD_gv_mMToDOrderBases, lp_base);

        }

    }

    else {

    }

    if (((UnitGroupCount(libMTOD_gv_mMToDOrderBases, c_unitCountAlive) == 6) || (UnitGroupCount(libMTOD_gv_mMToDChaosBases, c_unitCountAlive) == 6))) {

        libMTOD_gv_mMToDSixTownEventActive = true;

        StatEventCreate("Six Town Event Start");

        StatEventAddDataInt(StatEventLastCreated(), "Owning Team", libGame_gf_TeamNumberOfPlayer(lp_computerPlayer));

        StatEventAddDataFixed(StatEventLastCreated(), "Start Time", TimerGetElapsed(libGame_gv_gameTimer));

        StatEventSend(StatEventLastCreated());

        TimerStart(libMTOD_gv_mMToDSixCapTimer, libMTOD_gv_mMToDSixCapDelay_C, false, c_timeGame);

        libMTOD_gf_MMToDTransmissionBellSixTowersTaken();

        if ((UnitGroupCount(libMTOD_gv_mMToDOrderBases, c_unitCountAlive) == 6)) {

            SoundtrackStop(PlayerGroupAll(), c_soundtrackCategoryMusic, true);

            libSond_gf_SoundtrackApplyNewDefaultSoundtrackForPlayerGroup("MX_Towers_Capped_Raven", PlayerGroupAll());

        }

        else {

            SoundtrackStop(PlayerGroupAll(), c_soundtrackCategoryMusic, true);

            libSond_gf_SoundtrackApplyNewDefaultSoundtrackForPlayerGroup("MX_Towers_Capped_Necro", PlayerGroupAll());

        }

    }



    if ((UnitGroupCount(libMTOD_gv_mMToDOrderBases, c_unitCountAlive) != 6) && (UnitGroupCount(libMTOD_gv_mMToDChaosBases, c_unitCountAlive) != 6) && (libMTOD_gv_mMToDSixTownEventActive == true)) {

        libMTOD_gv_mMToDSixTownEventActive = false;

        StatEventCreate("Six Town Event End");

        StatEventAddDataInt(StatEventLastCreated(), "Owning Team", libGame_gf_TeamNumberOfPlayer(lp_computerPlayer));

        StatEventAddDataFixed(StatEventLastCreated(), "End Time", TimerGetElapsed(libGame_gv_gameTimer));

        StatEventSend(StatEventLastCreated());

        SoundtrackStop(PlayerGroupAll(), c_soundtrackCategoryMusic, true);

        libSond_gf_SoundtrackPlayMapSoundtrackAsDefaultSoundtrackForAllPlayers();

        TimerPause(libMTOD_gv_mMToDSixCapTimer, true);

    }



}



void libMTOD_gf_MMToDUpdatePotentialShotsLabels () {

    // Automatic Variable Declarations

    int auto17431B11_val;



    // Implementation

    libNtve_gf_SetDialogItemText(libMTOD_gv_mMToDPanels.lv_leftPotentialShotsLabel, IntToText(FixedToInt((UnitGroupCount(libMTOD_gv_mMToDOrderBases, c_unitCountAlive) + libMTOD_gv_mMToDCoreShots_C))), PlayerGroupAll());

    libNtve_gf_SetDialogItemText(libMTOD_gv_mMToDPanels.lv_rightPotentialShotsLabel, IntToText(FixedToInt((UnitGroupCount(libMTOD_gv_mMToDChaosBases, c_unitCountAlive) + libMTOD_gv_mMToDCoreShots_C))), PlayerGroupAll());

    auto17431B11_val = UnitGroupCount(libMTOD_gv_mMToDOrderBases, c_unitCountAll);

    if (auto17431B11_val == 0) {

        DialogControlSendAnimationEvent(libUIUI_gv_uIObserverUI.lv_mainPanel, libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], "BroadcastToD0v6");

    }

    else if (auto17431B11_val == 1) {

        DialogControlSendAnimationEvent(libUIUI_gv_uIObserverUI.lv_mainPanel, libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], "BroadcastToD1v5");

    }

    else if (auto17431B11_val == 2) {

        DialogControlSendAnimationEvent(libUIUI_gv_uIObserverUI.lv_mainPanel, libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], "BroadcastToD2v4");

    }

    else if (auto17431B11_val == 3) {

        DialogControlSendAnimationEvent(libUIUI_gv_uIObserverUI.lv_mainPanel, libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], "BroadcastToD3v3");

    }

    else if (auto17431B11_val == 4) {

        DialogControlSendAnimationEvent(libUIUI_gv_uIObserverUI.lv_mainPanel, libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], "BroadcastToD4v2");

    }

    else if (auto17431B11_val == 5) {

        DialogControlSendAnimationEvent(libUIUI_gv_uIObserverUI.lv_mainPanel, libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], "BroadcastToD5v1");

    }

    else if (auto17431B11_val == 6) {

        DialogControlSendAnimationEvent(libUIUI_gv_uIObserverUI.lv_mainPanel, libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], "BroadcastToD6v0");

    }

    else {

    }

}



trigger auto_libMTOD_gf_MMTodAddScoringAltarData_Trigger = null;

unit auto_libMTOD_gf_MMTodAddScoringAltarData_lp_altarUnit;

int auto_libMTOD_gf_MMTodAddScoringAltarData_lp_pointNumber;



void libMTOD_gf_MMTodAddScoringAltarData (unit lp_altarUnit, int lp_pointNumber) {

    auto_libMTOD_gf_MMTodAddScoringAltarData_lp_altarUnit = lp_altarUnit;

    auto_libMTOD_gf_MMTodAddScoringAltarData_lp_pointNumber = lp_pointNumber;



    if (auto_libMTOD_gf_MMTodAddScoringAltarData_Trigger == null) {

        auto_libMTOD_gf_MMTodAddScoringAltarData_Trigger = TriggerCreate("auto_libMTOD_gf_MMTodAddScoringAltarData_TriggerFunc");

    }



    TriggerExecute(auto_libMTOD_gf_MMTodAddScoringAltarData_Trigger, false, false);

}



bool auto_libMTOD_gf_MMTodAddScoringAltarData_TriggerFunc (bool testConds, bool runActions) {

    unit lp_altarUnit = auto_libMTOD_gf_MMTodAddScoringAltarData_lp_altarUnit;

    int lp_pointNumber = auto_libMTOD_gf_MMTodAddScoringAltarData_lp_pointNumber;



    // Automatic Variable Declarations

    // Implementation

    if ((lp_pointNumber > libMTOD_gv_mMToDScoringAltarMaxCount_C)) {

        TextExpressionSetToken("Param/Expression/lib_MTOD_767E089C", "A", IntToText(libMTOD_gv_mMToDScoringAltarMaxCount_C));

        TriggerDebugOutput(1, TextExpressionAssemble("Param/Expression/lib_MTOD_767E089C"), true);

        return true;

    }



    libMTOD_gv_mMToDScoringAltars[lp_pointNumber].lv_unit = lp_altarUnit;

    Wait(2.0, c_timeGame);

    libNtve_gf_SendActorMessageToUnit(lp_altarUnit, "Signal OneOrder");

    libNtve_gf_SendActorMessageToUnit(lp_altarUnit, "Signal TwoOrder");

    libNtve_gf_SendActorMessageToUnit(lp_altarUnit, "Signal ThreeOrder");

    libNtve_gf_SendActorMessageToUnit(lp_altarUnit, "Signal FourChaos");

    libNtve_gf_SendActorMessageToUnit(lp_altarUnit, "Signal FiveChaos");

    libNtve_gf_SendActorMessageToUnit(lp_altarUnit, "Signal SixChaos");

    return true;

}



void libMTOD_gf_MMToDTurnOnOffScoringAltar (bool lp_onOff, int lp_altarIndex) {

    // Automatic Variable Declarations

    bool autoC0B7FFD8_val;



    // Implementation

    autoC0B7FFD8_val = lp_onOff;

    if (autoC0B7FFD8_val == true) {

        libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_unit, "MinimapIconTintColor 255,0,222,255");

        libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_unit, "MinimapTooltip DOCSTR_ActiveAltar");

        UnitSetState(libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_unit, c_unitStateHighlightable, true);

        UnitSetState(libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_unit, c_unitStateTargetable, true);

        UnitBehaviorAdd(libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_unit, "MacguffinActivated", libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_unit, 1);

        libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_active = true;

    }

    else if (autoC0B7FFD8_val == false) {

        libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_unit, "MinimapIconTintColor 255,145,113,218");

        libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_unit, "Signal Deactivate");

        libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_unit, "SetMinimapVisibility");

        libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_unit, "SetMinimapVisibilityAlways");

        libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_unit, "MinimapTooltip DOCSTR_NextActiveAltar");

        UnitSetState(libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_unit, c_unitStateHighlightable, false);

        UnitSetState(libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_unit, c_unitStateTargetable, false);

        UnitBehaviorRemove(libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_unit, "MacguffinActivated", 1);

        libMTOD_gv_mMToDScoringAltars[lp_altarIndex].lv_active = false;

    }

    else {

    }

}



void libMTOD_gf_MMToDDefineNextAltarsandCreatePreviews () {

    // Variable Declarations

    int lv_itAltar;

    int lv_pointGroup;



    // Automatic Variable Declarations

    int auto78989EBF_val;

    playergroup auto956A1EFD_g;



    // Variable Initialization



    // Implementation

    libMTOD_gv_mMToDEventNumber += 1;

    auto78989EBF_val = libMTOD_gv_mMToDEventNumber;

    if (auto78989EBF_val == 1) {

        lv_pointGroup = PlayerGroupPlayer(libMTOD_gv_mMToDScoringAltarRemainingConfigsThreeAltarEvent, RandomInt(1, PlayerGroupCount(libMTOD_gv_mMToDScoringAltarRemainingConfigsThreeAltarEvent)));

        PlayerGroupRemove(libMTOD_gv_mMToDScoringAltarRemainingConfigsThreeAltarEvent, lv_pointGroup);

    }

    else if (auto78989EBF_val == 2) {

        lv_pointGroup = PlayerGroupPlayer(libMTOD_gv_mMToDScoringAltarRemainingConfigs, RandomInt(1, PlayerGroupCount(libMTOD_gv_mMToDScoringAltarRemainingConfigs)));

        PlayerGroupRemove(libMTOD_gv_mMToDScoringAltarRemainingConfigs, lv_pointGroup);

    }

    else if (auto78989EBF_val == 3) {

        lv_pointGroup = PlayerGroupPlayer(libMTOD_gv_mMToDScoringAltarRemainingConfigs, RandomInt(1, PlayerGroupCount(libMTOD_gv_mMToDScoringAltarRemainingConfigs)));

        PlayerGroupRemove(libMTOD_gv_mMToDScoringAltarRemainingConfigs, lv_pointGroup);

    }

    else if (auto78989EBF_val == 4) {

        lv_pointGroup = PlayerGroupPlayer(libMTOD_gv_mMToDScoringAltarRemainingConfigs, RandomInt(1, PlayerGroupCount(libMTOD_gv_mMToDScoringAltarRemainingConfigs)));

        PlayerGroupRemove(libMTOD_gv_mMToDScoringAltarRemainingConfigs, lv_pointGroup);

    }

    else if (auto78989EBF_val == 5) {

        lv_pointGroup = PlayerGroupPlayer(libMTOD_gv_mMToDScoringAltarRemainingConfigsThreeAltarEvent, RandomInt(1, PlayerGroupCount(libMTOD_gv_mMToDScoringAltarRemainingConfigsThreeAltarEvent)));

        PlayerGroupRemove(libMTOD_gv_mMToDScoringAltarRemainingConfigsThreeAltarEvent, lv_pointGroup);

    }

    else if (auto78989EBF_val == 6) {

        lv_pointGroup = PlayerGroupPlayer(libMTOD_gv_mMToDScoringAltarRemainingConfigs, RandomInt(1, PlayerGroupCount(libMTOD_gv_mMToDScoringAltarRemainingConfigs)));

        PlayerGroupRemove(libMTOD_gv_mMToDScoringAltarRemainingConfigs, lv_pointGroup);

        PlayerGroupClear(libMTOD_gv_mMToDScoringAltarRemainingConfigs);

        PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarRemainingConfigs, 1);

        PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarRemainingConfigs, 2);

        PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarRemainingConfigs, 3);

        PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarRemainingConfigs, 4);

    }

    else if (auto78989EBF_val == 7) {

        lv_pointGroup = PlayerGroupPlayer(libMTOD_gv_mMToDScoringAltarRemainingConfigs, RandomInt(1, PlayerGroupCount(libMTOD_gv_mMToDScoringAltarRemainingConfigs)));

        PlayerGroupRemove(libMTOD_gv_mMToDScoringAltarRemainingConfigs, lv_pointGroup);

    }

    else if (auto78989EBF_val == 8) {

        lv_pointGroup = PlayerGroupPlayer(libMTOD_gv_mMToDScoringAltarRemainingConfigs, RandomInt(1, PlayerGroupCount(libMTOD_gv_mMToDScoringAltarRemainingConfigs)));

        PlayerGroupRemove(libMTOD_gv_mMToDScoringAltarRemainingConfigs, lv_pointGroup);

    }

    else if (auto78989EBF_val == 9) {

        lv_pointGroup = PlayerGroupPlayer(libMTOD_gv_mMToDScoringAltarRemainingConfigs, RandomInt(1, PlayerGroupCount(libMTOD_gv_mMToDScoringAltarRemainingConfigs)));

        PlayerGroupRemove(libMTOD_gv_mMToDScoringAltarRemainingConfigs, lv_pointGroup);

    }

    else if (auto78989EBF_val == 10) {

        lv_pointGroup = PlayerGroupPlayer(libMTOD_gv_mMToDScoringAltarRemainingConfigs, RandomInt(1, PlayerGroupCount(libMTOD_gv_mMToDScoringAltarRemainingConfigs)));

        PlayerGroupRemove(libMTOD_gv_mMToDScoringAltarRemainingConfigs, lv_pointGroup);

    }

    else {

        lv_pointGroup = RandomInt(1, 4);

    }

    auto956A1EFD_g = libMTOD_gv_mMToDScoringAltarConfigs[lv_pointGroup];

    lv_itAltar = -1;

    while (true) {

        	lv_itAltar = PlayerGroupNextPlayer(auto956A1EFD_g, lv_itAltar);

        	if (lv_itAltar<0) { break; }

        	libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "MinimapIconTintColor 255,145,113,218");

        libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "MinimapTooltip DOCSTR_NextActiveAltar");

        libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "SetMinimapVisibility 1");

        libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "SetMinimapVisibilityAlways 1");

    }

    libMTOD_gv_mMToDEventCurrentPointGroup = lv_pointGroup;

}



void libMTOD_gf_MMToDAltarFireCannons (int lp_teamScored) {

    // Variable Declarations

    unit lv_itTown;



    // Automatic Variable Declarations

    int autoB1EAAD11_val;

    unitgroup auto8B70F9E1_g;

    int auto8B70F9E1_u;

    unitgroup autoCFA5C262_g;

    int autoCFA5C262_u;



    // Variable Initialization



    // Implementation

    autoB1EAAD11_val = lp_teamScored;

    if (autoB1EAAD11_val == libGame_gv_teamOrderIndex_C) {

        auto8B70F9E1_g = libMTOD_gv_mMToDOrderBases;

        auto8B70F9E1_u = UnitGroupCount(auto8B70F9E1_g, c_unitCountAll);

        for (;; auto8B70F9E1_u -= 1) {

            lv_itTown = UnitGroupUnitFromEnd(auto8B70F9E1_g, auto8B70F9E1_u);

            if (lv_itTown == null) { break; }

            UnitCreateEffectUnit(lv_itTown, "MapEventRavenLordCannonLaunchMissile", libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_core);

            libNtve_gf_SendActorMessageToUnit(lv_itTown, "Create Event_Towers_Tribute_RavenLord_Tower_Success");

        }

        UnitCreateEffectUnit(libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_core, "MapEventRavenLordCannonLaunchMissile", libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_core);

    }

    else if (autoB1EAAD11_val == libGame_gv_teamChaosIndex_C) {

        autoCFA5C262_g = libMTOD_gv_mMToDChaosBases;

        autoCFA5C262_u = UnitGroupCount(autoCFA5C262_g, c_unitCountAll);

        for (;; autoCFA5C262_u -= 1) {

            lv_itTown = UnitGroupUnitFromEnd(autoCFA5C262_g, autoCFA5C262_u);

            if (lv_itTown == null) { break; }

            UnitCreateEffectUnit(lv_itTown, "MapEventNecromancerCannonLaunchMissile", libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_core);

            libNtve_gf_SendActorMessageToUnit(lv_itTown, "Create Event_Towers_Tribute_Necro_Tower_Success");

        }

        UnitCreateEffectUnit(libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_core, "MapEventNecromancerCannonLaunchMissile", libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_core);

    }

    else {

    }

}



void libMTOD_gf_MMToDSixCapFireCannons () {

    // Variable Declarations

    int lv_trackFiringTimes;

    fixed lv_firingTimer;

    unit lv_itTown;



    // Automatic Variable Declarations

    // Variable Initialization



    // Implementation

    if ((UnitGroupCount(libMTOD_gv_mMToDOrderBases, c_unitCountAlive) == 6)) {

        libMTOD_gf_MMToDUIDisplayRavenNecroNotifications(StringExternal("Param/Value/lib_MTOD_48C30940"), 1, PlayerGroupAll());

        SoundPlayForPlayer(SoundLink("UI_Game_Ping_Raven_Captured_Building_All", -1), libCore_gv_cOMPUTER_TeamOrder, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

        libCore_gf_CreateMinimapPingStorm(PlayerGroupAll(), "StormAlert", UnitGetPosition(libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_core), ColorWithAlpha(100.00, 100.00, 0.00, 0.00), 5.0);

    }



    if ((UnitGroupCount(libMTOD_gv_mMToDChaosBases, c_unitCountAlive) == 6)) {

        libMTOD_gf_MMToDUIDisplayRavenNecroNotifications(StringExternal("Param/Value/lib_MTOD_843E5EFB"), 2, PlayerGroupAll());

        SoundPlayForPlayer(SoundLink("UI_Game_Ping_Necro_Captured_Building_All", -1), libCore_gv_cOMPUTER_TeamChaos, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

        libCore_gf_CreateMinimapPingStorm(PlayerGroupAll(), "StormAlert", UnitGetPosition(libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_core), ColorWithAlpha(100.00, 100.00, 0.00, 0.00), 5.0);

    }



    lv_firingTimer = 6.0;

    while (true) {

        if ((lv_trackFiringTimes == 6)) {

            lv_firingTimer -= 3.0;

        }



        if ((UnitGroupCount(libMTOD_gv_mMToDOrderBases, c_unitCountAlive) != 6) && (UnitGroupCount(libMTOD_gv_mMToDChaosBases, c_unitCountAlive) != 6)) {

            return ;

        }

        else {

            if ((UnitGroupCount(libMTOD_gv_mMToDOrderBases, c_unitCountAlive) == 6)) {

                UnitCreateEffectUnit(libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_core, "MapEventRavenLordCannonLaunchMissile", libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_core);

            }

            else {

                UnitCreateEffectUnit(libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_core, "MapEventNecromancerCannonLaunchMissile", libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_core);

            }

            Wait(lv_firingTimer, c_timeGame);

            lv_trackFiringTimes += 1;

        }

    }

}



void libMTOD_gf_MMTodAddTownData (unitgroup lp_buildingUnitGroup, int lp_townNumber, text lp_townName) {

    // Variable Declarations

    unitgroup lv_capturePointUnitGroup;

    unit lv_capturePointUnit;

    unit lv_itBuilding;

    int lv_itBuildingNum;

    unit lv_fortUnit;



    // Automatic Variable Declarations

    unitgroup auto6E710635_g;

    int auto6E710635_u;



    // Variable Initialization

    lv_capturePointUnitGroup = UnitGroupEmpty();



    // Implementation

    libMTOD_gv_mMToDTowns[lp_townNumber].lv_townName = lp_townName;

    auto6E710635_g = lp_buildingUnitGroup;

    auto6E710635_u = UnitGroupCount(auto6E710635_g, c_unitCountAll);

    for (;; auto6E710635_u -= 1) {

        lv_itBuilding = UnitGroupUnitFromEnd(auto6E710635_g, auto6E710635_u);

        if (lv_itBuilding == null) { break; }

        if ((libGame_gf_TownGetTownStructurePresetFromUnit(lv_itBuilding) == libGame_ge_TownStructureTypes_TownHall)) {

            libNtve_gf_SendActorMessageToUnit(lv_itBuilding, "Signal StartGame");

            libMTOD_gf_MMToDUpdateTownState(lv_itBuilding, UnitGetOwner(lv_itBuilding), libMTOD_ge_MMToDTownStateChange_Add);

            libMTOD_gv_mMToDTowns[lp_townNumber].lv_owningTeam = UnitGetOwner(lv_itBuilding);

            libMTOD_gv_mMToDTowns[lp_townNumber].lv_originalOwningTeam = UnitGetOwner(lv_itBuilding);

            libMTOD_gv_mMToDTowns[lp_townNumber].lv_fortUnit = lv_itBuilding;

            libMTOD_gv_mMToDTowns[lp_townNumber].lv_fortInfo.lv_buildingPosition = UnitGetPosition(lv_itBuilding);

            libMTOD_gv_mMToDTowns[lp_townNumber].lv_fortInfo.lv_buildingType = UnitGetType(lv_itBuilding);

        }

        else {

            if (((libGame_gf_TownGetTownStructurePresetFromUnit(lv_itBuilding) == libGame_ge_TownStructureTypes_Moonwell) || (UnitGetType(lv_itBuilding) == "TownCannonTowerL2Standalone"))) {

                lv_itBuildingNum += 1;

                libMTOD_gv_mMToDTowns[lp_townNumber].lv_structureArray[lv_itBuildingNum].lv_buildingFacing = UnitGetFacing(lv_itBuilding);

                libMTOD_gv_mMToDTowns[lp_townNumber].lv_structureArray[lv_itBuildingNum].lv_buildingPosition = UnitGetPosition(lv_itBuilding);

                libMTOD_gv_mMToDTowns[lp_townNumber].lv_structureArray[lv_itBuildingNum].lv_buildingType = UnitGetType(lv_itBuilding);

            }



        }

    }

}



void libMTOD_gf_MMToDRespawnTown (int lp_townNumber, unit lp_fortUnit, int lp_oldOwningTeam) {

    // Variable Declarations

    unitgroup lv_survivingBuildings;

    int lv_newOwningTeam;

    int lv_newEnemyTeam;

    unit lv_itUnit;

    int lv_itStructure;

    int lv_itTower;

    int lv_itPlayer;

    int lv_itCamp;



    // Automatic Variable Declarations

    unitgroup autoE2EC0DF5_g;

    int autoE2EC0DF5_u;

    int auto7E023449_ae;

    const int auto7E023449_ai = 1;

    const int auto98F8316E_ae = libCore_gv_bALMaxPlayers;

    const int auto98F8316E_ai = 1;

    int auto75C132DC_ae;

    const int auto75C132DC_ai = 1;

    const int autoA33993DC_ae = libMTOD_gv_mMToDTownStructureMaxCount_C;

    const int autoA33993DC_ai = 1;



    // Variable Initialization

    lv_survivingBuildings = UnitGroupEmpty();



    // Implementation

    if ((lp_oldOwningTeam == libCore_gv_cOMPUTER_TeamChaos)) {

        lv_newOwningTeam = libCore_gv_cOMPUTER_TeamOrder;

        lv_newEnemyTeam = libCore_gv_cOMPUTER_TeamChaos;

        libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_townsRemaining += 1;

    }

    else {

        lv_newOwningTeam = libCore_gv_cOMPUTER_TeamChaos;

        lv_newEnemyTeam = libCore_gv_cOMPUTER_TeamOrder;

        libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_townsRemaining += 1;

    }

    libMTOD_gf_MMToDShowHideTownOwnershipUI(false, lp_townNumber, lp_oldOwningTeam);

    UnitKill(libGame_gv_townTownData[lp_townNumber].lv_lootBannerUnit);

    libMTOD_gf_MMToDAnnouncementTownCaptured(lp_fortUnit, libGame_gf_TeamNumberOfPlayer(lv_newOwningTeam));

    libMTOD_gf_MMToDUpdateTownState(libMTOD_gv_mMToDTowns[lp_townNumber].lv_fortUnit, lp_oldOwningTeam, libMTOD_ge_MMToDTownStateChange_Remove);

    libMTOD_gf_MMToDUpdatePotentialShotsLabels();

    libMTOD_gf_MMToDChangeMarkerOwnershipOnAltars(lp_townNumber, libCore_gv_cOMPUTER_Neutral);

    StatEventCreate("Town Captured");

    StatEventAddDataInt(StatEventLastCreated(), "New Owner", lv_newOwningTeam);

    StatEventSend(StatEventLastCreated());

    lv_survivingBuildings = UnitGroup(null, lp_oldOwningTeam, libGame_gv_townTownData[lp_townNumber].lv_townRegion, UnitFilter((1 << c_targetFilterStructure), 0, (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0);

    autoE2EC0DF5_g = lv_survivingBuildings;

    autoE2EC0DF5_u = UnitGroupCount(autoE2EC0DF5_g, c_unitCountAll);

    for (;; autoE2EC0DF5_u -= 1) {

        lv_itUnit = UnitGroupUnitFromEnd(autoE2EC0DF5_g, autoE2EC0DF5_u);

        if (lv_itUnit == null) { break; }

        UnitGroupRemove(lv_survivingBuildings, lv_itUnit);

        if ((UnitGetType(lv_itUnit) != "TownCannonTowerL2") && (UnitGetType(lv_itUnit) != "TownCannonTowerL2Standalone") && (UnitGetType(lv_itUnit) != "TownCannonTowerL3Standalone")) {

            UnitBehaviorAdd(lv_itUnit, "UnitGivesNoXP", lv_itUnit, 1);

            UnitKill(lv_itUnit);

        }

        else {

            UnitCreateEffectUnit(lv_itUnit, "TownCannonTowerDeathSet", lv_itUnit);

        }

    }

    libMTOD_gv_mMToDTowns[lp_townNumber].lv_owningTeam = lv_newOwningTeam;

    libGame_gv_townTownData[lp_townNumber].lv_owner = lv_newOwningTeam;

    auto7E023449_ae = libMapM_gv_jungleNumberOfCreepCamps;

    lv_itCamp = 1;

    for ( ; ( (auto7E023449_ai >= 0 && lv_itCamp <= auto7E023449_ae) || (auto7E023449_ai < 0 && lv_itCamp >= auto7E023449_ae) ) ; lv_itCamp += auto7E023449_ai ) {

        if (((libMapM_gv_jungleCreepCamps[lv_itCamp].lv_mercMercCampHasSingleWaypoint[libGame_gv_teamOrderIndex_C] == false) || (libMapM_gv_jungleCreepCamps[lv_itCamp].lv_mercMercCampHasSingleWaypoint[libGame_gv_teamChaosIndex_C] == false))) {

            libMapM_gf_JungleUpdateMercCampData(lv_itCamp);

        }



    }

    libMTOD_gf_MMToDChangeTownMarkerOwnershipInRegion(RegionCircle(libMTOD_gv_mMToDTowns[lp_townNumber].lv_fortInfo.lv_buildingPosition, 26.0), libMTOD_gv_mMToDTowns[lp_townNumber].lv_owningTeam);

    Wait(libMTOD_gv_mMToDTownFlipDelayTime_C, c_timeGame);

    if ((libGame_gv_gameOver == true)) {

        return ;

    }



    libMTOD_gf_MMToDRemoveDeathModelsInRegion(RegionCircle(libMTOD_gv_mMToDTowns[lp_townNumber].lv_fortInfo.lv_buildingPosition, 8.0));

    libNtve_gf_CreateUnitsWithDefaultFacing(1, libMTOD_gv_mMToDTowns[lp_townNumber].lv_fortInfo.lv_buildingType, c_unitCreateIgnorePlacement, libMTOD_gv_mMToDTowns[lp_townNumber].lv_owningTeam, libMTOD_gv_mMToDTowns[lp_townNumber].lv_fortInfo.lv_buildingPosition, null);

    libMTOD_gv_mMToDTowns[lp_townNumber].lv_fortUnit = UnitLastCreated();

    UnitBehaviorAdd(UnitLastCreated(), "StructureOwnershipChangeRepairBehavior", UnitLastCreated(), 1);

    lv_itPlayer = 1;

    for ( ; ( (auto98F8316E_ai >= 0 && lv_itPlayer <= auto98F8316E_ae) || (auto98F8316E_ai < 0 && lv_itPlayer >= auto98F8316E_ae) ) ; lv_itPlayer += auto98F8316E_ai ) {

        if ((libGame_gf_TeamNumberOfPlayer(lv_itPlayer) == libGame_gf_TeamNumberOfPlayer(lv_newOwningTeam))) {

            UnitSetStateForPlayer(UnitLastCreated(), c_unitStateTargetable, lv_itPlayer, true);

        }

        else {

            UnitSetStateForPlayer(UnitLastCreated(), c_unitStateTargetable, lv_itPlayer, false);

        }

    }

    UnitSetPropertyFixed(UnitLastCreated(), c_unitPropLifePercent, 1.0);

    libNtve_gf_SendActorMessageToUnit(UnitLastCreated(), "Signal PlayBuild");

    libMTOD_gf_MMToDUpdateTownState(libMTOD_gv_mMToDTowns[lp_townNumber].lv_fortUnit, libMTOD_gv_mMToDTowns[lp_townNumber].lv_owningTeam, libMTOD_ge_MMToDTownStateChange_Add);

    libMTOD_gf_MMToDUpdatePotentialShotsLabels();

    libMTOD_gf_MMToDChangeMarkerOwnershipOnAltars(lp_townNumber, lv_newOwningTeam);

    libGame_gv_townTownData[lp_townNumber].lv_structureCount = 0;

    libGame_gv_townTownData[lp_townNumber].lv_structuresAlive = 0;

    libGame_gf_TownAddStructureToTownArray(lp_townNumber, UnitLastCreated(), libGame_gf_TownGetTownStructurePresetFromUnit(UnitLastCreated()), lv_newEnemyTeam);

    libMTOD_gf_MMToDShowHideTownOwnershipUI(true, lp_townNumber, lv_newOwningTeam);

    libAIAI_gf_HeroAISetupUnitDangerTracking(UnitLastCreated());

    if ((libGame_gf_TownGetTownStructurePresetFromUnit(UnitLastCreated()) == libGame_ge_TownStructureTypes_TownHall)) {

        if ((libGame_gf_TownGetTownHallPresetFromUnitID(UnitGetType(UnitLastCreated())) == libGame_ge_TownHallTypes_BackTown)) {

            AILaneUnitCreated(libGame_gv_townTownData[lp_townNumber].lv_lane, UnitLastCreated(), libNtve_ge_LaneUnitType_Keep);

        }

        else {

            AILaneUnitCreated(libGame_gv_townTownData[lp_townNumber].lv_lane, UnitLastCreated(), libNtve_ge_LaneUnitType_Fort);

        }

    }



    auto75C132DC_ae = libMapM_gv_jungleNumberOfCreepCamps;

    lv_itCamp = 1;

    for ( ; ( (auto75C132DC_ai >= 0 && lv_itCamp <= auto75C132DC_ae) || (auto75C132DC_ai < 0 && lv_itCamp >= auto75C132DC_ae) ) ; lv_itCamp += auto75C132DC_ai ) {

        if (((libMapM_gv_jungleCreepCamps[lv_itCamp].lv_mercMercCampHasSingleWaypoint[libGame_gv_teamOrderIndex_C] == false) || (libMapM_gv_jungleCreepCamps[lv_itCamp].lv_mercMercCampHasSingleWaypoint[libGame_gv_teamChaosIndex_C] == false))) {

            libMapM_gf_JungleUpdateMercCampData(lv_itCamp);

        }



    }

    if ((libMTOD_gv_mMToDTowns[lp_townNumber].lv_owningTeam == libMTOD_gv_mMToDTowns[lp_townNumber].lv_originalOwningTeam)) {

        lv_itStructure = 1;

        for ( ; ( (autoA33993DC_ai >= 0 && lv_itStructure <= autoA33993DC_ae) || (autoA33993DC_ai < 0 && lv_itStructure >= autoA33993DC_ae) ) ; lv_itStructure += autoA33993DC_ai ) {

            if ((libMTOD_gv_mMToDTowns[lp_townNumber].lv_structureArray[lv_itStructure].lv_buildingPosition != null)) {

                libMTOD_gf_MMToDBuildTownStructure(lp_townNumber, lv_itStructure);

            }

            else {

                break;

            }

        }

    }



}



void libMTOD_gf_MMToDBuildTownStructure (int lp_townNum, int lp_structureNum) {

    // Variable Declarations

    unit lv_itUnit;

    int lv_itTower;

    int lv_enemyTeam;

    int lv_itPlayer;



    // Automatic Variable Declarations

    const int auto9A21C160_ae = libCore_gv_bALMaxPlayers;

    const int auto9A21C160_ai = 1;

    const int auto3F32C040_ae = libGame_gv_moonwellMaxMoonwellCount;

    int auto3F32C040_var;



    // Variable Initialization



    // Implementation

    UnitCreate(1, libMTOD_gv_mMToDTowns[lp_townNum].lv_structureArray[lp_structureNum].lv_buildingType, c_unitCreateIgnorePlacement, libMTOD_gv_mMToDTowns[lp_townNum].lv_owningTeam, libMTOD_gv_mMToDTowns[lp_townNum].lv_structureArray[lp_structureNum].lv_buildingPosition, libMTOD_gv_mMToDTowns[lp_townNum].lv_structureArray[lp_structureNum].lv_buildingFacing, null);

    UnitBehaviorAdd(UnitLastCreated(), "StructureOwnershipChangeRepairBehavior", UnitLastCreated(), 1);

    if ((libMTOD_gv_mMToDTowns[lp_townNum].lv_owningTeam == libCore_gv_cOMPUTER_TeamOrder)) {

        lv_enemyTeam = libCore_gv_cOMPUTER_TeamChaos;

    }

    else {

        lv_enemyTeam = libCore_gv_cOMPUTER_TeamOrder;

    }

    libGame_gf_TownAddStructureToTownArray(lp_townNum, UnitLastCreated(), libGame_gf_TownGetTownStructurePresetFromUnit(UnitLastCreated()), lv_enemyTeam);

    if ((libGame_gf_TownGetTownStructurePresetFromUnit(UnitLastCreated()) == libGame_ge_TownStructureTypes_Moonwell)) {

        UIFlyerHelperOverride(PlayerGroupAll(), libNtve_ge_FlyerHelperDisplay_c_flyerDisplayNone);

        lv_itPlayer = 1;

        for ( ; ( (auto9A21C160_ai >= 0 && lv_itPlayer <= auto9A21C160_ae) || (auto9A21C160_ai < 0 && lv_itPlayer >= auto9A21C160_ae) ) ; lv_itPlayer += auto9A21C160_ai ) {

            if ((libGame_gf_TeamNumberOfPlayer(UnitGetOwner(UnitLastCreated())) == libGame_gf_TeamNumberOfPlayer(lv_itPlayer)) && (UnitHasBehavior2(libGame_gv_players[lv_itPlayer].lv_heroUnit, "HealingFountainCooldown") == true)) {

                UIFlyerHelperOverride(PlayerGroupSingle(lv_itPlayer), libNtve_ge_FlyerHelperDisplay_c_flyerDisplayAll);

                libNtve_gf_SendActorMessageToUnit(UnitLastCreated(), "Signal MoonwellDrink");

                UnitGroupAdd(libGame_gv_moonwellTextTagsUnitGroup[lv_itPlayer], UnitLastCreated());

                TextTagCreate((StringExternal("Param/Value/lib_MTOD_3AE660F8") + FixedToText(UnitBehaviorDuration(libGame_gv_players[lv_itPlayer].lv_heroUnit, "HealingFountainCooldown"), 0)), 20, UnitGetPosition(UnitLastCreated()), 4.2, false, false, PlayerGroupSingle(lv_itPlayer));

                auto3F32C040_var = 1;

                for ( ; auto3F32C040_var <= auto3F32C040_ae; auto3F32C040_var += 1 ) {

                    if ((UnitIsAlive(libGame_gv_moonwellTextTagsUnit[lv_itPlayer][auto3F32C040_var]) == false)) {

                        libGame_gv_moonwellTextTags[lv_itPlayer][auto3F32C040_var] = TextTagLastCreated();

                        libGame_gv_moonwellTextTagsUnit[lv_itPlayer][auto3F32C040_var] = UnitLastCreated();

                        break;

                    }



                }

            }



        }

        UIFlyerHelperClearOverride(PlayerGroupAll());

    }



    if ((libGame_gf_TownGetTownStructurePresetFromUnit(UnitLastCreated()) == libGame_ge_TownStructureTypes_CannonTower)) {

        libAIAI_gf_HeroAISetupUnitDangerTracking(UnitLastCreated());

        AILaneUnitCreated(libGame_gv_townTownData[lp_townNum].lv_lane, UnitLastCreated(), libNtve_ge_LaneUnitType_Tower);

    }



}



void libMTOD_gf_MMToDRemoveDeathModelsInRegion (region lp_region) {

    // Variable Declarations

    actor lv_actorRegion;



    // Automatic Variable Declarations

    // Variable Initialization



    // Implementation

    ActorRegionCreate(null, "TriggerRegion", lp_region);

    lv_actorRegion = libNtve_gf_ActorLastCreated();

    ActorRegionSend(lv_actorRegion, c_actorIntersectAgainstRadiusContact, "Destroy", "Model", "ScopeContains _ToDClearable");

    ActorRegionSend(lv_actorRegion, c_actorIntersectAgainstRadiusContact, "Destroy", "Unit", "ScopeContains _ToDClearable");

    ActorScopeKill(ActorScopeFromActor(lv_actorRegion));

}



void libMTOD_gf_MMToDAnnouncementTownCaptured (unit lp_fortUnit, int lp_team) {

    // Variable Declarations

    int lv_itTown;



    // Automatic Variable Declarations

    const int autoEB4EA6E3_ae = libMTOD_gv_mMToDTownsMaxCount_C;

    const int autoEB4EA6E3_ai = 1;



    // Variable Initialization



    // Implementation

    lv_itTown = 1;

    for ( ; ( (autoEB4EA6E3_ai >= 0 && lv_itTown <= autoEB4EA6E3_ae) || (autoEB4EA6E3_ai < 0 && lv_itTown >= autoEB4EA6E3_ae) ) ; lv_itTown += autoEB4EA6E3_ai ) {

        if ((libMTOD_gv_mMToDTowns[lv_itTown].lv_fortUnit == lp_fortUnit)) {

            break;

        }



    }

    if ((lp_team == libGame_gv_teamOrderIndex_C)) {

        MinimapPing(libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_teamPlayerGroup, UnitGetPosition(lp_fortUnit), 5.0, Color(0.00, 33.33, 100.00));

        MinimapPing(libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_teamPlayerGroup, UnitGetPosition(lp_fortUnit), 5.0, Color(100.00, 0.00, 0.00));

        MinimapPing(libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], UnitGetPosition(lp_fortUnit), 5.0, Color(0.00, 33.33, 100.00));

        SoundtrackPlay(libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_teamPlayerGroup, c_soundtrackCategoryMusic, "MX_Stinger_MercCampTaken_Ally", c_soundtrackCueAny, c_soundtrackIndexAny, false);

        SoundtrackPlay(libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], c_soundtrackCategoryMusic, "MX_Stinger_MercCampTaken_Ally", c_soundtrackCueAny, c_soundtrackIndexAny, false);

        SoundtrackPlay(libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_teamPlayerGroup, c_soundtrackCategoryMusic, "MX_Stinger_MercCampTaken_Enemy", c_soundtrackCueAny, c_soundtrackIndexAny, false);

        SoundPlayForPlayer(SoundLink("UI_Game_Ping_Raven_Captured_Building", -1), lp_team, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

    }

    else {

        MinimapPing(libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_teamPlayerGroup, UnitGetPosition(lp_fortUnit), 5.0, Color(100.00, 0.00, 0.00));

        MinimapPing(libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_teamPlayerGroup, UnitGetPosition(lp_fortUnit), 5.0, Color(0.00, 33.33, 100.00));

        MinimapPing(libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], UnitGetPosition(lp_fortUnit), 5.0, Color(100.00, 0.00, 0.00));

        SoundtrackPlay(libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_teamPlayerGroup, c_soundtrackCategoryMusic, "MX_Stinger_MercCampTaken_Enemy", c_soundtrackCueAny, c_soundtrackIndexAny, false);

        SoundtrackPlay(libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], c_soundtrackCategoryMusic, "MX_Stinger_MercCampTaken_Enemy", c_soundtrackCueAny, c_soundtrackIndexAny, false);

        SoundtrackPlay(libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_teamPlayerGroup, c_soundtrackCategoryMusic, "MX_Stinger_MercCampTaken_Ally", c_soundtrackCueAny, c_soundtrackIndexAny, false);

        SoundPlayForPlayer(SoundLink("UI_Game_Ping_Necro_Captured_Building", -1), lp_team, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

    }

    libMTOD_gf_MMToDUIDisplayCaptureNotification(lp_team, lv_itTown);

}



void libMTOD_gf_MMToDChangeMarkerOwnershipOnAltars (int lp_townNumber, int lp_newOwner) {

    // Variable Declarations

    int lv_itAltar;



    // Automatic Variable Declarations

    const int auto30A18360_ae = libMTOD_gv_mMToDScoringAltarMaxCount_C;

    const int auto30A18360_ai = 1;

    int auto742E75B5_val;

    int auto2157FD1B_val;

    int auto4CBE0F44_val;

    int auto2EAA6510_val;

    int auto970F0C66_val;

    int auto5F5A9689_val;

    int auto8BAB2322_val;



    // Variable Initialization



    // Implementation

    lv_itAltar = 1;

    for ( ; ( (auto30A18360_ai >= 0 && lv_itAltar <= auto30A18360_ae) || (auto30A18360_ai < 0 && lv_itAltar >= auto30A18360_ae) ) ; lv_itAltar += auto30A18360_ai ) {

        auto742E75B5_val = lp_townNumber;

        if (auto742E75B5_val == 1) {

            auto2157FD1B_val = lp_newOwner;

            if (auto2157FD1B_val == libCore_gv_cOMPUTER_TeamOrder) {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal OneOrder");

            }

            else if (auto2157FD1B_val == libCore_gv_cOMPUTER_TeamChaos) {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal OneChaos");

            }

            else {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal OneNeutral");

            }

        }

        else if (auto742E75B5_val == 2) {

            auto4CBE0F44_val = lp_newOwner;

            if (auto4CBE0F44_val == libCore_gv_cOMPUTER_TeamOrder) {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal TwoOrder");

            }

            else if (auto4CBE0F44_val == libCore_gv_cOMPUTER_TeamChaos) {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal TwoChaos");

            }

            else {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal TwoNeutral");

            }

        }

        else if (auto742E75B5_val == 3) {

            auto2EAA6510_val = lp_newOwner;

            if (auto2EAA6510_val == libCore_gv_cOMPUTER_TeamOrder) {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal ThreeOrder");

            }

            else if (auto2EAA6510_val == libCore_gv_cOMPUTER_TeamChaos) {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal ThreeChaos");

            }

            else {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal ThreeNeutral");

            }

        }

        else if (auto742E75B5_val == 4) {

            auto970F0C66_val = lp_newOwner;

            if (auto970F0C66_val == libCore_gv_cOMPUTER_TeamOrder) {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal FourOrder");

            }

            else if (auto970F0C66_val == libCore_gv_cOMPUTER_TeamChaos) {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal FourChaos");

            }

            else {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal FourNeutral");

            }

        }

        else if (auto742E75B5_val == 5) {

            auto5F5A9689_val = lp_newOwner;

            if (auto5F5A9689_val == libCore_gv_cOMPUTER_TeamOrder) {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal FiveOrder");

            }

            else if (auto5F5A9689_val == libCore_gv_cOMPUTER_TeamChaos) {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal FiveChaos");

            }

            else {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal FiveNeutral");

            }

        }

        else if (auto742E75B5_val == 6) {

            auto8BAB2322_val = lp_newOwner;

            if (auto8BAB2322_val == libCore_gv_cOMPUTER_TeamOrder) {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal SixOrder");

            }

            else if (auto8BAB2322_val == libCore_gv_cOMPUTER_TeamChaos) {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal SixChaos");

            }

            else {

                libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal SixNeutral");

            }

        }

        else {

        }

    }

}



void libMTOD_gf_MMToDChangeTownMarkerOwnershipInRegion (region lp_region, int lp_newOwningTeam) {

    // Variable Declarations

    actor lv_actorRegion;



    // Automatic Variable Declarations

    int autoF9E39A17_val;



    // Variable Initialization



    // Implementation

    ActorRegionCreate(null, "TriggerRegion", lp_region);

    lv_actorRegion = libNtve_gf_ActorLastCreated();

    autoF9E39A17_val = lp_newOwningTeam;

    if (autoF9E39A17_val == libCore_gv_cOMPUTER_TeamOrder) {

        ActorRegionSend(lv_actorRegion, c_actorIntersectAgainstRadiusContact, "SetPlayerId 11", "Doodad", "ScopeContains _TownIndicator");

        ActorRegionSend(lv_actorRegion, c_actorIntersectAgainstRadiusContact, "Signal Order", "Doodad", "ScopeContains _CaptureBanner");

    }

    else if (autoF9E39A17_val == libCore_gv_cOMPUTER_TeamChaos) {

        ActorRegionSend(lv_actorRegion, c_actorIntersectAgainstRadiusContact, "SetPlayerId 12", "Doodad", "ScopeContains _TownIndicator");

        ActorRegionSend(lv_actorRegion, c_actorIntersectAgainstRadiusContact, "Signal Chaos", "Doodad", "ScopeContains _CaptureBanner");

    }

    else {

    }

    ActorScopeKill(ActorScopeFromActor(lv_actorRegion));

}



unit libMTOD_gf_MMToDGetTownFort (int lp_townIndex) {

    // Automatic Variable Declarations

    // Implementation

    return libMTOD_gv_mMToDTowns[lp_townIndex].lv_fortUnit;

}



void libMTOD_gf_MMToDBossCampFireCannons (int lp_firingTeam) {

    // Variable Declarations

    revealer[libCore_gv_bALMaxTeams + 1] lv_revealers;

    int lv_shotsFired;

    int lv_enemyTeam;



    // Automatic Variable Declarations

    // Variable Initialization



    // Implementation

    VisRevealerCreate(libCore_gv_cOMPUTER_TeamOrder, RegionCircle(UnitGetPosition(libMTOD_gv_mMToDHorsemanCannon), 2.0));

    lv_revealers[libGame_gv_teamOrderIndex_C] = VisRevealerLastCreated();

    VisRevealerCreate(libCore_gv_cOMPUTER_TeamChaos, RegionCircle(UnitGetPosition(libMTOD_gv_mMToDHorsemanCannon), 2.0));

    lv_revealers[libGame_gv_teamChaosIndex_C] = VisRevealerLastCreated();

    Wait(0.0625, c_timeGame);

    libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDHorsemanCannon, "Signal StartFiring");

    Wait(0.9375, c_timeGame);

    if ((lp_firingTeam == libCore_gv_cOMPUTER_TeamOrder)) {

        lv_enemyTeam = libGame_gv_teamChaosIndex_C;

    }



    if ((lp_firingTeam == libCore_gv_cOMPUTER_TeamChaos)) {

        lv_enemyTeam = libGame_gv_teamOrderIndex_C;

    }



    while ((lv_shotsFired < libMTOD_gv_mMToDBossCannonShots_C)) {

        if ((UnitIsAlive(libGame_gv_teams[lv_enemyTeam].lv_core) == false)) {

            break;

        }



        UnitCreateEffectUnit(libMTOD_gv_mMToDHorsemanCannon, "BossMercCampCannonLaunchMissile", libGame_gv_teams[lv_enemyTeam].lv_core);

        lv_shotsFired += 1;

        Wait(0.5, c_timeGame);

    }

    Wait(0.5, c_timeGame);

    libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDHorsemanCannon, "Signal EndFiring");

    Wait(0.375, c_timeGame);

    VisRevealerDestroy(lv_revealers[libGame_gv_teamOrderIndex_C]);

    VisRevealerDestroy(lv_revealers[libGame_gv_teamChaosIndex_C]);

}



void libMTOD_gf_MMTodInitializeProtectionTowers (region lp_orderKillzone, region lp_chaosKillzone) {

    // Variable Declarations

    unitgroup lv_baseUnits;

    unit lv_itUnit;



    // Automatic Variable Declarations

    unitgroup auto86B6D27F_g;

    int auto86B6D27F_u;

    unitgroup auto86FFA004_g;

    int auto86FFA004_u;



    // Variable Initialization

    lv_baseUnits = UnitGroupEmpty();



    // Implementation

    if ((lp_orderKillzone == null)) {

        TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_86F3B26E"), true);

    }



    if ((lp_chaosKillzone == null)) {

        TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_B049B66C"), true);

    }



    libMTOD_gv_mMToDBaseKillZones[libGame_gv_teamOrderIndex_C] = lp_orderKillzone;

    libMTOD_gv_mMToDBaseKillZones[libGame_gv_teamChaosIndex_C] = lp_chaosKillzone;

    lv_baseUnits = UnitGroup(null, libCore_gv_cOMPUTER_TeamOrder, lp_orderKillzone, UnitFilter((1 << c_targetFilterStructure), 0, (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0);

    auto86B6D27F_g = lv_baseUnits;

    auto86B6D27F_u = UnitGroupCount(auto86B6D27F_g, c_unitCountAll);

    for (;; auto86B6D27F_u -= 1) {

        lv_itUnit = UnitGroupUnitFromEnd(auto86B6D27F_g, auto86B6D27F_u);

        if (lv_itUnit == null) { break; }

        if ((libGame_gf_TownGetTownStructurePresetFromUnit(lv_itUnit) == libGame_ge_TownStructureTypes_CannonTower)) {

            UnitGroupAdd(libMTOD_gv_mMToDProtectionTowers[libGame_gv_teamOrderIndex_C], lv_itUnit);

        }



    }

    lv_baseUnits = UnitGroup(null, libCore_gv_cOMPUTER_TeamChaos, lp_chaosKillzone, UnitFilter((1 << c_targetFilterStructure), 0, (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0);

    auto86FFA004_g = lv_baseUnits;

    auto86FFA004_u = UnitGroupCount(auto86FFA004_g, c_unitCountAll);

    for (;; auto86FFA004_u -= 1) {

        lv_itUnit = UnitGroupUnitFromEnd(auto86FFA004_g, auto86FFA004_u);

        if (lv_itUnit == null) { break; }

        if ((libGame_gf_TownGetTownStructurePresetFromUnit(lv_itUnit) == libGame_ge_TownStructureTypes_CannonTower)) {

            UnitGroupAdd(libMTOD_gv_mMToDProtectionTowers[libGame_gv_teamChaosIndex_C], lv_itUnit);

        }



    }

    TriggerExecute(libMTOD_gt_MMToDProtectionTowerScan, true, false);

}



void libMTOD_gf_MMTodAddWaygate (int lp_waygateIndex, unit lp_waygateUnit, unit lp_orderEntrance, unit lp_chaosEntrance) {

    // Automatic Variable Declarations

    // Implementation

    if (((lp_waygateUnit == null) || (lp_orderEntrance == null) || (lp_chaosEntrance == null))) {

        TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_945784BF"), true);

    }



    if ((lp_waygateIndex > libMTOD_gv_mMFieldofSlaughterWaygateMaxCount_C)) {

        TextExpressionSetToken("Param/Expression/lib_MTOD_8B535666", "A", IntToText(libMTOD_gv_mMFieldofSlaughterWaygateMaxCount_C));

        TriggerDebugOutput(1, TextExpressionAssemble("Param/Expression/lib_MTOD_8B535666"), true);

        return ;

    }



    libMTOD_gv_mMToDWaygates[lp_waygateIndex].lv_waygateUnit = lp_waygateUnit;

    libMTOD_gv_mMToDWaygates[lp_waygateIndex].lv_position = UnitGetPosition(lp_waygateUnit);

    libMTOD_gv_mMToDWaygates[lp_waygateIndex].lv_orderEntrance = lp_orderEntrance;

    libNtve_gf_CreateUnitsWithDefaultFacing(1, "WaygateEntranceMinimapIconActor", c_unitCreateIgnorePlacement, libCore_gv_cOMPUTER_TeamOrder, UnitGetPosition(lp_orderEntrance), null);

    libMTOD_gv_mMToDWaygates[lp_waygateIndex].lv_chaosEntrance = lp_chaosEntrance;

    libNtve_gf_CreateUnitsWithDefaultFacing(1, "WaygateEntranceMinimapIconActor", c_unitCreateIgnorePlacement, libCore_gv_cOMPUTER_TeamChaos, UnitGetPosition(lp_chaosEntrance), null);

}



void libMTOD_gf_MMToDActivateWaygates () {

    // Variable Declarations

    int lv_itWaygate;



    // Automatic Variable Declarations

    const int autoF56F075C_ae = libMTOD_gv_mMFieldofSlaughterWaygateMaxCount_C;

    const int autoF56F075C_ai = 1;

    const int autoEC877075_ae = libMTOD_gv_mMFieldofSlaughterWaygateMaxCount_C;

    const int autoEC877075_ai = 1;

    const int auto135094BF_ae = libMTOD_gv_mMFieldofSlaughterWaygateMaxCount_C;

    const int auto135094BF_ai = 1;



    // Variable Initialization



    // Implementation

    lv_itWaygate = 1;

    for ( ; ( (autoF56F075C_ai >= 0 && lv_itWaygate <= autoF56F075C_ae) || (autoF56F075C_ai < 0 && lv_itWaygate >= autoF56F075C_ae) ) ; lv_itWaygate += autoF56F075C_ai ) {

        if ((libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_waygateUnit != null)) {

            libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_orderEntrance, "Signal EntranceActive");

            libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_chaosEntrance, "Signal EntranceActive");

            libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_waygateUnit, "Signal WaygateOpen");

        }



    }

    DialogControlSendAnimationEvent(libMTOD_gv_mMToDPanels.lv_waygateNotificationPanel, PlayerGroupAll(), "Show");

    lv_itWaygate = 1;

    for ( ; ( (autoEC877075_ai >= 0 && lv_itWaygate <= autoEC877075_ae) || (autoEC877075_ai < 0 && lv_itWaygate >= autoEC877075_ae) ) ; lv_itWaygate += autoEC877075_ai ) {

        if ((libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_waygateUnit != null)) {

            libMTOD_gf_MMToDTransmissionTeleporterActivated();

        }



    }

    Wait(3.5, c_timeGame);

    lv_itWaygate = 1;

    for ( ; ( (auto135094BF_ai >= 0 && lv_itWaygate <= auto135094BF_ae) || (auto135094BF_ai < 0 && lv_itWaygate >= auto135094BF_ae) ) ; lv_itWaygate += auto135094BF_ai ) {

        if ((libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_waygateUnit != null)) {

            libCore_gf_CreateMinimapPingStorm(libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_teamPlayerGroupNoNPCPlayers, "StormAlert", UnitGetPosition(libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_orderEntrance), ColorWithAlpha(100.00, 100.00, 0.00, 0.00), 3.0);

            libCore_gf_CreateMinimapPingStorm(libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_teamPlayerGroupNoNPCPlayers, "StormAlert", UnitGetPosition(libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_chaosEntrance), ColorWithAlpha(100.00, 100.00, 0.00, 0.00), 3.0);

            libCore_gf_CreateMinimapPingStorm(PlayerGroupAll(), "StormAlert", UnitGetPosition(libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_waygateUnit), ColorWithAlpha(100.00, 100.00, 0.00, 0.00), 3.0);

            UnitSetState(libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_orderEntrance, c_unitStateHighlightable, true);

            UnitSetState(libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_orderEntrance, c_unitStateTargetable, true);

            UnitBehaviorAdd(libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_orderEntrance, "MacguffinActivated", libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_orderEntrance, 1);

            UnitBehaviorRemove(libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_orderEntrance, "UnitCannotBePinged", 1);

            UnitSetState(libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_chaosEntrance, c_unitStateHighlightable, true);

            UnitSetState(libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_chaosEntrance, c_unitStateTargetable, true);

            UnitBehaviorAdd(libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_chaosEntrance, "MacguffinActivated", libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_chaosEntrance, 1);

            UnitBehaviorRemove(libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_chaosEntrance, "UnitCannotBePinged", 1);

            libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_waygateUnit, "SetMinimapVisibility 1");

            AIAddPortal(libCore_gv_cOMPUTER_TeamOrder, libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_orderEntrance, libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_waygateUnit, 2.0, 0.0, "CaptureMacGuffinTwo", null);

            AIAddPortal(libCore_gv_cOMPUTER_TeamChaos, libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_chaosEntrance, libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_waygateUnit, 2.0, 0.0, "CaptureMacGuffinTwo", null);

        }



    }

    TextTagCreate(StringExternal("Param/Value/lib_MTOD_07643371"), 20, UnitGetPosition(libMTOD_gv_mMToDWaygates[libGame_gv_teamOrderIndex_C].lv_waygateUnit), 1.0, true, false, libCore_gv_allHeroPlayersPlusObserver);

    TextTagShow(TextTagLastCreated(), libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], false);

    Wait(1.5, c_timeGame);

    DialogControlSendAnimationEvent(libMTOD_gv_mMToDPanels.lv_waygateNotificationPanel, PlayerGroupAll(), "Hide");

}



void libMTOD_gf_MMToDCannonballImpactShakingCamera (point lp_targetLocation) {

    // Variable Declarations

    int lv_itPlayer;



    // Automatic Variable Declarations

    const int autoF0F401C7_ae = libCore_gv_bALMaxPlayers;

    const int autoF0F401C7_ai = 1;



    // Variable Initialization



    // Implementation

    lv_itPlayer = 1;

    for ( ; ( (autoF0F401C7_ai >= 0 && lv_itPlayer <= autoF0F401C7_ae) || (autoF0F401C7_ai < 0 && lv_itPlayer >= autoF0F401C7_ae) ) ; lv_itPlayer += autoF0F401C7_ai ) {

        if ((PlayerStatus(lv_itPlayer) != c_playerStatusActive)) {

            continue;

        }



        if ((DistanceBetweenPoints(CameraGetTarget(lv_itPlayer), lp_targetLocation) <= 15.0)) {

            CameraShake(lv_itPlayer, "Medium", "Earthquake", 0.0, 0.5, 0.75);

        }

        else if ((DistanceBetweenPoints(CameraGetTarget(lv_itPlayer), lp_targetLocation) <= 30.0)) {

            CameraShake(lv_itPlayer, "Light", "Earthquake", 0.0, 0.5, 0.5);

        }

    }

}



void libMTOD_gf_MMToDAltarDamageDoneCache (int lp_player, int lp_townCount) {

    // Automatic Variable Declarations

    // Implementation

    libMTOD_gv_mMToDAltarDamageDoneTotal[lp_player] = (libMTOD_gv_mMToDAltarDamageDoneTotal[lp_player] + (lp_townCount + 1));

    libGame_gf_ScoreValuesReportIntegerValueAndLog(lp_player, "AltarDamageDone", libMTOD_gv_mMToDAltarDamageDoneTotal[lp_player]);

    libGame_gf_SendMapSpecificAwardEvent(lp_player, libMTOD_gv_mMToDAltarDamageDoneTotal[lp_player], false);

}



trigger auto_libMTOD_gf_MMToDTransmissionBellTowersActivating_Trigger = null;



void libMTOD_gf_MMToDTransmissionBellTowersActivating () {

    if (auto_libMTOD_gf_MMToDTransmissionBellTowersActivating_Trigger == null) {

        auto_libMTOD_gf_MMToDTransmissionBellTowersActivating_Trigger = TriggerCreate("auto_libMTOD_gf_MMToDTransmissionBellTowersActivating_TriggerFunc");

    }



    TriggerExecute(auto_libMTOD_gf_MMToDTransmissionBellTowersActivating_Trigger, false, false);

}



bool auto_libMTOD_gf_MMToDTransmissionBellTowersActivating_TriggerFunc (bool testConds, bool runActions) {

    // Variable Declarations

    playergroup lv_groupNecromancer;

    playergroup lv_groupRaven;

    playergroup lv_observers;

    int lv_itIndex;



    // Automatic Variable Declarations

    // Variable Initialization

    lv_groupNecromancer = PlayerGroupEmpty();

    lv_groupRaven = PlayerGroupEmpty();

    lv_observers = PlayerGroupEmpty();



    // Implementation

    if ((libGame_gv_gameOver == true)) {

        return true;

    }



    TriggerQueueEnter();

    UserDataResetType("MapVOEvent");

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Necromancer"));

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Raven Lord"));

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Observer"));

    if ((libMTOD_gv_mMToDEventNumber == 1)) {

        UserDataSetInt("MapVOEvent", "Bell Towers Activating First", "Value", 1, 1);

    }

    else {

        UserDataSetInt("MapVOEvent", "Bell Towers Activating", "Value", 1, 1);

    }

    lv_groupRaven = libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamOrderIndex_C, false);

    lv_groupNecromancer = libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamChaosIndex_C, false);

    lv_observers = libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer];

    libNtve_gf_AddPlayerGroupToPlayerGroup(lv_observers, lv_groupRaven);

    ConversationDataLineSetPlayers("FieldofSlaughter", ("Necromancer"), lv_groupNecromancer);

    ConversationDataLineSetPlayers("FieldofSlaughter", ("Raven Lord"), lv_groupRaven);

    ConversationDataRun("FieldofSlaughter", PlayerGroupAll(), c_conversationSkipNone, false);

    libCore_gf_WaitForConversationToFinish();

    TriggerQueueExit();

    return true;

}



trigger auto_libMTOD_gf_MMToDTransmissionBellTowersActivate_Trigger = null;



void libMTOD_gf_MMToDTransmissionBellTowersActivate () {

    if (auto_libMTOD_gf_MMToDTransmissionBellTowersActivate_Trigger == null) {

        auto_libMTOD_gf_MMToDTransmissionBellTowersActivate_Trigger = TriggerCreate("auto_libMTOD_gf_MMToDTransmissionBellTowersActivate_TriggerFunc");

    }



    TriggerExecute(auto_libMTOD_gf_MMToDTransmissionBellTowersActivate_Trigger, false, false);

}



bool auto_libMTOD_gf_MMToDTransmissionBellTowersActivate_TriggerFunc (bool testConds, bool runActions) {

    // Variable Declarations

    playergroup lv_groupNecromancer;

    playergroup lv_groupRaven;

    playergroup lv_observers;

    int lv_itIndex;



    // Automatic Variable Declarations

    // Variable Initialization

    lv_groupNecromancer = PlayerGroupEmpty();

    lv_groupRaven = PlayerGroupEmpty();

    lv_observers = PlayerGroupEmpty();



    // Implementation

    if ((libGame_gv_gameOver == true)) {

        return true;

    }



    TriggerQueueEnter();

    UserDataResetType("MapVOEvent");

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Necromancer"));

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Raven Lord"));

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Observer"));

    if ((libMTOD_gv_mMToDEventNumber == 1)) {

        UserDataSetInt("MapVOEvent", "Bell Towers Active First", "Value", 1, 1);

    }

    else {

        UserDataSetInt("MapVOEvent", "Bell Towers Active", "Value", 1, 1);

    }

    lv_groupRaven = libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamOrderIndex_C, false);

    lv_groupNecromancer = libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamChaosIndex_C, false);

    lv_observers = libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer];

    libNtve_gf_AddPlayerGroupToPlayerGroup(lv_observers, lv_groupRaven);

    ConversationDataLineSetPlayers("FieldofSlaughter", ("Necromancer"), lv_groupNecromancer);

    ConversationDataLineSetPlayers("FieldofSlaughter", ("Raven Lord"), lv_groupRaven);

    ConversationDataRun("FieldofSlaughter", PlayerGroupAll(), c_conversationSkipNone, false);

    libCore_gf_WaitForConversationToFinish();

    TriggerQueueExit();

    return true;

}



trigger auto_libMTOD_gf_MMToDTransmissionTeleporterActivated_Trigger = null;



void libMTOD_gf_MMToDTransmissionTeleporterActivated () {

    if (auto_libMTOD_gf_MMToDTransmissionTeleporterActivated_Trigger == null) {

        auto_libMTOD_gf_MMToDTransmissionTeleporterActivated_Trigger = TriggerCreate("auto_libMTOD_gf_MMToDTransmissionTeleporterActivated_TriggerFunc");

    }



    TriggerExecute(auto_libMTOD_gf_MMToDTransmissionTeleporterActivated_Trigger, false, false);

}



bool auto_libMTOD_gf_MMToDTransmissionTeleporterActivated_TriggerFunc (bool testConds, bool runActions) {

    // Variable Declarations

    playergroup lv_groupNecromancer;

    playergroup lv_groupRaven;

    playergroup lv_observers;

    int lv_itIndex;



    // Automatic Variable Declarations

    // Variable Initialization

    lv_groupNecromancer = PlayerGroupEmpty();

    lv_groupRaven = PlayerGroupEmpty();

    lv_observers = PlayerGroupEmpty();



    // Implementation

    if ((libGame_gv_gameOver == true)) {

        return true;

    }



    TriggerQueueEnter();

    UserDataResetType("MapVOEvent");

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Necromancer"));

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Raven Lord"));

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Observer"));

    UserDataSetInt("MapVOEvent", "Teleporter Activated", "Value", 1, 1);

    lv_groupRaven = libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamOrderIndex_C, false);

    lv_groupNecromancer = libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamChaosIndex_C, false);

    lv_observers = libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer];

    libNtve_gf_AddPlayerGroupToPlayerGroup(lv_observers, lv_groupRaven);

    ConversationDataLineSetPlayers("FieldofSlaughter", ("Necromancer"), lv_groupNecromancer);

    ConversationDataLineSetPlayers("FieldofSlaughter", ("Raven Lord"), lv_groupRaven);

    ConversationDataRun("FieldofSlaughter", PlayerGroupAll(), c_conversationSkipNone, false);

    libCore_gf_WaitForConversationToFinish();

    TriggerQueueExit();

    return true;

}



trigger auto_libMTOD_gf_MMToDTransmissionBellTowersFiring_Trigger = null;

int auto_libMTOD_gf_MMToDTransmissionBellTowersFiring_lp_team;



void libMTOD_gf_MMToDTransmissionBellTowersFiring (int lp_team) {

    auto_libMTOD_gf_MMToDTransmissionBellTowersFiring_lp_team = lp_team;



    if (auto_libMTOD_gf_MMToDTransmissionBellTowersFiring_Trigger == null) {

        auto_libMTOD_gf_MMToDTransmissionBellTowersFiring_Trigger = TriggerCreate("auto_libMTOD_gf_MMToDTransmissionBellTowersFiring_TriggerFunc");

    }



    TriggerExecute(auto_libMTOD_gf_MMToDTransmissionBellTowersFiring_Trigger, false, false);

}



bool auto_libMTOD_gf_MMToDTransmissionBellTowersFiring_TriggerFunc (bool testConds, bool runActions) {

    int lp_team = auto_libMTOD_gf_MMToDTransmissionBellTowersFiring_lp_team;



    // Variable Declarations

    int lv_randomVar;

    playergroup lv_groupNecromancer;

    playergroup lv_groupRaven;

    playergroup lv_observers;

    int lv_itIndex;



    // Automatic Variable Declarations

    // Variable Initialization

    lv_groupNecromancer = PlayerGroupEmpty();

    lv_groupRaven = PlayerGroupEmpty();

    lv_observers = PlayerGroupEmpty();



    // Implementation

    if ((libGame_gv_gameOver == true)) {

        return true;

    }



    lv_randomVar = RandomInt(1, 5);

    TriggerQueueEnter();

    UserDataResetType("MapVOEvent");

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Necromancer"));

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Raven Lord"));

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Observer"));

    lv_groupRaven = libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamOrderIndex_C, false);

    lv_groupNecromancer = libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamChaosIndex_C, false);

    lv_observers = libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer];

    if ((lp_team == libGame_gv_teamOrderIndex_C)) {

        UserDataSetInt("MapVOEvent", "RavenTowers Firing", "Value", 1, 1);

        libNtve_gf_AddPlayerGroupToPlayerGroup(lv_observers, lv_groupRaven);

    }

    else {

        UserDataSetInt("MapVOEvent", "NecroTowers Firing", "Value", 1, 1);

        libNtve_gf_AddPlayerGroupToPlayerGroup(lv_observers, lv_groupNecromancer);

    }

    ConversationDataLineSetPlayers("FieldofSlaughter", ("Necromancer"), lv_groupNecromancer);

    ConversationDataLineSetPlayers("FieldofSlaughter", ("Raven Lord"), lv_groupRaven);

    ConversationDataRun("FieldofSlaughter", PlayerGroupAll(), c_conversationSkipNone, false);

    libCore_gf_WaitForConversationToFinish();

    if ((lp_team == libGame_gv_teamOrderIndex_C)) {

        if (((UnitGetPropertyFixed(libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_core, c_unitPropLife, c_unitPropCurrent) > 7.0) && (lv_randomVar == 1) && (libMTOD_gv_mMToDBanterVariable == true))) {

            ConversationDataLineResetPlayers("FieldofSlaughter", ("Necromancer"));

            ConversationDataLineResetPlayers("FieldofSlaughter", ("Raven Lord"));

            ConversationDataLineResetPlayers("FieldofSlaughter", ("Observer"));

            UserDataSetInt("MapVOEvent", "Response to Raven Firing", "Value", 1, 1);

            ConversationDataLineSetPlayers("FieldofSlaughter", ("Necromancer"), lv_groupNecromancer);

            ConversationDataLineSetPlayers("FieldofSlaughter", ("Raven Lord"), lv_groupRaven);

            ConversationDataRun("FieldofSlaughter", PlayerGroupAll(), c_conversationSkipNone, false);

            libCore_gf_WaitForConversationToFinish();

            libMTOD_gv_mMToDBanterVariable = false;

            TimerStart(libMTOD_gv_mMToDBanterTimer, 10.0, false, c_timeGame);

        }



    }

    else {

        if ((UnitGetPropertyFixed(libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_core, c_unitPropLife, c_unitPropCurrent) > 7.0) && (lv_randomVar == 1) && (libMTOD_gv_mMToDBanterVariable == true)) {

            ConversationDataLineResetPlayers("FieldofSlaughter", ("Necromancer"));

            ConversationDataLineResetPlayers("FieldofSlaughter", ("Raven Lord"));

            ConversationDataLineResetPlayers("FieldofSlaughter", ("Observer"));

            UserDataSetInt("MapVOEvent", "Response to Necro Firing", "Value", 1, 1);

            ConversationDataLineSetPlayers("FieldofSlaughter", ("Necromancer"), lv_groupNecromancer);

            ConversationDataLineSetPlayers("FieldofSlaughter", ("Raven Lord"), lv_groupRaven);

            ConversationDataRun("FieldofSlaughter", PlayerGroupAll(), c_conversationSkipNone, false);

            libCore_gf_WaitForConversationToFinish();

            libMTOD_gv_mMToDBanterVariable = false;

            TimerStart(libMTOD_gv_mMToDBanterTimer, 20.0, false, c_timeGame);

        }



    }

    TriggerQueueExit();

    return true;

}



trigger auto_libMTOD_gf_MMToDTransmissionBellSixTowersTaken_Trigger = null;



void libMTOD_gf_MMToDTransmissionBellSixTowersTaken () {

    if (auto_libMTOD_gf_MMToDTransmissionBellSixTowersTaken_Trigger == null) {

        auto_libMTOD_gf_MMToDTransmissionBellSixTowersTaken_Trigger = TriggerCreate("auto_libMTOD_gf_MMToDTransmissionBellSixTowersTaken_TriggerFunc");

    }



    TriggerExecute(auto_libMTOD_gf_MMToDTransmissionBellSixTowersTaken_Trigger, false, false);

}



bool auto_libMTOD_gf_MMToDTransmissionBellSixTowersTaken_TriggerFunc (bool testConds, bool runActions) {

    // Variable Declarations

    playergroup lv_groupNecromancer;

    playergroup lv_groupRaven;

    playergroup lv_observers;



    // Automatic Variable Declarations

    // Variable Initialization

    lv_groupNecromancer = PlayerGroupEmpty();

    lv_groupRaven = PlayerGroupEmpty();

    lv_observers = PlayerGroupEmpty();



    // Implementation

    if ((libGame_gv_gameOver == true)) {

        return true;

    }



    TriggerQueueEnter();

    UserDataResetType("MapVOEvent");

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Necromancer"));

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Raven Lord"));

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Observer"));

    lv_groupRaven = libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamOrderIndex_C, false);

    lv_groupNecromancer = libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamChaosIndex_C, false);

    lv_observers = libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer];

    if ((UnitGroupCount(libMTOD_gv_mMToDOrderBases, c_unitCountAlive) == 6)) {

        UserDataSetInt("MapVOEvent", "Bombardment Against Necro", "Value", 1, 1);

        libNtve_gf_AddPlayerGroupToPlayerGroup(lv_observers, lv_groupNecromancer);

    }

    else if ((UnitGroupCount(libMTOD_gv_mMToDChaosBases, c_unitCountAlive) == 6)) {

        UserDataSetInt("MapVOEvent", "Bombardment Against Raven", "Value", 1, 1);

        libNtve_gf_AddPlayerGroupToPlayerGroup(lv_observers, lv_groupRaven);

    }

    ConversationDataLineSetPlayers("FieldofSlaughter", ("Necromancer"), lv_groupNecromancer);

    ConversationDataLineSetPlayers("FieldofSlaughter", ("Raven Lord"), lv_groupRaven);

    ConversationDataRun("FieldofSlaughter", PlayerGroupAll(), c_conversationSkipNone, false);

    libCore_gf_WaitForConversationToFinish();

    TriggerQueueExit();

    return true;

}



trigger auto_libMTOD_gf_MMToDTownHallDestroyedForTeam_Trigger = null;

int auto_libMTOD_gf_MMToDTownHallDestroyedForTeam_lp_team;



void libMTOD_gf_MMToDTownHallDestroyedForTeam (int lp_team) {

    auto_libMTOD_gf_MMToDTownHallDestroyedForTeam_lp_team = lp_team;



    if (auto_libMTOD_gf_MMToDTownHallDestroyedForTeam_Trigger == null) {

        auto_libMTOD_gf_MMToDTownHallDestroyedForTeam_Trigger = TriggerCreate("auto_libMTOD_gf_MMToDTownHallDestroyedForTeam_TriggerFunc");

    }



    TriggerExecute(auto_libMTOD_gf_MMToDTownHallDestroyedForTeam_Trigger, false, false);

}



bool auto_libMTOD_gf_MMToDTownHallDestroyedForTeam_TriggerFunc (bool testConds, bool runActions) {

    int lp_team = auto_libMTOD_gf_MMToDTownHallDestroyedForTeam_lp_team;



    // Variable Declarations

    playergroup lv_groupNecromancer;

    playergroup lv_groupRaven;

    playergroup lv_observers;

    int lv_itIndex;



    // Automatic Variable Declarations

    // Variable Initialization

    lv_groupNecromancer = PlayerGroupEmpty();

    lv_groupRaven = PlayerGroupEmpty();

    lv_observers = PlayerGroupEmpty();



    // Implementation

    if ((libGame_gv_gameOver == true)) {

        return true;

    }



    TriggerQueueEnter();

    UserDataResetType("MapVOEvent");

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Necromancer"));

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Raven Lord"));

    ConversationDataLineResetPlayers("FieldofSlaughter", ("Observer"));

    if ((lp_team == libGame_gv_teamOrderIndex_C)) {

        UserDataSetInt("MapVOEvent", "Raven Lord Tower Captured", "Value", 1, 1);

    }

    else {

        UserDataSetInt("MapVOEvent", "Necromancer Tower Captured", "Value", 1, 1);

    }

    lv_groupRaven = libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamOrderIndex_C, false);

    lv_groupNecromancer = libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamChaosIndex_C, false);

    lv_observers = libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer];

    libNtve_gf_AddPlayerGroupToPlayerGroup(lv_observers, lv_groupRaven);

    ConversationDataLineSetPlayers("FieldofSlaughter", ("Necromancer"), lv_groupNecromancer);

    ConversationDataLineSetPlayers("FieldofSlaughter", ("Raven Lord"), lv_groupRaven);

    ConversationDataRun("FieldofSlaughter", PlayerGroupAll(), c_conversationSkipNone, false);

    libCore_gf_WaitForConversationToFinish();

    TriggerQueueExit();

    return true;

}



void libMTOD_gf_MMToDUIInit (int lp_parentPanel) {

    int init_i;



    // Variable Declarations

    int[6] lv_panels;

    int lv_currentPanelLayer;

    int lv_itTeam;

    int lv_enemyTeam;

    int lv_itTown;

    int lv_width_C;



    // Automatic Variable Declarations

    const int auto170F21D2_ae = libMTOD_gv_mMToDTownsMaxCount_C;

    const int auto170F21D2_ai = 1;

    int auto047339E0_val;



    // Variable Initialization

    for (init_i = 0; init_i <= 5; init_i += 1) {

        lv_panels[init_i] = c_invalidDialogControlId;

    }

    lv_width_C = 64;



    // Implementation

    DialogControlCreateInPanelFromTemplate(lp_parentPanel, c_triggerControlTypePanel, "FieldofSlaughter/MainFoSPanel");

    DialogControlSendAnimationEvent(DialogControlLastCreated(), libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamChaosIndex_C, true), "LeftTeamRed");

    lv_currentPanelLayer += 1;

    lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

    libMTOD_gv_mMToDPanels.lv_mainPanel = DialogControlLastCreated();

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "AltarSpawnNotificationFrame");

    lv_currentPanelLayer += 1;

    lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

    libMTOD_gv_mMToDPanels.lv_mainAltarTimerPanel = DialogControlLastCreated();

    DialogControlSetVisible(DialogControlLastCreated(), PlayerGroupAll(), false);

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypeLabel, "NotificationLabel");

    libMTOD_gv_mMToDPanels.lv_altarLabel = DialogControlLastCreated();

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypeLabel, "CountdownLabel");

    libMTOD_gv_mMToDPanels.lv_altarTimerLabel = DialogControlLastCreated();

    libNtve_gf_SetDialogItemText(libMTOD_gv_mMToDPanels.lv_altarTimerLabel, TextTimeFormat(StringToText("<mintotal/>:<sec2/>"), 0), PlayerGroupAll());

    lv_currentPanelLayer -= 1;

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "RavenNotificationFrame");

    lv_currentPanelLayer += 1;

    lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

    libMTOD_gv_mMToDPanels.lv_ravenNotificationPanel = DialogControlLastCreated();

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypeLabel, "NotificationLabel");

    libMTOD_gv_mMToDPanels.lv_ravenNotificationLabel = DialogControlLastCreated();

    lv_currentPanelLayer -= 1;

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "NecroNotificationFrame");

    lv_currentPanelLayer += 1;

    lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

    libMTOD_gv_mMToDPanels.lv_necroNotificationPanel = DialogControlLastCreated();

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypeLabel, "NotificationLabel");

    libMTOD_gv_mMToDPanels.lv_necroNotificationLabel = DialogControlLastCreated();

    lv_currentPanelLayer -= 1;

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "WaygateNotificationFrame");

    lv_currentPanelLayer += 1;

    lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

    libMTOD_gv_mMToDPanels.lv_waygateNotificationPanel = DialogControlLastCreated();

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypeLabel, "NotificationLabel");

    libNtve_gf_SetDialogItemText(DialogControlLastCreated(), StringExternal("Param/Value/lib_MTOD_0C2F897E"), PlayerGroupAll());

    lv_currentPanelLayer -= 1;

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "TowersNotificationFrame");

    lv_currentPanelLayer += 1;

    lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

    libMTOD_gv_mMToDPanels.lv_townUpgradeNotificationPanel = DialogControlLastCreated();

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypeLabel, "NotificationLabel");

    libNtve_gf_SetDialogItemText(DialogControlLastCreated(), StringExternal("Param/Value/lib_MTOD_EC757911"), PlayerGroupAll());

    lv_currentPanelLayer -= 1;

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "PotentialPointsPanel");

    lv_currentPanelLayer += 1;

    lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

    libMTOD_gv_mMToDPanels.lv_mainPotentialShotsPanel = DialogControlLastCreated();

    DialogControlSetVisible(DialogControlLastCreated(), PlayerGroupAll(), false);

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypeLabel, "PotentialPointsTitle");

    libNtve_gf_SetDialogItemText(DialogControlLastCreated(), StringExternal("Param/Value/lib_MTOD_87ED2AC6"), PlayerGroupAll());

    libMTOD_gv_mMToDPanels.lv_mainPotentialShotsLabel = DialogControlLastCreated();

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypeLabel, "LeftPotentialPoints");

    libMTOD_gv_mMToDPanels.lv_leftPotentialShotsLabel = DialogControlLastCreated();

    libNtve_gf_SetDialogItemText(libMTOD_gv_mMToDPanels.lv_leftPotentialShotsLabel, IntToText(0), PlayerGroupAll());

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypeLabel, "RightPotentialPoints");

    libMTOD_gv_mMToDPanels.lv_rightPotentialShotsLabel = DialogControlLastCreated();

    libNtve_gf_SetDialogItemText(libMTOD_gv_mMToDPanels.lv_rightPotentialShotsLabel, IntToText(0), PlayerGroupAll());

    lv_currentPanelLayer -= 1;

    libNtve_gf_SetDialogItemStyle(libMTOD_gv_mMToDPanels.lv_leftPotentialShotsLabel, "Storm_MapMechanic_MechanicCounterLeft_Red", libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_teamPlayerGroupNoNPCPlayers);

    libNtve_gf_SetDialogItemStyle(libMTOD_gv_mMToDPanels.lv_rightPotentialShotsLabel, "Storm_MapMechanic_MechanicCounterRight_Blue", libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_teamPlayerGroupNoNPCPlayers);

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "EnemyCaptureNotificationFrame");

    lv_currentPanelLayer += 1;

    lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

    libMTOD_gv_mMToDPanels.lv_enemyCaptureNotificationPanel = DialogControlLastCreated();

    DialogControlSetVisible(DialogControlLastCreated(), PlayerGroupAll(), false);

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypeLabel, "NotificationLabel");

    libMTOD_gv_mMToDPanels.lv_enemyCaptureNotificationLabel = DialogControlLastCreated();

    libNtve_gf_SetDialogItemText(libMTOD_gv_mMToDPanels.lv_enemyCaptureNotificationLabel, StringExternal("Param/Value/lib_MTOD_60813C72"), PlayerGroupAll());

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypeLabel, "NotificationTargetLabel");

    libMTOD_gv_mMToDPanels.lv_enemyCaptureNotificationTargetLabel = DialogControlLastCreated();

    lv_currentPanelLayer -= 1;

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "AllyCaptureNotificationFrame");

    lv_currentPanelLayer += 1;

    lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

    libMTOD_gv_mMToDPanels.lv_allyCaptureNotificationPanel = DialogControlLastCreated();

    DialogControlSetVisible(DialogControlLastCreated(), PlayerGroupAll(), false);

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypeLabel, "NotificationLabel");

    libMTOD_gv_mMToDPanels.lv_allyCaptureNotificationLabel = DialogControlLastCreated();

    libNtve_gf_SetDialogItemText(libMTOD_gv_mMToDPanels.lv_allyCaptureNotificationLabel, StringExternal("Param/Value/lib_MTOD_3069EA41"), PlayerGroupAll());

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypeLabel, "NotificationTargetLabel");

    libMTOD_gv_mMToDPanels.lv_allyCaptureNotificationTargetLabel = DialogControlLastCreated();

    lv_currentPanelLayer -= 1;

    DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "TownHealthPanel");

    DialogControlSetVisible(DialogControlLastCreated(), PlayerGroupAll(), false);

    lv_currentPanelLayer += 1;

    lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

    libMTOD_gv_mMToDPanels.lv_mainHealthPanel = DialogControlLastCreated();

    lv_itTown = 1;

    for ( ; ( (auto170F21D2_ai >= 0 && lv_itTown <= auto170F21D2_ae) || (auto170F21D2_ai < 0 && lv_itTown >= auto170F21D2_ae) ) ; lv_itTown += auto170F21D2_ai ) {

        auto047339E0_val = lv_itTown;

        if (auto047339E0_val == 1) {

            DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "TownOnePanel");

            lv_currentPanelLayer += 1;

            lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

            libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_mainTownPanel = DialogControlLastCreated();

        }

        else if (auto047339E0_val == 2) {

            DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "TownTwoPanel");

            lv_currentPanelLayer += 1;

            lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

            libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_mainTownPanel = DialogControlLastCreated();

        }

        else if (auto047339E0_val == 3) {

            DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "TownThreePanel");

            lv_currentPanelLayer += 1;

            lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

            libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_mainTownPanel = DialogControlLastCreated();

        }

        else if (auto047339E0_val == 4) {

            DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "TownFourPanel");

            lv_currentPanelLayer += 1;

            lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

            libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_mainTownPanel = DialogControlLastCreated();

        }

        else if (auto047339E0_val == 5) {

            DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "TownFivePanel");

            lv_currentPanelLayer += 1;

            lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

            libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_mainTownPanel = DialogControlLastCreated();

        }

        else if (auto047339E0_val == 6) {

            DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "TownSixPanel");

            lv_currentPanelLayer += 1;

            lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

            libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_mainTownPanel = DialogControlLastCreated();

        }

        else {

            break;

        }

        DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "BlueTown");

        DialogControlSetVisible(DialogControlLastCreated(), PlayerGroupAll(), false);

        lv_currentPanelLayer += 1;

        lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

        libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_blueTownPanel = DialogControlLastCreated();

        DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "BlueHealth");

        libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_blueTownHealth = DialogControlLastCreated();

        DialogControlSetSize(libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_blueTownHealth, libCore_gv_allHeroPlayersPlusObserver, lv_width_C, 1);

        DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "BlueHealthFrame");

        libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_blueTownHealthFrame = DialogControlLastCreated();

        DialogControlSetVisible(DialogControlLastCreated(), PlayerGroupAll(), false);

        lv_currentPanelLayer -= 1;

        DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "RedTown");

        DialogControlSetVisible(DialogControlLastCreated(), PlayerGroupAll(), false);

        lv_currentPanelLayer += 1;

        lv_panels[lv_currentPanelLayer] = DialogControlLastCreated();

        libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_redTownPanel = DialogControlLastCreated();

        DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "RedHealth");

        libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_redTownHealth = DialogControlLastCreated();

        DialogControlSetSize(libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_redTownHealth, libCore_gv_allHeroPlayersPlusObserver, lv_width_C, 1);

        DialogControlHookup(lv_panels[lv_currentPanelLayer], c_triggerControlTypePanel, "RedHealthFrame");

        libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_redTownHealthFrame = DialogControlLastCreated();

        DialogControlSetVisible(DialogControlLastCreated(), PlayerGroupAll(), false);

        lv_currentPanelLayer -= 1;

        lv_currentPanelLayer -= 1;

    }

    lv_currentPanelLayer -= 1;

    DialogControlSendAnimationEvent(libUIUI_gv_uIObserverUI.lv_mainPanel, libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], "BroadcastToDInit");

    DialogControlSendAnimationEvent(libUIUI_gv_uIObserverUI.lv_mainPanel, libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], "BroadcastToD3v3");

}



trigger auto_libMTOD_gf_MMToDUIDisplayCaptureNotification_Trigger = null;

int auto_libMTOD_gf_MMToDUIDisplayCaptureNotification_lp_teamThatCapturedTown;

int auto_libMTOD_gf_MMToDUIDisplayCaptureNotification_lp_townThatWasCaptured;



void libMTOD_gf_MMToDUIDisplayCaptureNotification (int lp_teamThatCapturedTown, int lp_townThatWasCaptured) {

    auto_libMTOD_gf_MMToDUIDisplayCaptureNotification_lp_teamThatCapturedTown = lp_teamThatCapturedTown;

    auto_libMTOD_gf_MMToDUIDisplayCaptureNotification_lp_townThatWasCaptured = lp_townThatWasCaptured;



    if (auto_libMTOD_gf_MMToDUIDisplayCaptureNotification_Trigger == null) {

        auto_libMTOD_gf_MMToDUIDisplayCaptureNotification_Trigger = TriggerCreate("auto_libMTOD_gf_MMToDUIDisplayCaptureNotification_TriggerFunc");

    }



    TriggerExecute(auto_libMTOD_gf_MMToDUIDisplayCaptureNotification_Trigger, false, false);

}



bool auto_libMTOD_gf_MMToDUIDisplayCaptureNotification_TriggerFunc (bool testConds, bool runActions) {

    int lp_teamThatCapturedTown = auto_libMTOD_gf_MMToDUIDisplayCaptureNotification_lp_teamThatCapturedTown;

    int lp_townThatWasCaptured = auto_libMTOD_gf_MMToDUIDisplayCaptureNotification_lp_townThatWasCaptured;



    // Variable Declarations

    int lv_enemyTeam;

    text lv_notificationText;

    string lv_directionalAnimation;



    // Automatic Variable Declarations

    int auto9477AF6E_val;



    // Variable Initialization

    lv_directionalAnimation = "";



    // Implementation

    lv_notificationText = libMTOD_gv_mMToDTowns[lp_townThatWasCaptured].lv_townName;

    lv_enemyTeam = libGame_gf_EnemyTeam(lp_teamThatCapturedTown);

    auto9477AF6E_val = lp_townThatWasCaptured;

    if (auto9477AF6E_val == 1) {

        lv_directionalAnimation = "CaptureNW";

        SoundPlayForPlayer(SoundLink("UI_Game_Ping_Towers_Captured_Lumbermill", -1), c_maxPlayers, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

    }

    else if (auto9477AF6E_val == 2) {

        lv_directionalAnimation = "CaptureW";

        SoundPlayForPlayer(SoundLink("UI_Game_Ping_Towers_Captured_Armory", -1), c_maxPlayers, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

    }

    else if (auto9477AF6E_val == 3) {

        lv_directionalAnimation = "CaptureSW";

        SoundPlayForPlayer(SoundLink("UI_Game_Ping_Towers_Captured_Farm", -1), c_maxPlayers, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

    }

    else if (auto9477AF6E_val == 4) {

        lv_directionalAnimation = "CaptureNE";

        SoundPlayForPlayer(SoundLink("UI_Game_Ping_Towers_Captured_Mine", -1), c_maxPlayers, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

    }

    else if (auto9477AF6E_val == 5) {

        lv_directionalAnimation = "CaptureE";

        SoundPlayForPlayer(SoundLink("UI_Game_Ping_Towers_Captured_Blacksmith", -1), c_maxPlayers, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

    }

    else if (auto9477AF6E_val == 6) {

        lv_directionalAnimation = "CaptureSE";

        SoundPlayForPlayer(SoundLink("UI_Game_Ping_Towers_Captured_Graveyard", -1), c_maxPlayers, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

    }

    else {

    }

    libNtve_gf_SetDialogItemText(libMTOD_gv_mMToDPanels.lv_allyCaptureNotificationTargetLabel, lv_notificationText, libGame_gf_PlayersOnTeamHeroes(lp_teamThatCapturedTown, true));

    libNtve_gf_SetDialogItemText(libMTOD_gv_mMToDPanels.lv_enemyCaptureNotificationTargetLabel, lv_notificationText, libGame_gf_PlayersOnTeamHeroes(lv_enemyTeam, true));

    DialogControlSendAnimationEvent(libMTOD_gv_mMToDPanels.lv_allyCaptureNotificationPanel, libGame_gf_PlayersOnTeamHeroes(lp_teamThatCapturedTown, true), lv_directionalAnimation);

    DialogControlSendAnimationEvent(libMTOD_gv_mMToDPanels.lv_enemyCaptureNotificationPanel, libGame_gf_PlayersOnTeamHeroes(lv_enemyTeam, true), lv_directionalAnimation);

    DialogControlSendAnimationEvent(libMTOD_gv_mMToDPanels.lv_allyCaptureNotificationPanel, libGame_gf_PlayersOnTeamHeroes(lp_teamThatCapturedTown, true), "Show");

    DialogControlSendAnimationEvent(libMTOD_gv_mMToDPanels.lv_enemyCaptureNotificationPanel, libGame_gf_PlayersOnTeamHeroes(lv_enemyTeam, true), "Show");

    Wait(5.0, c_timeGame);

    DialogControlSendAnimationEvent(libMTOD_gv_mMToDPanels.lv_allyCaptureNotificationPanel, libGame_gf_PlayersOnTeamHeroes(lp_teamThatCapturedTown, true), "Hide");

    DialogControlSendAnimationEvent(libMTOD_gv_mMToDPanels.lv_enemyCaptureNotificationPanel, libGame_gf_PlayersOnTeamHeroes(lv_enemyTeam, true), "Hide");

    return true;

}



trigger auto_libMTOD_gf_MMToDUIDisplayTowerUpgradeUI_Trigger = null;



void libMTOD_gf_MMToDUIDisplayTowerUpgradeUI () {

    if (auto_libMTOD_gf_MMToDUIDisplayTowerUpgradeUI_Trigger == null) {

        auto_libMTOD_gf_MMToDUIDisplayTowerUpgradeUI_Trigger = TriggerCreate("auto_libMTOD_gf_MMToDUIDisplayTowerUpgradeUI_TriggerFunc");

    }



    TriggerExecute(auto_libMTOD_gf_MMToDUIDisplayTowerUpgradeUI_Trigger, false, false);

}



bool auto_libMTOD_gf_MMToDUIDisplayTowerUpgradeUI_TriggerFunc (bool testConds, bool runActions) {

    // Variable Declarations

    int lv_enemyTeam;

    text lv_notificationText;

    string lv_directionalAnimation;



    // Automatic Variable Declarations

    // Variable Initialization

    lv_directionalAnimation = "";



    // Implementation

    DialogControlSendAnimationEvent(libMTOD_gv_mMToDPanels.lv_townUpgradeNotificationPanel, PlayerGroupAll(), "Show");

    Wait(5.0, c_timeGame);

    DialogControlSendAnimationEvent(libMTOD_gv_mMToDPanels.lv_townUpgradeNotificationPanel, PlayerGroupAll(), "Hide");

    return true;

}



trigger auto_libMTOD_gf_MMToDUIDisplayRavenNecroNotifications_Trigger = null;

text auto_libMTOD_gf_MMToDUIDisplayRavenNecroNotifications_lp_text;

int auto_libMTOD_gf_MMToDUIDisplayRavenNecroNotifications_lp_team;

playergroup auto_libMTOD_gf_MMToDUIDisplayRavenNecroNotifications_lp_players;



void libMTOD_gf_MMToDUIDisplayRavenNecroNotifications (text lp_text, int lp_team, playergroup lp_players) {

    auto_libMTOD_gf_MMToDUIDisplayRavenNecroNotifications_lp_text = lp_text;

    auto_libMTOD_gf_MMToDUIDisplayRavenNecroNotifications_lp_team = lp_team;

    auto_libMTOD_gf_MMToDUIDisplayRavenNecroNotifications_lp_players = lp_players;



    if (auto_libMTOD_gf_MMToDUIDisplayRavenNecroNotifications_Trigger == null) {

        auto_libMTOD_gf_MMToDUIDisplayRavenNecroNotifications_Trigger = TriggerCreate("auto_libMTOD_gf_MMToDUIDisplayRavenNecroNotifications_TriggerFunc");

    }



    TriggerExecute(auto_libMTOD_gf_MMToDUIDisplayRavenNecroNotifications_Trigger, false, false);

}



bool auto_libMTOD_gf_MMToDUIDisplayRavenNecroNotifications_TriggerFunc (bool testConds, bool runActions) {

    text lp_text = auto_libMTOD_gf_MMToDUIDisplayRavenNecroNotifications_lp_text;

    int lp_team = auto_libMTOD_gf_MMToDUIDisplayRavenNecroNotifications_lp_team;

    playergroup lp_players = auto_libMTOD_gf_MMToDUIDisplayRavenNecroNotifications_lp_players;



    // Variable Declarations

    text lv_notificationText;

    int lv_notificationPanel;

    int lv_notificationLabel;



    // Automatic Variable Declarations

    // Variable Initialization

    lv_notificationPanel = c_invalidDialogControlId;

    lv_notificationLabel = c_invalidDialogControlId;



    // Implementation

    if ((lp_team == libGame_gv_teamOrderIndex_C)) {

        lv_notificationPanel = libMTOD_gv_mMToDPanels.lv_ravenNotificationPanel;

        lv_notificationLabel = libMTOD_gv_mMToDPanels.lv_ravenNotificationLabel;

    }

    else {

        lv_notificationPanel = libMTOD_gv_mMToDPanels.lv_necroNotificationPanel;

        lv_notificationLabel = libMTOD_gv_mMToDPanels.lv_necroNotificationLabel;

    }

    libNtve_gf_SetDialogItemText(lv_notificationLabel, lp_text, lp_players);

    DialogControlSendAnimationEvent(lv_notificationPanel, lp_players, "Show");

    Wait(5.0, c_timeGame);

    DialogControlSendAnimationEvent(lv_notificationPanel, lp_players, "Hide");

    return true;

}



void libMTOD_gf_MMToDShowHideTownOwnershipUI (bool lp_showHide, int lp_townNumber, int lp_owningTeam) {

    // Automatic Variable Declarations

    // Implementation

    if ((lp_showHide == true)) {

        if ((lp_owningTeam == libCore_gv_cOMPUTER_TeamOrder)) {

            DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lp_townNumber].lv_blueTownPanel, libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_teamPlayerGroupNoNPCPlayers, true);

            DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lp_townNumber].lv_blueTownPanel, libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], true);

            DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lp_townNumber].lv_redTownPanel, libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_teamPlayerGroupNoNPCPlayers, true);

        }

        else {

            DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lp_townNumber].lv_redTownPanel, libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_teamPlayerGroupNoNPCPlayers, true);

            DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lp_townNumber].lv_redTownPanel, libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], true);

            DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lp_townNumber].lv_blueTownPanel, libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_teamPlayerGroupNoNPCPlayers, true);

        }

    }

    else {

        DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lp_townNumber].lv_blueTownPanel, libCore_gv_allHeroPlayersPlusObserver, false);

        DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lp_townNumber].lv_blueTownHealthFrame, libCore_gv_allHeroPlayersPlusObserver, false);

        DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lp_townNumber].lv_redTownPanel, libCore_gv_allHeroPlayersPlusObserver, false);

        DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lp_townNumber].lv_redTownHealthFrame, libCore_gv_allHeroPlayersPlusObserver, false);

    }

}



// Triggers

//--------------------------------------------------------------------------------------------------

// Trigger: #Include ToD

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_IncludeToD_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Actions

    if (!runActions) {

        return true;

    }



    libMTOD_gf_MMToDInitMercs();

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_IncludeToD_Init () {

    libMTOD_gt_IncludeToD = TriggerCreate("libMTOD_gt_IncludeToD_Func");

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Init

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDInit_Func (bool testConds, bool runActions) {

    // Variable Declarations

    int lv_itPlayer;



    // Automatic Variable Declarations

    // Variable Initialization



    // Conditions

    if (testConds) {

        if (!((libGame_gf_MapMechanicInitializationMechanicType() == libMTOD_gv_mMToDMechanicName_C))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    libGame_gf_MinionTurnOnOffCatapults(false);

    libGame_gf_TowerTurnOnOffCoreWarning(false);

    libGame_gf_TurnOnOffTownDestructionRemovesCoreInvulnerable(false);

    TriggerEnable(libMTOD_gt_MMToDGateOpen, true);

    TriggerEnable(libMTOD_gt_MMToDOwnedTownDies, true);

    TriggerExecute(libMTOD_gt_MMToDInitializeScoringAltars, true, false);

    TriggerExecute(libMTOD_gt_MMToDArchwayAnims, true, false);

    TriggerExecute(libMTOD_gt_MMToDInitStoreSpiritHealer, true, false);

    libGame_gf_TownTurnOnOffBasicMinimapHealthMonitor(false);

    libGame_gf_SendMapSpecificAwardInitializeEventwithUserData(null, "Generic Instance");

    libGame_gv_loot_DropBannerInTownHallRubble = false;

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDInit_Init () {

    libMTOD_gt_MMToDInit = TriggerCreate("libMTOD_gt_MMToDInit_Func");

    libGame_gf_MapMechanicInitialization(libMTOD_gt_MMToDInit);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Ping Data Init

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDPingDataInit_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Actions

    if (!runActions) {

        return true;

    }



    libUIUI_gf_PingCreateNewPingTarget("ScoringAltar", false, StringExternal("Param/Value/lib_MTOD_C5A84577"), StringExternal("Param/Value/lib_MTOD_8B3F9F28"), StringExternal("Param/Value/lib_MTOD_2EA546EC"), SoundLink("UI_Game_Ping_Attack", -1), SoundLink("UI_Game_Ping_Attack", -1));

    libUIUI_gf_PingCreateNewPingTarget("MercHorsemanDefender", false, StringExternal("Param/Value/lib_MTOD_6084BBD2"), StringExternal("Param/Value/lib_MTOD_9D423CC4"), StringExternal("Param/Value/lib_MTOD_E396B9C4"), SoundLink("UI_Game_Ping_Attack", -1), SoundLink("UI_Game_Ping_Attack", -1));

    libUIUI_gf_PingSetHumanAISourceHeroVOForPingTarget(libUIUI_gf_PingLastCreatedPingTarget(), libCore_ge_HeroVOEvents_PingAttackMercCamp, libCore_ge_HeroVOEvents_AIMercCapture);

    libUIUI_gf_PingCreateNewPingTarget("MercGoblinSapperDefender", false, StringExternal("Param/Value/lib_MTOD_A81CE80F"), StringExternal("Param/Value/lib_MTOD_22464847"), StringExternal("Param/Value/lib_MTOD_3B0B69BE"), SoundLink("UI_Game_Ping_Attack", -1), SoundLink("UI_Game_Ping_Attack", -1));

    libUIUI_gf_PingSetHumanAISourceHeroVOForPingTarget(libUIUI_gf_PingLastCreatedPingTarget(), libCore_ge_HeroVOEvents_PingAttackMercCamp, libCore_ge_HeroVOEvents_AIMercCapture);

    libUIUI_gf_PingCreateNewPingTarget("MercGoblinSapperLaner", false, null, StringExternal("Param/Value/lib_MTOD_062273EA"), StringExternal("Param/Value/lib_MTOD_4D6D24F1"), SoundLink("UI_Game_Ping_Attack", -1), SoundLink("UI_Game_Ping_Attack", -1));

    libUIUI_gf_PingSetAllyEnemyTargetHeroVOForPingTarget(libUIUI_gf_PingLastCreatedPingTarget(), libCore_ge_HeroVOEvents_PingAttackHere, libCore_ge_HeroVOEvents_PingAttackHere);

    libUIUI_gf_PingCreateNewPingTarget("WaygateEntrance", false, StringExternal("Param/Value/lib_MTOD_3F33DED3"), StringExternal("Param/Value/lib_MTOD_F10E524E"), StringExternal("Param/Value/lib_MTOD_950C7E12"), SoundLink("UI_Game_Ping_General", -1), SoundLink("UI_Game_Ping_General", -1));

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDPingDataInit_Init () {

    libMTOD_gt_MMToDPingDataInit = TriggerCreate("libMTOD_gt_MMToDPingDataInit_Func");

    libCore_gf_IncludeModInitialization(libMTOD_gt_MMToDPingDataInit);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Initialize Scoring Altars

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDInitializeScoringAltars_Func (bool testConds, bool runActions) {

    // Variable Declarations

    int lv_itTown;



    // Automatic Variable Declarations

    const int auto0FE546AA_ae = 4;

    const int auto0FE546AA_ai = 1;



    // Variable Initialization



    // Actions

    if (!runActions) {

        return true;

    }



    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarConfigs[1], 1);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarConfigs[1], 2);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarConfigs[2], 3);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarConfigs[3], 4);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarConfigs[4], 3);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarConfigs[4], 4);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarConfigs[5], 1);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarConfigs[5], 2);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarConfigs[5], 4);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarConfigs[6], 1);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarConfigs[6], 2);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarConfigs[6], 3);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarRemainingConfigs, 1);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarRemainingConfigs, 2);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarRemainingConfigs, 3);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarRemainingConfigs, 4);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarRemainingConfigsThreeAltarEvent, 5);

    PlayerGroupAdd(libMTOD_gv_mMToDScoringAltarRemainingConfigsThreeAltarEvent, 6);

    lv_itTown = 1;

    for ( ; ( (auto0FE546AA_ai >= 0 && lv_itTown <= auto0FE546AA_ae) || (auto0FE546AA_ai < 0 && lv_itTown >= auto0FE546AA_ae) ) ; lv_itTown += auto0FE546AA_ai ) {

        libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itTown].lv_unit, "MinimapIcon Assets\\Textures\\storm_ui_minimapicon_tod_altar_active.dds");

        libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itTown].lv_unit, "MinimapIconTintColor 255,145,113,218");

        libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itTown].lv_unit, "SetMinimapVisibility");

        libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itTown].lv_unit, "SetMinimapVisibilityAlways");

    }

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDInitializeScoringAltars_Init () {

    libMTOD_gt_MMToDInitializeScoringAltars = TriggerCreate("libMTOD_gt_MMToDInitializeScoringAltars_Func");

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Gate Open

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDGateOpen_Func (bool testConds, bool runActions) {

    // Variable Declarations

    int lv_itTown;



    // Automatic Variable Declarations

    // Variable Initialization



    // Conditions

    if (testConds) {

        if (!((libMapM_gv_mMMapMechanicDisabled == false))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    TimerStart(libMTOD_gv_mMToDScalingTimer, 60.0, true, c_timeGame);

    TriggerExecute(libMTOD_gt_MMToDStartPhaseTwoTimer, true, false);

    TriggerExecute(libMTOD_gt_MMToDScoringAltarTimerTrigger, true, false);

    libMTOD_gf_MMToDUpdatePotentialShotsLabels();

    TimerStart(libMTOD_gv_mMToDObjectivePreviewTimer, libMTOD_gv_mMToDObjectivePreviewDelay_C, false, c_timeGame);

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDGateOpen_Init () {

    libMTOD_gt_MMToDGateOpen = TriggerCreate("libMTOD_gt_MMToDGateOpen_Func");

    TriggerEnable(libMTOD_gt_MMToDGateOpen, false);

    TriggerAddEventTimer(libMTOD_gt_MMToDGateOpen, libGame_gv_openTheGatesTimer);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Archway Anims

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDArchwayAnims_Func (bool testConds, bool runActions) {

    // Variable Declarations

    unit lv_itUnit;

    actor lv_actorRegion;



    // Automatic Variable Declarations

    // Variable Initialization



    // Actions

    if (!runActions) {

        return true;

    }



    while (!((TimerGetRemaining(libGame_gv_openTheGatesTimer) >= 1))) {

        Wait(0.0625, c_timeGame);

    }

    libNtve_gf_WaitForTimer(libGame_gv_openTheGatesTimer, 6.0, false);

    ActorRegionCreate(null, "TriggerRegion", RegionEntireMap());

    lv_actorRegion = libNtve_gf_ActorLastCreated();

    ActorRegionSend(lv_actorRegion, c_actorIntersectAgainstRadiusContact, "Signal OpenSesame", "Doodad", "ScopeContains _ArchwayDoor");

    ActorScopeKill(ActorScopeFromActor(lv_actorRegion));

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDArchwayAnims_Init () {

    libMTOD_gt_MMToDArchwayAnims = TriggerCreate("libMTOD_gt_MMToDArchwayAnims_Func");

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Minimap Health Monitor

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDMinimapHealthMonitor_Func (bool testConds, bool runActions) {

    int init_i;



    // Variable Declarations

    int lv_itTown;

    fixed[libGame_gv_townMaxTownCount + 1] lv_townHallLastHealth;



    // Automatic Variable Declarations

    int auto090D3B36_ae;

    const int auto090D3B36_ai = 1;



    // Variable Initialization

    for (init_i = 0; init_i <= libGame_gv_townMaxTownCount; init_i += 1) {

        lv_townHallLastHealth[init_i] = 100.0;

    }



    // Actions

    if (!runActions) {

        return true;

    }



    while (true) {

        auto090D3B36_ae = libGame_gv_townTownCount;

        lv_itTown = 1;

        for ( ; ( (auto090D3B36_ai >= 0 && lv_itTown <= auto090D3B36_ae) || (auto090D3B36_ai < 0 && lv_itTown >= auto090D3B36_ae) ) ; lv_itTown += auto090D3B36_ai ) {

            if ((libGame_gf_TownTownHall(lv_itTown) == null)) {

                continue;

            }



            if ((UnitGetPropertyFixed(libGame_gf_TownTownHall(lv_itTown), c_unitPropLifePercent, c_unitPropCurrent) == 100.0) && (lv_townHallLastHealth[lv_itTown] < 100.0)) {

                libNtve_gf_SendActorMessageToUnit(libGame_gf_TownTownHall(lv_itTown), "MinimapIcon Assets\\Textures\\storm_ui_minimapicon_tod_town.dds");

                libNtve_gf_SendActorMessageToUnit(libGame_gf_TownTownHall(lv_itTown), "MinimapIconBackground Assets\\Textures\\storm_ui_minimapicon_tod_town_outline.dds");

            }



            if ((UnitGetPropertyFixed(libGame_gf_TownTownHall(lv_itTown), c_unitPropLifePercent, c_unitPropCurrent) < 18.0) && ((lv_townHallLastHealth[lv_itTown] >= 18.0) || (lv_townHallLastHealth[lv_itTown] == 0.0)) && (UnitHasBehavior2(libGame_gf_TownTownHall(lv_itTown), "StructureOwnershipChangeRepairBehavior") == true)) {

                libNtve_gf_SendActorMessageToUnit(libGame_gf_TownTownHall(lv_itTown), "MinimapIcon Assets\\Textures\\storm_ui_minimapicon_tod_town_regen_fill.dds");

                libNtve_gf_SendActorMessageToUnit(libGame_gf_TownTownHall(lv_itTown), "MinimapIconBackground Assets\\Textures\\storm_ui_minimapicon_tod_town_regen_outline.dds");

            }



            lv_townHallLastHealth[lv_itTown] = UnitGetPropertyFixed(libGame_gf_TownTownHall(lv_itTown), c_unitPropLifePercent, c_unitPropCurrent);

        }

        Wait(0.125, c_timeGame);

    }

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDMinimapHealthMonitor_Init () {

    libMTOD_gt_MMToDMinimapHealthMonitor = TriggerCreate("libMTOD_gt_MMToDMinimapHealthMonitor_Func");

    TriggerAddEventTimer(libMTOD_gt_MMToDMinimapHealthMonitor, libGame_gv_openTheGatesTimer);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Fast Spawn Minions

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDFastSpawnMinions_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Actions

    if (!runActions) {

        return true;

    }



    Wait(0.1, c_timeGame);

    TimerStart(libGame_gv_minionSpawnStartTimer, 0.0, false, c_timeGame);

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDFastSpawnMinions_Init () {

    libMTOD_gt_MMToDFastSpawnMinions = TriggerCreate("libMTOD_gt_MMToDFastSpawnMinions_Func");

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Scoring Altar Timer Trigger

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDScoringAltarTimerTrigger_Func (bool testConds, bool runActions) {

    // Variable Declarations

    fixed lv_variance;

    int lv_pointGroup;

    int lv_itAltar;

    bool lv_morphPlayed;

    bool lv_morphSoundPlayed;

    int lv_totalAltarCount;



    // Automatic Variable Declarations

    playergroup autoA57EF536_g;

    playergroup autoF74B1F8D_g;

    playergroup auto4342AB9A_g;

    playergroup auto820ABFCC_g;



    // Variable Initialization



    // Actions

    if (!runActions) {

        return true;

    }



    if ((libMTOD_gv_mMToDFirstEventSpawned == true)) {

        TimerStart(libMTOD_gv_mMToDScoringAltarTimer, libMTOD_gv_mMToDAltarRespawnDelay_C, false, c_timeGame);

    }

    else {

        libMTOD_gv_mMToDFirstEventSpawned = true;

        TimerStart(libMTOD_gv_mMToDScoringAltarTimer, libMTOD_gv_mMToDScoringEventDelay_C, false, c_timeGame);

    }

    libNtve_gf_WaitForTimer(libMTOD_gv_mMToDScoringAltarTimer, libMTOD_gv_mMToDScoringAltarWarningTime_C, false);

    if (((libMTOD_gv_mMToDMapEventDisabled == true) || (libGame_gv_gameOver == true))) {

        return true;

    }



    SoundPlayForPlayer(SoundLink("UI_Game_Ping_ScoringAlter_Spawning", -1), c_maxPlayers, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

    libMTOD_gf_MMToDTransmissionBellTowersActivating();

    lv_pointGroup = libMTOD_gv_mMToDEventCurrentPointGroup;

    autoA57EF536_g = libMTOD_gv_mMToDScoringAltarConfigs[lv_pointGroup];

    lv_itAltar = -1;

    while (true) {

        	lv_itAltar = PlayerGroupNextPlayer(autoA57EF536_g, lv_itAltar);

        	if (lv_itAltar<0) { break; }

        	libCore_gf_CreateMinimapPingStorm(PlayerGroupAll(), "StormAlert", UnitGetPosition(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit), ColorWithAlpha(100.00, 100.00, 0.00, 0.00), libMTOD_gv_mMToDScoringAltarWarningTime_C);

        lv_totalAltarCount = (lv_totalAltarCount + 1);

    }

    if ((lv_totalAltarCount == 1)) {

        libNtve_gf_SetDialogItemText(libMTOD_gv_mMToDPanels.lv_altarLabel, StringExternal("Param/Value/lib_MTOD_F838B570"), PlayerGroupAll());

    }

    else {

        libNtve_gf_SetDialogItemText(libMTOD_gv_mMToDPanels.lv_altarLabel, StringExternal("Param/Value/lib_MTOD_191414BF"), PlayerGroupAll());

    }

    libNtve_gf_SetDialogItemText(libMTOD_gv_mMToDPanels.lv_altarTimerLabel, TextTimeFormat(StringToText("<mintotal/>:<sec2/>"), FixedToInt(TimerGetRemaining(libMTOD_gv_mMToDScoringAltarTimer))), PlayerGroupAll());

    DialogControlSendAnimationEvent(libMTOD_gv_mMToDPanels.lv_mainAltarTimerPanel, PlayerGroupAll(), "Show");

    while ((TimerGetRemaining(libMTOD_gv_mMToDScoringAltarTimer) > 0.0)) {

        libNtve_gf_SetDialogItemText(libMTOD_gv_mMToDPanels.lv_altarTimerLabel, TextTimeFormat(StringToText("<mintotal/>:<sec2/>"), FixedToInt(TimerGetRemaining(libMTOD_gv_mMToDScoringAltarTimer))), PlayerGroupAll());

        if ((lv_morphSoundPlayed == false) && (TimerGetRemaining(libMTOD_gv_mMToDScoringAltarTimer) <= libMTOD_gv_mMToDScoringAltarSecondSpawnSoundTime_C)) {

            SoundPlayForPlayer(SoundLink("UI_Game_Ping_ScoringAlter_Spawning_Long_Build", -1), c_maxPlayers, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

            SoundtrackStop(PlayerGroupAll(), c_soundtrackCategoryMusic, true);

            libSond_gf_SoundtrackApplyNewDefaultSoundtrackForPlayerGroup("MX_Towers_Shrine_Prespawn", libCore_gv_allHeroPlayersPlusObserver);

            lv_morphSoundPlayed = true;

        }



        if ((lv_morphPlayed == false) && (TimerGetRemaining(libMTOD_gv_mMToDScoringAltarTimer) <= libMTOD_gv_mMToDScoringAltarAnimTime_C)) {

            lv_morphPlayed = true;

            autoF74B1F8D_g = libMTOD_gv_mMToDScoringAltarConfigs[lv_pointGroup];

            lv_itAltar = -1;

            while (true) {

                	lv_itAltar = PlayerGroupNextPlayer(autoF74B1F8D_g, lv_itAltar);

                	if (lv_itAltar<0) { break; }

                	libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, "Signal Activate");

                AddUnitOfInterest(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit, 0.0, libMTOD_gv_mMToDScoringAltarAnimTime_C, "UseAltar", libNtve_ge_GoalTeam_Both, 0);

            }

        }



        Wait(1.0, c_timeGame);

    }

    if ((libGame_gv_gameOver == true)) {

        return true;

    }



    SoundtrackStop(PlayerGroupAll(), c_soundtrackCategoryMusic, true);

    libSond_gf_SoundtrackPlayMapSoundtrackAsDefaultSoundtrackForAllPlayers();

    libMTOD_gf_MMToDTransmissionBellTowersActivate();

    DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_mainPotentialShotsPanel, PlayerGroupAll(), true);

    auto4342AB9A_g = libMTOD_gv_mMToDScoringAltarConfigs[lv_pointGroup];

    lv_itAltar = -1;

    while (true) {

        	lv_itAltar = PlayerGroupNextPlayer(auto4342AB9A_g, lv_itAltar);

        	if (lv_itAltar<0) { break; }

        	libMTOD_gf_MMToDTurnOnOffScoringAltar(true, lv_itAltar);

        libMTOD_gv_mMToDScoringAltarsActive += 1;

    }

    TriggerEnable(libMTOD_gt_MMToDScoringAltarCaptured, true);

    auto820ABFCC_g = libMTOD_gv_mMToDScoringAltarConfigs[lv_pointGroup];

    lv_itAltar = -1;

    while (true) {

        	lv_itAltar = PlayerGroupNextPlayer(auto820ABFCC_g, lv_itAltar);

        	if (lv_itAltar<0) { break; }

        	VisRevealerCreate(libCore_gv_cOMPUTER_TeamOrder, RegionCircle(UnitGetPosition(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit), libMTOD_gv_mMToDScoringAltarRevealArea_C));

        libMTOD_gv_mMToDScoringAltarOrderRevealers[lv_itAltar] = VisRevealerLastCreated();

        VisRevealerCreate(libCore_gv_cOMPUTER_TeamChaos, RegionCircle(UnitGetPosition(libMTOD_gv_mMToDScoringAltars[lv_itAltar].lv_unit), libMTOD_gv_mMToDScoringAltarRevealArea_C));

        libMTOD_gv_mMToDScoringAltarChaosRevealers[lv_itAltar] = VisRevealerLastCreated();

    }

    DialogControlSendAnimationEvent(libMTOD_gv_mMToDPanels.lv_mainAltarTimerPanel, PlayerGroupAll(), "Hide");

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDScoringAltarTimerTrigger_Init () {

    libMTOD_gt_MMToDScoringAltarTimerTrigger = TriggerCreate("libMTOD_gt_MMToDScoringAltarTimerTrigger_Func");

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Objective Preview Timer Expires

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDObjectivePreviewTimerExpires_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Actions

    if (!runActions) {

        return true;

    }



    libMTOD_gf_MMToDDefineNextAltarsandCreatePreviews();

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDObjectivePreviewTimerExpires_Init () {

    libMTOD_gt_MMToDObjectivePreviewTimerExpires = TriggerCreate("libMTOD_gt_MMToDObjectivePreviewTimerExpires_Func");

    TriggerAddEventTimer(libMTOD_gt_MMToDObjectivePreviewTimerExpires, libMTOD_gv_mMToDObjectivePreviewTimer);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Scoring Altar Captured

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDScoringAltarCaptured_Func (bool testConds, bool runActions) {

    // Variable Declarations

    int lv_itTempleIndex;

    unit lv_capturingHero;

    int lv_capturingPlayer;

    int lv_capturingTeam;

    unit lv_capturedAltar;



    // Automatic Variable Declarations

    const int autoBB63A186_ae = libMTOD_gv_mMToDScoringAltarMaxCount_C;

    const int autoBB63A186_ai = 1;

    int auto50716AB6_val;



    // Variable Initialization

    lv_capturingHero = EventPlayerEffectUsedUnit(c_effectUnitCaster);

    lv_capturingPlayer = UnitGetOwner(lv_capturingHero);

    lv_capturingTeam = libGame_gf_TeamNumberOfPlayer(lv_capturingPlayer);

    lv_capturedAltar = EventPlayerEffectUsedUnit(c_effectUnitTarget);



    // Conditions

    if (testConds) {

        if (!((libGame_gf_UnitIsHero(lv_capturingHero) == true))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    libGame_gf_AfkResetWarningTimerForPlayer(lv_capturingPlayer);

    lv_itTempleIndex = 1;

    for ( ; ( (autoBB63A186_ai >= 0 && lv_itTempleIndex <= autoBB63A186_ae) || (autoBB63A186_ai < 0 && lv_itTempleIndex >= autoBB63A186_ae) ) ; lv_itTempleIndex += autoBB63A186_ai ) {

        if ((lv_capturedAltar == libMTOD_gv_mMToDScoringAltars[lv_itTempleIndex].lv_unit)) {

            if ((libMTOD_gv_mMToDScoringAltars[lv_itTempleIndex].lv_active == false)) {

                return true;

            }



            StatEventCreate("Altar Captured");

            StatEventAddDataInt(StatEventLastCreated(), "Firing Team", lv_capturingTeam);

            if ((lv_capturingTeam == libGame_gv_teamOrderIndex_C)) {

                StatEventAddDataInt(StatEventLastCreated(), "Towns Owned", UnitGroupCount(libMTOD_gv_mMToDOrderBases, c_unitCountAlive));

                libMTOD_gf_MMToDAltarDamageDoneCache(lv_capturingPlayer, UnitGroupCount(libMTOD_gv_mMToDOrderBases, c_unitCountAlive));

            }

            else {

                StatEventAddDataInt(StatEventLastCreated(), "Towns Owned", UnitGroupCount(libMTOD_gv_mMToDChaosBases, c_unitCountAlive));

                libMTOD_gf_MMToDAltarDamageDoneCache(lv_capturingPlayer, UnitGroupCount(libMTOD_gv_mMToDChaosBases, c_unitCountAlive));

            }

            StatEventSend(StatEventLastCreated());

            auto50716AB6_val = lv_capturingTeam;

            if (auto50716AB6_val == libGame_gv_teamOrderIndex_C) {

                libMTOD_gf_MMToDUIDisplayRavenNecroNotifications(StringExternal("Param/Value/lib_MTOD_3231CC5C"), libGame_gv_teamOrderIndex_C, libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamOrderIndex_C, true));

                libMTOD_gf_MMToDUIDisplayRavenNecroNotifications(StringExternal("Param/Value/lib_MTOD_36E9BAD3"), libGame_gv_teamOrderIndex_C, libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamChaosIndex_C, true));

                SoundPlayForPlayer(SoundLink("Event_Raven_Cannon_Fire_Distant", -1), c_maxPlayers, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

                SoundPlayForPlayer(SoundLink("Event_Towers_ScoringAltar_Tribute_RavenLord_Success", -1), c_maxPlayers, libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamOrderIndex_C, true), 100.0, 0.0);

                SoundPlayForPlayer(SoundLink("Event_Towers_ScoringAltar_Tribute_RavenLord_Success", -1), c_maxPlayers, PlayerGroupSingle(libCore_gv_oBSERVER_ObserverUIPlayer), 100.0, 0.0);

                SoundPlayForPlayer(SoundLink("Event_Towers_ScoringAltar_Tribute_Necro_Fail", -1), c_maxPlayers, libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamChaosIndex_C, true), 100.0, 0.0);

                SoundPlayForPlayer(SoundLink("MX_Towers_Shrine_Raven", -1), c_maxPlayers, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

            }

            else if (auto50716AB6_val == libGame_gv_teamChaosIndex_C) {

                libMTOD_gf_MMToDUIDisplayRavenNecroNotifications(StringExternal("Param/Value/lib_MTOD_C033BA73"), libGame_gv_teamChaosIndex_C, libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamOrderIndex_C, true));

                libMTOD_gf_MMToDUIDisplayRavenNecroNotifications(StringExternal("Param/Value/lib_MTOD_900EE408"), libGame_gv_teamChaosIndex_C, libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamChaosIndex_C, true));

                SoundPlayForPlayer(SoundLink("Event_Necro_Cannon_Fire_Distant", -1), c_maxPlayers, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

                SoundPlayForPlayer(SoundLink("Event_Towers_ScoringAltar_Tribute_RavenLord_Fail", -1), c_maxPlayers, libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamOrderIndex_C, true), 100.0, 0.0);

                SoundPlayForPlayer(SoundLink("Event_Towers_ScoringAltar_Tribute_RavenLord_Fail", -1), c_maxPlayers, PlayerGroupSingle(libCore_gv_oBSERVER_ObserverUIPlayer), 100.0, 0.0);

                SoundPlayForPlayer(SoundLink("Event_Towers_ScoringAltar_Tribute_Necro_Success", -1), c_maxPlayers, libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamChaosIndex_C, true), 100.0, 0.0);

                SoundPlayForPlayer(SoundLink("MX_Towers_Shrine_Necro", -1), c_maxPlayers, libCore_gv_allHeroPlayersPlusObserver, 100.0, 0.0);

            }

            else {

            }

            libGame_gf_DropLootBannerinSconce(UnitGroupUnit(UnitGroup("LootBannerSconce", c_playerAny, RegionCircle(EventPlayerEffectUsedPoint(c_effectLocationTargetUnit), 10.0), UnitFilter(0, 0, (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 1), 1), libGame_gv_players[lv_capturingPlayer].lv_lootContent.lv_loot_Banner.lv_bannerID, lv_capturingPlayer, true);

            RemoveUnitOfInterest(lv_capturedAltar, "UseAltar", libNtve_ge_GoalTeam_Both);

            libMTOD_gf_MMToDAltarFireCannons(lv_capturingTeam);

            libMTOD_gf_MMToDTransmissionBellTowersFiring(lv_capturingTeam);

            libMTOD_gf_MMToDTurnOnOffScoringAltar(false, lv_itTempleIndex);

            VisRevealerDestroy(libMTOD_gv_mMToDScoringAltarOrderRevealers[lv_itTempleIndex]);

            VisRevealerDestroy(libMTOD_gv_mMToDScoringAltarChaosRevealers[lv_itTempleIndex]);

            libMTOD_gv_mMToDScoringAltarsActive -= 1;

            break;

        }



        if ((libMTOD_gv_mMToDScoringAltars[lv_itTempleIndex].lv_unit == null)) {

            TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_3E0FC884"), true);

            break;

        }



    }

    if ((libMTOD_gv_mMToDScoringAltarsActive == 0)) {

        TriggerEnable(TriggerGetCurrent(), false);

        TriggerExecute(libMTOD_gt_MMToDScoringAltarTimerTrigger, true, false);

        TimerStart(libMTOD_gv_mMToDObjectivePreviewTimer, libMTOD_gv_mMToDObjectivePreviewDelay_C, false, c_timeGame);

    }



    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDScoringAltarCaptured_Init () {

    libMTOD_gt_MMToDScoringAltarCaptured = TriggerCreate("libMTOD_gt_MMToDScoringAltarCaptured_Func");

    TriggerEnable(libMTOD_gt_MMToDScoringAltarCaptured, false);

    TriggerAddEventPlayerEffectUsed(libMTOD_gt_MMToDScoringAltarCaptured, c_playerAny, "CaptureMacGuffinCastComplete");

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Start Phase Two Timer

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDStartPhaseTwoTimer_Func (bool testConds, bool runActions) {

    // Variable Declarations

    int lv_itTown;

    int lv_itPlayer;

    unit lv_itStructure;

    int lv_itBuilding;

    int lv_itWaygate;

    unitgroup lv_townStructureUnitGroup;

    fixed lv_repairTimeRemaining;



    // Automatic Variable Declarations

    const int auto7870F5F9_ae = libMTOD_gv_mMToDTownsMaxCount_C;

    const int auto7870F5F9_ai = 1;

    unitgroup auto44F7200C_g;

    int auto44F7200C_u;

    const int auto4EAFB3E6_ae = libMTOD_gv_mMToDTownStructureMaxCount_C;

    const int auto4EAFB3E6_ai = 1;



    // Variable Initialization

    lv_townStructureUnitGroup = UnitGroupEmpty();



    // Actions

    if (!runActions) {

        return true;

    }



    TimerStart(libMTOD_gv_mMToDPhaseTwoTimer, libMTOD_gv_mMToDPhaseTwoDelay_C, false, c_timeGame);

    libNtve_gf_WaitForTimer(libMTOD_gv_mMToDPhaseTwoTimer, libMTOD_gv_mMToDPhaseTwoWarningTime_C, false);

    if ((libMTOD_gv_mMToDScoringAltarsActive == 0)) {

        if ((TimerIsPaused(libMTOD_gv_mMToDScoringAltarTimer) == false) && (TimerGetRemaining(libMTOD_gv_mMToDScoringAltarTimer) <= libMTOD_gv_mMToDPhaseTwoWarningTime_C)) {

            Wait((TimerGetRemaining(libMTOD_gv_mMToDScoringAltarTimer) + 1.0), c_timeGame);

        }

    }



    if ((libMTOD_gv_mMToDScoringAltarsActive > 0)) {

        while ((libMTOD_gv_mMToDScoringAltarsActive > 0)) {

            Wait(0.0625, c_timeGame);

        }

        Wait(15.0, c_timeGame);

    }



    if ((libMTOD_gv_mMToDPhaseTwoCheatUsed == false)) {

        Wait(libMTOD_gv_mMToDPhaseTwoWarningTime_C, c_timeGame);

    }



    if ((libGame_gv_gameOver == true)) {

        return true;

    }



    libMTOD_gf_MMToDUIDisplayTowerUpgradeUI();

    lv_itTown = 1;

    for ( ; ( (auto7870F5F9_ai >= 0 && lv_itTown <= auto7870F5F9_ae) || (auto7870F5F9_ai < 0 && lv_itTown >= auto7870F5F9_ae) ) ; lv_itTown += auto7870F5F9_ai ) {

        libMTOD_gv_mMToDTowns[lv_itTown].lv_fortInfo.lv_buildingType = "TownTownHallL3";

        UnitIssueOrder(libMTOD_gv_mMToDTowns[lv_itTown].lv_fortUnit, Order(AbilityCommand("L3TownMorph", 0)), c_orderQueueReplace);

        lv_townStructureUnitGroup = UnitGroup(null, c_playerAny, libGame_gv_townTownData[lv_itTown].lv_townRegion, UnitFilter((1 << c_targetFilterStructure), 0, (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32))), 0);

        auto44F7200C_g = lv_townStructureUnitGroup;

        auto44F7200C_u = UnitGroupCount(auto44F7200C_g, c_unitCountAll);

        for (;; auto44F7200C_u -= 1) {

            lv_itStructure = UnitGroupUnitFromEnd(auto44F7200C_g, auto44F7200C_u);

            if (lv_itStructure == null) { break; }

            if ((UnitGetType(lv_itStructure) == "TownMoonwellL2")) {

                UnitIssueOrder(lv_itStructure, Order(AbilityCommand("L3MoonwellMorph", 0)), c_orderQueueReplace);

            }



            if ((UnitGetType(lv_itStructure) == "TownCannonTowerL2Standalone")) {

                UnitIssueOrder(lv_itStructure, Order(AbilityCommand("L3StandaloneTowerMorph", 0)), c_orderQueueReplace);

            }



        }

        lv_itBuilding = 1;

        for ( ; ( (auto4EAFB3E6_ai >= 0 && lv_itBuilding <= auto4EAFB3E6_ae) || (auto4EAFB3E6_ai < 0 && lv_itBuilding >= auto4EAFB3E6_ae) ) ; lv_itBuilding += auto4EAFB3E6_ai ) {

            if ((libMTOD_gv_mMToDTowns[lv_itTown].lv_structureArray[lv_itBuilding].lv_buildingType == "TownMoonwellL2")) {

                libMTOD_gv_mMToDTowns[lv_itTown].lv_structureArray[lv_itBuilding].lv_buildingType = "TownMoonwellL3";

            }



            if ((libMTOD_gv_mMToDTowns[lv_itTown].lv_structureArray[lv_itBuilding].lv_buildingType == "TownCannonTowerL2Standalone")) {

                libMTOD_gv_mMToDTowns[lv_itTown].lv_structureArray[lv_itBuilding].lv_buildingType = "TownCannonTowerL3Standalone";

            }



            if ((libMTOD_gv_mMToDTowns[lv_itTown].lv_structureArray[lv_itBuilding].lv_buildingType == null)) {

                break;

            }



        }

    }

    libMTOD_gf_MMToDActivateWaygates();

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDStartPhaseTwoTimer_Init () {

    libMTOD_gt_MMToDStartPhaseTwoTimer = TriggerCreate("libMTOD_gt_MMToDStartPhaseTwoTimer_Func");

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD L2 Fort Morphs Into L3 Keep

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDL2FortMorphsIntoL3Keep_Func (bool testConds, bool runActions) {

    // Variable Declarations

    int lv_itTower;

    fixed lv_startAnimLength;

    fixed lv_endAnimLength;

    fixed lv_repairBehaviorElapsed;

    fixed lv_repairBehaviorRemaining;

    string lv_messageString;



    // Automatic Variable Declarations

    // Variable Initialization

    lv_startAnimLength = 6.333;

    lv_endAnimLength = 7.0;

    lv_messageString = "";



    // Actions

    if (!runActions) {

        return true;

    }



    libNtve_gf_SendActorMessageToUnit(EventUnit(), "Signal PlayMorph");

    if ((UnitHasBehavior2(EventUnit(), "StructureOwnershipChangeRepairBehavior") == true)) {

        lv_repairBehaviorElapsed = (UnitBehaviorDurationTotal(EventUnit(), "StructureOwnershipChangeRepairBehavior") - UnitBehaviorDuration(EventUnit(), "StructureOwnershipChangeRepairBehavior"));

        lv_repairBehaviorRemaining = UnitBehaviorDuration(EventUnit(), "StructureOwnershipChangeRepairBehavior");

        if ((lv_repairBehaviorRemaining <= 0.125)) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "Signal Upgrade");

        }

        else if ((lv_repairBehaviorElapsed < lv_startAnimLength)) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "AnimPlay CaptureStart Cover,Start 0 0.000000");

            lv_messageString = ("AnimSetTime CaptureStart " + FixedToString(lv_repairBehaviorElapsed, 3));

            libNtve_gf_SendActorMessageToUnit(EventUnit(), (lv_messageString));

            lv_messageString = ("TimerSet " + FixedToString((lv_repairBehaviorRemaining - lv_endAnimLength), 0) + " BuildTimer");

            libNtve_gf_SendActorMessageToUnit(EventUnit(), (lv_messageString));

        }

        else if ((lv_repairBehaviorRemaining <= lv_endAnimLength)) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "AnimPlay CaptureEnd Cover,End 0 0.000000");

            lv_messageString = ("AnimSetTime CaptureEnd " + FixedToString((lv_endAnimLength - lv_repairBehaviorRemaining), 3));

            libNtve_gf_SendActorMessageToUnit(EventUnit(), (lv_messageString));

        }

        else if (true) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "AnimPlay CaptureStand Cover,Stand PlayForever 0.000000");

            lv_messageString = ("TimerSet " + FixedToString((lv_repairBehaviorRemaining - lv_endAnimLength), 0) + " BuildTimer");

            libNtve_gf_SendActorMessageToUnit(EventUnit(), (lv_messageString));

        }

    }

    else {

        libNtve_gf_SendActorMessageToUnit(EventUnit(), "Signal Upgrade");

    }

    if ((UnitGetPropertyFixed(EventUnit(), c_unitPropLifePercent, c_unitPropCurrent) == 100.0)) {

        libNtve_gf_SendActorMessageToUnit(EventUnit(), "MinimapIcon Assets\\Textures\\storm_ui_minimapicon_tod_town.dds");

    }

    else if ((UnitGetPropertyFixed(EventUnit(), c_unitPropLifePercent, c_unitPropCurrent) < 100.0) && (UnitGetPropertyFixed(EventUnit(), c_unitPropLifePercent, c_unitPropCurrent) >= 83.0)) {

        if ((UnitHasBehavior2(EventUnit(), "StructureOwnershipChangeRepairBehavior") == true)) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "MinimapIcon Assets\\Textures\\storm_ui_minimapicon_tod_town_regen_90.dds");

        }

        else {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "MinimapIcon Assets\\Textures\\storm_ui_minimapicon_tod_town_90.dds");

        }

    }

    else if ((UnitGetPropertyFixed(EventUnit(), c_unitPropLifePercent, c_unitPropCurrent) < 83.0) && (UnitGetPropertyFixed(EventUnit(), c_unitPropLifePercent, c_unitPropCurrent) >= 63.0)) {

        if ((UnitHasBehavior2(EventUnit(), "StructureOwnershipChangeRepairBehavior") == true)) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "MinimapIcon Assets\\Textures\\storm_ui_minimapicon_tod_town_regen_75.dds");

        }

        else {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "MinimapIcon Assets\\Textures\\storm_ui_minimapicon_tod_town_75.dds");

        }

    }

    else if ((UnitGetPropertyFixed(EventUnit(), c_unitPropLifePercent, c_unitPropCurrent) < 63.0) && (UnitGetPropertyFixed(EventUnit(), c_unitPropLifePercent, c_unitPropCurrent) >= 38.0)) {

        if ((UnitHasBehavior2(EventUnit(), "StructureOwnershipChangeRepairBehavior") == true)) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "MinimapIcon Assets\\Textures\\storm_ui_minimapicon_tod_town_regen_50.dds");

        }

        else {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "MinimapIcon Assets\\Textures\\storm_ui_minimapicon_tod_town_50.dds");

        }

    }

    else if ((UnitGetPropertyFixed(EventUnit(), c_unitPropLifePercent, c_unitPropCurrent) < 38.0) && (UnitGetPropertyFixed(EventUnit(), c_unitPropLifePercent, c_unitPropCurrent) >= 18.0)) {

        if ((UnitHasBehavior2(EventUnit(), "StructureOwnershipChangeRepairBehavior") == true)) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "MinimapIcon Assets\\Textures\\storm_ui_minimapicon_tod_town_regen_25.dds");

        }

        else {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "MinimapIcon Assets\\Textures\\storm_ui_minimapicon_tod_town_25.dds");

        }

    }

    else if ((UnitGetPropertyFixed(EventUnit(), c_unitPropLifePercent, c_unitPropCurrent) < 18.0)) {

        if ((UnitHasBehavior2(EventUnit(), "StructureOwnershipChangeRepairBehavior") == true)) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "MinimapIcon Assets\\Textures\\storm_ui_minimapicon_tod_town_regen_10.dds");

        }

        else {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "MinimapIcon Assets\\Textures\\storm_ui_minimapicon_tod_town_10.dds");

        }

    }

    UnitCreateEffectUnit(EventUnit(), "CFHArmorGrantApplyDisableForForceUpdate", EventUnit());

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDL2FortMorphsIntoL3Keep_Init () {

    libMTOD_gt_MMToDL2FortMorphsIntoL3Keep = TriggerCreate("libMTOD_gt_MMToDL2FortMorphsIntoL3Keep_Func");

    TriggerAddEventUnitAbility(libMTOD_gt_MMToDL2FortMorphsIntoL3Keep, null, AbilityCommand("L3TownMorph", 0), c_abilMorphStageUnitEnd, false);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD L2 Tower Morphs Into L3 Tower

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDL2TowerMorphsIntoL3Tower_Func (bool testConds, bool runActions) {

    // Variable Declarations

    int lv_itTower;

    fixed lv_startAnimLength;

    fixed lv_endAnimLength;

    fixed lv_repairBehaviorElapsed;

    fixed lv_repairBehaviorRemaining;

    string lv_messageString;



    // Automatic Variable Declarations

    // Variable Initialization

    lv_startAnimLength = 6.333;

    lv_endAnimLength = 7.0;

    lv_messageString = "";



    // Actions

    if (!runActions) {

        return true;

    }



    if ((UnitHasBehavior2(EventUnit(), "StructureOwnershipChangeRepairBehavior") == true)) {

        lv_repairBehaviorElapsed = (UnitBehaviorDurationTotal(EventUnit(), "StructureOwnershipChangeRepairBehavior") - UnitBehaviorDuration(EventUnit(), "StructureOwnershipChangeRepairBehavior"));

        lv_repairBehaviorRemaining = UnitBehaviorDuration(EventUnit(), "StructureOwnershipChangeRepairBehavior");

        if ((lv_repairBehaviorRemaining <= 0.125)) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "Signal Upgrade");

        }

        else if ((lv_repairBehaviorElapsed < lv_startAnimLength)) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "AnimPlay CaptureStart Cover,Start 0 0.000000");

            lv_messageString = ("AnimSetTime CaptureStart " + FixedToString(lv_repairBehaviorElapsed, 3));

            libNtve_gf_SendActorMessageToUnit(EventUnit(), (lv_messageString));

            lv_messageString = ("TimerSet " + FixedToString((lv_repairBehaviorRemaining - lv_endAnimLength), 0) + " BuildTimer");

            libNtve_gf_SendActorMessageToUnit(EventUnit(), (lv_messageString));

        }

        else if ((lv_repairBehaviorRemaining <= lv_endAnimLength)) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "AnimPlay CaptureEnd Cover,End 0 0.000000");

            lv_messageString = ("AnimSetTime CaptureEnd " + FixedToString((lv_endAnimLength - lv_repairBehaviorRemaining), 3));

            libNtve_gf_SendActorMessageToUnit(EventUnit(), (lv_messageString));

        }

        else if (true) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "AnimPlay CaptureStand Cover,Stand PlayForever 0.000000");

            lv_messageString = ("TimerSet " + FixedToString((lv_repairBehaviorRemaining - lv_endAnimLength), 0) + " BuildTimer");

            libNtve_gf_SendActorMessageToUnit(EventUnit(), (lv_messageString));

        }

    }

    else {

        libNtve_gf_SendActorMessageToUnit(EventUnit(), "Signal Upgrade");

    }

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDL2TowerMorphsIntoL3Tower_Init () {

    libMTOD_gt_MMToDL2TowerMorphsIntoL3Tower = TriggerCreate("libMTOD_gt_MMToDL2TowerMorphsIntoL3Tower_Func");

    TriggerAddEventUnitAbility(libMTOD_gt_MMToDL2TowerMorphsIntoL3Tower, null, AbilityCommand("L3StandaloneTowerMorph", 0), c_abilMorphStageUnitEnd, false);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD L2 Moonwell Morphs Into L3 Moonwell

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDL2MoonwellMorphsIntoL3Moonwell_Func (bool testConds, bool runActions) {

    // Variable Declarations

    fixed lv_startAnimLength;

    fixed lv_endAnimLength;

    fixed lv_repairBehaviorElapsed;

    fixed lv_repairBehaviorRemaining;

    string lv_messageString;



    // Automatic Variable Declarations

    // Variable Initialization

    lv_startAnimLength = 6.333;

    lv_endAnimLength = 7.0;

    lv_messageString = "";



    // Actions

    if (!runActions) {

        return true;

    }



    if ((UnitHasBehavior2(EventUnit(), "StructureOwnershipChangeRepairBehavior") == true)) {

        lv_repairBehaviorElapsed = (UnitBehaviorDurationTotal(EventUnit(), "StructureOwnershipChangeRepairBehavior") - UnitBehaviorDuration(EventUnit(), "StructureOwnershipChangeRepairBehavior"));

        lv_repairBehaviorRemaining = UnitBehaviorDuration(EventUnit(), "StructureOwnershipChangeRepairBehavior");

        if ((lv_repairBehaviorRemaining <= 0.125)) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "Signal Upgrade");

        }

        else if ((lv_repairBehaviorElapsed < lv_startAnimLength)) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "AnimPlay CaptureStart Cover,Start 0 0.000000");

            lv_messageString = ("AnimSetTime CaptureStart " + FixedToString(lv_repairBehaviorElapsed, 3));

            libNtve_gf_SendActorMessageToUnit(EventUnit(), (lv_messageString));

            lv_messageString = ("TimerSet " + FixedToString((lv_repairBehaviorRemaining - lv_endAnimLength), 0) + " BuildTimer");

            libNtve_gf_SendActorMessageToUnit(EventUnit(), (lv_messageString));

        }

        else if ((lv_repairBehaviorRemaining <= lv_endAnimLength)) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "AnimPlay CaptureEnd Cover,End 0 0.000000");

            lv_messageString = ("AnimSetTime CaptureEnd " + FixedToString((lv_endAnimLength - lv_repairBehaviorRemaining), 3));

            libNtve_gf_SendActorMessageToUnit(EventUnit(), (lv_messageString));

        }

        else if (true) {

            libNtve_gf_SendActorMessageToUnit(EventUnit(), "AnimPlay CaptureStand Cover,Stand PlayForever 0.000000");

            lv_messageString = ("TimerSet " + FixedToString((lv_repairBehaviorRemaining - lv_endAnimLength), 0) + " BuildTimer");

            libNtve_gf_SendActorMessageToUnit(EventUnit(), (lv_messageString));

        }

    }

    else {

        libNtve_gf_SendActorMessageToUnit(EventUnit(), "Signal Upgrade");

    }

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDL2MoonwellMorphsIntoL3Moonwell_Init () {

    libMTOD_gt_MMToDL2MoonwellMorphsIntoL3Moonwell = TriggerCreate("libMTOD_gt_MMToDL2MoonwellMorphsIntoL3Moonwell_Func");

    TriggerAddEventUnitAbility(libMTOD_gt_MMToDL2MoonwellMorphsIntoL3Moonwell, null, AbilityCommand("L3MoonwellMorph", 0), c_abilMorphStageUnitEnd, false);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Six Cap Cannon Activation

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDSixCapCannonActivation_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Actions

    if (!runActions) {

        return true;

    }



    libMTOD_gf_MMToDSixCapFireCannons();

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDSixCapCannonActivation_Init () {

    libMTOD_gt_MMToDSixCapCannonActivation = TriggerCreate("libMTOD_gt_MMToDSixCapCannonActivation_Func");

    TriggerAddEventTimer(libMTOD_gt_MMToDSixCapCannonActivation, libMTOD_gv_mMToDSixCapTimer);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Owned Town Dies

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDOwnedTownDies_Func (bool testConds, bool runActions) {

    // Variable Declarations

    int lv_itPlayer;

    int lv_itTown;



    // Automatic Variable Declarations

    const int auto6F655126_ae = libMTOD_gv_mMToDTownsMaxCount_C;

    const int auto6F655126_ai = 1;

    const int auto9F4FA849_ae = libCore_gv_bALMaxPlayers;

    const int auto9F4FA849_ai = 1;



    // Variable Initialization



    // Conditions

    if (testConds) {

        if (!((libGame_gf_TownGetTownStructurePresetFromUnit(EventUnit()) == libGame_ge_TownStructureTypes_TownHall))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    if ((libGDHL_gv_ragnarosExists == true)) {

        UnitBehaviorAdd(EventUnit(), ("RagnarosImmuneToMoltenCore"), EventUnit(), 1);

    }



    if ((UnitGetOwner(EventUnit()) == libCore_gv_cOMPUTER_TeamOrder)) {

        libMTOD_gf_MMToDTownHallDestroyedForTeam(libGame_gv_teamOrderIndex_C);

    }

    else {

        libMTOD_gf_MMToDTownHallDestroyedForTeam(libGame_gv_teamChaosIndex_C);

    }

    lv_itTown = 1;

    for ( ; ( (auto6F655126_ai >= 0 && lv_itTown <= auto6F655126_ae) || (auto6F655126_ai < 0 && lv_itTown >= auto6F655126_ae) ) ; lv_itTown += auto6F655126_ai ) {

        if ((libMTOD_gv_mMToDTowns[lv_itTown].lv_fortUnit == EventUnit())) {

            lv_itPlayer = 1;

            for ( ; ( (auto9F4FA849_ai >= 0 && lv_itPlayer <= auto9F4FA849_ae) || (auto9F4FA849_ai < 0 && lv_itPlayer >= auto9F4FA849_ae) ) ; lv_itPlayer += auto9F4FA849_ai ) {

                if ((libGame_gf_TeamNumberOfPlayer(lv_itPlayer) == libGame_gf_TeamNumberOfPlayer(UnitGetOwner(EventUnit())))) {

                    UnitSetStateForPlayer(libMTOD_gv_mMToDTowns[lv_itTown].lv_fortUnit, c_unitStateTargetable, lv_itPlayer, false);

                }

                else {

                    UnitSetStateForPlayer(libMTOD_gv_mMToDTowns[lv_itTown].lv_fortUnit, c_unitStateTargetable, lv_itPlayer, true);

                }

            }

            libMTOD_gf_MMToDRespawnTown(lv_itTown, libMTOD_gv_mMToDTowns[lv_itTown].lv_fortUnit, libMTOD_gv_mMToDTowns[lv_itTown].lv_owningTeam);

            return true;

        }



    }

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDOwnedTownDies_Init () {

    libMTOD_gt_MMToDOwnedTownDies = TriggerCreate("libMTOD_gt_MMToDOwnedTownDies_Func");

    TriggerEnable(libMTOD_gt_MMToDOwnedTownDies, false);

    TriggerAddEventUnitDied(libMTOD_gt_MMToDOwnedTownDies, null);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Town Finished Building

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDTownFinishedBuilding_Func (bool testConds, bool runActions) {

    // Variable Declarations

    int lv_itTown;

    int lv_itPlayer;

    int lv_itTower;

    int lv_owningTeam;



    // Automatic Variable Declarations

    const int auto595B2907_ae = libCore_gv_bALMaxPlayers;

    const int auto595B2907_ai = 1;

    const int auto9836FA2B_ae = libMTOD_gv_mMToDTownsMaxCount_C;

    const int auto9836FA2B_ai = 1;



    // Variable Initialization



    // Conditions

    if (testConds) {

        if (!((libGame_gf_TownGetTownStructurePresetFromUnit(EventUnit()) == libGame_ge_TownStructureTypes_TownHall))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    lv_itPlayer = 1;

    for ( ; ( (auto595B2907_ai >= 0 && lv_itPlayer <= auto595B2907_ae) || (auto595B2907_ai < 0 && lv_itPlayer >= auto595B2907_ae) ) ; lv_itPlayer += auto595B2907_ai ) {

        UnitSetStateForPlayer(EventUnit(), c_unitStateTargetable, lv_itPlayer, true);

    }

    lv_itTown = 1;

    for ( ; ( (auto9836FA2B_ai >= 0 && lv_itTown <= auto9836FA2B_ae) || (auto9836FA2B_ai < 0 && lv_itTown >= auto9836FA2B_ae) ) ; lv_itTown += auto9836FA2B_ai ) {

        if ((libMTOD_gv_mMToDTowns[lv_itTown].lv_fortUnit == EventUnit())) {

            lv_owningTeam = UnitGetOwner(EventUnit());

            if ((lv_owningTeam == libCore_gv_cOMPUTER_TeamOrder)) {

                DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_blueTownHealthFrame, libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_teamPlayerGroupNoNPCPlayers, true);

                DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_blueTownHealthFrame, libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], true);

                DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_redTownHealthFrame, libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_teamPlayerGroupNoNPCPlayers, true);

            }

            else {

                DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_redTownHealthFrame, libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_teamPlayerGroupNoNPCPlayers, true);

                DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_redTownHealthFrame, libCore_gv_playerGroupFromPlayer[libCore_gv_oBSERVER_ObserverUIPlayer], true);

                DialogControlSetVisible(libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_blueTownHealthFrame, libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_teamPlayerGroupNoNPCPlayers, true);

            }

            if ((libMTOD_gv_mMToDTowns[lv_itTown].lv_owningTeam == libMTOD_gv_mMToDTowns[lv_itTown].lv_originalOwningTeam)) {

                libGame_gf_TownAddMoonwellMinimapIconstoTown(lv_itTown);

            }



        }



    }

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDTownFinishedBuilding_Init () {

    libMTOD_gt_MMToDTownFinishedBuilding = TriggerCreate("libMTOD_gt_MMToDTownFinishedBuilding_Func");

    TriggerAddEventUnitBehaviorChange(libMTOD_gt_MMToDTownFinishedBuilding, null, "StructureOwnershipChangeRepairBehavior", c_unitBehaviorChangeDestroy);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Merc Scaling

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDMercScaling_Func (bool testConds, bool runActions) {

    // Variable Declarations

    fixed lv_defenderModifier;

    fixed lv_lanerModifier;

    fixed lv_sapperModifier;

    unit lv_itUnit;



    // Automatic Variable Declarations

    // Variable Initialization



    // Actions

    if (!runActions) {

        return true;

    }



    CatalogFieldValueSet(c_gameCatalogEffect, "BaseProtectionTowerAttackDamage", "Amount", libCore_gv_cOMPUTER_TeamOrder, IntToString(FixedToInt((CatalogFieldValueGetAsInt(c_gameCatalogEffect, "BaseProtectionTowerAttackDamage", "Amount", libCore_gv_cOMPUTER_TeamOrder) + libMTOD_gv_mMToDBaseProtectionScaling))));

    CatalogFieldValueSet(c_gameCatalogEffect, "BaseProtectionTowerAttackDamage", "Amount", libCore_gv_cOMPUTER_TeamChaos, IntToString(FixedToInt((CatalogFieldValueGetAsInt(c_gameCatalogEffect, "BaseProtectionTowerAttackDamage", "Amount", libCore_gv_cOMPUTER_TeamChaos) + libMTOD_gv_mMToDBaseProtectionScaling))));

    lv_sapperModifier = (1.0 + libMTOD_gv_mMToDLanerSapperSuicideScaling_C);

    CatalogFieldValueSet(c_gameCatalogEffect, "MercLanerGoblinSapperNonStructureSuicideDamage", "Amount", libCore_gv_cOMPUTER_TeamOrder, IntToString(FixedToInt((CatalogFieldValueGetAsInt(c_gameCatalogEffect, "MercLanerGoblinSapperNonStructureSuicideDamage", "Amount", libCore_gv_cOMPUTER_TeamOrder) * lv_sapperModifier))));

    CatalogFieldValueSet(c_gameCatalogEffect, "MercLanerGoblinSapperNonStructureSuicideDamage", "Amount", libCore_gv_cOMPUTER_TeamChaos, IntToString(FixedToInt((CatalogFieldValueGetAsInt(c_gameCatalogEffect, "MercLanerGoblinSapperNonStructureSuicideDamage", "Amount", libCore_gv_cOMPUTER_TeamChaos) * lv_sapperModifier))));

    if ((libGame_gv_scalingTicks < 2)) {

        return true;

    }



    lv_defenderModifier = (1.0 + libMTOD_gv_mMToDDefenderHeadSpellScaling_C);

    CatalogFieldValueSet(c_gameCatalogEffect, "MercHorsemanFlyingHeadDefenderInitialDamage", "Amount", libCore_gv_cOMPUTER_Hostile, IntToString(FixedToInt((CatalogFieldValueGetAsInt(c_gameCatalogEffect, "MercHorsemanFlyingHeadDefenderInitialDamage", "Amount", libCore_gv_cOMPUTER_Hostile) * lv_defenderModifier))));

    CatalogFieldValueSet(c_gameCatalogEffect, "MercHorsemanFlyingHeadDefenderPeriodicDamage", "Amount", libCore_gv_cOMPUTER_Hostile, IntToString(FixedToInt((CatalogFieldValueGetAsInt(c_gameCatalogEffect, "MercHorsemanFlyingHeadDefenderPeriodicDamage", "Amount", libCore_gv_cOMPUTER_Hostile) * lv_defenderModifier))));

    lv_lanerModifier = (1.0 + libMTOD_gv_mMToDLanerHeadSpellScaling_C);

    CatalogFieldValueSet(c_gameCatalogEffect, "MercHorsemanFlyingHeadLanerInitialDamage", "Amount", libCore_gv_cOMPUTER_TeamOrder, IntToString(FixedToInt((CatalogFieldValueGetAsInt(c_gameCatalogEffect, "MercHorsemanFlyingHeadLanerInitialDamage", "Amount", libCore_gv_cOMPUTER_TeamOrder) * lv_lanerModifier))));

    CatalogFieldValueSet(c_gameCatalogEffect, "MercHorsemanFlyingHeadLanerPeriodicDamage", "Amount", libCore_gv_cOMPUTER_TeamOrder, IntToString(FixedToInt((CatalogFieldValueGetAsInt(c_gameCatalogEffect, "MercHorsemanFlyingHeadLanerPeriodicDamage", "Amount", libCore_gv_cOMPUTER_TeamOrder) * lv_lanerModifier))));

    CatalogFieldValueSet(c_gameCatalogEffect, "MercHorsemanFlyingHeadLanerInitialDamage", "Amount", libCore_gv_cOMPUTER_TeamChaos, IntToString(FixedToInt((CatalogFieldValueGetAsInt(c_gameCatalogEffect, "MercHorsemanFlyingHeadLanerInitialDamage", "Amount", libCore_gv_cOMPUTER_TeamChaos) * lv_lanerModifier))));

    CatalogFieldValueSet(c_gameCatalogEffect, "MercHorsemanFlyingHeadLanerPeriodicDamage", "Amount", libCore_gv_cOMPUTER_TeamChaos, IntToString(FixedToInt((CatalogFieldValueGetAsInt(c_gameCatalogEffect, "MercHorsemanFlyingHeadLanerPeriodicDamage", "Amount", libCore_gv_cOMPUTER_TeamChaos) * lv_lanerModifier))));

    if ((libGame_gv_scalingTicks >= 30)) {

        libNtve_gf_StopTimer(libMTOD_gv_mMToDScalingTimer);

        return true;

    }



    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDMercScaling_Init () {

    libMTOD_gt_MMToDMercScaling = TriggerCreate("libMTOD_gt_MMToDMercScaling_Func");

    TriggerAddEventTimer(libMTOD_gt_MMToDMercScaling, libMTOD_gv_mMToDScalingTimer);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Merc Damage Tracking

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDMercDamageTracking_Func (bool testConds, bool runActions) {

    // Variable Declarations

    int lv_MercCamp;



    // Automatic Variable Declarations

    // Variable Initialization



    // Conditions

    if (testConds) {

        if (!((libCore_gv_dEBUGDebuggingEnabled == true))) {

            return false;

        }



        if (!((libGame_gv_gameOver == false))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    lv_MercCamp = libMapM_gf_JungleGetMercCampForUnit(EventUnitDamageSourceUnit());

    libMapM_gf_JungleUpdateMercDamageTracker(lv_MercCamp, EventUnitDamageAmount());

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDMercDamageTracking_Init () {

    libMTOD_gt_MMToDMercDamageTracking = TriggerCreate("libMTOD_gt_MMToDMercDamageTracking_Func");

    TriggerAddEventUnitDamaged(libMTOD_gt_MMToDMercDamageTracking, null, c_unitDamageTypeAny, c_unitDamageEither, "MercHorsemanFlyingHeadLanerInitialDamage");

    TriggerAddEventUnitDamaged(libMTOD_gt_MMToDMercDamageTracking, null, c_unitDamageTypeAny, c_unitDamageEither, "MercHorsemanFlyingHeadLanerPeriodicDamage");

    TriggerAddEventUnitDamaged(libMTOD_gt_MMToDMercDamageTracking, null, c_unitDamageTypeAny, c_unitDamageEither, "MercHorsemanLanerWeaponDamage");

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Merc Laner Horseman Summons Head

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDMercLanerHorsemanSummonsHead_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Conditions

    if (testConds) {

        if (!((libGame_gv_gameOver == false))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    UnitSetCustomValue(EventPlayerEffectUsedUnit(c_effectUnitTarget), libCore_gf_CustomValueIndex(libCore_ge_CustomValueIndexes_JungleLanerCreepCampIndex), libMapM_gf_JungleGetMercCampForUnit(EventPlayerEffectUsedUnit(c_effectUnitCaster)));

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDMercLanerHorsemanSummonsHead_Init () {

    libMTOD_gt_MMToDMercLanerHorsemanSummonsHead = TriggerCreate("libMTOD_gt_MMToDMercLanerHorsemanSummonsHead_Func");

    TriggerAddEventPlayerEffectUsed(libMTOD_gt_MMToDMercLanerHorsemanSummonsHead, c_playerAny, "MercHorsemanFlyingHeadLanerUnitApplyBehavior");

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Boss Horseman Created

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDBossHorsemanCreated_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Conditions

    if (testConds) {

        if (!((UnitGetType(EventUnitCreatedUnit()) == "MercHorsemanDefender"))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDHorsemanCannon, "Signal Spawned");

    TriggerEnable(libMTOD_gt_MMToDBossHorsemanDies, true);

    TriggerEnable(TriggerGetCurrent(), false);

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDBossHorsemanCreated_Init () {

    libMTOD_gt_MMToDBossHorsemanCreated = TriggerCreate("libMTOD_gt_MMToDBossHorsemanCreated_Func");

    TriggerAddEventUnitCreated(libMTOD_gt_MMToDBossHorsemanCreated, null, null, null);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Boss Horseman Dies

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDBossHorsemanDies_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Conditions

    if (testConds) {

        if (!((UnitGetType(EventUnit()) == "MercHorsemanDefender"))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDHorsemanCannon, "Signal ReadyToFire");

    TriggerEnable(libMTOD_gt_MMToDBossHorsemanCreated, true);

    TriggerEnable(TriggerGetCurrent(), false);

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDBossHorsemanDies_Init () {

    libMTOD_gt_MMToDBossHorsemanDies = TriggerCreate("libMTOD_gt_MMToDBossHorsemanDies_Func");

    TriggerEnable(libMTOD_gt_MMToDBossHorsemanDies, false);

    TriggerAddEventUnitDied(libMTOD_gt_MMToDBossHorsemanDies, null);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Headless Horseman Camp Captured

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDHeadlessHorsemanCampCaptured_Func (bool testConds, bool runActions) {

    // Variable Declarations

    unit lv_itUnit;



    // Automatic Variable Declarations

    // Variable Initialization



    // Conditions

    if (testConds) {

        if (!((libMapM_gv_jungleCreepCamps[libGame_gf_MercCampCapturedIndex()].lv_mapDataCampDefenderType == libMapM_ge_JungleCampDefenderTypes_BossCamp1))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    libMTOD_gf_MMToDBossCampFireCannons(libGame_gf_MercCampCapturedOwner());

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDHeadlessHorsemanCampCaptured_Init () {

    libMTOD_gt_MMToDHeadlessHorsemanCampCaptured = TriggerCreate("libMTOD_gt_MMToDHeadlessHorsemanCampCaptured_Func");

    libGame_gf_MercCampCaptured(libMTOD_gt_MMToDHeadlessHorsemanCampCaptured);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Protection Tower Scan

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDProtectionTowerScan_Func (bool testConds, bool runActions) {

    // Variable Declarations

    int lv_itTeam;

    int lv_enemyTeam;

    int lv_itTower;

    unit lv_itUnit;

    unit lv_targetUnit;

    unitgroup lv_units;

    unitgroup lv_orderUnits;

    unitgroup lv_chaosUnits;



    // Automatic Variable Declarations

    const int auto07DE82EA_ae = libCore_gv_bALMaxTeams;

    const int auto07DE82EA_ai = 1;

    unitgroup autoD5800279_g;

    int autoD5800279_u;

    unitgroup autoB7B6F2E5_g;

    int autoB7B6F2E5_u;

    unitgroup auto69B1B9A5_g;

    int auto69B1B9A5_u;



    // Variable Initialization

    lv_units = UnitGroupEmpty();

    lv_orderUnits = UnitGroupEmpty();

    lv_chaosUnits = UnitGroupEmpty();



    // Actions

    if (!runActions) {

        return true;

    }



    while (true) {

        if ((libGame_gv_gameOver == true)) {

            return true;

        }



        lv_itTeam = 1;

        for ( ; ( (auto07DE82EA_ai >= 0 && lv_itTeam <= auto07DE82EA_ae) || (auto07DE82EA_ai < 0 && lv_itTeam >= auto07DE82EA_ae) ) ; lv_itTeam += auto07DE82EA_ai ) {

            lv_units = UnitGroup(null, c_playerAny, libMTOD_gv_mMToDBaseKillZones[lv_itTeam], UnitFilter(0, 0, (1 << c_targetFilterMissile), (1 << (c_targetFilterStasis - 32)) | (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32)) | (1 << (c_targetFilterInvulnerable - 32))), 0);

            lv_enemyTeam = libGame_gf_EnemyTeam(lv_itTeam);

            autoD5800279_g = lv_units;

            autoD5800279_u = UnitGroupCount(autoD5800279_g, c_unitCountAll);

            for (;; autoD5800279_u -= 1) {

                lv_itUnit = UnitGroupUnitFromEnd(autoD5800279_g, autoD5800279_u);

                if (lv_itUnit == null) { break; }

                if ((libGame_gf_TeamNumberOfPlayer(UnitGetOwner(lv_itUnit)) == lv_enemyTeam)) {

                    if ((lv_itTeam == libGame_gv_teamOrderIndex_C)) {

                        UnitGroupAdd(lv_chaosUnits, lv_itUnit);

                    }



                    if ((lv_itTeam == libGame_gv_teamChaosIndex_C)) {

                        UnitGroupAdd(lv_orderUnits, lv_itUnit);

                    }



                    if ((UnitGetType(lv_itUnit) == "MercGoblinSapperLaner")) {

                        UnitCreateEffectUnit(lv_itUnit, "MercLanerGoblinSapperCoreMortarInitialSet", libGame_gv_teams[lv_itTeam].lv_core);

                        UnitKill(lv_itUnit);

                        continue;

                    }



                    UnitCreateEffectUnitWithSource(libGame_gv_teams[lv_itTeam].lv_core, "BaseProtectionTowerAttackDamageSet", lv_itUnit, c_gameCatalogAbil, "attack");

                    if ((UnitHasBehavior2(lv_itUnit, "TowerAggroSoundCooldown") == false) && (UnitTypeTestFlag(UnitGetType(lv_itUnit), c_unitFlagHero) == true) && (UnitTestState(lv_itUnit, c_unitStateHallucination) == false)) {

                        SoundPlayForPlayer(SoundLink("Doodad_CannonTower_Targeting_Warning", -1), UnitGetOwner(lv_itUnit), libCore_gv_playerGroupFromPlayer[UnitGetOwner(lv_itUnit)], 100.0, 0.0);

                        UnitBehaviorAdd(lv_itUnit, "TowerAggroSoundCooldown", lv_itUnit, 1);

                    }

                    else {

                        UnitBehaviorAdd(lv_itUnit, "TowerAggroSoundCooldown", lv_itUnit, 1);

                    }

                }



            }

            if ((UnitGroupCount(lv_chaosUnits, c_unitCountAll) > 0)) {

                autoB7B6F2E5_g = libMTOD_gv_mMToDProtectionTowers[libGame_gv_teamOrderIndex_C];

                autoB7B6F2E5_u = UnitGroupCount(autoB7B6F2E5_g, c_unitCountAll);

                for (;; autoB7B6F2E5_u -= 1) {

                    lv_itUnit = UnitGroupUnitFromEnd(autoB7B6F2E5_g, autoB7B6F2E5_u);

                    if (lv_itUnit == null) { break; }

                    lv_targetUnit = UnitGroupClosestToPoint(lv_chaosUnits, UnitGetPosition(lv_itUnit));

                    if ((DistanceBetweenPoints(UnitGetPosition(lv_itUnit), UnitGetPosition(lv_targetUnit)) <= libMTOD_gv_mMToDCannonRangeThreshold)) {

                        if (((UnitGetType(lv_itUnit) == "BaseProtectionTowerGround") || (UnitGetType(lv_itUnit) == "BaseProtectionTowerMid") || (UnitGetType(lv_itUnit) == "BaseProtectionTowerHigh"))) {

                            UnitIssueOrder(lv_itUnit, OrderTargetingUnit(AbilityCommand("attack", 0), lv_targetUnit), c_orderQueueReplace);

                        }



                        UnitCreateEffectPoint(lv_itUnit, "BaseProtectionTowerAttackLaunchMissile", PointWithOffsetPolar(UnitGetPosition(lv_targetUnit), RandomFixed(0.0, 3.0), libNtve_gf_RandomAngle()));

                        UnitCreateEffectPoint(lv_itUnit, "BaseProtectionTowerAttackLaunchMissile", PointWithOffsetPolar(UnitGetPosition(lv_targetUnit), RandomFixed(0.0, 3.0), libNtve_gf_RandomAngle()));

                        UnitCreateEffectPoint(lv_itUnit, "BaseProtectionTowerAttackLaunchMissile", PointWithOffsetPolar(UnitGetPosition(lv_targetUnit), RandomFixed(0.0, 3.0), libNtve_gf_RandomAngle()));

                        libNtve_gf_SendActorMessageToUnit(lv_itUnit, "Signal FireCannon");

                    }



                }

                UnitGroupClear(lv_chaosUnits);

            }



            if ((UnitGroupCount(lv_orderUnits, c_unitCountAll) > 0)) {

                auto69B1B9A5_g = libMTOD_gv_mMToDProtectionTowers[libGame_gv_teamChaosIndex_C];

                auto69B1B9A5_u = UnitGroupCount(auto69B1B9A5_g, c_unitCountAll);

                for (;; auto69B1B9A5_u -= 1) {

                    lv_itUnit = UnitGroupUnitFromEnd(auto69B1B9A5_g, auto69B1B9A5_u);

                    if (lv_itUnit == null) { break; }

                    lv_targetUnit = UnitGroupClosestToPoint(lv_orderUnits, UnitGetPosition(lv_itUnit));

                    if ((DistanceBetweenPoints(UnitGetPosition(lv_itUnit), UnitGetPosition(lv_targetUnit)) <= libMTOD_gv_mMToDCannonRangeThreshold)) {

                        if (((UnitGetType(lv_itUnit) == "BaseProtectionTowerGround") || (UnitGetType(lv_itUnit) == "BaseProtectionTowerMid") || (UnitGetType(lv_itUnit) == "BaseProtectionTowerHigh"))) {

                            UnitIssueOrder(lv_itUnit, OrderTargetingUnit(AbilityCommand("attack", 0), lv_targetUnit), c_orderQueueReplace);

                        }



                        UnitCreateEffectPoint(lv_itUnit, "BaseProtectionTowerAttackLaunchMissile", PointWithOffsetPolar(UnitGetPosition(lv_targetUnit), RandomFixed(0.0, 3.0), libNtve_gf_RandomAngle()));

                        UnitCreateEffectPoint(lv_itUnit, "BaseProtectionTowerAttackLaunchMissile", PointWithOffsetPolar(UnitGetPosition(lv_targetUnit), RandomFixed(0.0, 3.0), libNtve_gf_RandomAngle()));

                        UnitCreateEffectPoint(lv_itUnit, "BaseProtectionTowerAttackLaunchMissile", PointWithOffsetPolar(UnitGetPosition(lv_targetUnit), RandomFixed(0.0, 3.0), libNtve_gf_RandomAngle()));

                        libNtve_gf_SendActorMessageToUnit(lv_itUnit, "Signal FireCannon");

                    }



                }

                UnitGroupClear(lv_orderUnits);

            }



        }

        Wait(0.5, c_timeGame);

    }

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDProtectionTowerScan_Init () {

    libMTOD_gt_MMToDProtectionTowerScan = TriggerCreate("libMTOD_gt_MMToDProtectionTowerScan_Func");

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Entered Waygate

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDEnteredWaygate_Func (bool testConds, bool runActions) {

    // Variable Declarations

    int lv_computerTeam;

    unit lv_hero;

    point lv_heroPreTeleportPosition;

    unit lv_waygateEntrance;

    int lv_itWaygate;

    int lv_player;

    string lv_mountCooldownLink;

    int lv_teleportingUnitTypeIndex;

    unit lv_teleportingUnit;



    // Automatic Variable Declarations

    const int auto0B176DCE_ae = libMTOD_gv_mMFieldofSlaughterWaygateMaxCount_C;

    const int auto0B176DCE_ai = 1;



    // Variable Initialization

    lv_hero = EventPlayerEffectUsedUnit(c_effectUnitCaster);

    lv_heroPreTeleportPosition = UnitGetPosition(lv_hero);

    lv_waygateEntrance = EventPlayerEffectUsedUnit(c_effectUnitTarget);

    lv_player = UnitGetOwner(lv_hero);

    lv_mountCooldownLink = "";



    // Conditions

    if (testConds) {

        if (!((libGame_gf_UnitIsHero(lv_hero) == true))) {

            return false;

        }



        if (!((UnitGetType(lv_waygateEntrance) == "WaygateEntrance"))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    if ((libGame_gf_TeamNumberOfPlayer(UnitGetOwner(lv_hero)) == 1)) {

        lv_computerTeam = libCore_gv_cOMPUTER_TeamOrder;

    }

    else {

        lv_computerTeam = libCore_gv_cOMPUTER_TeamChaos;

    }

    UnitCreateEffectPoint(lv_hero, "TeleportVisualDummyEffect", UnitGetPosition(lv_hero));

    UnitIssueOrder(lv_hero, Order(AbilityCommand("stop", 0)), c_orderQueueReplace);

    libNtve_gf_MakeUnitUncommandable(lv_hero, true);

    libNtve_gf_SendActorMessageToUnit(lv_hero, "Signal InvisibleModel");

    UnitSetState(lv_hero, c_unitStateTargetable, false);

    UnitBehaviorAdd(lv_hero, "WaygateUnstoppable", lv_hero, 1);

    if ((libGame_gv_players[lv_player].lv_remountHeroAfterTeleport == true)) {

        libGame_gf_ApplyMountBehaviorToHero(lv_hero);

        lv_mountCooldownLink = CatalogFieldValueGet(c_gameCatalogAbil, "Mount", "Cost[" + IntToString(0) + "].Cooldown.Link", lv_player);

        libNtve_gf_UnitRemoveCooldown(lv_hero, lv_mountCooldownLink);

        libNtve_gf_PlayerRemoveCooldown(lv_player, lv_mountCooldownLink);

    }



    lv_itWaygate = 1;

    for ( ; ( (auto0B176DCE_ai >= 0 && lv_itWaygate <= auto0B176DCE_ae) || (auto0B176DCE_ai < 0 && lv_itWaygate >= auto0B176DCE_ae) ) ; lv_itWaygate += auto0B176DCE_ai ) {

        if (((lv_waygateEntrance == libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_orderEntrance) || (lv_waygateEntrance == libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_chaosEntrance))) {

            break;

        }



        if (((libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_orderEntrance == null) || (libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_chaosEntrance == null))) {

            TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_297E3290"), true);

            return true;

        }



    }

    if ((libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_waygateUnit != null)) {

        UnitSetPosition(lv_hero, libMTOD_gv_mMToDWaygates[lv_itWaygate].lv_position, false);

    }

    else {

        TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_80D819C3"), true);

        return true;

    }

    UnitCreateEffectUnit(lv_hero, "UnderworldTeleport", lv_hero);

    if ((libGame_gv_gameOver == false) && (lv_hero == UnitGroupUnit(libGame_gv_players[lv_player].lv_cameraPlayerUnitGroupToFocusOn, 1))) {

        libGame_gf_CameraPanCameraForPlayerAndUpdateMapBoundsIfNecessary(lv_player, UnitGetPosition(lv_hero), 0.0, -1, 0.0, false);

    }



    SoundPlayOnUnitForPlayer(SoundLink("Event_Mines_EnterMinesEnd", -1), c_maxPlayers, PlayerGroupAll(), lv_hero, 0.0, 100.0, 0.0);

    Wait(0.125, c_timeGame);

    libNtve_gf_MakeUnitUncommandable(lv_hero, false);

    UnitSetState(lv_hero, c_unitStateTargetable, true);

    UnitBehaviorRemove(lv_hero, "WaygateUnstoppable", 1);

    UnitIssueOrder(lv_hero, Order(AbilityCommand("stop", 0)), c_orderQueueReplace);

    libNtve_gf_SendActorMessageToUnit(lv_hero, "Signal RestoreModel");

    PathSetSourceUnit(libGame_gv_players[lv_player].lv_pathDisplay, lv_hero);

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDEnteredWaygate_Init () {

    libMTOD_gt_MMToDEnteredWaygate = TriggerCreate("libMTOD_gt_MMToDEnteredWaygate_Func");

    TriggerAddEventPlayerEffectUsed(libMTOD_gt_MMToDEnteredWaygate, c_playerAny, "CaptureMacGuffinTwoCastComplete");

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Init Store Spirit Healer

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDInitStoreSpiritHealer_Func (bool testConds, bool runActions) {

    // Variable Declarations

    unit lv_itUnit;



    // Automatic Variable Declarations

    unitgroup autoB17B1578_g;

    int autoB17B1578_u;



    // Variable Initialization



    // Actions

    if (!runActions) {

        return true;

    }



    autoB17B1578_g = UnitGroup("SpiritHealer", c_playerAny, null, UnitFilter(0, 0, 0, (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0);

    autoB17B1578_u = UnitGroupCount(autoB17B1578_g, c_unitCountAll);

    for (;; autoB17B1578_u -= 1) {

        lv_itUnit = UnitGroupUnitFromEnd(autoB17B1578_g, autoB17B1578_u);

        if (lv_itUnit == null) { break; }

        libMTOD_gv_mMToDSpiritHealer = lv_itUnit;

    }

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDInitStoreSpiritHealer_Init () {

    libMTOD_gt_MMToDInitStoreSpiritHealer = TriggerCreate("libMTOD_gt_MMToDInitStoreSpiritHealer_Func");

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Show Spirit Healer

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDShowSpiritHealer_Func (bool testConds, bool runActions) {

    // Variable Declarations

    string lv_actorMessage;

    unitgroup lv_lVUnitsWithoutController;



    // Automatic Variable Declarations

    // Variable Initialization

    lv_actorMessage = "";

    lv_lVUnitsWithoutController = UnitGroupEmpty();



    // Actions

    if (!runActions) {

        return true;

    }



    if ((UnitGetType(libGame_gv_players[libGame_gf_HeroKilledPlayer()].lv_heroUnit) != "HeroAbathur") && ((UnitGetType(libGame_gf_HeroKilledUnit()) == "HeroBaleog") || (UnitGetType(libGame_gf_HeroKilledUnit()) == "HeroOlaf") || (UnitGetType(libGame_gf_HeroKilledUnit()) == "HeroErik"))) {

        lv_lVUnitsWithoutController = libGame_gv_players[libGame_gf_HeroKilledPlayer()].lv_heroUnitGroup;

        UnitGroupRemove(lv_lVUnitsWithoutController, libGame_gv_players[libGame_gf_HeroKilledPlayer()].lv_heroUnit);

        if ((libNtve_gf_UnitGroupIsDead(lv_lVUnitsWithoutController) == false)) {

            return true;

        }



    }



    lv_actorMessage = ("SetFilterPlayers " + IntToString(libGame_gf_HeroKilledPlayer()) + " Clear");

    libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDSpiritHealer, (lv_actorMessage));

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDShowSpiritHealer_Init () {

    libMTOD_gt_MMToDShowSpiritHealer = TriggerCreate("libMTOD_gt_MMToDShowSpiritHealer_Func");

    libGame_gf_HeroKilled(libMTOD_gt_MMToDShowSpiritHealer);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Hide Spirit Healer

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDHideSpiritHealer_Func (bool testConds, bool runActions) {

    // Variable Declarations

    string lv_actorMessage;



    // Automatic Variable Declarations

    // Variable Initialization

    lv_actorMessage = "";



    // Actions

    if (!runActions) {

        return true;

    }



    lv_actorMessage = ("SetFilterPlayers " + IntToString(libGame_gf_HeroRespawnPlayer()));

    libNtve_gf_SendActorMessageToUnit(libMTOD_gv_mMToDSpiritHealer, (lv_actorMessage));

    if ((libMTOD_gv_mMToDSpiritHealerTextTags[libGame_gf_HeroRespawnPlayer()] != c_textTagNone)) {

        TextTagDestroy(libMTOD_gv_mMToDSpiritHealerTextTags[libGame_gf_HeroRespawnPlayer()]);

    }



    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDHideSpiritHealer_Init () {

    libMTOD_gt_MMToDHideSpiritHealer = TriggerCreate("libMTOD_gt_MMToDHideSpiritHealer_Func");

    libGame_gf_HeroRespawn(libMTOD_gt_MMToDHideSpiritHealer);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Spirit Healer Clicked

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDSpiritHealerClicked_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Conditions

    if (testConds) {

        if (!((UnitGetType(EventUnit()) == "SpiritHealer"))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    if ((libMTOD_gv_mMToDSpiritHealerClicked == false)) {

        libMTOD_gv_mMToDSpiritHealerClicked = true;

    }



    if ((libMTOD_gv_mMToDSpiritHealerTextTags[EventPlayer()] != c_textTagNone)) {

        TextTagDestroy(libMTOD_gv_mMToDSpiritHealerTextTags[EventPlayer()]);

    }



    TextTagCreate(StringExternal("Param/Value/lib_MTOD_94F5C4A8"), 15, PointWithOffset(UnitGetPosition(EventUnit()), 0.0, -1.5), 2.5, true, false, PlayerGroupSingle(EventPlayer()));

    TextTagSetTime(TextTagLastCreated(), c_textTagTimeDuration, 5.0);

    TextTagSetTime(TextTagLastCreated(), c_textTagTimeFadeOut, 4.75);

    TextTagSetTime(TextTagLastCreated(), c_textTagTimeFadeDuration, 0.25);

    libMTOD_gv_mMToDSpiritHealerTextTags[EventPlayer()] = TextTagLastCreated();

    if ((TimerGetRemaining(libMTOD_gv_mMToDSpiritHealerVOTimers[EventPlayer()]) == 0.0)) {

        TimerStart(libMTOD_gv_mMToDSpiritHealerVOTimers[EventPlayer()], libMTOD_gv_mMToDSpiritHealerVOCooldown, false, c_timeGame);

        Wait(0.5, c_timeGame);

        libSond_gf_HeroVOPlayHeroLine(libCore_ge_HeroVOEvents_Healed, EventPlayer(), libCore_gv_playerGroupFromPlayer[EventPlayer()]);

    }



    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDSpiritHealerClicked_Init () {

    libMTOD_gt_MMToDSpiritHealerClicked = TriggerCreate("libMTOD_gt_MMToDSpiritHealerClicked_Func");

    TriggerAddEventUnitClick(libMTOD_gt_MMToDSpiritHealerClicked, null, c_playerAny);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Cannon Missile Created

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDCannonMissileCreated_Func (bool testConds, bool runActions) {

    // Variable Declarations

    unit lv_missile;

    int lv_pingBallOrder;

    int lv_pingBallChaos;

    int lv_pingTrail;

    point lv_missilePosition;

    playergroup lv_leftTeamPlayerGroup;



    // Automatic Variable Declarations

    string auto99C722CA_val;



    // Variable Initialization

    lv_pingBallOrder = c_invalidPingId;

    lv_pingBallChaos = c_invalidPingId;

    lv_pingTrail = c_invalidPingId;

    lv_leftTeamPlayerGroup = PlayerGroupEmpty();



    // Conditions

    if (testConds) {

        if (!(((UnitGetType(EventUnitCreatedUnit()) == "MapEventNecromancerCannonMissile") || (UnitGetType(EventUnitCreatedUnit()) == "MapEventRavenLordCannonMissile") || (UnitGetType(EventUnitCreatedUnit()) == "BossMercCampCannonMissile") || (UnitGetType(EventUnitCreatedUnit()) == "MercLanerGoblinSapperCoreMortarMissile")))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    Wait(0.0625, c_timeGame);

    lv_missile = EventUnitCreatedUnit();

    lv_leftTeamPlayerGroup = libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamOrderIndex_C, true);

    PlayerGroupAdd(lv_leftTeamPlayerGroup, libCore_gv_oBSERVER_ObserverUIPlayer);

    auto99C722CA_val = UnitGetType(EventUnitCreatedUnit());

    if (auto99C722CA_val == "MapEventRavenLordCannonMissile") {

        libNtve_gf_CreatePingFacingAngleWithType(lv_leftTeamPlayerGroup, "RavenLordCannonMissileIconBlue", UnitGetPosition(lv_missile), ColorWithAlpha(0.00, 0.00, 0.00, 0.00), 0.0, UnitGetFacing(lv_missile), -1, -1);

        lv_pingBallOrder = PingLastCreated();

        PingSetScale(PingLastCreated(), 0.125);

        libNtve_gf_CreatePingFacingAngleWithType(libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamChaosIndex_C, true), "RavenLordCannonMissileIconRed", UnitGetPosition(lv_missile), ColorWithAlpha(0.00, 0.00, 0.00, 0.00), 0.0, UnitGetFacing(lv_missile), -1, -1);

        lv_pingBallChaos = PingLastCreated();

        PingSetScale(PingLastCreated(), 0.125);

    }

    else if (auto99C722CA_val == "MapEventNecromancerCannonMissile") {

        libNtve_gf_CreatePingFacingAngleWithType(lv_leftTeamPlayerGroup, "NecromancerCannonMissileIconRed", UnitGetPosition(lv_missile), ColorWithAlpha(0.00, 0.00, 0.00, 0.00), 0.0, UnitGetFacing(lv_missile), -1, -1);

        lv_pingBallOrder = PingLastCreated();

        PingSetScale(PingLastCreated(), 0.1);

        libNtve_gf_CreatePingFacingAngleWithType(libGame_gf_PlayersOnTeamHeroes(libGame_gv_teamChaosIndex_C, true), "NecromancerCannonMissileIconBlue", UnitGetPosition(lv_missile), ColorWithAlpha(0.00, 0.00, 0.00, 0.00), 0.0, UnitGetFacing(lv_missile), -1, -1);

        lv_pingBallChaos = PingLastCreated();

        PingSetScale(PingLastCreated(), 0.1);

    }

    else {

        libNtve_gf_CreatePingFacingAngleWithType(PlayerGroupAll(), "MercCannonMissileIcon", UnitGetPosition(lv_missile), ColorWithAlpha(0.00, 0.00, 0.00, 0.00), 0.0, 270.0, -1, -1);

        PingSetScale(PingLastCreated(), 0.08);

        lv_pingBallOrder = PingLastCreated();

        libNtve_gf_CreatePingFacingAngleWithType(PlayerGroupAll(), "Invisible", UnitGetPosition(lv_missile), ColorWithAlpha(0.00, 0.00, 0.00, 0.00), 0.0, UnitGetFacing(lv_missile), -1, -1);

        lv_pingBallChaos = PingLastCreated();

    }

    PingSetUnit(lv_pingBallOrder, lv_missile);

    PingSetUnit(lv_pingBallChaos, lv_missile);

    Wait(0.125, c_timeGame);

    while (true) {

        if ((UnitIsAlive(lv_missile) == false)) {

            PingDestroy(lv_pingBallOrder);

            PingDestroy(lv_pingBallChaos);

            libNtve_gf_CreatePingFacingAngleWithType(PlayerGroupAll(), "GeneralCannonMissileImpactIcon", lv_missilePosition, ColorWithAlpha(0.00, 0.00, 0.00, 0.00), 0.0625, 270.0, -1, -1);

            PingSetScale(PingLastCreated(), 0.1);

            libMTOD_gf_MMToDCannonballImpactShakingCamera(lv_missilePosition);

            return true;

        }



        lv_missilePosition = UnitGetPosition(lv_missile);

        Wait(0.0625, c_timeGame);

    }

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDCannonMissileCreated_Init () {

    libMTOD_gt_MMToDCannonMissileCreated = TriggerCreate("libMTOD_gt_MMToDCannonMissileCreated_Func");

    TriggerAddEventUnitCreated(libMTOD_gt_MMToDCannonMissileCreated, null, null, null);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD End of Game Clean Up

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDEndofGameCleanUp_Func (bool testConds, bool runActions) {

    // Variable Declarations

    unitgroup lv_excessProjectiles;

    unit lv_projectile;



    // Automatic Variable Declarations

    unitgroup auto1764BE8E_g;

    int auto1764BE8E_u;



    // Variable Initialization

    lv_excessProjectiles = UnitGroupEmpty();



    // Actions

    if (!runActions) {

        return true;

    }



    lv_excessProjectiles = UnitGroup("MapEventRavenLordCannonMissile", c_playerAny, null, UnitFilter(0, 0, 0, (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0);

    UnitGroupAddUnitGroup(lv_excessProjectiles, UnitGroup("MapEventNecromancerCannonMissile", c_playerAny, null, UnitFilter(0, 0, 0, (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0));

    UnitGroupAddUnitGroup(lv_excessProjectiles, UnitGroup("BossMercCampCannonMissile", c_playerAny, null, UnitFilter(0, 0, 0, (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0));

    UnitGroupAddUnitGroup(lv_excessProjectiles, UnitGroup("MercLanerGoblinSapperCoreMortarMissile", c_playerAny, null, UnitFilter(0, 0, 0, (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0));

    auto1764BE8E_g = lv_excessProjectiles;

    auto1764BE8E_u = UnitGroupCount(auto1764BE8E_g, c_unitCountAll);

    for (;; auto1764BE8E_u -= 1) {

        lv_projectile = UnitGroupUnitFromEnd(auto1764BE8E_g, auto1764BE8E_u);

        if (lv_projectile == null) { break; }

        UnitKill(lv_projectile);

    }

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDEndofGameCleanUp_Init () {

    libMTOD_gt_MMToDEndofGameCleanUp = TriggerCreate("libMTOD_gt_MMToDEndofGameCleanUp_Func");

    TriggerAddEventUnitDamaged(libMTOD_gt_MMToDEndofGameCleanUp, UnitRefFromVariable("libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_core"), c_unitDamageTypeAny, c_unitDamageFatal, null);

    TriggerAddEventUnitDamaged(libMTOD_gt_MMToDEndofGameCleanUp, UnitRefFromVariable("libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_core"), c_unitDamageTypeAny, c_unitDamageFatal, null);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD BanterTimer

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDBanterTimer_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Actions

    if (!runActions) {

        return true;

    }



    libMTOD_gv_mMToDBanterVariable = true;

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDBanterTimer_Init () {

    libMTOD_gt_MMToDBanterTimer = TriggerCreate("libMTOD_gt_MMToDBanterTimer_Func");

    TriggerAddEventTimer(libMTOD_gt_MMToDBanterTimer, libMTOD_gv_mMToDBanterTimer);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Town Health Tracker

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDTownHealthTracker_Func (bool testConds, bool runActions) {

    // Variable Declarations

    int lv_itTown;

    int lv_width_C;

    int lv_height_C;

    int lv_calculatedHeight;



    // Automatic Variable Declarations

    const int autoF3361FCE_ae = libMTOD_gv_mMToDTownsMaxCount_C;

    const int autoF3361FCE_ai = 1;



    // Variable Initialization

    lv_width_C = 64;

    lv_height_C = 64;



    // Actions

    if (!runActions) {

        return true;

    }



    while (true) {

        if ((libGame_gv_gameOver == true)) {

            return true;

        }



        lv_itTown = 1;

        for ( ; ( (autoF3361FCE_ai >= 0 && lv_itTown <= autoF3361FCE_ae) || (autoF3361FCE_ai < 0 && lv_itTown >= autoF3361FCE_ae) ) ; lv_itTown += autoF3361FCE_ai ) {

            if ((libMTOD_gv_mMToDTowns[lv_itTown].lv_fortUnit != null)) {

                lv_calculatedHeight = FixedToInt((lv_height_C * (UnitGetPropertyFixed(libMTOD_gv_mMToDTowns[lv_itTown].lv_fortUnit, c_unitPropLifePercent, c_unitPropCurrent) / 100.0)));

                DialogControlSetSize(libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_blueTownHealth, libCore_gv_allHeroPlayersPlusObserver, lv_width_C, lv_calculatedHeight);

                DialogControlSetSize(libMTOD_gv_mMToDPanels.lv_townHealth[lv_itTown].lv_redTownHealth, libCore_gv_allHeroPlayersPlusObserver, lv_width_C, lv_calculatedHeight);

            }



        }

        Wait(0.125, c_timeGame);

    }

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDTownHealthTracker_Init () {

    libMTOD_gt_MMToDTownHealthTracker = TriggerCreate("libMTOD_gt_MMToDTownHealthTracker_Func");

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD UI Mod Initialize

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDUIModInitialize_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Actions

    if (!runActions) {

        return true;

    }



    libMTOD_gf_MMToDUIInit(libUIUI_gv_mapMechanicsPanel.lv_mainPanel);

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDUIModInitialize_Init () {

    libMTOD_gt_MMToDUIModInitialize = TriggerCreate("libMTOD_gt_MMToDUIModInitialize_Func");

    libCore_gf_IncludeModInitialization(libMTOD_gt_MMToDUIModInitialize);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD DisableJungle

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDDisableJungle_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Conditions

    if (testConds) {

        if (!((GameCheatsEnabled(c_gameCheatCategoryDevelopment) == true))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    TriggerEnable(TriggerGetCurrent(), false);

    libCore_gv_sYSJungleCreepCamps = false;

    TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_49590A7C"), true);

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDDisableJungle_Init () {

    libMTOD_gt_MMToDDisableJungle = TriggerCreate("libMTOD_gt_MMToDDisableJungle_Func");

    TriggerAddEventChatMessage(libMTOD_gt_MMToDDisableJungle, c_playerAny, "DisableJungle", false);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Debug FlipTown

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDDebugFlipTown_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    string auto9F79D6A4_val;



    // Conditions

    if (testConds) {

        if (!((GameCheatsEnabled(c_gameCheatCategoryDevelopment) == true))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    auto9F79D6A4_val = StringSub(EventChatMessage(false), 10, 10);

    if (auto9F79D6A4_val == "1") {

        if ((libMTOD_gv_mMToDTowns[1].lv_fortUnit != null)) {

            UnitKill(libMTOD_gv_mMToDTowns[1].lv_fortUnit);

        }

        else {

            TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_ADB052E5"), true);

        }

    }

    else if (auto9F79D6A4_val == "2") {

        if ((libMTOD_gv_mMToDTowns[2].lv_fortUnit != null)) {

            UnitKill(libMTOD_gv_mMToDTowns[2].lv_fortUnit);

        }

        else {

            TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_0A1C6380"), true);

        }

    }

    else if (auto9F79D6A4_val == "3") {

        if ((libMTOD_gv_mMToDTowns[3].lv_fortUnit != null)) {

            UnitKill(libMTOD_gv_mMToDTowns[3].lv_fortUnit);

        }

        else {

            TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_865752E9"), true);

        }

    }

    else if (auto9F79D6A4_val == "4") {

        if ((libMTOD_gv_mMToDTowns[4].lv_fortUnit != null)) {

            UnitKill(libMTOD_gv_mMToDTowns[4].lv_fortUnit);

        }

        else {

            TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_06474D2C"), true);

        }

    }

    else if (auto9F79D6A4_val == "5") {

        if ((libMTOD_gv_mMToDTowns[5].lv_fortUnit != null)) {

            UnitKill(libMTOD_gv_mMToDTowns[5].lv_fortUnit);

        }

        else {

            TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_7FD5C03D"), true);

        }

    }

    else if (auto9F79D6A4_val == "6") {

        if ((libMTOD_gv_mMToDTowns[6].lv_fortUnit != null)) {

            UnitKill(libMTOD_gv_mMToDTowns[6].lv_fortUnit);

        }

        else {

            TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_07C03423"), true);

        }

    }

    else {

        TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_3A82E851"), true);

    }

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDDebugFlipTown_Init () {

    libMTOD_gt_MMToDDebugFlipTown = TriggerCreate("libMTOD_gt_MMToDDebugFlipTown_Func");

    TriggerAddEventChatMessage(libMTOD_gt_MMToDDebugFlipTown, c_playerAny, "FlipTown", false);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Debug PhaseTwo

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDDebugPhaseTwo_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Conditions

    if (testConds) {

        if (!((GameCheatsEnabled(c_gameCheatCategoryDevelopment) == true))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    if ((TimerGetRemaining(libMTOD_gv_mMToDPhaseTwoTimer) > 1)) {

        TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_7A26E2AD"), true);

        libMTOD_gv_mMToDPhaseTwoCheatUsed = true;

        TimerStart(libMTOD_gv_mMToDPhaseTwoTimer, 1.0, false, c_timeGame);

    }



    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDDebugPhaseTwo_Init () {

    libMTOD_gt_MMToDDebugPhaseTwo = TriggerCreate("libMTOD_gt_MMToDDebugPhaseTwo_Func");

    TriggerAddEventChatMessage(libMTOD_gt_MMToDDebugPhaseTwo, c_playerAny, "PhaseTwo", false);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Debug Waygates

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDDebugWaygates_Func (bool testConds, bool runActions) {

    // Variable Declarations

    int lv_itWaygate;



    // Automatic Variable Declarations

    // Variable Initialization



    // Conditions

    if (testConds) {

        if (!((GameCheatsEnabled(c_gameCheatCategoryDevelopment) == true))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    libMTOD_gf_MMToDActivateWaygates();

    TriggerEnable(TriggerGetCurrent(), false);

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDDebugWaygates_Init () {

    libMTOD_gt_MMToDDebugWaygates = TriggerCreate("libMTOD_gt_MMToDDebugWaygates_Func");

    TriggerAddEventChatMessage(libMTOD_gt_MMToDDebugWaygates, c_playerAny, "Waygates", false);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Debug AllCannons

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDDebugAllCannons_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Conditions

    if (testConds) {

        if (!((GameCheatsEnabled(c_gameCheatCategoryDevelopment) == true))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    libMTOD_gf_MMToDAltarFireCannons(libGame_gv_teamOrderIndex_C);

    libMTOD_gf_MMToDAltarFireCannons(libGame_gv_teamChaosIndex_C);

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDDebugAllCannons_Init () {

    libMTOD_gt_MMToDDebugAllCannons = TriggerCreate("libMTOD_gt_MMToDDebugAllCannons_Func");

    TriggerAddEventChatMessage(libMTOD_gt_MMToDDebugAllCannons, c_playerAny, "AllCannons", false);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Debug OrderCannons

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDDebugOrderCannons_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Conditions

    if (testConds) {

        if (!((GameCheatsEnabled(c_gameCheatCategoryDevelopment) == true))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    libMapM_gf_MapMechanicDisplayAnnouncement(TextExpressionAssemble("Param/Expression/lib_MTOD_E53AA897"), true, 0.5, 3.0, libMapM_ge_MapMechanicAnnouncementAllyOptions_Neutral, PlayerGroupAll());

    libMTOD_gf_MMToDAltarFireCannons(libGame_gv_teamOrderIndex_C);

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDDebugOrderCannons_Init () {

    libMTOD_gt_MMToDDebugOrderCannons = TriggerCreate("libMTOD_gt_MMToDDebugOrderCannons_Func");

    TriggerAddEventChatMessage(libMTOD_gt_MMToDDebugOrderCannons, c_playerAny, "OrderCannons", false);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Debug ChaosCannons

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDDebugChaosCannons_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Conditions

    if (testConds) {

        if (!((GameCheatsEnabled(c_gameCheatCategoryDevelopment) == true))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    libMapM_gf_MapMechanicDisplayAnnouncement(TextExpressionAssemble("Param/Expression/lib_MTOD_D1E80F69"), true, 0.5, 3.0, libMapM_ge_MapMechanicAnnouncementAllyOptions_Neutral, PlayerGroupAll());

    libMTOD_gf_MMToDAltarFireCannons(libGame_gv_teamChaosIndex_C);

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDDebugChaosCannons_Init () {

    libMTOD_gt_MMToDDebugChaosCannons = TriggerCreate("libMTOD_gt_MMToDDebugChaosCannons_Func");

    TriggerAddEventChatMessage(libMTOD_gt_MMToDDebugChaosCannons, c_playerAny, "ChaosCannons", false);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Debug BossCannons

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDDebugBossCannons_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Conditions

    if (testConds) {

        if (!((GameCheatsEnabled(c_gameCheatCategoryDevelopment) == true))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    if ((UnitGetPropertyFixed(libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_core, c_unitPropLife, c_unitPropCurrent) > UnitGetPropertyFixed(libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_core, c_unitPropLife, c_unitPropCurrent))) {

        TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_7F947559"), true);

        libMTOD_gf_MMToDBossCampFireCannons(libCore_gv_cOMPUTER_TeamChaos);

    }



    if ((UnitGetPropertyFixed(libGame_gv_teams[libGame_gv_teamOrderIndex_C].lv_core, c_unitPropLife, c_unitPropCurrent) <= UnitGetPropertyFixed(libGame_gv_teams[libGame_gv_teamChaosIndex_C].lv_core, c_unitPropLife, c_unitPropCurrent))) {

        TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_32E668CD"), true);

        libMTOD_gf_MMToDBossCampFireCannons(libCore_gv_cOMPUTER_TeamOrder);

    }



    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDDebugBossCannons_Init () {

    libMTOD_gt_MMToDDebugBossCannons = TriggerCreate("libMTOD_gt_MMToDDebugBossCannons_Func");

    TriggerAddEventChatMessage(libMTOD_gt_MMToDDebugBossCannons, c_playerAny, "BossCannons", false);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Debug WarningOn

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDDebugWarningOn_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Conditions

    if (testConds) {

        if (!((GameCheatsEnabled(c_gameCheatCategoryDevelopment) == true))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    if ((TimerGetRemaining(libMTOD_gv_mMToDScoringAltarTimer) > 1)) {

        TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_8BC9190F"), true);

        TimerStart(libMTOD_gv_mMToDScoringAltarTimer, libMTOD_gv_mMToDScoringAltarWarningTime_C, false, c_timeGame);

    }



    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDDebugWarningOn_Init () {

    libMTOD_gt_MMToDDebugWarningOn = TriggerCreate("libMTOD_gt_MMToDDebugWarningOn_Func");

    TriggerAddEventChatMessage(libMTOD_gt_MMToDDebugWarningOn, c_playerAny, "WarningOn", false);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Debug AltarsOn

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDDebugAltarsOn_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Conditions

    if (testConds) {

        if (!((GameCheatsEnabled(c_gameCheatCategoryDevelopment) == true))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    if ((TimerGetRemaining(libMTOD_gv_mMToDScoringAltarTimer) > 1)) {

        TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_801F4BF8"), true);

        TimerStart(libMTOD_gv_mMToDScoringAltarTimer, 1.0, false, c_timeGame);

    }



    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDDebugAltarsOn_Init () {

    libMTOD_gt_MMToDDebugAltarsOn = TriggerCreate("libMTOD_gt_MMToDDebugAltarsOn_Func");

    TriggerAddEventChatMessage(libMTOD_gt_MMToDDebugAltarsOn, c_playerAny, "AltarsOn", false);

}



//--------------------------------------------------------------------------------------------------

// Trigger: MMToD Debug Event Start

//--------------------------------------------------------------------------------------------------

bool libMTOD_gt_MMToDDebugEventStart_Func (bool testConds, bool runActions) {

    // Automatic Variable Declarations

    // Conditions

    if (testConds) {

        if (!((GameCheatsEnabled(c_gameCheatCategoryDevelopment) == true))) {

            return false;

        }

    }



    // Actions

    if (!runActions) {

        return true;

    }



    TriggerDebugOutput(1, StringExternal("Param/Value/lib_MTOD_D46E7F48"), true);

    libMTOD_gv_mMToDFirstEventSpawned = true;

    TimerStart(libMTOD_gv_mMToDObjectivePreviewTimer, 1.0, false, c_timeGame);

    Wait(2.0, c_timeGame);

    TimerStart(libMTOD_gv_mMToDScoringAltarTimer, 1.0, false, c_timeGame);

    return true;

}



//--------------------------------------------------------------------------------------------------

void libMTOD_gt_MMToDDebugEventStart_Init () {

    libMTOD_gt_MMToDDebugEventStart = TriggerCreate("libMTOD_gt_MMToDDebugEventStart_Func");

    TriggerAddEventChatMessage(libMTOD_gt_MMToDDebugEventStart, c_playerAny, "eventstart", false);

}



void libMTOD_InitTriggers () {

    libMTOD_gt_IncludeToD_Init();

    libMTOD_gt_MMToDInit_Init();

    libMTOD_gt_MMToDPingDataInit_Init();

    libMTOD_gt_MMToDInitializeScoringAltars_Init();

    libMTOD_gt_MMToDGateOpen_Init();

    libMTOD_gt_MMToDArchwayAnims_Init();

    libMTOD_gt_MMToDMinimapHealthMonitor_Init();

    libMTOD_gt_MMToDFastSpawnMinions_Init();

    libMTOD_gt_MMToDScoringAltarTimerTrigger_Init();

    libMTOD_gt_MMToDObjectivePreviewTimerExpires_Init();

    libMTOD_gt_MMToDScoringAltarCaptured_Init();

    libMTOD_gt_MMToDStartPhaseTwoTimer_Init();

    libMTOD_gt_MMToDL2FortMorphsIntoL3Keep_Init();

    libMTOD_gt_MMToDL2TowerMorphsIntoL3Tower_Init();

    libMTOD_gt_MMToDL2MoonwellMorphsIntoL3Moonwell_Init();

    libMTOD_gt_MMToDSixCapCannonActivation_Init();

    libMTOD_gt_MMToDOwnedTownDies_Init();

    libMTOD_gt_MMToDTownFinishedBuilding_Init();

    libMTOD_gt_MMToDMercScaling_Init();

    libMTOD_gt_MMToDMercDamageTracking_Init();

    libMTOD_gt_MMToDMercLanerHorsemanSummonsHead_Init();

    libMTOD_gt_MMToDBossHorsemanCreated_Init();

    libMTOD_gt_MMToDBossHorsemanDies_Init();

    libMTOD_gt_MMToDHeadlessHorsemanCampCaptured_Init();

    libMTOD_gt_MMToDProtectionTowerScan_Init();

    libMTOD_gt_MMToDEnteredWaygate_Init();

    libMTOD_gt_MMToDInitStoreSpiritHealer_Init();

    libMTOD_gt_MMToDShowSpiritHealer_Init();

    libMTOD_gt_MMToDHideSpiritHealer_Init();

    libMTOD_gt_MMToDSpiritHealerClicked_Init();

    libMTOD_gt_MMToDCannonMissileCreated_Init();

    libMTOD_gt_MMToDEndofGameCleanUp_Init();

    libMTOD_gt_MMToDBanterTimer_Init();

    libMTOD_gt_MMToDTownHealthTracker_Init();

    libMTOD_gt_MMToDUIModInitialize_Init();

    libMTOD_gt_MMToDDisableJungle_Init();

    libMTOD_gt_MMToDDebugFlipTown_Init();

    libMTOD_gt_MMToDDebugPhaseTwo_Init();

    libMTOD_gt_MMToDDebugWaygates_Init();

    libMTOD_gt_MMToDDebugAllCannons_Init();

    libMTOD_gt_MMToDDebugOrderCannons_Init();

    libMTOD_gt_MMToDDebugChaosCannons_Init();

    libMTOD_gt_MMToDDebugBossCannons_Init();

    libMTOD_gt_MMToDDebugWarningOn_Init();

    libMTOD_gt_MMToDDebugAltarsOn_Init();

    libMTOD_gt_MMToDDebugEventStart_Init();

}



//--------------------------------------------------------------------------------------------------

// Library Initialization

//--------------------------------------------------------------------------------------------------

bool libMTOD_InitLib_completed = false;



void libMTOD_InitLib () {

    if (libMTOD_InitLib_completed) {

        return;

    }



    libMTOD_InitLib_completed = true;



    libMTOD_InitLibraries();

    libMTOD_InitVariables();

    libMTOD_InitTriggers();

}