Ticket #1908: exponential-armor.patch

File exponential-armor.patch, 9.4 KB (added by alpha123, 11 years ago)
  • binaries/data/mods/public/simulation/components/Armour.js

     
    4747    if (this.invulnerable)
    4848        return { "killed": false };
    4949
    50     // Adjust damage values based on armour
     50    // Adjust damage values based on armour; exponential armour: damage = attack * 0.9^armour
    5151    var armourStrengths = this.GetArmourStrengths();
    52     var adjHack = Math.max(0, hack - armourStrengths.hack);
    53     var adjPierce = Math.max(0, pierce - armourStrengths.pierce);
    54     var adjCrush = Math.max(0, crush - armourStrengths.crush);
     52    var adjHack = hack * Math.pow(0.9, armourStrengths.hack);
     53    var adjPierce = pierce * Math.pow(0.9, armourStrengths.pierce);
     54    var adjCrush = crush * Math.pow(0.9, armourStrengths.crush);
    5555
    5656    // Total is sum of individual damages, with minimum damage 1
    5757    //  Round to nearest integer, since HP is integral
  • binaries/data/mods/public/gui/session/selection_details.js

     
    192192    // Show max attack range if ranged attack, also convert to tiles (4m per tile)
    193193    if (entState.attack && entState.attack.type == "Ranged")
    194194        attack += ", [font=\"serif-bold-13\"]Range:[/font] " + Math.round(entState.attack.maxRange/4);
    195     getGUIObjectByName("attackAndArmorStats").tooltip = attack + "\n[font=\"serif-bold-13\"]Armor:[/font] " + damageTypeDetails(entState.armour);
     195    getGUIObjectByName("attackAndArmorStats").tooltip = attack + "\n[font=\"serif-bold-13\"]Armor:[/font] " + armorTypeDetails(entState.armour);
    196196
    197197    // Icon Tooltip
    198198    var iconTooltip = "";
  • binaries/data/mods/public/gui/session/utility_functions.js

     
    176176    }
    177177}
    178178
     179// Converts an armor level into the actual reduction percentage
     180function armorLevelToPercentage(level)
     181{
     182    return 100 - Math.round(Math.pow(0.9, level) * 100);
     183}
     184
     185// Also for the unit details panel
     186function armorTypeDetails(dmg)
     187{
     188    if (dmg)
     189    {
     190        var dmgArray = [];
     191        if (dmg.hack)
     192        {
     193            dmgArray.push(dmg.hack + "[font=\"sans-10\"][color=\"orange\"] Hack[/color][/font] " +
     194                " [font=\"sans-10\"](" + armorLevelToPercentage(dmg.hack) + "%)[/font]");
     195        }
     196        if (dmg.pierce)
     197        {
     198            dmgArray.push(dmg.pierce + "[font=\"sans-10\"][color=\"orange\"] Pierce[/color][/font] " +
     199                " [font=\"sans-10\"](" + armorLevelToPercentage(dmg.pierce) + "%)[/font]");
     200        }
     201        if (dmg.crush)
     202        {
     203            dmgArray.push(dmg.crush + "[font=\"sans-10\"][color=\"orange\"] Crush[/color][/font] " +
     204                " [font=\"sans-10\"](" + armorLevelToPercentage(dmg.crush) + "%)[/font]");
     205        }
     206
     207        return dmgArray.join(", ");
     208    }
     209    else
     210    {
     211        return "[font=\"serif-12\"](None)[/font]";
     212    }
     213}
     214
    179215// For the training tooltip
    180216function damageTypesToText(dmg)
    181217{
     
    197233    return dmgArray.join("[font=\"serif-12\"], [/font]");
    198234}
    199235
     236// Also for the training tooltip
     237function armorTypesToText(dmg)
     238{
     239    if (!dmg)
     240        return "[font=\"serif-12\"](None)[/font]";
     241
     242    var hackDamage = dmg.hack;
     243    var pierceDamage = dmg.pierce;
     244    var crushDamage = dmg.crush;
     245    var hackLabel = "[font=\"serif-12\"] Hack (" + armorLevelToPercentage(hackDamage) + "%)[/font]";
     246    var pierceLabel = "[font=\"serif-12\"] Pierce (" + armorLevelToPercentage(pierceDamage) + "%)[/font]";
     247    var crushLabel = "[font=\"serif-12\"] Crush (" + armorLevelToPercentage(crushDamage) + "%)[/font]";
     248
     249    var dmgArray = [];
     250    if (hackDamage) dmgArray.push(hackDamage + hackLabel);
     251    if (pierceDamage) dmgArray.push(pierceDamage + pierceLabel);
     252    if (crushDamage) dmgArray.push(crushDamage + crushLabel);
     253
     254    return dmgArray.join("[font=\"serif-12\"], [/font]");
     255}
     256
    200257function getEntityCommandsList(entState)
    201258{
    202259    var commands = [];
  • binaries/data/mods/public/gui/session/unit_commands.js

     
    455455                if (template.health)
    456456                    tooltip += "\n[font=\"serif-bold-13\"]Health:[/font] " + template.health;
    457457                if (template.armour)
    458                     tooltip += "\n[font=\"serif-bold-13\"]Armour:[/font] " + damageTypesToText(template.armour);
     458                    tooltip += "\n[font=\"serif-bold-13\"]Armour:[/font] " + armorTypesToText(template.armour);
    459459                if (template.attack)
    460460                    tooltip += "\n" + getEntityAttack(template);
    461461                if (template.speed)
  • binaries/data/mods/public/simulation/data/technologies/armor_ship_hullsheathing.json

     
    77    "supersedes": "armor_ship_hypozomata",
    88    "icon": "armor_ship_gold.png",
    99    "researchTime": 20,
    10     "tooltip": "Lead sheathing protects ship hulls. Adds +2 to all ship armor types.",
     10    "tooltip": "Lead sheathing protects ship hulls. +2 levels to all ship armor types.",
    1111    "modifications": [
    1212        {"value": "Armour/Hack", "add": 2.0},
    1313        {"value": "Armour/Pierce", "add": 2.0},
  • binaries/data/mods/public/simulation/data/technologies/armor_cav_chamfron.json

     
    1313    "requirementsTooltip": "Unlocked in City Phase.",
    1414    "icon": "armor_plates_cavalry.png",
    1515    "researchTime": 20,
    16     "tooltip": "Equip your cavalry mounts with armour. All Cavalry +1 Hack Armour.",
     16    "tooltip": "Equip your cavalry mounts with armor. All Cavalry +1 Hack armor level.",
    1717    "modifications": [{"value": "Armour/Hack", "add": 1.0}],
    1818    "affects": ["Cavalry"]
    1919}
     20 No newline at end of file
  • binaries/data/mods/public/simulation/data/technologies/armor_ship_reinforcedhull.json

     
    66    "requirementsTooltip": "Unlocked in Village Phase.",
    77    "icon": "armor_ship_bronze.png",
    88    "researchTime": 20,
    9     "tooltip": "Wooden reinforcement beams for hulls. Adds +2 to all ship armor types.",
     9    "tooltip": "Wooden reinforcement beams for hulls. +2 levels to all ship armor types.",
    1010    "modifications": [
    1111        {"value": "Armour/Hack", "add": 2.0},
    1212        {"value": "Armour/Pierce", "add": 2.0},
  • binaries/data/mods/public/simulation/data/technologies/armor_ship_hypozomata.json

     
    77    "supersedes": "armor_ship_reinforcedhull",
    88    "icon": "armor_ship_silver.png",
    99    "researchTime": 20,
    10     "tooltip": "The hypozomata braces the ship's structure. Adds +2 to all ship armor types.",
     10    "tooltip": "The hypozomata braces the ship's structure. +2 levels to all ship armor types.",
    1111    "modifications": [
    1212        {"value": "Armour/Hack", "add": 2.0},
    1313        {"value": "Armour/Pierce", "add": 2.0},
  • binaries/data/mods/public/simulation/data/technologies/armor_trade_convoys.json

     
    66    "requirementsTooltip": "Unlocked in City Phase.",
    77    "icon": "wheel.png",
    88    "researchTime": 20,
    9     "tooltip": "Traders +2 Hack and Pierce Armour",
     9    "tooltip": "Traders +2 Hack and Pierce armor levels.",
    1010    "modifications": [
    1111        {"value": "Armour/Hack", "add": 2.0},
    1212        {"value": "Armour/Pierce", "add": 2.0}],
  • binaries/data/mods/public/simulation/data/technologies/siege_armor.json

     
    66    "requirementsTooltip": "Unlocked in City Phase.",
    77    "icon": "armor_plates_gold.png",
    88    "researchTime": 30,
    9     "tooltip": "All Siege weapons +2 Hack Armour",
     9    "tooltip": "All Siege weapons +2 Hack armor levels.",
    1010    "modifications": [{"value": "Armour/Hack", "add": 5.0}],
    1111    "affects": ["Siege"]
    1212}
     13 No newline at end of file