Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/helpers/DamageBonus.js
- This file was added.
/** | |||||
* Calculate the attack damage multiplier against a target. | |||||
*/ | |||||
function GetDamageBonus(target, template) | |||||
{ | |||||
let attackBonus = 1; | |||||
let cmpIdentity = Engine.QueryInterface(target, IID_Identity); | |||||
if (!cmpIdentity) | |||||
return 1; | |||||
// Multiply the bonuses for all matching classes | |||||
for (let key in template) | |||||
{ | |||||
let bonus = template[key]; | |||||
if (bonus.Civ && bonus.Civ !== cmpIdentity.GetCiv()) | |||||
continue; | |||||
if (bonus.Classes && bonus.Classes.split(/\s+/).some(cls => !cmpIdentity.HasClass(cls))) | |||||
Mate-86: Shouldn't this condition be the other way around? Eg. bonus.Classes = "Infantry", "Cavarly" and… | |||||
fatherbushidoAuthorUnsubmitted Not Done Inline ActionsIt's the bonus of the attacker against entities which have one of those classes. fatherbushido: It's the bonus of the attacker against entities which have one of those classes. | |||||
continue; | |||||
attackBonus *= bonus.Multiplier; | |||||
} | |||||
return attackBonus; | |||||
} | |||||
Engine.RegisterGlobal("GetDamageBonus", GetDamageBonus); |
Wildfire Games · Phabricator
Shouldn't this condition be the other way around? Eg. bonus.Classes = "Infantry", "Cavarly" and when the target has class Infantry then the attack should remove the bonus. Or did I misunderstand this feature?