Ticket #4098: 4098.1.diff

File 4098.1.diff, 20.7 KB (added by Stan, 8 years ago)

Some more fat arrow functions, further simplification

  • binaries/data/mods/public/simulation/components/UnitAI.js

     
    356356        // Check if we need to move     TODO implement a better way to know if we are on the shoreline
    357357        var needToMove = true;
    358358        var cmpPosition = Engine.QueryInterface(this.entity, IID_Position);
    359         if (this.lastShorelinePosition && cmpPosition && (this.lastShorelinePosition.x == cmpPosition.GetPosition().x)
    360             && (this.lastShorelinePosition.z == cmpPosition.GetPosition().z))
     359        if (this.lastShorelinePosition && cmpPosition &&
     360            this.lastShorelinePosition.x == cmpPosition.GetPosition().x &&
     361            this.lastShorelinePosition.z == cmpPosition.GetPosition().z)
    361362        {
    362363            // we were already on the shoreline, and have not moved since
    363364            if (DistanceBetweenEntities(this.entity, this.order.data.target) < 50)
     
    13761377
    13771378        "GuardedAttacked": function(msg) {
    13781379            // do nothing if we have a forced order in queue before the guard order
    1379             for (var i = 0; i < this.orderQueue.length; ++i)
     1380            for (let i = 0; i < this.orderQueue.length; ++i)
    13801381            {
    13811382                if (this.orderQueue[i].type == "Guard")
    13821383                    break;
     
    18311832                    var animationName = "attack_" + this.order.data.attackType.toLowerCase();
    18321833                    if (this.IsFormationMember())
    18331834                    {
    1834                         var cmpFormation = Engine.QueryInterface(this.formationController, IID_Formation);
     1835                        let cmpFormation = Engine.QueryInterface(this.formationController, IID_Formation);
    18351836                        if (cmpFormation)
    18361837                            animationName = cmpFormation.GetFormationAnimation(this.entity, animationName);
    18371838                    }
     
    20542055
    20552056                        // Try to find another nearby target of the same specific type
    20562057                        // Also don't switch to a different type of huntable animal
    2057                         var nearby = this.FindNearbyResource(function (ent, type, template) {
    2058                             return (
    2059                                 ent != oldTarget
    2060                                  && ((type.generic == "treasure" && oldType.generic == "treasure")
    2061                                  || (type.specific == oldType.specific
    2062                                  && (type.specific != "meat" || oldTemplate == template)))
    2063                             );
    2064                         }, oldTarget);
     2058                        let nearby = this.FindNearbyResource((ent, type, template) =>
     2059                                ent != oldTarget &&
     2060                                (type.generic == "treasure" && oldType.generic == "treasure" ||
     2061                                (type.specific == oldType.specific &&
     2062                                (type.specific != "meat" || oldTemplate == template))),
     2063                                oldTarget);
    20652064                        if (nearby)
    20662065                        {
    20672066                            this.PerformGather(nearby, false, false);
     
    20822081                            else
    20832082                            {
    20842083                                // we're kind of stuck here. Return resource.
    2085                                 var nearby = this.FindNearestDropsite(oldType.generic);
     2084                                nearby = this.FindNearestDropsite(oldType.generic);
    20862085                                if (nearby)
    20872086                                {
    20882087                                    this.PushOrderFront("ReturnResource", { "target": nearby, "force": false });
     
    21192118
    21202119                        // Try to find another nearby target of the same specific type
    21212120                        // Also don't switch to a different type of huntable animal
    2122                         var nearby = this.FindNearbyResource(function (ent, type, template) {
    2123                             return (
    2124                                 ent != oldTarget
    2125                                 && ((type.generic == "treasure" && oldType.generic == "treasure")
    2126                                 || (type.specific == oldType.specific
    2127                                 && (type.specific != "meat" || oldTemplate == template)))
    2128                             );
    2129                         });
     2121                        let nearby = this.FindNearbyResource((ent, type, template) =>
     2122                            ent != oldTarget &&
     2123                            (type.generic == "treasure" && oldType.generic == "treasure" ||
     2124                            (type.specific == oldType.specific &&
     2125                            (type.specific != "meat" || oldTemplate == template))));
    21302126                        if (nearby)
    21312127                        {
    21322128                            this.PerformGather(nearby, false, false);
     
    21652161
    21662162                    // Try to find another nearby target of the same specific type
    21672163                    // Also don't switch to a different type of huntable animal
    2168                     var nearby = this.FindNearbyResource(function (ent, type, template) {
    2169                         return (
    2170                             (type.generic == "treasure" && resourceType.generic == "treasure")
    2171                             || (type.specific == resourceType.specific
    2172                             && (type.specific != "meat" || resourceTemplate == template))
    2173                         );
    2174                     });
     2164                    let nearby = this.FindNearbyResource((ent, type, template) =>
     2165                        (type.generic == "treasure" && resourceType.generic == "treasure") ||
     2166                        (type.specific == resourceType.specific &&
     2167                        (type.specific != "meat" || resourceTemplate == template)));
    21752168
    21762169                    // If there is a nearby resource start gathering
    21772170                    if (nearby)
     
    21852178                        return;
    21862179
    21872180                    // Nothing better to do: go back to dropsite
    2188                     var nearby = this.FindNearestDropsite(resourceType.generic);
     2181                    nearby = this.FindNearestDropsite(resourceType.generic);
    21892182                    if (nearby)
    21902183                    {
    21912184                        this.PushOrderFront("ReturnResource", { "target": nearby, "force": false });
     
    22892282                        {
    22902283                            // Gather the resources:
    22912284
    2292                             var cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer);
     2285                            let cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer);
    22932286
    22942287                            // Try to gather treasure
    22952288                            if (cmpResourceGatherer.TryInstantGather(this.gatheringTarget))
     
    23072300                            // return to the nearest dropsite
    23082301                            if (status.filled)
    23092302                            {
    2310                                 var nearby = this.FindNearestDropsite(resourceType.generic);
     2303                                let nearby = this.FindNearestDropsite(resourceType.generic);
    23112304                                if (nearby)
    23122305                                {
    23132306                                    // (Keep this Gather order on the stack so we'll
     
    23572350
    23582351                    // Give up on this order and try our next queued order
    23592352                    // but first check what is our next order and, if needed, insert a returnResource order
    2360                     var cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer);
     2353                    let cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer);
    23612354                    if (cmpResourceGatherer.IsCarrying(resourceType.generic) &&
    23622355                        this.orderQueue.length > 1 && this.orderQueue[1] !== "ReturnResource" &&
    23632356                        (this.orderQueue[1].type !== "Gather" || this.orderQueue[1].data.type.generic !== resourceType.generic))
     
    23732366
    23742367                    // Try to find a new resource of the same specific type near our current position:
    23752368                    // Also don't switch to a different type of huntable animal
    2376                     var nearby = this.FindNearbyResource(function (ent, type, template) {
    2377                         return (
    2378                             (type.generic == "treasure" && resourceType.generic == "treasure")
    2379                             || (type.specific == resourceType.specific
    2380                             && (type.specific != "meat" || resourceTemplate == template))
    2381                         );
    2382                     });
     2369                    let nearby = this.FindNearbyResource((ent, type, template) =>
     2370                        (type.generic == "treasure" && resourceType.generic == "treasure") ||
     2371                        (type.specific == resourceType.specific &&
     2372                        (type.specific != "meat" || resourceTemplate == template)));
    23832373                    if (nearby)
    23842374                    {
    23852375                        this.PerformGather(nearby, false, false);
     
    23972387                    // drop it off, and if not then we might as well head to the dropsite
    23982388                    // anyway because that's a nice enough place to congregate and idle
    23992389
    2400                     var nearby = this.FindNearestDropsite(resourceType.generic);
     2390                    nearby = this.FindNearestDropsite(resourceType.generic);
    24012391                    if (nearby)
    24022392                    {
    24032393                        this.PushOrderFront("ReturnResource", { "target": nearby, "force": false });
     
    25652555                            // Dump any resources we can
    25662556                            var dropsiteTypes = cmpResourceDropsite.GetTypes();
    25672557
    2568                             var cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer);
     2558                            let cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer);
    25692559                            cmpResourceGatherer.CommitResources(dropsiteTypes);
    25702560
    25712561                            // Stop showing the carried resource animation.
     
    25812571                    // The dropsite was destroyed, or we couldn't reach it, or ownership changed
    25822572                    // Look for a new one.
    25832573
    2584                     var cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer);
     2574                    let cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer);
    25852575                    var genericType = cmpResourceGatherer.GetMainCarryingType();
    25862576                    var nearby = this.FindNearestDropsite(genericType);
    25872577                    if (nearby)
     
    27762766                // the build command should look for nearby resources to gather
    27772767                if ((oldData.force || oldData.autoharvest) && this.CanReturnResource(msg.data.newentity, false))
    27782768                {
    2779                     var cmpResourceDropsite = Engine.QueryInterface(msg.data.newentity, IID_ResourceDropsite);
    2780                     var types = cmpResourceDropsite.GetTypes();
     2769                    cmpResourceDropsite = Engine.QueryInterface(msg.data.newentity, IID_ResourceDropsite);
     2770                    let types = cmpResourceDropsite.GetTypes();
    27812771                    // TODO: Slightly undefined behavior here, we don't know what type of resource will be collected,
    27822772                    //   may cause problems for AIs (especially hunting fast animals), but avoid ugly hacks to fix that!
    2783                     var nearby = this.FindNearbyResource(function (ent, type, template) {
    2784                         return (types.indexOf(type.generic) != -1);
    2785                     });
     2773                    let nearby = this.FindNearbyResource((ent, type, template) => types.indexOf(type.generic) != -1);
    27862774                    if (nearby)
    27872775                    {
    27882776                        this.PerformGather(nearby, true, false);
     
    28612849            "GARRISONED": {
    28622850                "enter": function() {
    28632851                    // Target is not handled the same way with Alert and direct garrisoning
    2864                     if (this.order.data.target)
    2865                         var target = this.order.data.target;
    2866                     else
     2852                    var target = this.order.data.target;
     2853                    if (!target)
    28672854                    {
    28682855                        if (!this.alertGarrisoningTarget)
    28692856                        {
     
    28712858                            this.FinishOrder();
    28722859                            return true;
    28732860                        }
    2874                         var target = this.alertGarrisoningTarget;
     2861                        target = this.alertGarrisoningTarget;
    28752862                    }
    28762863
    28772864                    // Check that we can garrison here
     
    32433230
    32443231UnitAI.prototype.IsUnderAlert = function()
    32453232{
    3246     return this.alertRaiser != undefined;
     3233    return this.alertRaiser !== undefined;
    32473234};
    32483235
    32493236UnitAI.prototype.ResetAlert = function()
     
    33673354    {
    33683355        // Switch to a virgin state to let states execute their leave handlers.
    33693356        // except if garrisoned or cheering or (un)packing, in which case we only clear the order queue
    3370         if (this.isGarrisoned || (this.orderQueue[0] && (this.orderQueue[0].type == "Cheering"
    3371             || this.orderQueue[0].type == "Pack" || this.orderQueue[0].type == "Unpack")))
     3357        if (this.isGarrisoned || (this.orderQueue[0] && (this.orderQueue[0].type == "Cheering" ||
     3358            this.orderQueue[0].type == "Pack" || this.orderQueue[0].type == "Unpack")))
    33723359        {
    33733360            this.orderQueue.length = Math.min(this.orderQueue.length, 1);
    33743361            Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
     
    34273414    {
    34283415        if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
    34293416            continue;
    3430         if (i == 0)
     3417        if (i === 0)
    34313418            this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
    34323419        else
    34333420            this.orderQueue.splice(i, 1);
     
    37293716    // TODO: maybe a better way of doing this would be to use priority levels
    37303717    if (this.order && this.order.type == "Cheering")
    37313718    {
    3732         var order = { "type": type, "data": data };
     3719        let order = { "type": type, "data": data };
    37333720        var cheeringOrder = this.orderQueue.shift();
    37343721        this.orderQueue = [cheeringOrder, order];
    37353722    }
    37363723    else if (this.IsPacking() && type != "CancelPack" && type != "CancelUnpack")
    37373724    {
    3738         var order = { "type": type, "data": data };
     3725        let order = { "type": type, "data": data };
    37393726        var packingOrder = this.orderQueue.shift();
    37403727        this.orderQueue = [packingOrder, order];
    37413728    }
     
    37923779        var cmpUnitAI = Engine.QueryInterface(this.formationController, IID_UnitAI);
    37933780        if (cmpUnitAI)
    37943781        {
    3795             for (var i = 0; i < cmpUnitAI.orderQueue.length; ++i)
     3782            for (let i = 0; i < cmpUnitAI.orderQueue.length; ++i)
    37963783            {
    37973784                if (isWorkType(cmpUnitAI.orderQueue[i].type))
    37983785                {
     
    38043791    }
    38053792
    38063793    // If nothing found, take the unit orders
    3807     for (var i = 0; i < this.orderQueue.length; ++i)
     3794    for (let i = 0; i < this.orderQueue.length; ++i)
    38083795    {
    38093796        if (isWorkType(this.orderQueue[i].type))
    38103797        {
     
    38163803
    38173804UnitAI.prototype.BackToWork = function()
    38183805{
    3819     if (this.workOrders.length == 0)
     3806    if (!this.workOrders.length)
    38203807        return false;
    38213808
    38223809    // Clear the order queue considering special orders not to avoid
     
    39983985        return true;
    39993986
    40003987    var cmpHealth = QueryMiragedInterface(ent, IID_Health);
    4001     return cmpHealth && cmpHealth.GetHitpoints() != 0;
     3988    return cmpHealth && cmpHealth.GetHitpoints() !== 0;
    40023989};
    40033990
    40043991/**
     
    43364323    var t = targetCmpPosition.GetPosition();
    43374324    // h is positive when I'm higher than the target
    43384325    var h = s.y-t.y+range.elevationBonus;
    4339 
     4326    let parabolicMaxRange = 0;
    43404327    // No negative roots please
    4341     if (h>-range.max/2)
    4342         var parabolicMaxRange = Math.sqrt(range.max*range.max+2*range.max*h);
    4343     else
    4344         // return false? Or hope you come close enough?
    4345         var parabolicMaxRange = 0;
    4346         //return false;
     4328    if (h > - range.max / 2)
     4329        parabolicMaxRange = Math.sqrt(range.max*range.max+2*range.max*h);
    43474330
    43484331    // the parabole changes while walking, take something in the middle
    43494332    var guessedMaxRange = (range.max + parabolicMaxRange)/2;
     
    44084391    if (this.IsFormationMember())
    44094392    {
    44104393        var cmpFormationUnitAI = Engine.QueryInterface(this.formationController, IID_UnitAI);
    4411         if (cmpFormationUnitAI && cmpFormationUnitAI.IsAttackingAsFormation()
    4412             && cmpFormationUnitAI.order.data.target == target)
     4394        if (cmpFormationUnitAI && cmpFormationUnitAI.IsAttackingAsFormation() && cmpFormationUnitAI.order.data.target == target)
    44134395            return true;
    44144396    }
    44154397
     
    45884570UnitAI.prototype.AttackEntityInZone = function(ents, forceResponse)
    45894571{
    45904572    var target = ents.find(target =>
    4591         this.CanAttack(target, forceResponse)
    4592         && this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
    4593         && (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
     4573        this.CanAttack(target, forceResponse) &&
     4574        this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
     4575        (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
    45944576    );
    45954577    if (!target)
    45964578        return false;
     
    50985080
    50995081    // Remember the position of our target, if any, in case it disappears
    51005082    // later and we want to head to its last known position
    5101     var lastPos = undefined;
     5083    var lastPos;
    51025084    var cmpPosition = Engine.QueryInterface(target, IID_Position);
    51035085    if (cmpPosition && cmpPosition.IsInWorld())
    51045086        lastPos = cmpPosition.GetPosition();
     
    52255207
    52265208UnitAI.prototype.MoveToMarket = function(targetMarket)
    52275209{
    5228     if (this.waypoints && this.waypoints.length > 1)
    5229     {
    5230         var point = this.waypoints.pop();
    5231         var ok = this.MoveToPoint(point.x, point.z);
    5232         if (!ok)
    5233             ok = this.MoveToMarket(targetMarket);
    5234     }
    5235     else
    5236     {
    5237         this.waypoints = undefined;
    5238         var ok = this.MoveToTarget(targetMarket);
    5239     }
    5240 
    5241     return ok;
     5210    if (this.waypoints && this.waypoints.length > 1)
     5211    {
     5212        var point = this.waypoints.pop();
     5213        return this.MoveToPoint(point.x, point.z) || this.MoveToMarket(targetMarket);
     5214    }
     5215   
     5216    this.waypoints = undefined;
     5217    return this.MoveToTarget(targetMarket);
    52425218};
    52435219
    52445220UnitAI.prototype.PerformTradeAndMoveToNextMarket = function(currentMarket)
     
    54275403    {
    54285404        var cmpUnitAI;
    54295405        var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation);
    5430         for each (var ent in cmpFormation.members)
     5406        for (let ent of cmpFormation.members)
    54315407        {
    54325408            if (!(cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI)))
    54335409                continue;
    5434             var targets = cmpUnitAI.GetTargetsFromUnit();
    5435             for (var targ of targets)
     5410            let targets = cmpUnitAI.GetTargetsFromUnit();
     5411            for (let target of targets)
    54365412            {
    5437                 if (!cmpUnitAI.CanAttack(targ))
     5413                if (!cmpUnitAI.CanAttack(target))
    54385414                    continue;
    54395415                if (this.order.data.targetClasses)
    54405416                {
    5441                     var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
    5442                     var targetClasses = this.order.data.targetClasses;
    5443                     if (targetClasses.attack && cmpIdentity
    5444                         && !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
     5417                    var cmpIdentity = Engine.QueryInterface(target, IID_Identity);
     5418                    let targetClasses = this.order.data.targetClasses;
     5419                    if (targetClasses.attack && cmpIdentity && !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
    54455420                        continue;
    5446                     if (targetClasses.avoid && cmpIdentity
    5447                         && MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
     5421                    if (targetClasses.avoid && cmpIdentity && MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
    54485422                        continue;
    54495423                    // Only used by the AIs to prevent some choices of targets
    5450                     if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
     5424                    if (targetClasses.vetoEntities && targetClasses.vetoEntities[target])
    54515425                        continue;
    54525426                }
    5453                 this.PushOrderFront("Attack", { "target": targ, "force": true, "allowCapture": true });
     5427                this.PushOrderFront("Attack", { "target": target, "force": true, "allowCapture": true });
    54545428                return true;
    54555429            }
    54565430        }
     
    54585432    }
    54595433
    54605434    var targets = this.GetTargetsFromUnit();
    5461     for (var targ of targets)
     5435    for (let target of targets)
    54625436    {
    5463         if (!this.CanAttack(targ))
     5437        if (!this.CanAttack(target))
    54645438            continue;
    54655439        if (this.order.data.targetClasses)
    54665440        {
    5467             var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
    5468             var targetClasses = this.order.data.targetClasses;
    5469             if (cmpIdentity && targetClasses.attack
    5470                 && !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
     5441            let cmpIdentity = Engine.QueryInterface(target, IID_Identity);
     5442            let targetClasses = this.order.data.targetClasses;
     5443            if (cmpIdentity && targetClasses.attack && !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
    54715444                continue;
    5472             if (cmpIdentity && targetClasses.avoid
    5473                 && MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
     5445            if (cmpIdentity && targetClasses.avoid && MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
    54745446                continue;
    54755447            // Only used by the AIs to prevent some choices of targets
    5476             if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
     5448            if (targetClasses.vetoEntities && targetClasses.vetoEntities[target])
    54775449                continue;
    54785450        }
    5479         this.PushOrderFront("Attack", { "target": targ, "force": true, "allowCapture": true });
     5451        this.PushOrderFront("Attack", { "target": target, "force": true, "allowCapture": true });
    54805452        return true;
    54815453    }
    54825454
     
    55335505    var ret = { "min": 0, "max": 0 };
    55345506    if (this.GetStance().respondStandGround)
    55355507    {
    5536         var cmpRanged = Engine.QueryInterface(this.entity, iid);
     5508        let cmpRanged = Engine.QueryInterface(this.entity, iid);
    55375509        if (!cmpRanged)
    55385510            return ret;
    5539         var range = iid !== IID_Attack ? cmpRanged.GetRange() : cmpRanged.GetFullAttackRange();
     5511        let range = iid !== IID_Attack ? cmpRanged.GetRange() : cmpRanged.GetFullAttackRange();
    55405512        ret.min = range.min;
    55415513        ret.max = range.max;
    55425514    }
    55435515    else if (this.GetStance().respondChase)
    55445516    {
    5545         var cmpVision = Engine.QueryInterface(this.entity, IID_Vision);
     5517        let cmpVision = Engine.QueryInterface(this.entity, IID_Vision);
    55465518        if (!cmpVision)
    55475519            return ret;
    5548         var range = cmpVision.GetRange();
    5549         ret.max = range;
     5520        ret.max = cmpVision.GetRange();
    55505521    }
    55515522    else if (this.GetStance().respondHoldGround)
    55525523    {
    5553         var cmpRanged = Engine.QueryInterface(this.entity, iid);
     5524        let cmpRanged = Engine.QueryInterface(this.entity, iid);
    55545525        if (!cmpRanged)
    55555526            return ret;
    5556         var range = iid !== IID_Attack ? cmpRanged.GetRange() : cmpRanged.GetFullAttackRange();
    5557         var cmpVision = Engine.QueryInterface(this.entity, IID_Vision);
     5527        let range = iid !== IID_Attack ? cmpRanged.GetRange() : cmpRanged.GetFullAttackRange();
     5528        let cmpVision = Engine.QueryInterface(this.entity, IID_Vision);
    55585529        if (!cmpVision)
    55595530            return ret;
    55605531        var halfvision = cmpVision.GetRange() / 2;
     
    55645535    // but as it is the default for healers we need to set it to something sane.
    55655536    else if (iid === IID_Heal)
    55665537    {
    5567         var cmpVision = Engine.QueryInterface(this.entity, IID_Vision);
     5538        let cmpVision = Engine.QueryInterface(this.entity, IID_Vision);
    55685539        if (!cmpVision)
    55695540            return ret;
    5570         var range = cmpVision.GetRange();
    5571         ret.max = range;
     5541       
     5542        ret.max = cmpVision.GetRange();
    55725543    }
    55735544    return ret;
    55745545};
     
    58655836UnitAI.prototype.IsAttackingAsFormation = function()
    58665837{
    58675838    var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
    5868     return cmpAttack && cmpAttack.CanAttackAsFormation()
    5869         && this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
     5839    return cmpAttack && cmpAttack.CanAttackAsFormation() && this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
    58705840};
    58715841
    58725842//// Animal specific functions ////