Ticket #3406: t3406_prevent_attacking_field_WIP_v1.patch

File t3406_prevent_attacking_field_WIP_v1.patch, 901 bytes (added by elexis, 9 years ago)

Doesn't work for mirages and we should implement an attackable attribute for structures.

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

    Attack.prototype.GetRestrictedClasses =  
    236236    return [];
    237237};
    238238
    239239Attack.prototype.CanAttack = function(target)
    240240{
     241    // Fields cannot be attacked
     242    var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
     243    var template = cmpTemplateManager.GetTemplate(cmpTemplateManager.GetCurrentTemplateName(target));
     244    if (template["@parent"] == "template_structure_resource_field")
     245        return false;
     246
    241247    var cmpFormation = Engine.QueryInterface(target, IID_Formation);
    242248    if (cmpFormation)
    243249        return true;
    244250
    245251    var cmpThisPosition = Engine.QueryInterface(this.entity, IID_Position);