This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Ticket #2160: Regicide_v1.7.1.patch

File Regicide_v1.7.1.patch, 10.1 KB (added by Sandarac, 8 years ago)

Adds gamesetup option to toggle whether Heroes can garrison or not.

  • binaries/data/mods/public/gui/gamesetup/gamesetup.js

     
    498498        "ExploreMap": "exploreMap",
    499499        "DisableTreasures": "disableTreasures",
    500500        "LockTeams": "lockTeams",
    501         "LastManStanding" : "lastManStanding",
     501        "LastManStanding": "lastManStanding",
     502        "RegicideGarrison": "regicideGarrison",
    502503        "CheatsEnabled": "enableCheats"
    503504    };
    504505
     
    11831184    {
    11841185        delete g_GameAttributes.settings.WonderDuration;
    11851186        delete g_GameAttributes.settings.LastManStanding;
     1187        delete g_GameAttributes.settings.RegicideGarrison;
    11861188    }
    11871189
    11881190    if (mapSettings.PlayerData)
     
    13801382    setGUIBoolean("revealMap", "revealMapText", !!mapSettings.RevealMap);
    13811383    setGUIBoolean("lockTeams", "lockTeamsText", !!mapSettings.LockTeams);
    13821384    setGUIBoolean("lastManStanding", "lastManStandingText", !!mapSettings.LastManStanding);
     1385    setGUIBoolean("regicideGarrison", "regicideGarrisonText", !!mapSettings.RegicideGarrison);
    13831386    setGUIBoolean("enableRating", "enableRatingText", !!mapSettings.RatingEnabled);
    13841387
    13851388    Engine.GetGUIObjectByName("optionWonderDuration").hidden =
     
    13861389        g_GameAttributes.settings.GameType &&
    13871390        g_GameAttributes.settings.GameType != "wonder";
    13881391    Engine.GetGUIObjectByName("optionLastManStanding").hidden = mapSettings.LockTeams;
     1392    Engine.GetGUIObjectByName("optionRegicideGarrison").hidden =
     1393        g_GameAttributes.settings.GameType &&
     1394        g_GameAttributes.settings.GameType != "regicide";
    13891395
    13901396    Engine.GetGUIObjectByName("cheatWarningText").hidden = !g_IsNetworked || !mapSettings.CheatsEnabled;
    13911397
     
    14031409
    14041410    for (let ctrl of ["victoryCondition", "wonderDuration", "populationCap",
    14051411                      "startingResources", "ceasefire", "revealMap",
    1406                       "exploreMap", "disableTreasures", "lockTeams", "lastManStanding"])
     1412                      "exploreMap", "disableTreasures", "lockTeams",
     1413                      "lastManStanding", "regicideGarrison"])
    14071414        hideControl(ctrl, ctrl + "Text", notScenario);
    14081415
    14091416    Engine.GetGUIObjectByName("civResetButton").hidden = !notScenario;
  • binaries/data/mods/public/gui/gamesetup/gamesetup.xml

     
    335335                    </object>
    336336                </object>
    337337
    338                 <object name="optionPopulationCap" size="14 98 94% 126">
     338                <object name="optionRegicideGarrison" size="14 98 94% 126">
    339339                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
     340                        <translatableAttribute id="caption">Hero Garrison:</translatableAttribute>
     341                    </object>
     342                    <object name="regicideGarrisonText" size="40% 0 100% 28" type="text" style="ModernLeftLabelText"/>
     343                    <object name="regicideGarrison" size="40%+10 5 40%+30 100%-5" type="checkbox" style="ModernTickBox" hidden="true" tooltip_style="onscreenToolTip">
     344                        <translatableAttribute id="tooltip">Toggle whether heroes can be garrisoned.</translatableAttribute>
     345                    </object>
     346                </object>
     347
     348                <object name="optionPopulationCap" size="14 128 94% 156">
     349                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
    340350                        <translatableAttribute id="caption">Population Cap:</translatableAttribute>
    341351                    </object>
    342352                    <object name="populationCapText" size="40% 0 100% 100%" type="text" style="ModernLeftLabelText"/>
     
    345355                    </object>
    346356                </object>
    347357
    348                 <object name="optionStartingResources" size="14 128 94% 156">
     358                <object name="optionStartingResources" size="14 158 94% 186">
    349359                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
    350360                        <translatableAttribute id="caption">Starting Resources:</translatableAttribute>
    351361                    </object>
     
    355365                    </object>
    356366                </object>
    357367
    358                 <object name="optionCeasefire" size="14 158 94% 186">
     368                <object name="optionCeasefire" size="14 188 94% 216">
    359369                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
    360370                        <translatableAttribute id="caption">Ceasefire:</translatableAttribute>
    361371                    </object>
     
    440450                    name="hideMoreOptions"
    441451                    type="button"
    442452                    style="StoneButton"
    443                     size="50%-70 428 50%+70 456"
     453                    size="50%-70 458 50%+70 486"
    444454                    tooltip_style="onscreenToolTip"
    445455                    hotkey="cancel"
    446456                >
  • binaries/data/mods/public/maps/scripts/Regicide.js

     
    66
    77Trigger.prototype.InitRegicideGame = function(msg)
    88{
     9    let cmpEndGameManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager);
     10    this.regicideGarrison = !!cmpEndGameManager.GetGameTypeSettings().regicideGarrison;
     11
    912    let playersCivs = [];
    1013    for (let playerID = 1; playerID < TriggerHelper.GetNumberOfPlayers(); ++playerID)
    1114        playersCivs[playerID] = QueryPlayerIDInterface(playerID).GetCiv();
     
    8992
    9093            hero = hero[0];
    9194
     95            if (!this.regicideGarrison && !isShip)
     96                QueryPlayerIDInterface(playerID).AddDisabledGarrisonClass("Hero");
     97
    9298            if (isShip)
    9399            {
    94100                let cmpUnitAI = Engine.QueryInterface(hero, IID_UnitAI);
     
    102108    return undefined;
    103109};
    104110
     111Trigger.prototype.CheckRegicideHeroGarrison = function(data)
     112{
     113    if (this.regicideHeroes.indexOf(...data.removed) == -1 || this.regicideGarrison)
     114        return;
     115
     116    QueryOwnerInterface(...data.removed).AddDisabledGarrisonClass("Hero");
     117};
     118
    105119let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
    106120cmpTrigger.regicideHeroes = [];
     121cmpTrigger.regicideGarrison = false;
    107122cmpTrigger.DoAfterDelay(0, "InitRegicideGame", {});
    108123cmpTrigger.RegisterTrigger("OnOwnershipChanged", "CheckRegicideDefeat", { "enabled": true });
     124cmpTrigger.RegisterTrigger("OnGarrisonedUnitsChanged", "CheckRegicideHeroGarrison", { "enabled": true });
  • binaries/data/mods/public/simulation/components/GarrisonHolder.js

     
    196196    if (!this.IsGarrisoningAllowed())
    197197        return false;
    198198
     199    let cmpPlayer = QueryOwnerInterface(entity);
    199200    var cmpIdentity = Engine.QueryInterface(entity, IID_Identity);
    200201    if (!cmpIdentity)
    201202        return false;
    202203    var entityClasses = cmpIdentity.GetClassesList();
     204    if (cmpPlayer && entityClasses.some(className => cmpPlayer.GetDisabledGarrisonClasses().indexOf(className) != -1))
     205        return false;
     206
    203207    return MatchesClassList(entityClasses, this.template.List._string);
    204208};
    205209
  • binaries/data/mods/public/simulation/components/interfaces/Trigger.js

     
    1111 * sent from Player component.
    1212 */
    1313Engine.RegisterMessageType("DisabledTechnologiesChanged");
     14
     15/**
     16 * Message of the form {}
     17 * sent from Player component.
     18 */
     19Engine.RegisterMessageType("DisabledGarrisonClassesChanged");
  • binaries/data/mods/public/simulation/components/Player.js

     
    5353    this.disabledTemplates = {};
    5454    this.disabledTechnologies = {};
    5555    this.startingTechnologies = [];
     56    this.disabledGarrisonClasses = [];
    5657};
    5758
    5859Player.prototype.SetPlayerID = function(id)
     
    853854    this.startingTechnologies = techs;
    854855};
    855856
     857Player.prototype.AddDisabledGarrisonClass = function(className)
     858{
     859    if (this.disabledGarrisonClasses.indexOf(className) == -1)
     860        this.disabledGarrisonClasses.push(className);
     861    Engine.BroadcastMessage(MT_DisabledGarrisonClassesChanged, {});
     862};
     863
     864Player.prototype.RemoveDisabledGarrisonClasses = function(className)
     865{
     866    this.disabledGarrisonClasses.splice(this.disabledGarrisonClasses.indexOf(className), 1);
     867    Engine.BroadcastMessage(MT_DisabledGarrisonClassesChanged, {});
     868};
     869
     870Player.prototype.SetDisabledGarrisonClasses = function(classes)
     871{
     872    for (let className of classes)
     873        this.disabledGarrisonClasses.push(className);
     874    Engine.BroadcastMessage(MT_DisabledGarrisonClassesChanged, {});
     875};
     876
     877Player.prototype.GetDisabledGarrisonClasses = function()
     878{
     879    return this.disabledGarrisonClasses;
     880};
     881
    856882Engine.RegisterComponentType(IID_Player, "Player", Player);
  • binaries/data/mods/public/simulation/components/Trigger.js

     
    1111    "CinemaPathEnded",
    1212    "CinemaQueueEnded",
    1313    "ConstructionStarted",
     14    "GarrisonedUnitsChanged",
    1415    "Interval",
    1516    "OwnershipChanged",
    1617    "PlayerCommand",
     
    265266    this.CallEvent("PlayerWon", msg);
    266267};
    267268
     269Trigger.prototype.OnGlobalGarrisonedUnitsChanged = function(msg)
     270{
     271    this.CallEvent("GarrisonedUnitsChanged", msg);
     272};
     273
    268274/**
    269275 * Execute a function after a certain delay.
    270276 *
  • binaries/data/mods/public/simulation/helpers/Setup.js

     
    4747    let gameTypeSettings = {};
    4848    if (settings.WonderDuration)
    4949        gameTypeSettings.wonderDuration = settings.WonderDuration * 60 * 1000;
     50    if (settings.GameType == "regicide")
     51        gameTypeSettings.regicideGarrison = settings.RegicideGarrison;
    5052    if (settings.GameType)
    5153        cmpEndGameManager.SetGameType(settings.GameType, gameTypeSettings);
    5254