Benutzer-Werkzeuge

Webseiten-Werkzeuge


utilfunctions:priester_und_schamanen

FIXME Diese Seite ist noch im Bau!
Erläuterungen werden folgen, wenn der Code vollständig ist.

Scriptlog:

  • Update auf Version 1.01:
    • Bugs sind gefixt die auftraten, wenn mehrere Priester/Schamanen auf einer Map verwendet werden.
    • Prototypen für die Schamanenflüche Lv1 und Lv2 sind enthalten


  • Update auf Version 1.02:
    • Die Inflationswerte wurden verringert


  • Update auf Version 1.03: (Betrifft nur den Priestercode)
    • Zusätzliche (kontextsensitive) Angabe in den Tooltips der Priester
    • Anpassung der Tooltips von Kapelle und Onlinehilfe-Button
    • Neue (effektivere) Funktionen zum Ändern von Manabeständen und Wunderkosten
    • Geringfügige Layout- und Balancingänderungen


  • Update auf Version 1.04: (Betrifft nur den Priestercode)
    • ungeschickte Abfragekombination während der Laufzeit des 3. Wunders ausgebessert
    • stilistische Verbesserungen
    • Entfernen von fälschlischerweise als benötigt angegebenen Comfort-Funktionen ;-)



Priestercode

function Priests_SetupManaProduction()
    GUIAction_BlessSettlers_OrigPriests = GUIAction_BlessSettlers;
    gvMana = {
        mana_1 = 0,
        mana_1_costs = 120,
        mana_2 = 0,
        mana_2_costs = 180,
        mana_3 = 0,
        mana_3_costs = 240,
        mana_4 = 0,
        mana_4_costs = 280,
        mana_5 = 0,
        mana_5_costs = 420,
    };
    GUIAction_BlessSettlers = function( _count )
        local faith = Logic.GetPlayersGlobalResource( 1, ResourceType.Faith );
        local addMana;
        if faith >= 5000 then
            addMana = true;
        else
            addMana = false;
        end
        StartDelayFunc( Priests_BugfixDelay, _count, addMana );
    end
    Priests_Miracle3_IsRunning = false;
    Priests_InitMonasteryTooltips();
end
 
function Priests_BugfixDelay( _count, _addMana )
    local GUIAction_BlessSettlers_OrigBugfixDelay = GUIAction_BlessSettlers;
    GUIAction_BlessSettlers = function() end;
    if _count == 1 then
        GUIAction_BlessSettlers_OrigPriests( BlessCategories.Construction );
        DelayShort(1);
        if _addMana then
            gvMana.mana_1 = gvMana.mana_1 + 100;
            Message("@color:0,0,255 Mana LvL1: "..gvMana.mana_1);
        end
    elseif _count == 2 then
        GUIAction_BlessSettlers_OrigPriests( BlessCategories.Research );
        DelayShort(1);
        if _addMana then
            gvMana.mana_2 = gvMana.mana_2 + 100;
            Message("@color:0,255,0 Mana LvL2: "..gvMana.mana_2);
        end
    elseif _count == 3 then
        GUIAction_BlessSettlers_OrigPriests( BlessCategories.Weapons );
        DelayShort(1);
        if _addMana then
            gvMana.mana_3 = gvMana.mana_3 + 100;
            Message("@color:255,232,0 Mana LvL3: "..gvMana.mana_3);
        end
    elseif _count == 4 then
        GUIAction_BlessSettlers_OrigPriests( BlessCategories.Financial );
        DelayShort(1);
        if _addMana then
            gvMana.mana_4 = gvMana.mana_4 + 100;
            Message("@color:255,0,0 Mana LvL4: "..gvMana.mana_4);
        end
    elseif _count == 5 then
        GUIAction_BlessSettlers_OrigPriests( BlessCategories.Canonisation );
        DelayShort(1);
        if _addMana then
            gvMana.mana_5 = gvMana.mana_5 + 100;
            Message("@color:175,0,175 Mana LvL5: "..gvMana.mana_5);
        end
    end
    if _addMana then
        while Logic.GetPlayersGlobalResource( 1, ResourceType.Faith ) > 0 do
            Logic.AddToPlayersGlobalResource( 1, ResourceType.Faith, -100 );
        end
    end
    GUIAction_BlessSettlers = GUIAction_BlessSettlers_OrigBugfixDelay;
end
 
function Priests_InitMonasteryTooltips()
    GUITooltip_BlessSettlers_OrigPriests = GUITooltip_BlessSettlers;
    GUITooltip_BlessSettlers = function( a, b, c, d )
        GUITooltip_BlessSettlers_OrigPriests( a, b, c, d );
        local newString, numberOfChanges = string.gsub( a, "MenuMonastery/", "" );
        if numberOfChanges == 1 then
            if newString == "BlessSettlers_disabled" then
                if c == "AOMenuMonastery/BlessSettlers1_researched" then
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:0,0,255 Läutet die Glocke @cr @color:150,150,150 ermöglicht: @color:255,255,255 Erhöht die Motivation von Bauern, Ziegelbrennern, Sägewerkern, Steinmetzen, Schankwirten und Bergmännern. @cr Produktion von Mana LvL1." );
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "@color:150,150,150 Mana: @color:0,0,255 +100" );
                elseif c == "AOMenuMonastery/BlessSettlers2_researched" then
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:0,255,0 Ablassbriefe @cr @color:150,150,150 ermöglicht: @color:255,255,255 Erhöht die Motivation von Gelehrten, Ingenieuren, Brückenarchitekten und Priestern. @cr Produktion von Mana LvL2." );
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "@color:150,150,150 Mana: @color:0,255,0 +100" );
                end
            elseif newString == "AOBlessSettlers3_disabled" then
                XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:255,232,0 Bibeln @cr @color:150,150,150 ermöglicht: @color:255,255,255 Erhöht die Motivation von Schmieden, Alchimisten, Büchsenmachern und Kanonengießern. @cr Produktion von Mana LvL3." );
                XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "@color:150,150,150 Mana: @color:255,232,0 +100" );
            elseif newString == "AOBlessSettlers4_disabled" then
                XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:255,0,0 Kollekte @cr @color:150,150,150 ermöglicht: @color:255,255,255 Erhöht die Motivation von Schatzmeistern und Händlern. @cr Produktion von Mana LvL4." );
                XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "@color:150,150,150 Mana: @color:255,0,0 +100" );
            elseif newString == "AOBlessSettlers5_disabled" then
                XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:175,0,175 Heiligsprechung @cr @color:150,150,150 ermöglicht: @color:255,255,255 Erhöht die Motivation aller Arbeiter. @cr Produktion von Mana LvL5." );
                XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "@color:150,150,150 Mana: @color:175,0,175 +100" );
            end
        end
    end
end
 
function CreatePriest( _name )
    assert( type( _name ) == "string", "Priest ERROR[CreatePriest]: wrong Input!" )
    gvPriests = gvPriests or {
        PJobID = StartSimpleHiResJob( "Priests_ControlPriests" ),
        PTooltips = Priests_InitPriestTooltips(),
        PButtons = Priests_InitPriestButtons(),
        OHButton = Priests_InitPriestOnlineHelpButton(),
    };
    local priest = {
        name = _name,
        miracle1Possible = false,
        miracle2Possible = false,
        miracle3Possible = false,
        miracle4Possible = false,
        miracle5Possible = false,
    };
    table.insert( gvPriests, priest );
end
 
function Priests_ControlPriests()
    for i = 1,table.getn( gvPriests ) do
        if not IsExisting( gvPriests[i].name ) then
            DestroyPriest( gvPriests[i].name );
        else
            if gvMana.mana_1 >= gvMana.mana_1_costs and not gvPriests[i].miracle1Possible then
                gvPriests[i].miracle1Possible = true;
                if GUI.GetSelectedEntity() == GetEntityId( gvPriests[i].name) then
                    GameCallback_GUI_SelectionChanged();
                end
            elseif gvMana.mana_1 < gvMana.mana_1_costs and gvPriests[i].miracle1Possible then
                gvPriests[i].miracle1Possible = false;
                GameCallback_GUI_SelectionChanged();
            end
            if gvMana.mana_2 >= gvMana.mana_2_costs and not gvPriests[i].miracle2Possible then
                gvPriests[i].miracle2Possible = true;
                if GUI.GetSelectedEntity() == GetEntityId( gvPriests[i].name) then
                    GameCallback_GUI_SelectionChanged();
                end
            elseif gvMana.mana_2 < gvMana.mana_2_costs and gvPriests[i].miracle2Possible then
                gvPriests[i].miracle2Possible = false;
                GameCallback_GUI_SelectionChanged();
            end
            if not Priests_Miracle3_IsRunning and gvMana.mana_3 >= gvMana.mana_3_costs and not gvPriests[i].miracle3Possible then
                gvPriests[i].miracle3Possible = true;
                if GUI.GetSelectedEntity() == GetEntityId( gvPriests[i].name) then
                    GameCallback_GUI_SelectionChanged();
                end
            elseif Priests_Miracle3_IsRunning or ( gvMana.mana_3 < gvMana.mana_3_costs and gvPriests[i].miracle3Possible ) then
                gvPriests[i].miracle3Possible = false;
                if not Priests_Miracle3_IsRunning then
                    GameCallback_GUI_SelectionChanged();
                end
            end
            if gvMana.mana_4 >= gvMana.mana_4_costs and not gvPriests[i].miracle4Possible then
                gvPriests[i].miracle4Possible = true;
                if GUI.GetSelectedEntity() == GetEntityId( gvPriests[i].name) then
                    GameCallback_GUI_SelectionChanged();
                end
            elseif gvMana.mana_4 < gvMana.mana_4_costs and gvPriests[i].miracle4Possible then
                gvPriests[i].miracle4Possible = false;
                GameCallback_GUI_SelectionChanged();
            end
            if gvMana.mana_5 >= gvMana.mana_5_costs and not gvPriests[i].miracle5Possible then
                gvPriests[i].miracle5Possible = true;
                if GUI.GetSelectedEntity() == GetEntityId( gvPriests[i].name) then
                    GameCallback_GUI_SelectionChanged();
                end
            elseif gvMana.mana_5 < gvMana.mana_5_costs and gvPriests[i].miracle5Possible then
                gvPriests[i].miracle5Possible = false;
                GameCallback_GUI_SelectionChanged();
            end
        end
    end
