Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/entityExtend.js
/** returns true if this unit should be considered as a siege unit */ | /** returns true if this unit should be considered as a siege unit */ | ||||
PETRA.isSiegeUnit = function(ent) | PETRA.isSiegeUnit = function(ent) | ||||
{ | { | ||||
return ent.hasClass("Siege") || ent.hasClass("Elephant") && ent.hasClass("Melee"); | return ent.hasClasses(["Siege", "Elephant+Melee"]); | ||||
}; | }; | ||||
/** returns true if this unit should be considered as "fast". */ | /** returns true if this unit should be considered as "fast". */ | ||||
PETRA.isFastMoving = function(ent) | PETRA.isFastMoving = function(ent) | ||||
{ | { | ||||
// TODO: use clever logic based on walkspeed comparisons. | // TODO: use clever logic based on walkspeed comparisons. | ||||
return ent.hasClass("FastMoving"); | return ent.hasClass("FastMoving"); | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | PETRA.getAttackBonus = function(ent, target, type) | ||||
if (!ent.get("Attack/" + type) || !ent.get("Attack/" + type + "/Bonuses")) | if (!ent.get("Attack/" + type) || !ent.get("Attack/" + type + "/Bonuses")) | ||||
return attackBonus; | return attackBonus; | ||||
let bonuses = ent.get("Attack/" + type + "/Bonuses"); | let bonuses = ent.get("Attack/" + type + "/Bonuses"); | ||||
for (let key in bonuses) | for (let key in bonuses) | ||||
{ | { | ||||
let bonus = bonuses[key]; | let bonus = bonuses[key]; | ||||
if (bonus.Civ && bonus.Civ !== target.civ()) | if (bonus.Civ && bonus.Civ !== target.civ()) | ||||
continue; | continue; | ||||
if (bonus.Classes && bonus.Classes.split(/\s+/).some(cls => !target.hasClass(cls))) | if (!bonus.Classes || target.hasClasses(bonus.Classes)) | ||||
continue; | |||||
attackBonus *= bonus.Multiplier; | attackBonus *= bonus.Multiplier; | ||||
Silier: From old code it looks like it requires AND but this will more likely result in OR. | |||||
Done Inline ActionsI also switched the condition. (See also the Attack.js-helper implementation.) Freagarach: I also switched the condition. (See also the Attack.js-helper implementation.) | |||||
Done Inline ActionsBut bonus classes looks like this "class1 class2" right? Silier: But bonus classes looks like this "class1 class2" right?
Logic was if some class is missing… | |||||
Done Inline ActionsYou can have bonus classes Melee Infantry. Freagarach: You can have bonus classes `Melee Infantry`.
Bonus applies when entity is either `Melee` or… | |||||
} | } | ||||
return attackBonus; | return attackBonus; | ||||
}; | }; | ||||
/** Makes the worker deposit the currently carried resources at the closest accessible dropsite */ | /** Makes the worker deposit the currently carried resources at the closest accessible dropsite */ | ||||
PETRA.returnResources = function(gameState, ent) | PETRA.returnResources = function(gameState, ent) | ||||
{ | { | ||||
if (!ent.resourceCarrying() || !ent.resourceCarrying().length || !ent.position()) | if (!ent.resourceCarrying() || !ent.resourceCarrying().length || !ent.position()) | ||||
▲ Show 20 Lines • Show All 215 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
From old code it looks like it requires AND but this will more likely result in OR.