Excruciating FOCS doubts

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

Moderators: Oberlus, Committer

Message
Author
User avatar
Oberlus
Cosmic Dragon
Posts: 5827
Joined: Mon Apr 10, 2017 4:25 pm

Re: Excruciating FOCS doubts

#211 Post by Oberlus »

Ok, thank you for the answers, Ophiuchus, they were helpful.
Now on another doubt:

I'm trying to disable research and influence foci on non-capital, non-exobot species when the owner has adopted a policy. I think the coding must be done in species/common/focus.macros, something like this:

HAS_RESEARCH_FOCUS

Code: Select all

        Focus
            name = "FOCUS_RESEARCH"
            description = "FOCUS_RESEARCH_DESC"
            location = And [
                Planet
                Or [
                    Not EmpireHasAdoptedPolicy empire = Source.Owner name = "PLC_RACIAL_PURITY"
                    Species name = Source.Species
                ]
            ]
            graphic = "icons/focus/research.png"
It parses OK but doesn't work as intended, presumably because Source.Species is the planet's species, and not the capital species.
I've been browsing the effects in the code base but can't find how to ask for the capital species name. Capital.Species didn't work :lol:

I finally did it doing this:

Code: Select all

            location = And [
                Planet
                Or [
                    Not EmpireHasAdoptedPolicy empire = Source.Owner name = "PLC_RACIAL_PURITY"
                    Number low = 1 condition = And [
                        Planet
                        OwnedBy empire = Source.Owner
                        Species name = Source.Species
                        Contains Building name = "BLD_IMPERIAL_PALACE"
                    ]
                ]
            ]
This reads as "is there at least one planet, of the same owner, with this species, that contains an imperial palace?". A bit convoluted.

Is there a better way to check out if a given planet is of the same species than owner's capital?

wobbly
Cosmic Dragon
Posts: 1999
Joined: Thu Oct 10, 2013 6:48 pm

Re: Excruciating FOCS doubts

#212 Post by wobbly »

Oberlus wrote: Thu Sep 01, 2022 1:04 pm Is there a better way to check out if a given planet is of the same species than owner's capital?
Not sure about "better", but the way it handles the stability bonus for same species as capital is to have the effect on the imperial palace building itself.

https://github.com/freeorion/freeorion/ ... E.focs.txt

User avatar
Oberlus
Cosmic Dragon
Posts: 5827
Joined: Mon Apr 10, 2017 4:25 pm

Re: Excruciating FOCS doubts

#213 Post by Oberlus »

But focus effect needs to be on the species (via focus macros).

User avatar
Oberlus
Cosmic Dragon
Posts: 5827
Joined: Mon Apr 10, 2017 4:25 pm

Re: Excruciating FOCS doubts

#214 Post by Oberlus »

There is no TurnsSincePolicyDeadopted, or LastTurnPolicyAdopted.

How can I script a fading (stability) effect after a policy has been deadopted? Maybe with a building similar to the Conc Camp Remnants?
Or just modifying the current meter and letting it recover normaly with meter growth?

Any better ideas?

Ophiuchus
Programmer
Posts: 3513
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Excruciating FOCS doubts

#215 Post by Ophiuchus »

Oberlus wrote: Thu Sep 01, 2022 6:28 pm Or just modifying the current meter and letting it recover normaly with meter growth?

Any better ideas?
just stopping giving a bonus to a target meter and let it shrink naturally? dont know if stability is a target meter though
Oberlus wrote: Thu Sep 01, 2022 1:04 pm I've been browsing the effects in the code base but can't find how to ask for the capital species name. Capital.Species didn't work :lol:
no, there is currently only a Capital condition, not a ValueRef. so you could use that in a statistic. something along the line like

Code: Select all

            location = And [
                Planet
                Or [
                    Not EmpireHasAdoptedPolicy empire = Source.Owner name = "PLC_RACIAL_PURITY"
                    Number low = 1 condition = And [
                        Planet
                        Capital
                        OwnedBy empire = Source.Owner
                        Species name = Source.Species
                    ]
                ]
            ]
also the question is what if there is currently no capital? in other situations, the EmpireSource is used, but I think there is no way to access/filter that.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Oberlus
Cosmic Dragon
Posts: 5827
Joined: Mon Apr 10, 2017 4:25 pm

Re: Excruciating FOCS doubts

#216 Post by Oberlus »

Ophiuchus wrote: Thu Sep 01, 2022 7:18 pm also the question is what if there is currently no capital?
If there is no palace building, the malus still applies despite of the policy. I like it: if there is no palace, Empire is convulsive and the Racial Purity principles are not properly followed.

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

Re: Excruciating FOCS doubts

#217 Post by Geoff the Medio »

Oberlus wrote: Thu Sep 01, 2022 1:04 pmIs there a better way to check out if a given planet is of the same species than owner's capital?
You could probably get a species by writing something like