end
 
function Priests_InitPriestTooltips()
    GUITooltip_NormalButton_OrigPriests = GUITooltip_NormalButton;
    GUITooltip_NormalButton = function( a, b )
        GUITooltip_NormalButton_OrigPriests( a, b );
        if IsPriest( GUI.GetSelectedEntity() ) then
            local newString, numberOfChanges = string.gsub( a, "MenuCommandsGeneric/", "" );
            if numberOfChanges == 1 then
                if newString == "command_attack" then
                    local possibilities, totalCosts = 0,0;
                    local costsPerMiracle = gvMana.mana_3_costs;
                    while ( totalCosts + costsPerMiracle ) <= gvMana.mana_3 do
                        totalCosts = totalCosts + costsPerMiracle;
                        local inflation = costsPerMiracle * 1.05;
                        costsPerMiracle = round(inflation);
                        possibilities = possibilities + 1;
                    end
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:255,232,0 Göttlicher Schutz @cr @color:150,150,150 Segnung: @color:255,255,255 \"Bibeln\" @cr @color:150,150,150 Effekt: @color:255,255,255 Der Schutz Gottes lässt eigene Einheiten oder Gebäude nahe des Priesters für kurze Zeit unverwundbar werden." );
                    if possibilities == 0 then
                        local manaRequired = ( gvMana.mana_3_costs - gvMana.mana_3 );
                        XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "@color:150,150,150 Mana: @color:255,232,0 "..gvMana.mana_3_costs.." @color:150,150,150 @cr Fehlendes Mana: @color:255,255,255 "..manaRequired );
                    else
                        XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "@color:150,150,150 Mana: @color:255,232,0 "..gvMana.mana_3_costs.." @color:150,150,150 @cr Einsetzbar: @color:255,255,255 "..possibilities.."x" );
                    end
                elseif newString == "command_stand" then
                    local possibilities, totalCosts = 0,0;
                    local costsPerMiracle = gvMana.mana_2_costs;
                    while ( totalCosts + costsPerMiracle ) <= gvMana.mana_2 do
                        totalCosts = totalCosts + costsPerMiracle;
                        local inflation = costsPerMiracle * 1.06;
                        costsPerMiracle = round(inflation);
                        possibilities = possibilities + 1;
                    end
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:0,255,0 Waldsegen @cr @color:150,150,150 Segnung: @color:255,255,255 \"Ablassbriefe\" @cr @color:150,150,150 Effekt: @color:255,255,255 Gefallene Wälder mögen wieder aufleben! Dieses Wunder vermag Baumstümpfe wieder in Bäume zu verwandeln." );
                    if possibilities == 0 then
                        local manaRequired = ( gvMana.mana_2_costs - gvMana.mana_2 );
                        XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "@color:150,150,150 Mana: @color:0,255,0 "..gvMana.mana_2_costs.." @color:150,150,150 @cr Fehlendes Mana: @color:255,255,255 "..manaRequired );
                    else
                        XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "@color:150,150,150 Mana: @color:0,255,0 "..gvMana.mana_2_costs.." @color:150,150,150 @cr Einsetzbar: @color:255,255,255 "..possibilities.."x" );
                    end
                elseif newString == "command_defend" then
                    local possibilities, totalCosts = 0,0;
                    local costsPerMiracle = gvMana.mana_1_costs;
                    while ( totalCosts + costsPerMiracle ) <= gvMana.mana_1 do
                        totalCosts = totalCosts + costsPerMiracle;
                        local inflation = costsPerMiracle * 1.06;
                        costsPerMiracle = round(inflation);
                        possibilities = possibilities + 1;
                    end
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:0,0,255 Göttliche Gabe @cr @color:150,150,150 Segnung: @color:255,255,255 \"Glocke Läuten\" @cr @color:150,150,150 Effekt: @color:255,255,255 In alter Manier fällt ein Strauss göttlicher Geschenke vom Himmel. Lasst Euch überraschen!" );
                    if possibilities == 0 then
                        local manaRequired = ( gvMana.mana_1_costs - gvMana.mana_1 );
                        XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "@color:150,150,150 Mana: @color:0,0,255 "..gvMana.mana_1_costs.." @color:150,150,150 @cr Fehlendes Mana: @color:255,255,255 "..manaRequired );
                    else
                        XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "@color:150,150,150 Mana: @color:0,0,255 "..gvMana.mana_1_costs.." @color:150,150,150 @cr Einsetzbar: @color:255,255,255 "..possibilities.."x" );
                    end
                elseif newString == "command_patrol" then
                    local possibilities, totalCosts = 0,0;
                    local costsPerMiracle = gvMana.mana_4_costs;
                    while ( totalCosts + costsPerMiracle ) <= gvMana.mana_4 do
                        totalCosts = totalCosts + costsPerMiracle;
                        local inflation = costsPerMiracle * 1.05;
                        costsPerMiracle = round(inflation);
                        possibilities = possibilities + 1;
                    end
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:255,0,0 Rohstoffreichtum @cr @color:150,150,150 Segnung: @color:255,255,255 \"Kollekte\" @cr @color:150,150,150 Effekt: @color:255,255,255 Dieser Spruch füllt Häuflein und Schächte in der Nähe des Priesters mit neuen Bodenschätzen." );
                    if possibilities == 0 then
                        local manaRequired = ( gvMana.mana_4_costs - gvMana.mana_4 );
                        XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "@color:150,150,150 Mana: @color:255,0,0 "..gvMana.mana_4_costs.." @color:150,150,150 @cr Fehlendes Mana: @color:255,255,255 "..manaRequired );
                    else
                        XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "@color:150,150,150 Mana: @color:255,0,0 "..gvMana.mana_4_costs.." @color:150,150,150 @cr Einsetzbar: @color:255,255,255 "..possibilities.."x" );
                    end
                elseif newString == "command_guard" then
                    local possibilities, totalCosts = 0,0;
                    local costsPerMiracle = gvMana.mana_5_costs;
                    while ( totalCosts + costsPerMiracle ) <= gvMana.mana_5 do
                        totalCosts = totalCosts + costsPerMiracle;
                        local inflation = costsPerMiracle * 1.04;
                        costsPerMiracle = round(inflation);
                        possibilities = possibilities + 1;
                    end
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:175,0,175 Feinde Bekehren @cr @color:150,150,150 Segnung: @color:255,255,255 \"Heiligsprechung\" @cr @color:150,150,150 Effekt: @color:255,255,255 Feindliche Einheiten mögen zum Christentum bekehrt und davon überzeugt werden, fortan für Euch tätig zu sein." );
                    if possibilities == 0 then
                        local manaRequired = ( gvMana.mana_5_costs - gvMana.mana_5 );
                        XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "@color:150,150,150 Mana: @color:175,0,175 "..gvMana.mana_5_costs.." @color:150,150,150 @cr Fehlendes Mana: @color:255,255,255 "..manaRequired );
                    else
                        XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "@color:150,150,150 Mana: @color:175,0,175 "..gvMana.mana_5_costs.." @color:150,150,150 @cr Einsetzbar: @color:255,255,255 "..possibilities.."x" );
                    end
                end
            end
        end
    end
    return true;
end
 
