Ticket #2905: wallGarrison.diff

File wallGarrison.diff, 2.5 KB (added by mimo, 9 years ago)
  • binaries/data/mods/public/simulation/components/GarrisonHolder.js

     
    242242        vgp.entity = entity;
    243243        cmpPosition.SetTurretParent(this.entity, vgp.offset);
    244244        visiblyGarrisoned = true;
     245        var cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI);
     246        if (cmpUnitAI)
     247            cmpUnitAI.SetTurretStance();
    245248        break;
    246249    }
    247250    if (!visiblyGarrisoned)
     
    337340        if (vgp.entity != entity)
    338341            continue;
    339342        cmpNewPosition.SetTurretParent(INVALID_ENTITY, new Vector3D());
     343        var cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI);
     344        if (cmpUnitAI)
     345            cmpUnitAI.ResetTurretStance();
    340346        vgp.entity = null;
    341347        break;
    342348    }
  • binaries/data/mods/public/simulation/components/UnitAI.js

     
    52845284    this.SetupRangeQueries();
    52855285};
    52865286
     5287UnitAI.prototype.SetTurretStance = function()
     5288{
     5289    this.previousStance = undefined;
     5290    if (this.GetStance().respondStandGround)
     5291        return;
     5292    for (let stance in g_Stances)
     5293    {
     5294        if (!g_Stances[stance].respondStandGround)
     5295            continue;
     5296        this.previousStance = this.GetStanceName();
     5297        this.SwitchToStance(stance);
     5298        return;
     5299    }
     5300};
     5301
     5302UnitAI.prototype.ResetTurretStance = function()
     5303{
     5304    if (!this.previousStance)
     5305        return;
     5306    this.SwitchToStance(this.previousStance);
     5307    this.previousStance = undefined;
     5308};
     5309
    52875310/**
    52885311 * Resets losRangeQuery, and if there are some targets in range that we can
    52895312 * attack then we start attacking and this returns true; otherwise, returns false.
     
    54685491
    54695492UnitAI.prototype.GetPossibleStances = function()
    54705493{
     5494    if (this.IsTurret())
     5495        return [];
    54715496    return Object.keys(g_Stances);
    54725497};
    54735498
  • binaries/data/mods/public/simulation/helpers/Commands.js

     
    548548        for each (var ent in data.entities)
    549549        {
    550550            var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
    551             if (cmpUnitAI)
     551            if (cmpUnitAI && !cmpUnitAI.IsTurret())
    552552                cmpUnitAI.SwitchToStance(cmd.name);
    553553        }
    554554    },