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.3.patch

File Regicide_v1.3.patch, 12.0 KB (added by Sandarac, 8 years ago)

Adds option to disable aura/attack of heroes until City Phase

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

     
    499499        "DisableTreasures": "disableTreasures",
    500500        "LockTeams": "lockTeams",
    501501        "LastManStanding" : "lastManStanding",
     502        "RegicideEarlyAttack" : "regicideEarlyAttack",
    502503        "CheatsEnabled": "enableCheats"
    503504    };
    504505
     
    11831184    {
    11841185        delete g_GameAttributes.settings.WonderDuration;
    11851186        delete g_GameAttributes.settings.LastManStanding;
     1187        delete g_GameAttributes.settings.RegicideEarlyAttack;
    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("regicideEarlyAttack", "regicideEarlyAttackText", !!mapSettings.RegicideEarlyAttack);
    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("optionRegicideEarlyAttack").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", "regicideEarlyAttack"])
    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="optionRegicideEarlyAttack" size="14 98 94% 126">
    339339                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
     340                        <translatableAttribute id="caption">Hero Attack at Start:</translatableAttribute>
     341                    </object>
     342                    <object name="regicideEarlyAttackText" size="40% 0 100% 28" type="text" style="ModernLeftLabelText"/>
     343                    <object name="regicideEarlyAttack" 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 attack from the start of the game, or only once City Phase has been reached.</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 218 94% 246">
    359369                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
    360370                        <translatableAttribute id="caption">Ceasefire:</translatableAttribute>
    361371                    </object>
     
    365375                    </object>
    366376                </object>
    367377
    368                 <object name="optionRevealMap" size="14 218 94% 246">
     378                <object name="optionRevealMap" size="14 248 94% 276">
    369379                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
    370380                        <translatableAttribute id="caption" comment="Make sure to differentiate between the revealed map and explored map options!">Revealed Map:</translatableAttribute>
    371381                    </object>
     
    375385                    </object>
    376386                </object>
    377387
    378                 <object name="optionExploreMap" size="14 248 94% 276">
     388                <object name="optionExploreMap" size="14 278 94% 306">
    379389                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
    380390                        <translatableAttribute id="caption" comment="Make sure to differentiate between the revealed map and explored map options!">Explored Map:</translatableAttribute>
    381391                    </object>
     
    385395                    </object>
    386396                </object>
    387397
    388                 <object name="optionDisableTreasures" size="14 278 94% 306">
     398                <object name="optionDisableTreasures" size="14 308 94% 336">
    389399                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
    390400                        <translatableAttribute id="caption">Disable Treasures:</translatableAttribute>
    391401                    </object>
     
    395405                    </object>
    396406                </object>
    397407
    398                 <object name="optionLockTeams" size="14 308 94% 336">
     408                <object name="optionLockTeams" size="14 338 94% 366">
    399409                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
    400410                        <translatableAttribute id="caption">Teams Locked:</translatableAttribute>
    401411                    </object>
     
    405415                    </object>
    406416                </object>
    407417
    408                 <object name="optionLastManStanding" size="14 338 94% 366">
     418                <object name="optionLastManStanding" size="14 368 94% 396">
    409419                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
    410420                        <translatableAttribute id="caption">Last Man Standing:</translatableAttribute>
    411421                    </object>
     
    415425                    </object>
    416426                </object>
    417427
    418                 <object name="optionCheats" size="14 368 94% 396" hidden="true">
     428                <object name="optionCheats" size="14 398 94% 426" hidden="true">
    419429                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
    420430                        <translatableAttribute id="caption">Cheats:</translatableAttribute>
    421431                    </object>
     
    425435                    </object>
    426436                </object>
    427437
    428                 <object name="optionRating" size="14 398 94% 426" hidden="true">
     438                <object name="optionRating" size="14 428 94% 456" hidden="true">
    429439                    <object size="0 0 40% 28" hidden="false" type="text" style="ModernRightLabelText">
    430440                        <translatableAttribute id="caption">Rated Game:</translatableAttribute>
    431441                    </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

     
    4545
    4646    // Attempt to spawn one hero per player
    4747    let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
     48    let cmpEndGameManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager);
     49    this.regicideEarlyAttack = cmpEndGameManager.GetGameTypeSettings().regicideEarlyAttack || false;
     50
    4851    for (let playerID = 1; playerID < TriggerHelper.GetNumberOfPlayers(); ++playerID)
    4952    {
    5053        let spawnPoints = cmpRangeManager.GetEntitiesByPlayer(playerID).sort((entity1, entity2) =>
     
    5154            getSpawnPreference(entity2) - getSpawnPreference(entity1));
    5255
    5356        this.regicideHeroes[playerID] = this.SpawnRegicideHero(playerID, heroTemplates[playersCivs[playerID]], spawnPoints);
     57
     58        if (!this.regicideEarlyAttack)
     59        {
     60            let cmpAttack = Engine.QueryInterface(this.regicideHeroes[playerID], IID_Attack);
     61            if (cmpAttack)
     62                cmpAttack.SetEnabled(false);
     63
     64            let cmpAuras = Engine.QueryInterface(this.regicideHeroes[playerID], IID_Auras);
     65            if (cmpAuras)
     66                for (let aura of cmpAuras.GetAuraNames())
     67                {
     68                    cmpAuras.SetEnabled(false);
     69                    cmpAuras.Clean();
     70                }
     71        }
    5472    }
    5573};
    5674
     
    98116    return undefined;
    99117};
    100118
     119Trigger.prototype.CityPhaseReached = function(data)
     120{
     121    if (data.tech.indexOf("phase_city") == -1)
     122        return;
     123
     124    if (!this.regicideEarlyAttack)
     125    {
     126        let cmpAttack = Engine.QueryInterface(this.regicideHeroes[data.player], IID_Attack);
     127        if (cmpAttack)
     128            cmpAttack.SetEnabled(true);
     129
     130        let cmpAuras = Engine.QueryInterface(this.regicideHeroes[data.player], IID_Auras);
     131        if (cmpAuras)
     132            for (let aura of cmpAuras.GetAuraNames())
     133            {
     134                cmpAuras.SetEnabled(true);
     135                cmpAuras.Clean();
     136            }
     137    }
     138};
     139
    101140let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
    102141cmpTrigger.regicideHeroes = [];
     142cmpTrigger.regicideEarlyAttack = false;
    103143cmpTrigger.DoAfterDelay(0, "InitRegicideGame", {});
    104144cmpTrigger.RegisterTrigger("OnOwnershipChanged", "CheckRegicideDefeat", { "enabled": true });
     145cmpTrigger.RegisterTrigger("OnResearchFinished", "CityPhaseReached", { "enabled": true });
  • binaries/data/mods/public/simulation/components/Attack.js

     
    202202
    203203Attack.prototype.Init = function()
    204204{
     205    this.enabled = true;
    205206};
    206207
    207208Attack.prototype.Serialize = null; // we have no dynamic state to save
    208209
     210Attack.prototype.GetEnabled = function(enabled)
     211{
     212    return this.enabled;
     213};
     214
     215Attack.prototype.SetEnabled = function(enabled)
     216{
     217    this.enabled = enabled;
     218};
     219
    209220Attack.prototype.GetAttackTypes = function()
    210221{
    211222    return ["Melee", "Ranged", "Capture"].filter(type => !!this.template[type]);
     
    231242
    232243Attack.prototype.CanAttack = function(target)
    233244{
     245    if (!this.enabled)
     246        return false;
     247
    234248    let cmpFormation = Engine.QueryInterface(target, IID_Formation);
    235249    if (cmpFormation)
    236250        return true;
  • binaries/data/mods/public/simulation/components/Auras.js

     
    88
    99Auras.prototype.Init = function()
    1010{
     11    this.enabled = true;
    1112    let cmpDataTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_DataTemplateManager);
    1213    this.auras = {};
    1314    this.affectedPlayers = {};
     
    2223    this.Clean();
    2324};
    2425
     26Auras.prototype.GetEnabled = function(enabled)
     27{
     28    return this.enabled;
     29};
     30
     31Auras.prototype.SetEnabled = function(enabled)
     32{
     33    this.enabled = enabled;
     34};
     35
    2536// We can modify identifier if we want stackable auras in some case.
    2637Auras.prototype.GetModifierIdentifier = function(name)
    2738{
     
    109120
    110121Auras.prototype.CanApply = function(name)
    111122{
     123    if (!this.enabled)
     124        return false;
    112125    if (!this.auras[name].requiredTechnology)
    113126        return true;
    114127    let cmpTechnologyManager = QueryOwnerInterface(this.entity, IID_TechnologyManager);
  • 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.RegicideEarlyAttack && settings.GameType == "regicide")
     51        gameTypeSettings.regicideEarlyAttack = true;
    5052    if (settings.GameType)
    5153        cmpEndGameManager.SetGameType(settings.GameType, gameTypeSettings);
    5254