function Priests_InitPriestButtons()
    GUIUpdate_CommandGroup_OrigPriests = GUIUpdate_CommandGroup;
    GameCallback_GUI_SelectionChanged_OrigPriests = GameCallback_GUI_SelectionChanged;
    GUIAction_Command_OrigPriests = GUIAction_Command;
    GUIUpdate_CommandGroup = function()
        GUIUpdate_CommandGroup_OrigPriests();
        if IsPriest( GUI.GetSelectedEntity() ) then
            XGUIEng.HighLightButton( gvGUI_WidgetID.CommandDefend, 0 );
        end
    end
    GameCallback_GUI_SelectionChanged = function()
        if IsPriest( GUI.GetSelectedEntity() ) then
            local priest, priestnumber = GUI.GetSelectedEntity();
            for i = 1,table.getn( gvPriests ) do
                if priest == GetEntityId( gvPriests[i].name ) then
                    priestnumber = i;
                end
            end
            GameCallback_GUI_SelectionChanged_OrigPriests();
            if gvPriests[priestnumber].miracle1Possible then
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandDefend, 0);
            else
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandDefend, 1);
            end
            if gvPriests[priestnumber].miracle2Possible then
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandStand, 0);
            else
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandStand, 1);
            end
            if not Priests_Miracle3_IsRunning and gvPriests[priestnumber].miracle3Possible then
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandAttack, 0);
            else
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandAttack, 1);
            end
            if gvPriests[priestnumber].miracle4Possible then
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandPatrol, 0);
            else
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandPatrol, 1);
            end
            if gvPriests[priestnumber].miracle5Possible then
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandGuard, 0);
            else
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandGuard, 1);
            end
            GUIAction_Command = function( _count )
                if _count == 3 then  -- Wurde der Defend-Button gedrückt...
                    if GUI.GetSelectedEntity() == GetEntityId( priest ) then
                        -- ... wird das erste Wunder ausgelöst!
                        Priests_Miracle1_Action( priest );
                        gvPriests[priestnumber].miracle1Possible = false;
                        gvMana.mana_1 = gvMana.mana_1 - gvMana.mana_1_costs;
                        local inflation = gvMana.mana_1_costs * 1.06;
                        gvMana.mana_1_costs = round(inflation);
                        GameCallback_GUI_SelectionChanged();
                    else
                        GUIAction_Command_OrigPriests( _count );
                    end
                end
                if _count == 2 then  -- Wurde der Stand-Button gedrückt...
                    if GUI.GetSelectedEntity() == GetEntityId( priest ) then
                        -- ... wird das zweite Wunder ausgelöst!
                        Priests_Miracle2_Action( priest );
                        gvPriests[priestnumber].miracle2Possible = false;
                        gvMana.mana_2 = gvMana.mana_2 - gvMana.mana_2_costs;
                        local inflation = gvMana.mana_2_costs * 1.06;
                        gvMana.mana_2_costs = round(inflation);
                        GameCallback_GUI_SelectionChanged();
                    else
                        GUIAction_Command_OrigPriests( _count );
                    end
                end
                if _count == 1 then  -- Wurde der Attack-Button gedrückt...
                    if GUI.GetSelectedEntity() == GetEntityId( priest ) then
                        -- ... wird das dritte Wunder ausgelöst!
                        Priests_Miracle3_Action( priest );
                        gvPriests[priestnumber].miracle3Possible = false;
                        gvMana.mana_3 = gvMana.mana_3 - gvMana.mana_3_costs;
                        local inflation = gvMana.mana_3_costs * 1.05;
                        gvMana.mana_3_costs = round(inflation);
                        GameCallback_GUI_SelectionChanged();
                    else
                        GUIAction_Command_OrigPriests( _count );
                    end
                end
                if _count == 4 then  -- Wurde der Patrol-Button gedrückt...
                    if GUI.GetSelectedEntity() == GetEntityId( priest ) then
                        -- ... wird das vierte Wunder ausgelöst!
                        Priests_Miracle4_Action( priest );
                        gvPriests[priestnumber].miracle4Possible = false;
                        gvMana.mana_4 = gvMana.mana_4 - gvMana.mana_4_costs;
                        local inflation = gvMana.mana_4_costs * 1.05;
                        gvMana.mana_4_costs = round(inflation);
                        GameCallback_GUI_SelectionChanged();
                    else
                        GUIAction_Command_OrigPriests( _count );
                    end
                end
                if _count == 5 then  -- Wurde der Guard-Button gedrückt...
                    if GUI.GetSelectedEntity() == GetEntityId( priest ) then
                        -- ... wird das fünfte Wunder ausgelöst!
                        Priests_Miracle5_Action( priest );
                        gvPriests[priestnumber].miracle5Possible = false;
                        gvMana.mana_5 = gvMana.mana_5 - gvMana.mana_5_costs;
                        local inflation = gvMana.mana_5_costs * 1.04;
                        gvMana.mana_5_costs = round(inflation);
                        GameCallback_GUI_SelectionChanged();
                    else
                        GUIAction_Command_OrigPriests( _count );
                    end
                end
            end
        else  -- Wenn kein Priester selektiert ist...
            XGUIEng.DisableButton( gvGUI_WidgetID.CommandDefend, 0 );
            XGUIEng.DisableButton( gvGUI_WidgetID.CommandPatrol, 0 );
            XGUIEng.DisableButton( gvGUI_WidgetID.CommandAttack, 0 );
            XGUIEng.DisableButton( gvGUI_WidgetID.CommandGuard, 0 );
            XGUIEng.DisableButton( gvGUI_WidgetID.CommandStand, 0 );
            GameCallback_GUI_SelectionChanged_OrigPriests();
        end
    end
    return true;
end
 
function Priests_InitPriestOnlineHelpButton()
    GUIAction_OnlineHelp_OrigPriests = GUIAction_OnlineHelp;
    GUIAction_OnlineHelp = function()
        if IsPriest( GUI.GetSelectedEntity() ) then
            Message("@color:0,0,0 ~-~-~-~-~-~-~-~-~-~-~");
            Message("@color:0,0,255 Mana LvL1: "..gvMana.mana_1);
            Message("@color:0,255,0 Mana LvL2: "..gvMana.mana_2);
            Message("@color:255,232,0 Mana LvL3: "..gvMana.mana_3);
            Message("@color:255,0,0 Mana LvL4: "..gvMana.mana_4);
            Message("@color:175,0,175 Mana LvL5: "..gvMana.mana_5);
            Message("@color:0,0,0 ~-~-~-~-~-~-~-~-~-~-~");
        else
            GUIAction_OnlineHelp_OrigPriests();
        end
    end
    GUITooltip_Generic_OrigPriests = GUITooltip_Generic;
    GUITooltip_Generic = function( a, b, c )
        GUITooltip_Generic_OrigPriests( a, b, c );
        if IsPriest( GUI.GetSelectedEntity() ) then
            local newString, numberOfChanges = string.gsub( a, "MenuMap/", "" );
            if numberOfChanges == 1 then
                if newString == "OnlineHelp" then
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:180,180,180 Manakonto @cr @color:255,255,255 Hier könnt Ihr Euch einen Überblick über Eure aktuellen Bestände an Mana verschaffen." );
                end
            end
        end
    end
    return true;
end
 
function IsPriest( _entity )
    if type( _entity ) == "string" then
        for i = 1,table.getn( gvPriests ) do
            if gvPriests[i].name == _entity then
                return true;
            end
        end
    elseif type( _entity ) == "number" then
        for i = 1,table.getn( gvPriests ) do
            if GetEntityId( gvPriests[i].name ) == _entity then
                return true;
            end
        end
    end
end
 
function DestroyPriest( _name )
    for i = 1,table.getn( gvPriests ) do
        if gvPriests[i].name == _name then
            table.remove( gvPriests, i );
            return true;
        end
    end
end
 
function Priests_Miracle1_Action( _priest )
    local playerID = GetPlayer( _priest )
    local pos = GetPosition( _priest )
    Logic.CreateEffect( GGL_Effects.FXDarioFear, pos.X, pos.Y, 0 )
    Sound.PlayGUISound( Sounds.OnKlick_PB_Monastery2, 0 )
    Message("@color:0,0,0 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~");
    for i = 1,2 do
        local resourcetypes = math.random(1,6)
        local resourceamount = math.random(100,200)
        if resourcetypes == 1 then
            Tools.GiveResouces( playerID, resourceamount, 0, 0, 0, 0, 0 )
            Message("Gott schenkte Euch @color:255,232,30 "..resourceamount.." TALER!")
        end
        if resourcetypes == 2 then
            Tools.GiveResouces( playerID, 0, resourceamount, 0, 0, 0, 0 )
            Message("Ihr erhieltet eine göttliche Gabe mit @color:165,100,0 "..resourceamount.." LEHM!")
        end
        if resourcetypes == 3 then
            Tools.GiveResouces( playerID, 0, 0, resourceamount, 0, 0, 0 )
            Message("@color:105,70,20 "..resourceamount.." HOLZ! @color:255,255,255 Ein himmlisches Geschenk!")
        end
        if resourcetypes == 4 then
            Tools.GiveResouces( playerID, 0, 0, 0, resourceamount, 0, 0 )
            Message("Ihr wurdet mit @color:70,70,70 "..resourceamount.." STEIN @color:255,255,255 gesegnet!")
        end
        if resourcetypes == 5 then
            Tools.GiveResouces( playerID, 0, 0, 0, 0, resourceamount, 0 )
            Message("Halleluja! Ihr seid nun um @color:120,120,180 "..resourceamount.." EISEN @color:255,255,255 reicher!")
        end
        if resourcetypes == 6 then
            Tools.GiveResouces( playerID, 0, 0, 0, 0, 0, resourceamount )
            Message("@color:170,170,0 "..resourceamount.." SCHWEFEL @color:255,255,255 fielen vom Himmel!")
        end
    end
    Message("@color:0,0,0 ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~");
end
 
