Index: ps/trunk/binaries/data/mods/public/simulation/components/Attack.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/Attack.js +++ ps/trunk/binaries/data/mods/public/simulation/components/Attack.js @@ -613,7 +613,7 @@ if (attackerOwner == INVALID_PLAYER) return; - let multiplier = GetDamageBonus(target, this.GetBonusTemplate(type)); + let multiplier = GetDamageBonus(this.entity, target, type, this.GetBonusTemplate(type)); let cmpHealth = Engine.QueryInterface(target, IID_Health); if (!cmpHealth || cmpHealth.GetHitpoints() == 0) return; @@ -640,7 +640,7 @@ "strengths": this.GetAttackStrengths(type), "target": target, "attacker": this.entity, - "multiplier": GetDamageBonus(target, this.GetBonusTemplate(type)), + "multiplier": GetDamageBonus(this.entity, target, type, this.GetBonusTemplate(type)), "type": type, "attackerOwner": attackerOwner }); Index: ps/trunk/binaries/data/mods/public/simulation/components/Damage.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/Damage.js +++ ps/trunk/binaries/data/mods/public/simulation/components/Damage.js @@ -134,7 +134,7 @@ let cmpDamageReceiver = Engine.QueryInterface(data.target, IID_DamageReceiver); if (cmpDamageReceiver && this.TestCollision(data.target, data.position, lateness)) { - data.multiplier = GetDamageBonus(data.target, data.bonus); + data.multiplier = GetDamageBonus(data.attacker, data.target, data.type, data.bonus); this.CauseDamage(data); cmpProjectileManager.RemoveProjectile(data.projectileId); @@ -161,7 +161,7 @@ "strengths": data.strengths, "target": ent, "attacker": data.attacker, - "multiplier": GetDamageBonus(ent, data.bonus), + "multiplier": GetDamageBonus(data.attacker, ent, data.type, data.bonus), "type": data.type, "attackerOwner": data.attackerOwner }); @@ -223,7 +223,7 @@ } if (data.splashBonus) - damageMultiplier *= GetDamageBonus(ent, data.splashBonus); + damageMultiplier *= GetDamageBonus(data.attacker, ent, data.type, data.splashBonus); // Call CauseDamage which reduces the hitpoints, posts network command, plays sounds.... this.CauseDamage({ Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Attack.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Attack.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Attack.js @@ -184,12 +184,12 @@ TS_ASSERT(cmpAttack.GetBonusTemplate("Capture") === null); - let getAttackBonus = (t, e) => GetDamageBonus(e, cmpAttack.GetBonusTemplate(t)); - TS_ASSERT_UNEVAL_EQUALS(getAttackBonus("Melee", defender), className == "Cavalry" ? 2 : 1); - TS_ASSERT_UNEVAL_EQUALS(getAttackBonus("Ranged", defender), 1); - TS_ASSERT_UNEVAL_EQUALS(getAttackBonus("Ranged.Splash", defender), className == "Cavalry" ? 3 : 1); - TS_ASSERT_UNEVAL_EQUALS(getAttackBonus("Capture", defender), 1); - TS_ASSERT_UNEVAL_EQUALS(getAttackBonus("Slaughter", defender), 1); + let getAttackBonus = (s, t, e) => GetDamageBonus(s, e, t, cmpAttack.GetBonusTemplate(t)); + TS_ASSERT_UNEVAL_EQUALS(getAttackBonus(attacker, "Melee", defender), className == "Cavalry" ? 2 : 1); + TS_ASSERT_UNEVAL_EQUALS(getAttackBonus(attacker, "Ranged", defender), 1); + TS_ASSERT_UNEVAL_EQUALS(getAttackBonus(attacker, "Ranged.Splash", defender), className == "Cavalry" ? 3 : 1); + TS_ASSERT_UNEVAL_EQUALS(getAttackBonus(attacker, "Capture", defender), 1); + TS_ASSERT_UNEVAL_EQUALS(getAttackBonus(attacker, "Slaughter", defender), 1); }); // CanAttack rejects elephant attack due to RestrictedClasses Index: ps/trunk/binaries/data/mods/public/simulation/helpers/DamageBonus.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/helpers/DamageBonus.js +++ ps/trunk/binaries/data/mods/public/simulation/helpers/DamageBonus.js @@ -1,7 +1,12 @@ /** - * Calculate the attack damage multiplier against a target. + * Calculates the attack damage multiplier against a target. + * @param {entity_id_t} source - The source entity's id. + * @param {entity_id_t} target - The target entity's id. + * @param {string} type - The type of attack. + * @param {Object} template - The bonus' template. + * @return {number} - The source entity's attack bonus against the specified target. */ -function GetDamageBonus(target, template) +function GetDamageBonus(source, target, type, template) { let attackBonus = 1; @@ -17,7 +22,7 @@ continue; if (bonus.Classes && bonus.Classes.split(/\s+/).some(cls => !cmpIdentity.HasClass(cls))) continue; - attackBonus *= bonus.Multiplier; + attackBonus *= ApplyValueModificationsToEntity("Attack/" + type + "/Bonuses/" + key + "/Multiplier", +bonus.Multiplier, source); } return attackBonus;