Updating the Protection Focus

Creation, discussion, and balancing of game content such as techs, buildings, ship parts.

Moderators: Oberlus, Committer

Message
Author
User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Updating the Protection Focus

#16 Post by Geoff the Medio »

Dilvish wrote:Keep in mind that these are Tech Effects that operate synergistically with species Effects, and were moved into Species.txt to deal with priority issues related to the processing of the different Effects.
...
The scripting as I left it leads to the result that once an empire's last colony is captured, the defenses/shields/troops on any remaining outposts will have their tech reinforcement shot.
Ah, well yeah... That's a case where having the effect in a species doesn't make much sense, though I suppose you don't have much of a workaround for the desired behaviour.
...for an AND the later conditions search within the subset matched by the first. I suppose Or type conditions are done independently.
For And, it checks each candidate object that hasn't yet not matched a subcondition. For Or, it checks each candidate object that hasn't yet matched a subcondition. Have a look in the Eval functions in Condition.cpp.
...we would want to make sure we're using the 'best' condition first, and index most or all of those...
The "best" condition should already be being used to optimize. Generally, a fast and exclusive condition (eg. Source) is best first in an And condition, as all candidates will be tested once to see if they're the source, and then any subsequent conditions would only be tested on the 0 or 1 objects that were the source. If a more general condition was done first, like Planet, then all the objects that matched planet would subsequently be checked to see if they were matched Source. That said, if the first condition is very slow, it might be better to do a faster condition first. For example, a complicated WithinStarlaneJumps should be done after a simple / fast System condition, even though only one or two objects might match the WithinStarlaneJumps, because evaluating WithinStarlaneJumps takes a long time, as it's best to exclude as many candidates before getting to it.
...we don't necessarily want to index all the "most commonly used" conditions
I'd avoid trying to do something as complicated as caching the results of subconditions within And conditions and trying to keep track of when cached results could be used (which is not trivial). Instead, I'd just cache the results of top-level effectsgroup scope conditions that are source-object invariant (at a higher level) or any of them (within a loop for a particular source object).

Post Reply