function Priests_Miracle2_Action( _priest )
    local pos = GetPosition( _priest );
    local treestumps = {Logic.GetEntitiesInArea( Entities.XD_TreeStump1, pos.X, pos.Y, 1500, 8 )};
    local animaltype = math.random(1,3);
    if animaltype == 1 then
        CreateEntity( 0, Entities.XA_Rabbit, pos );
    elseif animaltype == 2 then
        CreateEntity( 0, Entities.XA_Doe, pos );
    elseif animaltype == 3 then
        CreateEntity( 0, Entities.XA_Deer, pos );
    end
    Sound.PlayGUISound( Sounds.AmbientSounds_forest_daytime_rnd_1, 180 );
    Logic.CreateEffect( GGL_Effects.FXDarioFear, pos.X, pos.Y, 0 );
    for i = 2,treestumps[1]+1 do
        local randomtype = math.random(1,8);
        local treepos = GetPosition( treestumps[i] );
        Logic.CreateEffect( GGL_Effects.FXDieHero, treepos.X, treepos.Y, randomtype );
        Logic.CreateEffect( GGL_Effects.FXChopTreeDead, treepos.X, treepos.Y, 0 );
        -- WICHTIG: Die Baumtypen je nach Landschaft anpassen:
        if randomtype == 1 then
            ReplaceEntity( treestumps[i], Entities.XD_Tree1_small );
        elseif randomtype == 2 then
            ReplaceEntity( treestumps[i], Entities.XD_Tree1 );
        elseif randomtype == 3 then
            ReplaceEntity( treestumps[i], Entities.XD_Tree2_small );
        elseif randomtype == 4 then
            ReplaceEntity( treestumps[i], Entities.XD_Tree1 );
        elseif randomtype == 5 then
            ReplaceEntity( treestumps[i], Entities.XD_DarkTree1 );
        elseif randomtype == 6 then
            ReplaceEntity( treestumps[i], Entities.XD_DarkTree2 );
        elseif randomtype == 7 then
            ReplaceEntity( treestumps[i], Entities.XD_Fir2_small );
        elseif randomtype == 8 then
            ReplaceEntity( treestumps[i], Entities.XD_Fir1 );
        end
    end
end
 
function Priests_Miracle3_Action( _priest )
    local playerID = GetPlayer( _priest );
    local pos = GetPosition( _priest );
    Priests_Miracle3_Allies = {Logic.GetPlayerEntitiesInArea( playerID, 0, pos.X, pos.Y, 2000, 16 )};
    for i = 2, Priests_Miracle3_Allies[1] + 1 do
        local allypos = GetPosition( Priests_Miracle3_Allies[i] );
        if Logic.IsBuilding( Priests_Miracle3_Allies[i] ) == 1 then
            for i = 1,2 do
                Logic.CreateEffect( GGL_Effects.FXKalaPoison, allypos.X, allypos.Y, 0 );
            end
        else
            Logic.CreateEffect( GGL_Effects.FXSalimHeal, allypos.X, allypos.Y, 0 );
        end
        MakeInvulnerable( Priests_Miracle3_Allies[i] );
    end
    Priests_Miracle3_Counter = 20;
    StartSimpleJob("Priests_Miracle3_Job");
    Priests_Miracle3_IsRunning = true;
    for i = 1,table.getn(gvPriests) do
        gvPriests[i].miracle3Possible = false;
    end
    Logic.CreateEffect( GGL_Effects.FXDarioFear, pos.X, pos.Y, 0 );
    Sound.PlayGUISound( Sounds.VoicesHero6_HERO6_Bless_rnd_01, 0 );
    Sound.PlayGUISound( Sounds.OnKlick_PB_Outpost, 0 );
end
 
function Priests_Miracle3_Job()
    if Priests_Miracle3_Counter ==  0 then
        for i = 2, Priests_Miracle3_Allies[1] + 1 do
            MakeVulnerable( Priests_Miracle3_Allies[i] )
        end
        Priests_Miracle3_Counter = nil
        Priests_Miracle3_Allies = nil
        Priests_Miracle3_IsRunning = false
        return true
    else
        for i = 2, Priests_Miracle3_Allies[1] + 1 do
            local pos = GetPosition( Priests_Miracle3_Allies[i] )
            if Logic.IsBuilding( Priests_Miracle3_Allies[i] ) == 0 then
                for i = 1,2 do
                    Logic.CreateEffect( GGL_Effects.FXSalimHeal, pos.X, pos.Y, 0 );
                end
            end
        end
        Priests_Miracle3_Counter = Priests_Miracle3_Counter - 1;
    end
end
 
function Priests_Miracle4_Action( _priest )
    local pos = GetPosition( _priest );
    local claypits = {Logic.GetEntitiesInArea( Entities.XD_ClayPit1, pos.X, pos.Y, 1500, 2 )};
    for i = 2,claypits[1]+1 do
        local resources = Logic.GetResourceDoodadGoodAmount( claypits[i] );
        local randombonus = math.random(1,30);
        Logic.SetResourceDoodadGoodAmount( claypits[i], resources + round( resources/100*6 ) + randombonus );
        local targetpos = GetPosition( claypits[i] );
        for i = 1,2 do
            Logic.CreateEffect( GGL_Effects.FXCrushBuilding, targetpos.X, targetpos.Y, 0 );
            Logic.CreateEffect( GGL_Effects.FXExplosionShrapnel, targetpos.X, targetpos.Y, 0 );
        end
    end
    local stonepits = {Logic.GetEntitiesInArea( Entities.XD_StonePit1, pos.X, pos.Y, 1500, 2 )};
    for i = 2,stonepits[1]+1 do
        local resources = Logic.GetResourceDoodadGoodAmount( stonepits[i] );
        local randombonus = math.random(1,30);
        Logic.SetResourceDoodadGoodAmount( stonepits[i], resources + round( resources/100*6 ) + randombonus );
        local targetpos = GetPosition( stonepits[i] );
        for i = 1,2 do
            Logic.CreateEffect( GGL_Effects.FXCrushBuilding, targetpos.X, targetpos.Y, 0 );
            Logic.CreateEffect( GGL_Effects.FXExplosionShrapnel, targetpos.X, targetpos.Y, 0 );
        end
    end
    local ironpits = {Logic.GetEntitiesInArea( Entities.XD_IronPit1, pos.X, pos.Y, 1500, 2 )};
    for i = 2,ironpits[1]+1 do
        local resources = Logic.GetResourceDoodadGoodAmount( ironpits[i] );
        local randombonus = math.random(1,30);
        Logic.SetResourceDoodadGoodAmount( ironpits[i], resources + round( resources/100*6 ) + randombonus );
        local targetpos = GetPosition( ironpits[i] );
        for i = 1,2 do
            Logic.CreateEffect( GGL_Effects.FXCrushBuilding, targetpos.X, targetpos.Y, 0 );
            Logic.CreateEffect( GGL_Effects.FXExplosionShrapnel, targetpos.X, targetpos.Y, 0 );
        end
    end
    local sulfurpits = {Logic.GetEntitiesInArea( Entities.XD_SulfurPit1, pos.X, pos.Y, 1500, 2 )};
    for i = 2,sulfurpits[1]+1 do
        local resources = Logic.GetResourceDoodadGoodAmount( sulfurpits[i] );
        local randombonus = math.random(1,30);
        Logic.SetResourceDoodadGoodAmount( sulfurpits[i], resources + round( resources/100*6 ) + randombonus );
        local targetpos = GetPosition( sulfurpits[i] );
        for i = 1,2 do
            Logic.CreateEffect( GGL_Effects.FXCrushBuilding, targetpos.X, targetpos.Y, 0 );
            Logic.CreateEffect( GGL_Effects.FXExplosionShrapnel, targetpos.X, targetpos.Y, 0 );
        end
    end
    local clayheaps = {Logic.GetEntitiesInArea( Entities.XD_Clay1, pos.X, pos.Y, 1500, 5 )};
    for i = 2,clayheaps[1]+1 do
        local resources = Logic.GetResourceDoodadGoodAmount( clayheaps[i] );
        local randombonus = math.random(1,30);
        Logic.SetResourceDoodadGoodAmount( clayheaps[i], resources + round( resources/100*15 ) + randombonus );
        local targetpos = GetPosition( clayheaps[i] );
        Logic.CreateEffect( GGL_Effects.FXExplosionShrapnel, targetpos.X, targetpos.Y, 0 );
    end
    local stoneheaps = {Logic.GetEntitiesInArea( Entities.XD_Stone1, pos.X, pos.Y, 1500, 5 )};
    for i = 2,stoneheaps[1]+1 do
        local resources = Logic.GetResourceDoodadGoodAmount( stoneheaps[i] );
        local randombonus = math.random(1,30);
        Logic.SetResourceDoodadGoodAmount( stoneheaps[i], resources + round( resources/100*15 ) + randombonus );
        local targetpos = GetPosition( stoneheaps[i] );
        Logic.CreateEffect( GGL_Effects.FXExplosionShrapnel, targetpos.X, targetpos.Y, 0 );
    end
    local ironheaps = {Logic.GetEntitiesInArea( Entities.XD_Iron1, pos.X, pos.Y, 1500, 5 )};
    for i = 2,ironheaps[1]+1 do
        local resources = Logic.GetResourceDoodadGoodAmount( ironheaps[i] );
        local randombonus = math.random(1,30);
        Logic.SetResourceDoodadGoodAmount( ironheaps[i], resources + round( resources/100*15 ) + randombonus );
        local targetpos = GetPosition( ironheaps[i] );
        Logic.CreateEffect( GGL_Effects.FXExplosionShrapnel, targetpos.X, targetpos.Y, 0 );
    end
    local sulfurheaps = {Logic.GetEntitiesInArea( Entities.XD_Sulfur1, pos.X, pos.Y, 1500, 5 )};
    for i = 2,sulfurheaps[1]+1 do
        local resources = Logic.GetResourceDoodadGoodAmount( sulfurheaps[i] );
        local randombonus = math.random(1,30);
        Logic.SetResourceDoodadGoodAmount( sulfurheaps[i], resources + round( resources/100*15 ) + randombonus );
        local targetpos = GetPosition( sulfurheaps[i] );
        Logic.CreateEffect( GGL_Effects.FXExplosionShrapnel, targetpos.X, targetpos.Y, 0 );
    end
    Logic.CreateEffect( GGL_Effects.FXDarioFear, pos.X, pos.Y, 0 );
    Sound.PlayGUISound( Sounds.OnKlick_PB_SulfurMine3, 80 );
    Sound.PlayGUISound( Sounds.OnKlick_PB_StoneMine3, 80 );
    Sound.PlayGUISound( Sounds.OnKlick_PB_ClayMine3, 80 );
