Ticket #1652: skittish.patch

File skittish.patch, 2.0 KB (added by smarlowe, 12 years ago)
  • data/mods/public/simulation/components/Attack.js

     
    276276    const isPreferred = function (value, i, a) { return attack.GetPreferredClasses(value).some(isTargetClass); }
    277277    const byPreference = function (a, b) { return (types.indexOf(a) + (isPreferred(a) ? types.length : 0) ) - (types.indexOf(b) + (isPreferred(b) ? types.length : 0) ); }
    278278
    279     return types.filter(isAllowed).sort(byPreference).pop();
     279    const bestAttackAgainst = types.filter(isAllowed).sort(byPreference).pop();
     280
     281    //Have ranged attacker use a melee attack on nonskittish animals. Otherwise it is too difficult for ranged attackers to kill.
     282    const targetNotSkittish = cmpIdentity.HasClass("Animal") && (Engine.QueryInterface(target, IID_UnitAI).template.NaturalBehaviour!="skittish");
     283    if (bestAttackAgainst == "Ranged" && targetNotSkittish)
     284        return "Melee";
     285
     286    return bestAttackAgainst;
    280287};
    281288
    282289Attack.prototype.CompareEntitiesByPreference = function(a, b)
     
    642649                // Remove the projectile
    643650                var cmpProjectileManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ProjectileManager);
    644651                cmpProjectileManager.RemoveProjectile(data.projectileId);
     652
    645653            }
    646654        }
    647655    }
  • data/mods/public/simulation/templates/template_unit_cavalry_ranged.xml

     
    1414      <RestrictedClasses datatype="tokens">StoneWall</RestrictedClasses>
    1515      <Spread>1.6</Spread>
    1616    </Ranged>
     17    <Melee>
     18      <Hack>5.0</Hack>
     19      <Pierce>15.0</Pierce>
     20      <Crush>0.0</Crush>
     21      <MaxRange>6.0</MaxRange>
     22      <RepeatTime>1000</RepeatTime>
     23    </Melee>
    1724  </Attack>
    1825  <Identity>
    1926    <GenericName>Ranged Cavalry</GenericName>