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

File Regicide_v1.2.patch, 8.0 KB (added by Sandarac, 8 years ago)
  • 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

     
    415415                    </object>
    416416                </object>
    417417
    418                 <object name="optionCheats" size="14 368 94% 396" hidden="true">
     418                <object name="optionRegicideEarlyAttack" size="14 368 94% 396">
    419419                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
     420                        <translatableAttribute id="caption">Hero Attack at Start:</translatableAttribute>
     421                    </object>
     422                    <object name="regicideEarlyAttackText" size="40% 0 100% 28" type="text" style="ModernLeftLabelText"/>
     423                    <object name="regicideEarlyAttack" size="40%+10 5 40%+30 100%-5" type="checkbox" style="ModernTickBox" hidden="true" tooltip_style="onscreenToolTip">
     424                        <translatableAttribute id="tooltip">Toggle whether heroes can attack from the start of the game, or only once City Phase has been reached.</translatableAttribute>
     425                    </object>
     426                </object>
     427
     428                <object name="optionCheats" size="14 398 94% 426" hidden="true">
     429                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
    420430                        <translatableAttribute id="caption">Cheats:</translatableAttribute>
    421431                    </object>
    422432                    <object name="enableCheatsText" size="40% 0 100% 28" type="text" style="ModernLeftLabelText"/>
     
    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                    cmpAuras.RemoveTemplateBonus(aura);
     68        }
    5469    }
    5570};
    5671
     
    98113    return undefined;
    99114};
    100115
     116Trigger.prototype.CityPhaseReached = function(data)
     117{
     118    if (data.tech.indexOf("phase_city") == -1)
     119        return;
     120
     121    if (!this.regicideEarlyAttack)
     122    {
     123        let cmpAttack = Engine.QueryInterface(this.regicideHeroes[data.player], IID_Attack);
     124        if (cmpAttack)
     125            cmpAttack.SetEnabled(true);
     126
     127        let cmpAuras = Engine.QueryInterface(this.regicideHeroes[data.player], IID_Auras);
     128        if (cmpAuras)
     129            for (let aura of cmpAuras.GetAuraNames())
     130                if (cmpAuras.IsGlobalAura(aura))
     131                    cmpAuras.ApplyTemplateBonus(aura, [data.player]);
     132    }
     133};
     134
    101135let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
    102136cmpTrigger.regicideHeroes = [];
     137cmpTrigger.regicideEarlyAttack = false;
    103138cmpTrigger.DoAfterDelay(0, "InitRegicideGame", {});
    104139cmpTrigger.RegisterTrigger("OnOwnershipChanged", "CheckRegicideDefeat", { "enabled": true });
     140cmpTrigger.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/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