end
 
function Priests_Miracle5_Action( _priest )
    local playerID = GetPlayer( _priest );
    local pos = GetPosition( _priest );
    for i = 1,8 do
        if Logic.GetDiplomacyState( playerID, i ) == Diplomacy.Hostile then
            local enemies = {Logic.GetPlayerEntitiesInArea( i, 0, pos.X, pos.Y, 1200, 15 )};
            for j = 2, enemies[1] + 1 do
                if ( Logic.IsLeader( enemies[j] ) == 1 ) or ( Logic.IsSerf( enemies[j] ) == 1 ) then
                    ChangePlayer( enemies[j], playerID );
                else
                    local leader = Logic.SoldierGetLeaderEntityID( enemies[j] );
                    if Logic.IsLeader( leader ) == 1 then
                        ChangePlayer( leader, playerID );
                    end
                end
            end
        end
    end
    Logic.CreateEffect( GGL_Effects.FXDarioFear, pos.X, pos.Y, 0 );
    Sound.PlayGUISound( Sounds.VoicesHero6_HERO6_ConvertSettler_rnd_01, 0 );
    Sound.PlayGUISound( Sounds.OnKlick_Select_ari, 0 );
end
 
function Priests_AddMana( _level, _amount )
    assert( type( _level ) == "number" );
    assert( type( _amount ) == "number" );
    if gvMana then
        if _level == 1 then
            gvMana.mana_1 = gvMana.mana_1 + _amount;
            return gvMana.mana_1;
        elseif _level == 2 then
            gvMana.mana_2 = gvMana.mana_2 + _amount;
            return gvMana.mana_2;
        elseif _level == 3 then
            gvMana.mana_3 = gvMana.mana_3 + _amount;
            return gvMana.mana_3;
        elseif _level == 4 then
            gvMana.mana_4 = gvMana.mana_4 + _amount;
            return gvMana.mana_4;
        elseif _level == 5 then
            gvMana.mana_5 = gvMana.mana_5 + _amount;
            return gvMana.mana_5;
        end
    else
        Message("@color:255,0,0 ERROR! @color:255,255,255 Attempt to add Mana without init Mana-Production!");
    end
end
 
function Priests_SetMiracleCosts( _level, _amount )
    assert( type( _level ) == "number" );
    assert( type( _amount ) == "number" );
    if gvMana then
        if _level == 1 then
            gvMana.mana_1_costs = _amount;
            return gvMana.mana_1_costs;
        elseif _level == 2 then
            gvMana.mana_2_costs = _amount;
            return gvMana.mana_2_costs;
        elseif _level == 3 then
            gvMana.mana_3_costs = _amount;
            return gvMana.mana_3_costs;
        elseif _level == 4 then
            gvMana.mana_4_costs = _amount;
            return gvMana.mana_4_costs;
        elseif _level == 5 then
            gvMana.mana_5_costs = _amount;
            return gvMana.mana_5_costs;
        end
    else
        Message("@color:255,0,0 ERROR! @color:255,255,255 Attempt to change miracle-costs without init Mana-Production!");
    end
end

Schamanencode

----------------------------------------------------------------------------------------------
-- SCHAMANENFUNKTIONEN
----------------------------------------------------------------------------------------------
 
function Shamans_SetupGaiaProduction()
    GUIAction_ChangeWeatherOrig = GUIAction_ChangeWeather;
    gvGaia = {
        gaia_1 = 0,
        gaia_1_costs = 120,  -- Die Kosten müssen jeweils noch angepasst werden.
        gaia_2 = 0,
        gaia_2_costs = 180,
        gaia_3 = 0,
        gaia_3_costs = 240,
        gaia_4 = 0,
        gaia_4_costs = 280,
        gaia_5 = 0,
        gaia_5_costs = 420,
    }
    GUIAction_ChangeWeather = function( _count )
        local energy = Logic.GetPlayersGlobalResource( 1, ResourceType.WeatherEnergy )
        if energy >= 1000 then
            local addGaia = true;
            StartDelayFunc( Shamans_BugfixDelay, _count, addGaia )
        else
            local addGaia = false;
            StartDelayFunc( Shamans_BugfixDelay, _count, addGaia )
        end
    end
end
 
function Shamans_BugfixDelay( _count, _addGaia )
    local GUIAction_ChangeWeatherOrig_BugfixDelay = GUIAction_ChangeWeather;
    GUIAction_ChangeWeather = function() end;
    if _count == 1 then
        GUIAction_ChangeWeatherOrig(1,1)
        DelayShort(1);
        if _addGaia == true then
            gvGaia.gaia_1 = gvGaia.gaia_1 + 100
            gvGaia.gaia_2 = gvGaia.gaia_2 + 100
            Message("@color:0,130,0 Gaia Lv1: "..gvGaia.gaia_1);
            Message("@color:180,130,0 Gaia Lv2: "..gvGaia.gaia_2);
            Sound.PlayGUISound(Sounds.OnKlick_PB_WeatherTower1, 0);
            Sound.PlayGUISound(Sounds.Military_SO_CannonTowerFire_rnd_1, 0);
        end
    elseif _count == 2 then
        GUIAction_ChangeWeatherOrig(2,1)
        DelayShort(1);
        if _addGaia == true then
            gvGaia.gaia_3 = gvGaia.gaia_3 + 100
            gvGaia.gaia_4 = gvGaia.gaia_4 + 100
            Message("@color:180,0,0 Gaia Lv3: "..gvGaia.gaia_3);
            Message("@color:105,70,20 Gaia Lv4: "..gvGaia.gaia_4);
            Sound.PlayGUISound(Sounds.OnKlick_PB_PowerPlant1, 0);
            Sound.PlayGUISound(Sounds.Military_SO_Cannon_rnd_1, 0);
        end
    elseif _count == 3 then
        GUIAction_ChangeWeatherOrig(3,1)
        DelayShort(1);
        if _addGaia == true then
            gvGaia.gaia_5 = gvGaia.gaia_5 + 150
            Message("@color:80,80,80 Gaia Lv5: "..gvGaia.gaia_5);
            Sound.PlayGUISound(Sounds.Military_SO_CannonHit_rnd_1, 160);
            Sound.PlayGUISound(Sounds.Buildings_SO_Weathermachine1, 0);
        end
    end
    GUIAction_ChangeWeather = GUIAction_ChangeWeatherOrig_BugfixDelay;
end
 
function CreateShaman( _name )
    assert( type( _name ) == "string" )
    gvShamans = gvShamans or {
        ShamanJobID = StartSimpleHiResJob( "Shamans_ControlShamans" ),
        Shamans_InitShamanTooltips(),
        Shamans_InitShamanButtons(),
        Shamans_InitShamanOnlineHelpButton(),
    }
    local shaman = {
        name = _name,
        curse1Possible = false,
        curse2Possible = false,
        curse3Possible = false,
        curse4Possible = false,
        curse5Possible = false,
    }
    table.insert( gvShamans, shaman )
end
 
function Shamans_ControlShamans()
    for i = 1,table.getn( gvShamans ) do
        if not IsExisting( gvShamans[i].name ) then
            DestroyShaman( gvShamans[i].name )
        else
            if gvGaia.gaia_1 >= gvGaia.gaia_1_costs and not gvShamans[i].curse1Possible and GUI.GetSelectedEntity() == GetEntityId( gvShamans[i].name) then
                gvShamans[i].curse1Possible = true
                GameCallback_GUI_SelectionChanged()
            elseif gvGaia.gaia_1 >= gvGaia.gaia_1_costs and not gvShamans[i].curse1Possible then
                gvShamans[i].curse1Possible = true
            elseif gvGaia.gaia_1 < gvGaia.gaia_1_costs and gvShamans[i].curse1Possible == true then
                gvShamans[i].curse1Possible = false
                GameCallback_GUI_SelectionChanged()
            end
            if gvGaia.gaia_2 >= gvGaia.gaia_2_costs and not gvShamans[i].curse2Possible and GUI.GetSelectedEntity() == GetEntityId( gvShamans[i].name) then
                gvShamans[i].curse2Possible = true
                GameCallback_GUI_SelectionChanged()
            elseif gvGaia.gaia_2 >= gvGaia.gaia_2_costs and not gvShamans[i].curse2Possible then
                gvShamans[i].curse2Possible = true
            elseif gvGaia.gaia_2 < gvGaia.gaia_2_costs and gvShamans[i].curse2Possible == true then
                gvShamans[i].curse2Possible = false
                GameCallback_GUI_SelectionChanged()
            end
            if gvGaia.gaia_3 >= gvGaia.gaia_3_costs and not gvShamans[i].curse3Possible and GUI.GetSelectedEntity() == GetEntityId( gvShamans[i].name) then
                gvShamans[i].curse3Possible = true
                GameCallback_GUI_SelectionChanged()
            elseif gvGaia.gaia_3 >= gvGaia.gaia_3_costs and not gvShamans[i].curse3Possible then
                gvShamans[i].curse3Possible = true
            elseif gvGaia.gaia_3 < gvGaia.gaia_3_costs and gvShamans[i].curse3Possible == true then
                gvShamans[i].curse3Possible = false
                GameCallback_GUI_SelectionChanged()
            end
            if gvGaia.gaia_4 >= gvGaia.gaia_4_costs and not gvShamans[i].curse4Possible and GUI.GetSelectedEntity() == GetEntityId( gvShamans[i].name) then
                gvShamans[i].curse4Possible = true
                GameCallback_GUI_SelectionChanged()
            elseif gvGaia.gaia_4 >= gvGaia.gaia_4_costs and not gvShamans[i].curse4Possible then
                gvShamans[i].curse4Possible = true
            elseif gvGaia.gaia_4 < gvGaia.gaia_4_costs and gvShamans[i].curse4Possible == true then
                gvShamans[i].curse4Possible = false
                GameCallback_GUI_SelectionChanged()
            end
            if gvGaia.gaia_5 >= gvGaia.gaia_5_costs and not gvShamans[i].curse5Possible and GUI.GetSelectedEntity() == GetEntityId( gvShamans[i].name) then
                gvShamans[i].curse5Possible = true
                GameCallback_GUI_SelectionChanged()
            elseif gvGaia.gaia_5 >= gvGaia.gaia_5_costs and not gvShamans[i].curse5Possible then
                gvShamans[i].curse5Possible = true
            elseif gvGaia.gaia_5 < gvGaia.gaia_5_costs and gvShamans[i].curse5Possible == true then
                gvShamans[i].curse5Possible = false
                GameCallback_GUI_SelectionChanged()
            end
        end
    end
