Please have a short look at the optimization commit and tell me if my reasoning is good.
Changes to the government function stealth building:
* move check of capital to the end of activation - The CONDITION_GOVERNMENT_TYPE_IS_ macro looks up the empires capital and checks if the correct government building is there. I think finding the government is not trivial, so i moved it to the end of the activation
* replace ContainedBy by Number and PlanetID - I want to find out which species stealth bonus is on the planet. ContainedBy will try to match against the planet, all fleets, and buildings on that planet. I only need the planet, and I already have the PlanetID. So I used the Object id condition to get the current planet. Also I guessed that ContainedBy will in itself do some work, so I used NumberOf high=1 to do this, not sure if there is a more suitable condition.
Other questions:
* the building should substitute the stealth bonus given by the species, so i used the stackinggroup used there.
* I generated effectgroups for all of the BAD_STEALTH, GOOD_STEALTH using macros. This works but feels very hackish and was quite error prone.
p.s. for the *_STEALTH macros, what I wished for was a ValueRef condition similar to
Code: Select all
// Find the BAD, GOOD.. stealth level from the tag and look up the fitting value
If condition = TagPart matchTag="%candidate%_STEALTH" effects = SetStealth value = value + [[STEALTH_VALUE_FOR(LocalCandidate)]]
Or maybe something like
Code: Select all
SetStealth value = value + [[STEALTH_VALUE_FOR(TagSubstring regexp="(.*)_STEALTH")]]