Quantcast
Channel: FreeOrion
Viewing all articles
Browse latest Browse all 386

Programming • Re: C++ help needed: add filter for potential effect targets

$
0
0
With the PR, things like the following side-effect happen:
  • the boost for creating a new ship with robotic interface shields effect kicks in +1 turn for old ships, but kicks in first turn for newly created ones. E.g. have 1 robotic shield ship -> old shields 0; build a second robotic shield ship: old shields 0.0, new shields 6.0; next turn both ships shields 6.0
UI-wise this is fine. The robotic shield value is correctly estimated, and the UI estimations would be also correct for effects with non-combat related meters.

What we really want here is not completely clear. Probably having the boost +1 turn or having the boost +0 turn for both old and new ships would be more consistent. Probably a newly created ship should have at least the value based on old ship count.

The difference is because of object counts being different before production and after production.

Note that destruction in combat and scrapping kicks in earlier; those have no effect on meters before the main effect evaluation before production; e.g. scrapping will not have an effect on robotic shield values in combat. Destruction and scrapping will change the meters in before-production effects; e.g. the robotic shield value will be lower in the turn those objects get destroyed (counting for next turn combat).

I am not completely sure of object destruction and creation in effects - i would guess that those change the object counts in before-production effect application for effects which happen later. But those could be delayed as well.

Personally i do not mind if there are +1 turn effects in case of newly created objects. So that in a sense, production happens too late to have an effect on existing objects. The forum may differ though.

The current PR restricts the scope/targets to newly created objects.

Geoff found a class of cases where this probably will be weird/have very wrong results:
if one has an effect which uses a derived value of the set of target candidates, e.g. the count of all targets, the count could usually contain the whole universe; so restricting that targets to only newly created ones will usually much much lower than not restricting targets.
There are two cases actually: effects which
Side-note: we do not have such content and it can be worked around in 99% of cases by using a sub-condition instead of using Target; e.g. the robotic interface shields use no Target in the sub-condition for the Statistic Count.

There is a fix which could amend this/makes this slightly less wrong: not restricting the scope (so the candidates would be both old objects and new objects), but simply not applying the effect to the old objects. I looked at the code how to do this,

I think there is no way to get this perfect by having only a default behavior.
I also think it would be detrimental to solve this like a phase, because in 99% of meter effects you want those to apply to the old objects before-production and apply to the new objects after-production; adding code to the scripting to 99% of content in order to tweak 1% right seems wrong.

So lets go for the current PR as default behavior and make sure one can override that default behavior (or at least work around it).

An example of a work around would be to not counting newly created ships in the robotic shield effect, so both old and new ships get the shields based on the old object count. In this case I would not apply any workaround to the robotic interface shields here - i think having the newly created ships already powered up and the old ships getting the effect +1 turn is fine.

Overriding the default behaviour would probably need a switch like NoDefaultMeterEffectAfterProduction and in the effectsgroup one would have to conditionally work with old/new objects; e.g. by using different activation conditions or tweaking the effect.

Statistics: Posted by Ophiuchus — Mon Jul 08, 2024 7:10 am



Viewing all articles
Browse latest Browse all 386

Trending Articles