end
 
function Shamans_InitShamanTooltips()
    GUITooltip_NormalButtonOrig_Shamans = GUITooltip_NormalButton;
    GUITooltip_NormalButton = function( a, b )
        GUITooltip_NormalButtonOrig_Shamans( a, b );
        if IsShaman( GUI.GetSelectedEntity() ) then
            local newString, numberOfChanges = string.gsub( a, "MenuCommandsGeneric/", "" );
            if numberOfChanges == 1 then
                if newString == "command_attack" then
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:180,0,0 Höllenbrut @cr @color:150,150,150 Wetterwechsel: @color:255,255,255 \"Regen\" @cr @color:150,150,150 Effekt: @color:255,255,255 Eine Horde Dämonen fährt aus den Abgründen der Hölle empor, um Euch im Kampfe zu unterstützen." );
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "Gaia: "..gvGaia.gaia_3_costs );
                elseif newString == "command_stand" then
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:180,130,0 2. Fluch @cr @color:150,150,150 Wetterwechsel: @color:255,255,255 \"Sommer\" @cr @color:150,150,150 Effekt: @color:255,255,255 Beschreibung des Effektes." );
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "Gaia: "..gvGaia.gaia_2_costs );
                elseif newString == "command_defend" then
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:0,130,0 1. Fluch @cr @color:150,150,150 Wetterwechsel: @color:255,255,255 \"Sommer\" @cr @color:150,150,150 Effekt: @color:255,255,255 Beschreibung des Effektes." );
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "Gaia: "..gvGaia.gaia_1_costs );
                elseif newString == "command_patrol" then
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:105,70,20 4. Fluch @cr @color:150,150,150 Wetterwechsel: @color:255,255,255 \"Regen\" @cr @color:150,150,150 Effekt: @color:255,255,255 Beschreibung des Effektes." );
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "Gaia: "..gvGaia.gaia_4_costs );
                elseif newString == "command_guard" then
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomText, "@color:80,80,80 Dunkle Apokalypse @cr @color:150,150,150 Wetterwechsel: @color:255,255,255 \"Winter\" @cr @color:150,150,150 Effekt: @color:255,255,255 Ein Blitzschlag tötet jeden Feind und beschädigt jedes feindliche Gebäude in der Nähe des Schamanen." );
                    XGUIEng.SetText( gvGUI_WidgetID.TooltipBottomCosts, "Gaia: "..gvGaia.gaia_5_costs );
                end
            end
        end
    end
end
 
function Shamans_InitShamanButtons()
    GUIUpdate_CommandGroupOrig_Shamans = GUIUpdate_CommandGroup;
    GameCallback_GUI_SelectionChangedOrig_Shamans = GameCallback_GUI_SelectionChanged;
    GUIAction_CommandOrig_Shamans = GUIAction_Command;
    GUIUpdate_CommandGroup = function()
        GUIUpdate_CommandGroupOrig_Shamans();
        for i = 1,table.getn( gvShamans ) do
            if GUI.GetSelectedEntity() == GetEntityId( gvShamans[i].name ) then
                XGUIEng.HighLightButton( gvGUI_WidgetID.CommandDefend, 0 );
            end
        end
    end
    GameCallback_GUI_SelectionChanged = function()
        if IsShaman( GUI.GetSelectedEntity() ) then
            local shaman = GUI.GetSelectedEntity()
            local shamannumber
            for i = 1,table.getn( gvShamans ) do
                if shaman == GetEntityId( gvShamans[i].name ) then
                    shamannumber = i
                end
            end
            GameCallback_GUI_SelectionChangedOrig_Shamans()
            if gvShamans[shamannumber].curse1Possible == true then
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandDefend, 0)
            else  -- Wenn nicht genug Gaia vorhanden ist...
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandDefend, 1)
            end
            if gvShamans[shamannumber].curse2Possible == true then
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandStand, 0)
            else
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandStand, 1)
            end
            if gvShamans[shamannumber].curse3Possible == true then
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandAttack, 0)
            else
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandAttack, 1)
            end
            if gvShamans[shamannumber].curse4Possible == true then
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandPatrol, 0)
            else
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandPatrol, 1)
            end
            if gvShamans[shamannumber].curse5Possible == true then
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandGuard, 0)
            else
                XGUIEng.DisableButton(gvGUI_WidgetID.CommandGuard, 1)
            end
            GUIAction_Command = function( _count )
                if _count == 3 then  -- Wurde der Defend-Button gedrückt...
                    if GUI.GetSelectedEntity() == GetEntityId( shaman ) then
                        -- ... wird der erste Fluch ausgelöst!
                        Shamans_Curse1_Action( shaman )
                        gvShamans[shamannumber].curse1Possible = false
                        gvGaia.gaia_1 = gvGaia.gaia_1 - gvGaia.gaia_1_costs
                        local inflation = gvGaia.gaia_1_costs * 1.06
                        gvGaia.gaia_1_costs = round(inflation)
                        GameCallback_GUI_SelectionChanged()
                    else
                        GUIAction_CommandOrig_Shamans(3);
                    end
                end
                if _count == 2 then  -- Wurde der Stand-Button gedrückt...
                    if GUI.GetSelectedEntity() == GetEntityId( shaman ) then
                        -- ... wird der zweite Fluch ausgelöst!
                        Shamans_Curse2_Action( shaman )
                        gvShamans[shamannumber].curse2Possible = false
                        gvGaia.gaia_2 = gvGaia.gaia_2 - gvGaia.gaia_2_costs
                        local inflation = gvGaia.gaia_2_costs * 1.06
                        gvGaia.gaia_2_costs = round(inflation)
                        GameCallback_GUI_SelectionChanged()
                    else
                        GUIAction_CommandOrig_Shamans(2);
                    end
                end
                if _count == 1 then  -- Wurde der Attack-Button gedrückt...
                    if GUI.GetSelectedEntity() == GetEntityId( shaman ) then
                        -- ... wird der dritte Fluch ausgelöst!
                        Shamans_Curse3_Action( shaman )
                        gvShamans[shamannumber].curse3Possible = false
                        gvGaia.gaia_3 = gvGaia.gaia_3 - gvGaia.gaia_3_costs
                        local inflation = gvGaia.gaia_3_costs * 1.05
                        gvGaia.gaia_3_costs = round(inflation)
                        GameCallback_GUI_SelectionChanged()
                    else
                        GUIAction_CommandOrig_Shamans(1);
                    end
                end
                if _count == 4 then  -- Wurde der Patrol-Button gedrückt...
                    if GUI.GetSelectedEntity() == GetEntityId( shaman ) then
                        -- ... wird der vierte Fluch ausgelöst!
                        Shamans_Curse4_Action( shaman )
                        gvShamans[shamannumber].curse4Possible = false
                        gvGaia.gaia_4 = gvGaia.gaia_4 - gvGaia.gaia_4_costs
                        local inflation = gvGaia.gaia_4_costs * 1.05
                        gvGaia.gaia_4_costs = round(inflation)
                        GameCallback_GUI_SelectionChanged()
                    else
                        GUIAction_CommandOrig_Shamans(4);
                    end
                end
                if _count == 5 then  -- Wurde der Guard-Button gedrückt...
                    if GUI.GetSelectedEntity() == GetEntityId( shaman ) then
                        -- ... wird der fünfte Fluch ausgelöst!
                        Shamans_Curse5_Action( shaman )
                        gvShamans[shamannumber].curse5Possible = false
                        gvGaia.gaia_5 = gvGaia.gaia_5 - gvGaia.gaia_5_costs
                        local inflation = gvGaia.gaia_5_costs * 1.04
                        gvGaia.gaia_5_costs = round(inflation)
                        GameCallback_GUI_SelectionChanged()
                    else
                        GUIAction_CommandOrig_Shamans(5);
                    end
                end
            end
        else  -- Wenn die selektierte Entität kein Schamane ist...
            XGUIEng.DisableButton(gvGUI_WidgetID.CommandDefend, 0)
            XGUIEng.DisableButton(gvGUI_WidgetID.CommandPatrol, 0)
            XGUIEng.DisableButton(gvGUI_WidgetID.CommandAttack, 0)
            XGUIEng.DisableButton(gvGUI_WidgetID.CommandGuard, 0)
            XGUIEng.DisableButton(gvGUI_WidgetID.CommandStand, 0)
            GameCallback_GUI_SelectionChangedOrig_Shamans();
        end
    end