Code: Select all

Statistic Mode value = LocalCandidate.Species condition = And [ Capital OwnedBy empire = Source.Owner]

User avatar
Oberlus
Cosmic Dragon
Posts: 5827
Joined: Mon Apr 10, 2017 4:25 pm

Re: Excruciating FOCS doubts

#218 Post by Oberlus »

I'm trying to script a fading stability effect after de-adopting Racial Purity policy.

I'm trying to do it looking at how Conc. Camps work:

Conc Camp building (CCB)
- Boost to industry.
- If no Racial Purity or no CCS1, add CCS1.
- If no CCS1, add CCS1.
- If CCS1, "kill" 3 pop and override industry meter growth.
- If no Racial Purity or not produced by owner, destroy this building.

Conc Camp Remnant building (CCRB)
- If no CCB, override industry meter groth.
- If industry < target+2 and no CCS1 and no CCS2, destroy this building.

Conc Camp Master special (CCS1)
- If no CCB and pop>0, add CCS2 and remove this special.
- If no CCB and no CCRB, create CCRB.
- If no CCB and pop=0, remove this special.

Conc Camp Slave special (CCS2)
- Function that overrides population calculation (as if CCB was still present killing some population).
- If no CCB and no CCRB, create CCRB.
- With 0.167 probability, remove this special.


Both specials keep recreating the remnant building when none of the buildings are present. But I think and hope I don't need any building.
The population effect after destroying conc. camp building is done in the second special, so I think that's where I should place the stability effect.
Adopting Racial Purity would be like building a conc. camp., so the policy is what should creates my first special.
The first special adds the second special when the conc. camps are not there anymore, so my special will do the same, create the second special once the policy is de-adopted:

Racial Purity policy (RPP)
- Various effects
- If no RPPS1, add RPPS1 // add first special on adoption

Racial Purity First special (RPS1)
- If no RPP, add RPS2 and remove this special // add second special on de-adoption

Racial Purity Second special (RPS2)
- Stability malus that decreases with age of this special, to all owned planets of capital species
- If this special age>20, remove this special


