Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/common-api/filters.js
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | "hasDefensiveFire": () => ({ | |||||||||||
"dynamicProperties": [] | "dynamicProperties": [] | |||||||||||
}), | }), | |||||||||||
"isDropsite": resourceType => ({ | "isDropsite": resourceType => ({ | |||||||||||
"func": ent => ent.resourceDropsiteTypes() && (resourceType === undefined || ent.resourceDropsiteTypes().indexOf(resourceType) != -1), | "func": ent => ent.resourceDropsiteTypes() && (resourceType === undefined || ent.resourceDropsiteTypes().indexOf(resourceType) != -1), | |||||||||||
"dynamicProperties": [] | "dynamicProperties": [] | |||||||||||
}), | }), | |||||||||||
"isTreasure": () => ({ | ||||||||||||
"func": ent => { | ||||||||||||
if (!ent.isTreasure()) | ||||||||||||
return false; | ||||||||||||
// Don't go for floating treasures since we might not be able | ||||||||||||
// to reach them and that kills the pathfinder. | ||||||||||||
Stan: What does that function do? Is it expensive? you can also inline returning the value of that… | ||||||||||||
let template = ent.templateName(); | ||||||||||||
return template != "gaia/treasure/shipwreck_debris" && | ||||||||||||
template != "gaia/treasure/shipwreck"; | ||||||||||||
Done Inline Actions
For another diff. Freagarach: For another diff. | ||||||||||||
}, | ||||||||||||
"dynamicProperties": [] | ||||||||||||
}), | ||||||||||||
"byResource": resourceType => ({ | "byResource": resourceType => ({ | |||||||||||
"func": ent => { | "func": ent => { | |||||||||||
if (!ent.resourceSupplyMax()) | if (!ent.resourceSupplyMax()) | |||||||||||
return false; | return false; | |||||||||||
let type = ent.resourceSupplyType(); | let type = ent.resourceSupplyType(); | |||||||||||
if (!type) | if (!type) | |||||||||||
return false; | return false; | |||||||||||
// Skip targets that are too hard to hunt | // Skip targets that are too hard to hunt | |||||||||||
if (!ent.isHuntable() || ent.hasClass("SeaCreature")) | if (!ent.isHuntable() || ent.hasClass("SeaCreature")) | |||||||||||
return false; | return false; | |||||||||||
// Don't go for floating treasures since we won't be able to reach them and it kills the pathfinder. | ||||||||||||
if (ent.templateName() == "gaia/treasure/shipwreck_debris" || | ||||||||||||
ent.templateName() == "gaia/treasure/shipwreck") | ||||||||||||
return false; | ||||||||||||
if (type.generic == "treasure") | ||||||||||||
return resourceType == type.specific; | ||||||||||||
return resourceType == type.generic; | return resourceType == type.generic; | |||||||||||
}, | }, | |||||||||||
"dynamicProperties": [] | "dynamicProperties": [] | |||||||||||
}), | }), | |||||||||||
"isHuntable": () => ({ | "isHuntable": () => ({ | |||||||||||
// Skip targets that are too hard to hunt and don't go for the fish! TODO: better accessibility checks | // Skip targets that are too hard to hunt and don't go for the fish! TODO: better accessibility checks | |||||||||||
"func": ent => ent.hasClass("Animal") && ent.resourceSupplyMax() && | "func": ent => ent.hasClass("Animal") && ent.resourceSupplyMax() && | |||||||||||
ent.isHuntable() && !ent.hasClass("SeaCreature"), | ent.isHuntable() && !ent.hasClass("SeaCreature"), | |||||||||||
"dynamicProperties": [] | "dynamicProperties": [] | |||||||||||
}), | }), | |||||||||||
"isFishable": () => ({ | "isFishable": () => ({ | |||||||||||
// temporarily do not fish moving fish (i.e. whales) | // temporarily do not fish moving fish (i.e. whales) | |||||||||||
Done Inline Actions"temporarily" (rP15152) Freagarach: "temporarily" (rP15152) | ||||||||||||
"func": ent => !ent.get("UnitMotion") && ent.hasClass("SeaCreature") && ent.resourceSupplyMax(), | "func": ent => !ent.get("UnitMotion") && ent.hasClass("SeaCreature") && ent.resourceSupplyMax(), | |||||||||||
"dynamicProperties": [] | "dynamicProperties": [] | |||||||||||
}) | }) | |||||||||||
}; | }; | |||||||||||
return m; | return m; | |||||||||||
}(API3); | }(API3); | |||||||||||
Wildfire Games · Phabricator
What does that function do? Is it expensive? you can also inline returning the value of that boolean expression.