end
 
function Shamans_InitShamanOnlineHelpButton()
    GUIAction_OnlineHelpOrig_Shamans = GUIAction_OnlineHelp;
    GUIAction_OnlineHelp = function()
        if IsShaman( GUI.GetSelectedEntity() ) then
            Message("@color:0,0,0 --------------------");
            Message("@color:0,130,0 Gaia Lv1: "..gvGaia.gaia_1);
            Message("@color:180,130,0 Gaia Lv2: "..gvGaia.gaia_2);
            Message("@color:180,0,0 Gaia Lv3: "..gvGaia.gaia_3);
            Message("@color:105,70,20 Gaia Lv4: "..gvGaia.gaia_4);
            Message("@color:80,80,80 Gaia Lv5: "..gvGaia.gaia_5);
            Message("@color:0,0,0 --------------------");
            return true
        else
            GUIAction_OnlineHelpOrig_Shamans();
        end
    end
end
 
function IsShaman( _entity )
    if type( _entity ) == "string" then
        for i = 1,table.getn( gvShamans ) do
            if gvShamans[i].name == _entity then
                return true
            end
        end
    elseif type( _entity ) == "number" then
        for i = 1,table.getn( gvShamans ) do
            if GetEntityId( gvShamans[i].name ) == _entity then
                return true
            end
        end
    end
end
 
function DestroyShaman( _name )
    for i = 1,table.getn( gvShamans ) do
        if gvShamans[i].name == _name then
            table.remove( gvShamans, i )
            return true
        end
    end
end
 
function Shamans_Curse1_Action( _shaman )
    local playerID = GetPlayer( _shaman )
    local pos = GetPosition( _shaman )
    Shamans_Curse1_Traps = Shamans_Curse1_Traps or {
        Shamans_Curse1_JobID = StartSimpleJob( "Shamans_Curse1_ControlTraps" ),
    }
    Shamans_Curse1_Traps_Counter = Shamans_Curse1_Traps_Counter or 0
    Shamans_Curse1_Traps_Counter = Shamans_Curse1_Traps_Counter+1
    CreateEntity( playerID, Entities.XD_ScriptEntity, pos, "Shamans_Curse1_Trap_"..Shamans_Curse1_Traps_Counter )
    CreateEntity( 0, Entities.XD_BoneHuman1, pos )
    local trap = GetEntityId( "Shamans_Curse1_Trap_"..Shamans_Curse1_Traps_Counter )
    table.insert( Shamans_Curse1_Traps, trap )
    Message( "Shamans_Curse1_Trap_"..Shamans_Curse1_Traps_Counter )
end
 
function Shamans_Curse1_ControlTraps()
    for i = 1,table.getn( Shamans_Curse1_Traps ) do
        local trap = Shamans_Curse1_Traps[i]
        local playerID = GetPlayer( trap )
        local position = GetPosition( trap )
        if AreEnemiesInArea( playerID, position, 1000 ) then
            Message( trap.." wurde ausgelöst!")
            for j = 1,8 do
                if Logic.GetDiplomacyState( playerID, j ) == Diplomacy.Hostile then
                    local targets = {Logic.GetPlayerEntitiesInArea( j, 0, position.X, position.Y, 2000, 8 )}
                    for k = 2, targets[1] + 1 do
                        local animaltype = math.random(1,5)
                        if animaltype == 1 then
                            ReplaceEntity( targets[k], Entities.XA_Rabbit )
                        elseif animaltype == 2 then
                            ReplaceEntity( targets[k], Entities.XA_Doe )
                        elseif animaltype == 3 then
                            ReplaceEntity( targets[k], Entities.XA_Deer )
                        elseif animaltype == 4 then
                            ReplaceEntity( targets[k], Entities.XA_SheepDog )
                        elseif animaltype == 5 then
                            ReplaceEntity( targets[k], Entities.XA_Wolf )
                        end
                    end
                end
            end
            table.remove( Shamans_Curse1_Traps, i )
            DestroyEntity( trap )
            Message( trap.." existiert nicht mehr!")
        end
    end
end
 
function Shamans_Curse2_Action( _shaman )
    local playerID = GetPlayer( _shaman )
    local pos = GetPosition( _shaman )
    local rabbits = {Logic.GetEntitiesInArea( Entities.XA_Rabbit, pos.X, pos.Y, 2000, 3 )}
    for i = 2,rabbits[1]+1 do
        local rabbitpos = GetPosition( rabbits[i] )
        Logic.CreateEffect( GGL_Effects.FXDie, rabbitpos.X, rabbitpos.Y, 0 );
        Logic.CreateEffect( GGL_Effects.FXDestroyTree, rabbitpos.X, rabbitpos.Y, 0 );
        ReplaceEntity( rabbits[i], Entities.PU_Serf )
        ChangePlayer( rabbits[i], playerID )
        if i == 2 then
            Sound.PlayGUISound( Sounds.VoicesSerf_SERF_Yes_rnd_01, 0 )
        end
    end
    local does = {Logic.GetEntitiesInArea( Entities.XA_Doe, pos.X, pos.Y, 2000, 3 )}
    for i = 2,does[1]+1 do
        local doepos = GetPosition( does[i] )
        Logic.CreateEffect( GGL_Effects.FXDie, doepos.X, doepos.Y, 0 );
        Logic.CreateEffect( GGL_Effects.FXDestroyTree, doepos.X, doepos.Y, 0 );
        ReplaceEntity( does[i], Entities.PU_Scout )
        ChangePlayer( does[i], playerID )
        if i == 2 then
            Sound.PlayGUISound( Sounds.AOVoicesScout_Scout_Yes_rnd_01, 0 )
        end
    end
    local deers = {Logic.GetEntitiesInArea( Entities.XA_Deer, pos.X, pos.Y, 2000, 3 )}
    for i = 2,deers[1]+1 do
        local deerpos = GetPosition( deers[i] )
        Logic.CreateEffect( GGL_Effects.FXDie, deerpos.X, deerpos.Y, 0 );
        Logic.CreateEffect( GGL_Effects.FXDestroyTree, deerpos.X, deerpos.Y, 0 );
        ReplaceEntity( deers[i], Entities.PU_Thief )
        ChangePlayer( deers[i], playerID )
        if i == 2 then
            Sound.PlayGUISound( Sounds.AOVoicesThief_Thief_Yes_rnd_01, 0 )
        end
    end
    local dogs = {Logic.GetEntitiesInArea( Entities.XA_SheepDog, pos.X, pos.Y, 2000, 3 )}
    for i = 2,dogs[1]+1 do
        local dogpos = GetPosition( dogs[i] )
        Logic.CreateEffect( GGL_Effects.FXDie, dogpos.X, dogpos.Y, 0 );
        Logic.CreateEffect( GGL_Effects.FXDestroyTree, dogpos.X, dogpos.Y, 0 );
        ReplaceEntity( dogs[i], Entities.PU_LeaderCavalry2 )
        ChangePlayer( dogs[i], playerID )
        if i == 2 then
            Sound.PlayGUISound( Sounds.VoicesLeader_LEADER_Yes_rnd_01, 0 )
        end
    end
    local wolves = {Logic.GetEntitiesInArea( Entities.XA_Wolf, pos.X, pos.Y, 2000, 3 )}
    for i = 2,wolves[1]+1 do
        local wolfpos = GetPosition( wolves[i] )
        Logic.CreateEffect( GGL_Effects.FXDie, wolfpos.X, wolfpos.Y, 0 );
        Logic.CreateEffect( GGL_Effects.FXDestroyTree, wolfpos.X, wolfpos.Y, 0 );
        ReplaceEntity( wolves[i], Entities.PU_LeaderHeavyCavalry1 )
        ChangePlayer( wolves[i], playerID )
        if i == 2 then
            Sound.PlayGUISound( Sounds.VoicesLeader_LEADER_Yes_rnd_01, 0 )
        end
    end
    Logic.CreateEffect( GGL_Effects.FXKerberosFear, pos.X, pos.Y, 0 );
end
 
function Shamans_Curse3_Action( _shaman )
    local playerID = GetPlayer( _shaman )
    local pos = GetPosition( _shaman )
    CreateMilitaryGroup( playerID, Entities.CU_Evil_LeaderSkirmisher1, 7, pos )
    CreateMilitaryGroup( playerID, Entities.CU_Evil_LeaderBearman1, 13, pos )
    Logic.CreateEffect( GGL_Effects.FXKerberosFear, pos.X, pos.Y, 0 )
    for i = 1,2 do
        Logic.CreateEffect( GGL_Effects.FXMaryPoison, pos.X, pos.Y, 0 )
    end
    Sound.PlayGUISound( Sounds.OnKlick_Select_kerberos, 0 )
    Sound.PlayGUISound( Sounds.AmbientSounds_Nephilim_rnd_1, 0 )
end
 
function Shamans_Curse4_Action( _shaman )
end
 
function Shamans_Curse5_Action( _shaman )
    local playerID = GetPlayer( _shaman )
    local pos = GetPosition( _shaman )
    for i = 1,8 do
        if Logic.GetDiplomacyState( playerID, i ) == Diplomacy.Hostile then
            local enemies = {Logic.GetPlayerEntitiesInArea( i, 0, pos.X, pos.Y, 2500, 60 )}
            for i = 2, enemies[1] + 1 do
                if Logic.IsBuilding( enemies[i] ) == 1 then
                    local enemybuildingpos = GetPosition( enemies[i] )
                    Logic.HurtEntity( enemies[i], 800 )
                    Logic.CreateEffect( GGL_Effects.FXLightning, enemybuildingpos.X, enemybuildingpos.Y, 0 )
                    Logic.CreateEffect( GGL_Effects.FXExplosion, enemybuildingpos.X, enemybuildingpos.Y, 0 )
                elseif Logic.IsLeader( enemies[i] ) == 1 then
                    local soldiers = {Logic.GetSoldiersAttachedToLeader( enemies[i] )}
                    for j = 2, soldiers[1] + 1 do
                        local soldierspos = GetPosition( soldiers[j] )
                        Logic.CreateEffect( GGL_Effects.FXLightning, soldierspos.X, soldierspos.Y, 0 )
                        SetHealth( soldiers[j], 0 )
                    end
                elseif Logic.IsSerf( enemies[i] ) == 1 then
                    local enemyserfpos = GetPosition( enemies[i] )
                    Logic.CreateEffect( GGL_Effects.FXLightning, enemyserfpos.X, enemyserfpos.Y, 0 )
                    SetHealth( enemies[i], 0 )
                end
            end
        end
    end
    Logic.CreateEffect( GGL_Effects.FXMaryDemoralize, pos.X, pos.Y, 0 )
    Sound.PlayGUISound( Sounds.Military_SO_BallistaFire_rnd_1, 0 )
    Sound.PlayGUISound( Sounds.Military_SO_CannonTowerFire_rnd_1, 0 )
    Sound.PlayGUISound( Sounds.OnKlick_PB_WeatherTower1, 0 )
end
 
function Shamans_AddGaia_Lv1( _amount )
    assert( type( _amount ) == "number" )
    if gvGaia ~= nil then
        gvGaia.gaia_1 = gvGaia.gaia_1 + _amount;
        return true;
    else
        Message("@color:255,0,0 ERROR! @color:255,255,255 Attempt to add Gaia without init Gaia-Production!");
    end
end
 
function Shamans_AddGaia_Lv2( _amount )
    assert( type( _amount ) == "number" )
    if gvGaia ~= nil then
        gvGaia.gaia_2 = gvGaia.gaia_2 + _amount;
        return true;
    else
        Message("@color:255,0,0 ERROR! @color:255,255,255 Attempt to add Gaia without init Gaia-Production!");
    end
end
 
function Shamans_AddGaia_Lv3( _amount )
    assert( type( _amount ) == "number" )
    if gvGaia ~= nil then
        gvGaia.gaia_3 = gvGaia.gaia_3 + _amount;
        return true;
    else
        Message("@color:255,0,0 ERROR! @color:255,255,255 Attempt to add Gaia without init Gaia-Production!");
    end
end
 
function Shamans_AddGaia_Lv4( _amount )
    assert( type( _amount ) == "number" )
    if gvGaia ~= nil then
        gvGaia.gaia_4 = gvGaia.gaia_4 + _amount;
        return true;
    else
        Message("@color:255,0,0 ERROR! @color:255,255,255 Attempt to add Gaia without init Gaia-Production!");
    end
end
 
function Shamans_AddGaia_Lv5( _amount )
    assert( type( _amount ) == "number" )
    if gvGaia ~= nil then
        gvGaia.gaia_5 = gvGaia.gaia_5 + _amount;
        return true;
    else
        Message("@color:255,0,0 ERROR! @color:255,255,255 Attempt to add Gaia without init Gaia-Production!");
    end
end
 
function Shamans_SetCurseCosts_Lv1( _amount )
    assert( type( _amount ) == "number" )
    if gvGaia ~= nil then
        gvGaia.gaia_1_costs = _amount;
        return true;
    else
        Message("@color:255,0,0 ERROR! @color:255,255,255 Attempt to change curse-costs without init Gaia-Production!");
    end
end
 
function Shamans_SetCurseCosts_Lv2( _amount )
    assert( type( _amount ) == "number" )
    if gvGaia ~= nil then
        gvGaia.gaia_2_costs = _amount;
        return true;
    else
        Message("@color:255,0,0 ERROR! @color:255,255,255 Attempt to change curse-costs without init Gaia-Production!");
    end
end
 
function Shamans_SetCurseCosts_Lv3( _amount )
    assert( type( _amount ) == "number" )
    if gvGaia ~= nil then
        gvGaia.gaia_3_costs = _amount;
        return true;
    else
        Message("@color:255,0,0 ERROR! @color:255,255,255 Attempt to change curse-costs without init Gaia-Production!");
    end
end
 
function Shamans_SetCurseCosts_Lv4( _amount )
    assert( type( _amount ) == "number" )
    if gvGaia ~= nil then
        gvGaia.gaia_4_costs = _amount;
        return true;
    else
        Message("@color:255,0,0 ERROR! @color:255,255,255 Attempt to change curse-costs without init Gaia-Production!");
    end
end
 
function Shamans_SetCurseCosts_Lv5( _amount )
    assert( type( _amount ) == "number" )
    if gvGaia ~= nil then
        gvGaia.gaia_5_costs = _amount;
        return true;
    else
        Message("@color:255,0,0 ERROR! @color:255,255,255 Attempt to change curse-costs without init Gaia-Production!");
    end
end

Benötigte Comfort-Funktionen

Das Priester- und Schamanenskript verwendet die folgenden Comfort-Funktionen.
Sie müssen mindestens einmal in Eurem Mapskript vorhanden sein.

--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
----------------------------------------------------------------------------------------------
-- ZUSATZFUNKTIONEN
----------------------------------------------------------------------------------------------
 
function round( _n )
    return math.floor( _n + 0.5 );
end
 
CxTools = CxTools or {};
function unpack2(_table, _i)
	_i = _i or 1;
	assert(type(_table) == "table");
	if _i <= table.getn(_table) then
		return _table[_i], unpack2(_table, _i + 1);
	end
end
 
if not unpack( { true } ) then
    unpack = unpack2;
end
 
CxTools.tDelayFuncs = CxTools.tDelayFuncs or {};
CxTools.tDelayFuncsJob = false;
 
function CxTools:StartDelayFunc( _func, ... )
    assert( type(_func) == "function" );
    local thread = coroutine.create( _func );
    local fThread =
        function()
            local tRes = { coroutine.resume( thread, unpack( arg ) ) };
            local res = table.remove( tRes, 1 );
            if not res then
                if self.tDelayFuncsJob then EndJob( self.tDelayFuncsJob ); end
                assert( false, "DelayFunc error: " .. (retval or "unknown") );
            end
            local retval = table.remove( tRes, 1 );
            if type( retval ) == "function" then
                retval( unpack( tRes ) );
                retval = nil;
            end
            if not retval then
                return false;
            end
            assert( type( retval ) == "number" );
            assert( math.floor( retval ) == retval );
            assert( retval ~= 0 );
            return true, retval;
        end
    local status, retval = fThread();
    if status then
        local entry = {};
        entry.func = fThread;
        entry.nextTime = Logic.GetCurrentTurn() + retval;
        table.insert( self.tDelayFuncs, entry );
        if not self.tDelayFuncsJob then
            self.tDelayFuncsJob = StartSimpleHiResJob( "DelayFuncsJob" );
            XGUIEng.ShowWidget( gvGUI_WidgetID.MainMenuWindow_SaveGame, 0 );
            QuickSave = function() Message( "@color:255,0,0 CxTools:DelayFuncs @cr @color:200,200,200 Das Spiel kann momentan nicht gespeichert werden!" ); end
        end
    end
end
 
function CxTools:DelayFuncsJob()
    assert( self.tDelayFuncsJob );
    local jobcount = table.getn( self.tDelayFuncs );
    if jobcount == 0 then
        self.tDelayFuncsJob = false;
        XGUIEng.ShowWidget( gvGUI_WidgetID.MainMenuWindow_SaveGame, 1 );
        QuickSave = QuickSaveOrig;
 
        return true;
    end
    local currentTurn = Logic.GetCurrentTurn();
    for i = jobcount, 1, -1 do
        local entry = self.tDelayFuncs[i];
        assert( currentTurn <= entry.nextTime );
        if entry.nextTime == currentTurn then
            local status, retval = entry.func();
            if status then
                entry.nextTime = currentTurn + retval;
            else
                table.remove( self.tDelayFuncs, i );
            end
        end
    end
end
 
function CxTools.Delay( _seconds )
    assert( type( _seconds ) == "number" );
    coroutine.yield( _seconds * 10 );
end
 
function CxTools.DelayShort( _tenthseconds )
    assert( type( _tenthseconds ) == "number" );
    coroutine.yield( _tenthseconds );
end
 
StartDelayFunc = function( ... ) return CxTools:StartDelayFunc( unpack(arg) ); end;
DelayFuncsJob = function() return CxTools:DelayFuncsJob(); end;
Delay = CxTools.Delay;
DelayShort = CxTools.DelayShort;
QuickSaveOrig = QuickSave;
utilfunctions/priester_und_schamanen.txt · Zuletzt geändert: 2021/09/18 19:16 von 127.0.0.1