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: 5714
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: 1876
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: 5714
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: 5714
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: 3433
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: 5714
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: 13587
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: 5714
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: 2004
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-03-15.b3de094.
Donations're welcome:BTC:bc1q007qldm6eppqcukewtfkfcj0naut9njj7audnm

Ophiuchus
Programmer
Posts: 3433
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: 13587
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: 335
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: 2004
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-03-15.b3de094.
Donations're welcome:BTC:bc1q007qldm6eppqcukewtfkfcj0naut9njj7audnm

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
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).

Post Reply