Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/entityExtend.js
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | for (let str in attackTimes) | ||||
case "prepare": | case "prepare": | ||||
strength -= val / 100000; | strength -= val / 100000; | ||||
break; | break; | ||||
default: | default: | ||||
API3.warn("Petra: " + str + " unknown attackTimes in getMaxStrength"); | API3.warn("Petra: " + str + " unknown attackTimes in getMaxStrength"); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
let armourStrength = ent.armourStrengths(); | let resistanceStrength = ent.resistanceStrengths(); | ||||
Stan: Maybe you could filter the array ? | |||||
Done Inline ActionsWhat is the benefit of that if I may ask? Less looping? Freagarach: What is the benefit of that if I may ask? Less looping? | |||||
Done Inline ActionsDon't really see the purpose of this loop, since we hardcode the types anyhow, so we can access them directly (same comment applies to some other places) bb: Don't really see the purpose of this loop, since we hardcode the types anyhow, so we can access… | |||||
for (let str in armourStrength) | |||||
if (resistanceStrength.Damage) | |||||
Done Inline Actionswhat happens if you use + instead ? Parse float being slower. Stan: what happens if you use + instead ? Parse float being slower. | |||||
for (let str in resistanceStrength.Damage) | |||||
{ | { | ||||
let val = parseFloat(armourStrength[str]); | let val = +resistanceStrength.Damage[str]; | ||||
if (DamageTypeImportance[str]) | if (DamageTypeImportance[str]) | ||||
strength += DamageTypeImportance[str] * val / damageTypes.length; | strength += DamageTypeImportance[str] * val / damageTypes.length; | ||||
else if (debugLevel > 0) | else if (debugLevel > 0) | ||||
API3.warn("Petra: " + str + " unknown armourStrength in getMaxStrength (please add " + str + " to config.js)."); | API3.warn("Petra: " + str + " unknown resistanceStrength in getMaxStrength (please add " + str + " to config.js)."); | ||||
} | } | ||||
// ToDo: Add support for StatusEffects and Capture. | |||||
return strength * ent.maxHitpoints() / 100.0; | return strength * ent.maxHitpoints() / 100.0; | ||||
}; | }; | ||||
/** Get access and cache it (except for units as it can change) in metadata if not already done */ | /** Get access and cache it (except for units as it can change) in metadata if not already done */ | ||||
PETRA.getLandAccess = function(gameState, ent) | PETRA.getLandAccess = function(gameState, ent) | ||||
{ | { | ||||
if (ent.hasClass("Unit")) | if (ent.hasClass("Unit")) | ||||
return gameState.ai.accessibility.getAccessValue(ent.position()); | return gameState.ai.accessibility.getAccessValue(ent.position()); | ||||
▲ Show 20 Lines • Show All 344 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Maybe you could filter the array ?