But it is not working.
It creates the first special on adoption, that has no aparent effect while the policy is adopted (that's as expected).
On de-adoption, the second special replaces the first one, but the calculation seems off, penalty=-0 stability on first turn after de-adoption.
After advacing one turn, the second special removes itself.

Does anyone spot what I am missing?

The code is mostly like this one: https://github.com/freeorion/freeorion/pull/4116
(I haven't pushed some unfruitful modifications and failed workarounds.)

o01eg
Programmer
Posts: 2052
Joined: Sat Dec 10, 2011 5:46 am

Re: Excruciating FOCS doubts

#219 Post by o01eg »

Found that unlock in tech accepts type of unlocked item and name but for likes and dislikes in species it enough to known only name. Is it intended or techs could be changed to accept only names of unlocked items?
Gentoo Linux x64, gcc-11.2, boost-1.78.0
Ubuntu Server 22.04 x64, gcc-12, boost-1.74.0
Welcome to the slow multiplayer game at freeorion-lt.dedyn.io.Version 2024-05-24.6c553c9.
Donations're welcome:BTC:bc1q007qldm6eppqcukewtfkfcj0naut9njj7audnm

Ophiuchus
Programmer
Posts: 3513
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Excruciating FOCS doubts

#220 Post by Ophiuchus »

o01eg wrote: Tue Sep 06, 2022 8:10 am Found that unlock in tech accepts type of unlocked item and name but for likes and dislikes in species it enough to known only name.
Probably adding type information is in order to remove ambuigity (because technically you can have the same name for different types of content) and maybe to make registration/lookup easier.
o01eg wrote: Tue Sep 06, 2022 8:10 am Is it intended or techs could be changed to accept only names of unlocked items?
I dont think those are circumstantial and not intended/planned. Personally I dont mind either way, but I guess geoff prefers the strict typing on registration.

There probably should be a warning if the same name is getting reused for different unlockable content or the unlock should be typed.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

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

Re: Excruciating FOCS doubts

#221 Post by Geoff the Medio »

o01eg wrote: Tue Sep 06, 2022 8:10 am Found that unlock in tech accepts type of unlocked item and name but for likes and dislikes in species it enough to known only name.
Likes and dislikes just store the name and a check for liking or disliking just checks for the name in the tags list. But unlocking requires looking up the thing to work, so it needs to know the type for that to work. It's also faster / easier if it knows where to look.

User avatar
Grummel7
Space Dragon
Posts: 342
Joined: Mon Oct 09, 2017 3:44 pm

Re: Excruciating FOCS doubts

#222 Post by Grummel7 »

I found that with policy Terraforming, colonies on already terraformed planets start with a higher stability.

E.g. with Capital Markets applied, stability usually grows by 3 points per turn and new colonies start with 3. A colony on an artificial planet (which counts as 4 steps away for Terraforming) however starts with 7, then grows by 3 per turn.

But Terraforming only modifies TargetHappiness, just like many other effects. I just cannot figure out what is causing this effect...

o01eg
Programmer
Posts: 2052
Joined: Sat Dec 10, 2011 5:46 am

Re: Excruciating FOCS doubts

#223 Post by o01eg »

What in FOCS mean multiplication of number to condition in https://github.com/freeorion/freeorion/ ... os#L55-L57?

Code: Select all

            effects = SetStockpile value = Value +
                min(abs(Value(Target.MaxStockpile) - Value), 1) *
                    (1 - 2*(Value > Value(Target.MaxStockpile)))
Is condition cast to 0 and 1 here?
Gentoo Linux x64, gcc-11.2, boost-1.78.0
Ubuntu Server 22.04 x64, gcc-12, boost-1.74.0
Welcome to the slow multiplayer game at freeorion-lt.dedyn.io.Version 2024-05-24.6c553c9.
Donations're welcome:BTC:bc1q007qldm6eppqcukewtfkfcj0naut9njj7audnm

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

Re: Excruciating FOCS doubts

#224 Post by Geoff the Medio »

o01eg wrote: Thu Sep 29, 2022 1:40 pm What in FOCS mean multiplication of number to condition in https://github.com/freeorion/freeorion/ ... os#L55-L57?

Code: Select all

            effects = SetStockpile value = Value +
                min(abs(Value(Target.MaxStockpile) - Value), 1) *
                    (1 - 2*(Value > Value(Target.MaxStockpile)))
Is condition cast to 0 and 1 here?
I don't see any conditions there. > is an arithmetic comparison operation ( https://github.com/freeorion/freeorion/ ... es.cpp#L83 ) that returns 0 or 1 depending on Value and Value(Target.MaxStockpile).

User avatar
LienRag
Cosmic Dragon
Posts: 2275
Joined: Fri May 17, 2019 5:03 pm

Re: Excruciating FOCS doubts

#225 Post by LienRag »

I don't understand the code for the Moderation policy ?

Code: Select all

Policy
    name = "PLC_MODERATION"
    description = "PLC_MODERATION_DESC"
    short_description = "PLC_MODERATION_SHORT_DESC"
    category = "ECONOMIC_CATEGORY"
    adoptioncost = floor(2.0 * [[POPULATION_OWNED_BY_EMPIRE]]^0.5)
    exclusions = [ "PLC_INDUSTRIALISM" "PLC_STOCKPILE_LIQUIDATION" "PLC_TECHNOCRACY" ]
    effectsgroups = [
        [[SPECIES_LIKES_OR_DISLIKES_POLICY_STABILITY_EFFECTS]]
    
        EffectsGroup
            scope = And [
                Capital
                OwnedBy empire = Source.Owner
            ]
            priority = [[TARGET_AFTER_2ND_SCALING_PRIORITY]]
            effects = [
                // want bigger bonus for using equal numbers of each focus settings
                // and for using a greater variety of focus settings
                // focus used equally -> decrease with HistoSpread
                // use more different focus -> increase with CountUnique
                SetTargetInfluence value = Value + ((NamedReal name = "PLC_MODERATION_INFLUENCE_SCALING" value = 3.0) *
                    ((Statistic Count
                        condition = And [ Planet OwnedBy empire = Source.Owner ])
                    / (Statistic HistogramMax
                        value = LocalCandidate.Focus
                        condition = And [ Planet OwnedBy empire = Source.Owner ])
                    - 1.0))
                    
                SetTargetHappiness value = Value + ((NamedReal name = "PLC_MODERATION_STABILITY_SCALING" value = 1.0) *
                    ((Statistic Count
                        condition = And [ Planet OwnedBy empire = Source.Owner ])
                    / (Statistic HistogramMax
                        value = LocalCandidate.Focus
                        condition = And [ Planet OwnedBy empire = Source.Owner ])
                    - 1.0))
            ]
    ]
    graphic = "icons/policies/economic_moderation.png"

#include "/scripting/macros/base_prod.macros"
#include "/scripting/macros/priorities.macros"
#include "/scripting/policies/policies.macros"

It adds a bonus to the Capital influence, but what bonus exactly ?

Code: Select all

 SetTargetInfluence value = Value + ((NamedReal name = "PLC_MODERATION_INFLUENCE_SCALING" value = 3.0) *
                    ((Statistic Count
                        condition = And [ Planet OwnedBy empire = Source.Owner ])
                    / (Statistic HistogramMax
                        value = LocalCandidate.Focus
                        condition = And [ Planet OwnedBy empire = Source.Owner ])
                    - 1.0))
I tried to look for the function "HistogramMax" in the Detailed FOCS scripting page but it's not documented there.

Does it takes into account only the number of different foci ?

Post Reply