Ticket #4421: d.diff

File d.diff, 5.8 KB (added by fpre_O_O_O_O_O_O, 6 years ago)

a23 port

  • binaries/data/mods/public/globalscripts/Templates.js

    diff --git a/binaries/data/mods/public/globalscripts/Templates.js b/binaries/data/mods/public/globalscripts/Templates.js
    index a9e46fc..30d36d1 100644
    a b function GetTemplateDataHelper(template, player, auraTemplates, resources, damag  
    187187                ret.attack[type] = {
    188188                    "minRange": getAttackStat("MinRange"),
    189189                    "maxRange": getAttackStat("MaxRange"),
    190                     "elevationBonus": getAttackStat("ElevationBonus")
     190                    "elevationBonus": getAttackStat("ElevationBonus"),
     191                    "spread": getAttackStat("Spread")
    191192                };
    192193                for (let damageType of damageTypes.GetTypes())
    193194                    ret.attack[type][damageType] = getAttackStat(damageType);
  • binaries/data/mods/public/gui/common/tooltips.js

    diff --git a/binaries/data/mods/public/gui/common/tooltips.js b/binaries/data/mods/public/gui/common/tooltips.js
    index e907c62..b6da3dc 100644
    a b var g_SplashDamageTypes = {  
    2424var g_RangeTooltipString = {
    2525    "relative": {
    2626        // Translation: For example: Ranged Attack: 12.0 Pierce, Range: 2 to 10 (+2) meters, Interval: 3 arrows / 2 seconds
    27         "minRange": translate("%(attackLabel)s %(damageTypes)s, %(rangeLabel)s %(minRange)s to %(maxRange)s (%(relativeRange)s) %(rangeUnit)s, %(rate)s"),
     27        "minRange": translate("%(attackLabel)s %(damageTypes)s, %(rangeLabel)s %(minRange)s to %(maxRange)s (%(relativeRange)s) %(rangeUnit)s, %(rate)s, %(spread)s"),
    2828        // Translation: For example: Ranged Attack: 12.0 Pierce, Range: 10 (+2) meters, Interval: 3 arrows / 2 seconds
    29         "no-minRange": translate("%(attackLabel)s %(damageTypes)s, %(rangeLabel)s %(maxRange)s (%(relativeRange)s) %(rangeUnit)s, %(rate)s"),
     29        "no-minRange": translate("%(attackLabel)s %(damageTypes)s, %(rangeLabel)s %(maxRange)s (%(relativeRange)s) %(rangeUnit)s, %(rate)s, %(spread)s"),
    3030    },
    3131    "non-relative": {
    3232        // Translation: For example: Ranged Attack: 12.0 Pierce, Range: 2 to 10 meters, Interval: 3 arrows / 2 seconds
    33         "minRange": translate("%(attackLabel)s %(damageTypes)s, %(rangeLabel)s %(minRange)s to %(maxRange)s %(rangeUnit)s, %(rate)s"),
     33        "minRange": translate("%(attackLabel)s %(damageTypes)s, %(rangeLabel)s %(minRange)s to %(maxRange)s %(rangeUnit)s, %(rate)s, %(spread)s"),
    3434        // Translation: For example: Ranged Attack: 12.0 Pierce, Range: 10 meters, Interval: 3 arrows / 2 seconds
    35         "no-minRange": translate("%(attackLabel)s %(damageTypes)s, %(rangeLabel)s %(maxRange)s %(rangeUnit)s, %(rate)s"),
     35        "no-minRange": translate("%(attackLabel)s %(damageTypes)s, %(rangeLabel)s %(maxRange)s %(rangeUnit)s, %(rate)s, %(spread)s"),
    3636    }
    3737};
    3838
    function getAttackTooltip(template)  
    284284        let maxRange = Math.round(template.attack[type].maxRange);
    285285        let realRange = template.attack[type].elevationAdaptedRange;
    286286        let relativeRange = realRange ? Math.round(realRange - maxRange) : 0;
     287        let spread = +template.attack[type].spread;
    287288
    288289        tooltips.push(sprintf(g_RangeTooltipString[relativeRange ? "relative" : "non-relative"][minRange ? "minRange" : "no-minRange"], {
    289290            "attackLabel": attackLabel,
    function getAttackTooltip(template)  
    298299                    translate("meters") :
    299300                    translatePlural("meter", "meters", maxRange)),
    300301            "rate": rate,
     302            "spread": sprintf(translate("%(label)s %(val)s %(unit)s at %(range)s"), {
     303                "label": headerFont(translate("Spread Hit Radius:")),
     304                "val": spread,
     305                "unit": unitFont(translatePlural("meter", "meters", spread)),
     306                "range": sprintf("%(range)s %(unit)s", { "range": maxRange, "unit": translatePlural("meter", "meters", maxRange) })
     307            })
    301308        }));
    302309    }
    303310    return tooltips.join("\n");
  • binaries/data/mods/public/simulation/components/Attack.js

    diff --git a/binaries/data/mods/public/simulation/components/Attack.js b/binaries/data/mods/public/simulation/components/Attack.js
    index b048152..69259a6 100644
    a b Attack.prototype.GetAttackStrengths = function(type)  
    440440    return ret;
    441441};
    442442
     443Attack.prototype.GetSpread = function(type)
     444{
     445    if (type != "Ranged" || !this.template[type])
     446        return 0;
     447
     448    let spread = +this.template[type].Spread;
     449    return ApplyValueModificationsToEntity("Attack/" + type + "/Spread", spread, this.entity);
     450}
     451
    443452Attack.prototype.GetSplashDamage = function(type)
    444453{
    445454    if (!this.template[type].Splash)
    Attack.prototype.PerformAttack = function(type, target)  
    513522        let predictedPosition = (timeToTarget !== false) ? Vector3D.mult(targetVelocity, timeToTarget).add(targetPosition) : targetPosition;
    514523
    515524        // Add inaccuracy based on spread.
    516         let distanceModifiedSpread = ApplyValueModificationsToEntity("Attack/Ranged/Spread", +this.template.Ranged.Spread, this.entity) *
    517             predictedPosition.horizDistanceTo(selfPosition) / 100;
     525        // let distanceModifiedSpread = ApplyValueModificationsToEntity("Attack/Ranged/Spread", +this.template.Ranged.Spread, this.entity) *
     526        let distanceModifiedSpread = this.GetSpread(type) * predictedPosition.horizDistanceTo(selfPosition) / 100;
    518527
    519528        let randNorm = randomNormal2D();
    520529        let offsetX = randNorm[0] * distanceModifiedSpread;
  • binaries/data/mods/public/simulation/components/GuiInterface.js

    diff --git a/binaries/data/mods/public/simulation/components/GuiInterface.js b/binaries/data/mods/public/simulation/components/GuiInterface.js
    index b0d8007..eb04f6a 100644
    a b GuiInterface.prototype.GetEntityState = function(player, ent)  
    389389        for (let type of types)
    390390        {
    391391            ret.attack[type] = cmpAttack.GetAttackStrengths(type);
     392            ret.attack[type].spread = cmpAttack.GetSpread(type);
    392393            ret.attack[type].splash = cmpAttack.GetSplashDamage(type);
    393394
    394395            let range = cmpAttack.GetRange(type);