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

File Regicide_v1.1.patch, 2.6 KB (added by Sandarac, 8 years ago)
  • binaries/data/mods/public/maps/scripts/Regicide.js

     
    5151            getSpawnPreference(entity2) - getSpawnPreference(entity1));
    5252
    5353        this.regicideHeroes[playerID] = this.SpawnRegicideHero(playerID, heroTemplates[playersCivs[playerID]], spawnPoints);
     54
     55        let cmpAttack = Engine.QueryInterface(this.regicideHeroes[playerID], IID_Attack);
     56        cmpAttack.SetEnabled(false);
     57
     58        let cmpAuras = Engine.QueryInterface(this.regicideHeroes[playerID], IID_Auras);
     59        for (let aura of cmpAuras.GetAuraNames())
     60            if (cmpAuras.IsGlobalAura(aura))
     61                cmpAuras.RemoveTemplateBonus(aura);
    5462    }
    5563};
    5664
     
    98106    return undefined;
    99107};
    100108
     109Trigger.prototype.CityPhaseReached = function(data)
     110{
     111    if (data.tech.indexOf("phase_city") == -1)
     112        return;
     113
     114    let cmpAttack = Engine.QueryInterface(this.regicideHeroes[data.player], IID_Attack);
     115    cmpAttack.SetEnabled(true);
     116
     117    let cmpAuras = Engine.QueryInterface(this.regicideHeroes[data.player], IID_Auras);
     118    for (let aura of cmpAuras.GetAuraNames())
     119        if (cmpAuras.IsGlobalAura(aura))
     120            cmpAuras.ApplyTemplateBonus(aura, [data.player]);
     121
     122};
     123
    101124let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
    102125cmpTrigger.regicideHeroes = [];
    103126cmpTrigger.DoAfterDelay(0, "InitRegicideGame", {});
    104127cmpTrigger.RegisterTrigger("OnOwnershipChanged", "CheckRegicideDefeat", { "enabled": true });
     128cmpTrigger.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;