Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/globalscripts/Templates.js
Show First 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | function GetTemplateDataHelper(template, player, auraTemplates, resources, damageTypes, modifiers={}) | ||||
if (template.Armour) | if (template.Armour) | ||||
{ | { | ||||
ret.armour = {}; | ret.armour = {}; | ||||
for (let damageType in template.Armour) | for (let damageType in template.Armour) | ||||
if (damageType != "Foundation") | if (damageType != "Foundation") | ||||
ret.armour[damageType] = getEntityValue("Armour/" + damageType); | ret.armour[damageType] = getEntityValue("Armour/" + damageType); | ||||
} | } | ||||
let getAttackEffects = (temp, path) => { | |||||
let effects = {}; | |||||
if (temp.Capture) | |||||
effects.Capture = getEntityValue(path + "/Capture"); | |||||
if (temp.Damage) | |||||
{ | |||||
effects.Damage = {}; | |||||
for (let damageType in temp.Damage) | |||||
effects.Damage[damageType] = getEntityValue(path + "/Damage/" + damageType); | |||||
} | |||||
// TODO: status effects | |||||
return effects; | |||||
}; | |||||
if (template.Attack) | if (template.Attack) | ||||
{ | { | ||||
ret.attack = {}; | ret.attack = {}; | ||||
for (let type in template.Attack) | for (let type in template.Attack) | ||||
{ | { | ||||
let getAttackStat = function(stat) { | let getAttackStat = function(stat) { | ||||
return getEntityValue("Attack/" + type + "/" + stat); | return getEntityValue("Attack/" + type + "/" + stat); | ||||
}; | }; | ||||
if (type == "Capture") | |||||
ret.attack.Capture = { | |||||
"value": getAttackStat("Value") | |||||
}; | |||||
else | |||||
{ | |||||
ret.attack[type] = { | ret.attack[type] = { | ||||
"minRange": getAttackStat("MinRange"), | "minRange": getAttackStat("MinRange"), | ||||
"maxRange": getAttackStat("MaxRange"), | "maxRange": getAttackStat("MaxRange"), | ||||
"elevationBonus": getAttackStat("ElevationBonus"), | "elevationBonus": getAttackStat("ElevationBonus"), | ||||
"damage": {} | |||||
}; | }; | ||||
for (let damageType in template.Attack[type].Damage) | |||||
ret.attack[type].damage[damageType] = getAttackStat("Damage/" + damageType); | |||||
ret.attack[type].elevationAdaptedRange = Math.sqrt(ret.attack[type].maxRange * | ret.attack[type].elevationAdaptedRange = Math.sqrt(ret.attack[type].maxRange * | ||||
(2 * ret.attack[type].elevationBonus + ret.attack[type].maxRange)); | (2 * ret.attack[type].elevationBonus + ret.attack[type].maxRange)); | ||||
} | |||||
ret.attack[type].repeatTime = getAttackStat("RepeatTime"); | ret.attack[type].repeatTime = getAttackStat("RepeatTime"); | ||||
Object.assign(ret.attack[type], getAttackEffects(template.Attack[type], "Attack/" + type)); | |||||
if (template.Attack[type].Splash) | if (template.Attack[type].Splash) | ||||
{ | { | ||||
ret.attack[type].splash = { | ret.attack[type].splash = { | ||||
// true if undefined | // true if undefined | ||||
"friendlyFire": template.Attack[type].Splash.FriendlyFire != "false", | "friendlyFire": template.Attack[type].Splash.FriendlyFire != "false", | ||||
"shape": template.Attack[type].Splash.Shape, | "shape": template.Attack[type].Splash.Shape, | ||||
"damage": {} | |||||
}; | }; | ||||
for (let damageType in template.Attack[type].Splash.Damage) | Object.assign(ret.attack[type].splash, getAttackEffects(template.Attack[type].Splash, "Attack/" + type + "/Splash")); | ||||
ret.attack[type].splash.damage[damageType] = getAttackStat("Splash/Damage/" + damageType); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
if (template.DeathDamage) | if (template.DeathDamage) | ||||
{ | { | ||||
ret.deathDamage = { | ret.deathDamage = { | ||||
"friendlyFire": template.DeathDamage.FriendlyFire != "false", | "friendlyFire": template.DeathDamage.FriendlyFire != "false", | ||||
"damage": {} | |||||
}; | }; | ||||
for (let damageType in template.DeathDamage.Damage) | |||||
ret.deathDamage.damage[damageType] = getEntityValue("DeathDamage/Damage/" + damageType); | Object.assign(ret.deathDamage, getAttackEffects(template.DeathDamage, "DeathDamage")); | ||||
} | } | ||||
if (template.Auras && auraTemplates) | if (template.Auras && auraTemplates) | ||||
{ | { | ||||
ret.auras = {}; | ret.auras = {}; | ||||
for (let auraID of template.Auras._string.split(/\s+/)) | for (let auraID of template.Auras._string.split(/\s+/)) | ||||
{ | { | ||||
let aura = auraTemplates[auraID]; | let aura = auraTemplates[auraID]; | ||||
▲ Show 20 Lines • Show All 314 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator