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: 5715
Joined: Mon Apr 10, 2017 4:25 pm

Re: Excruciating FOCS doubts

#46 Post by Oberlus »

Geoff the Medio wrote: Sun Nov 15, 2020 12:11 pm This sounds a bit awkward to use in practice, as it would seem to require the initial scout to leave the system immediately to avoid triggering the refuel effect.
Moreover, it forces player to remember where the tanker is. I like it more the way it is now.

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

Re: Excruciating FOCS doubts

#47 Post by Ophiuchus »

Oberlus wrote: Sun Nov 15, 2020 1:24 pm
Geoff the Medio wrote: Sun Nov 15, 2020 12:11 pm This sounds a bit awkward to use in practice, as it would seem to require the initial scout to leave the system immediately to avoid triggering the refuel effect.
Moreover, it forces player to remember where the tanker is. I like it more the way it is now.
Those are solvable I think.
Activate the effect if there are ships that arrived two turns before. One turn before activation there could be a sitrep "In next turn tankers at system refuel ships".
For making the effect one could create a field around that system as soon as tankers are discovered.

Note to the current implementation: using the extra special is the workaround so the sitrep can refer to the affected ships. If sitreps supported multiple ships, the special would not be necessary
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: 5715
Joined: Mon Apr 10, 2017 4:25 pm

Re: Excruciating FOCS doubts

#48 Post by Oberlus »

Can I use "Statistic" or something else to query the planetary focus within an effect?

Something like

Code: Select all

value = Value + (Statistic Condition LocalCandidate.focus = "FOCUS_PROTECTION") + 1
Or should I make two effects, one for planets with the focus and one with planets without it?

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

Re: Excruciating FOCS doubts

#49 Post by Geoff the Medio »

Oberlus wrote: Sat Dec 12, 2020 3:42 pm Can I use "Statistic" or something else to query the planetary focus within an effect?

Something like

Code: Select all

value = Value + (Statistic Condition LocalCandidate.focus = "FOCUS_PROTECTION") + 1
Yes, with an arbitrary condition, like
https://github.com/freeorion/freeorion/ ... cs.txt#L24

Code: Select all

            effects = SetMaxCapacity partname = "FT_BAY_1" value = (
                3 +
                Statistic If condition = And [ Target  OwnerHasTech name = "SHP_FIGHTERS_2" ] +
                Statistic If condition = And [ Target  OwnerHasTech name = "SHP_FIGHTERS_3" ] +
                Statistic If condition = And [ Target  OwnerHasTech name = "SHP_FIGHTERS_4" ]
            )
Or should I make two effects, one for planets with the focus and one with planets without it?
Would be arguably simpler.

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

Re: Excruciating FOCS doubts

#50 Post by Oberlus »

How to refer to the Capital of an empire within an effect whose Source is a planet?

For example, in Centralization (policy) we have this effect (edited):

Code: Select all

        EffectsGroup
            scope = And [
                Planet
                OwnedBy empire = Source.Owner
                Population low = 0.001
                ResourceSupplyConnected empire = LocalCandidate.Owner condition = And [
                    Planet
                    OwnedBy empire = Source.Owner
                    Capital
                ]
                Not Capital
            ]
            effects = SetTargetInfluence value = Value + 
                        (NamedReal name = "PLC_CENTRALIZATION_TARGET_INFLUENCE_PERJUMP" value = -0.2)
                            * JumpsBetween object = Source.ID object = Target.ID
The JumpsBetween gets as parameters Source.ID and Target.ID.
Source.ID is the ID of the capital planet (I assume Source is the policy and asking an ID to a policy returns the planet ID of the capital empire, but IDK).
Target.ID is the ID of the planet being processed in the effect (from the planets in the Scope).

If I move this effect based on JumpsBetween to a species effect (those in default/scripting/species/common/*.macros), such as in influence.macros, it will not work:

Code: Select all

EffectsGroup      // colonies consume influence, proportional to how many planets the empire controls
            scope = Source
            activation = And [
                Planet
                Not Unowned
                Not Capital
            ]
            stackinggroup = "IMPERIAL_PALACE_MANY_PLANETS_INFLUENCE_PENALTY"
            accountinglabel = "COLONY_ADMIN_COSTS_LABEL"
            effects = SetTargetInfluence value = Value - (NamedReal name = "OLONY_ADMIN_COSTS_PER_PLANET" value = 0.2) *
                Statistic Count condition = And [
                    Planet
                    OwnedBy empire = Source.Owner
                ] - (NamedReal name = "PLC_CENTRALIZATION_TARGET_INFLUENCE_PERJUMP" value = -0.2)
                * JumpsBetween object = Source.ID object = Target.ID
The first part, based on Statistic Count, does work (as it did work before changing anything), but the second part, distance-based upkeep, is broken: JumpsBetween object = Source.ID object = Target.ID returns 0.
Source is the... species? And so Source.ID does not give anything useful to JumpsBetween?

I solved this problem moving the EffectsGroup from species/common/influence.macros to a tech unlocked at start, which also makes sense since it is an effect that only applies to empires (and not to unowned planets) and all empires have that tech unlocked at start. However, I wonder if it could be done within the species/common/influence.macros file.

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

Re: Excruciating FOCS doubts

#51 Post by Ophiuchus »

Oberlus wrote: Tue Feb 02, 2021 5:49 pmThe first part, based on Statistic Count, does work (as it did work before changing anything), but the second part, distance-based upkeep, is broken: JumpsBetween object = Source.ID object = Target.ID returns 0.
Source is the... species? And so Source.ID does not give anything useful to JumpsBetween?
No, source for a species is a ship or planet with the species. So in this case it is a planet with the current species (and it is not a capital).

And you chose your targets to be the source. So distance is always zero.

I guess the source for policies is either the capital or more likely the empire root.

It should work in a species file if you make the source the capital via activation condition - you want to apply an effect to the non-capital so it has to be in scope/the target.
Note that using a tech is probably more appropiate.
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

#52 Post by Geoff the Medio »

Ophiuchus wrote: Tue Feb 02, 2021 10:22 pmAnd you chose your targets to be the source. So distance is always zero.
To clarify, the script has

Code: Select all

scope = Source
which means that the the set of targets for the effectsgroup is just the source object, which is the planet on which a species is located. The effect is evaluated and executed once per object that matches the activation condition and that has the species on it.

Then later it has

Code: Select all

JumpsBetween object = Source.ID object = Target.ID
but since the scope (ie. targets) is just the source, the only target is the source itself, so the distance from the source to itself is 0.

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

Re: Excruciating FOCS doubts

#53 Post by Oberlus »

Is there a way to query if the species in a planet has this or that trait?

To clarify, could I query in a tech effect (e.g. robotic production) if the species has BAD_INDUSTRY, GOOD_INDUSTRY, etc., or better, use something like Source.Species.ResearchTrait that would return the multiplier (0.75, 1.5...)?

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

Re: Excruciating FOCS doubts

#54 Post by Geoff the Medio »

Oberlus wrote: Sun Feb 07, 2021 7:27 pmIs there a way to query if the species in a planet has this or that trait?
"trait" is not a FOCS thing. But tags are, and a planet has the tags of its species, so you can query if a planet has a tag with the HasTag condition, in order to find if the planet's species has that tag specified in its script.
To clarify, could I query in a tech effect (e.g. robotic production) if the species has BAD_INDUSTRY, GOOD_INDUSTRY, etc., or better, use something like Source.Species.ResearchTrait that would return the multiplier (0.75, 1.5...)?
"ResearchTrait" isn't a think known to FOCS or the C++ code.

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

Re: Excruciating FOCS doubts

#55 Post by Oberlus »

Understood. Thank you.

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

Re: Excruciating FOCS doubts

#56 Post by Oberlus »

Is there a FOCS command to adopt (or de-adopt) a policy?
It would be to get policies adopted from start (before game starts), because I am having a hard time coping with the idea that no government-type policy equals some type of government (I'd like to allow empire to start with different types of government) and because I'd rather have the influence upkeep effects from policies coded in their policy files instead of in some root tech filled with if conditions to consider the different upkeep equations and modifiers depending on adopted policies.
Related to this, could it be possible to disallow not having any government-type policy? So that each player must have a government policy adopted at all time. That would make implementation simpler IMO.


Can planetary focus type be forbidden under certain conditions? E.g. a policy is (not) adopted, the species is (not) the same as capital.
This would be to forbid influence focus at non-capital species colonies when government is Empire/Dominion.

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

Re: Excruciating FOCS doubts

#57 Post by Geoff the Medio »

Oberlus wrote: Sat Feb 20, 2021 3:51 pmIs there a FOCS command to adopt (or de-adopt) a policy?
No. Adopting or de-adopting a policy is/was thought of as an empire order, like production queue management or fleet movement. There are use cases, though, so it could be added.
Related to this, could it be possible to disallow not having any government-type policy? So that each player must have a government policy adopted at all time. That would make implementation simpler IMO.
That sounds like a problematic complication if enforce as a hard game rule. Doing it with an effect would seem more appropriate. But there's also no "government-type policy" concept in the game mechanics... The policies are all part of / aspects of the government of the empire.
Can planetary focus type be forbidden under certain conditions?
Focus definitions have a location condition, which the planet where they are to be set must meet. The planet's owner's policies can be checked in that with an EmpireHasAdoptedPolicy condition.

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

Re: Excruciating FOCS doubts

#58 Post by LienRag »

I'm trying to launch a test game with the latest version and some FOCS files of mine, and I get a LOT of parse errors, some of them due to the new rules about case-sensitiveness (which are tedious to solve but understandable - though apparently camel case is not supported, which makes the code less readable), some of them due to the evolution of the FOCS format (apparently there are no more "preferred foci" for Species due to the likes/dislikes novelty) and some that I do not understand at all.
Most if not all of the FOCS mistakes I have made have been corrected already since I played with the same files in a test game on Master, so there can be formatting mistakes due to the new format but normally there shouldn't be real mistakes left.

I tried to test the Whumsoon specie as a non-colonizable one in order to be able to advocate for its inclusion in the game, and here's the error I get :

Code: Select all

scripting/default/scripting/species/SP_WHUMSOOM.focs.txt:1105:54: Parse error.  Expected real number expression here:
            activation = And [
                Planet
                Unowned
            ]
            accountinglabel = "NATIVE_PLANETARY_DEFENSE_LABEL"
            effects = SetMaxDefense value = Value + ( @1@ )
                                                      ^

        EffectsGroup
            scope = Source
            activation = And [
                Planet
I had similar errors in previous game and it took me some time to understand that they were from macros called by the file mentioned in the parse error, but there I cannot find why the relevant macro code is faulty since the only macro I touched is the focus.macros and I didn't erase it, I just added the modified version of Send and Receive stargate foci in order to use my Wormholes entrances and exits.
Whumsoon calls the [[NATIVE_PLANETARY_DEFENSE]] but I didn't touch this file ?
planet_defense.macros has the code

Code: Select all

NATIVE_PLANETARY_DEFENSE
'''EffectsGroup
            scope = Source
            activation = And [
                Planet
                Unowned
            ]
            accountinglabel = "NATIVE_PLANETARY_DEFENSE_LABEL"
            effects = SetMaxDefense value = Value + ( @1@ )
'''
but why doesn't it parse ?


Also when I launch the game I have a quite reduced screen with a strange screen in the middle :


Last time I had that it was because in the string table I had entries spanning more than one line without ''' before and after them, but I checked many times and I don't think I have this problem in my string table now.

Could there be another reason ?
Attachments
FO sreecn.png
FO sreecn.png (884.78 KiB) Viewed 1020 times

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

Re: Excruciating FOCS doubts

#59 Post by Geoff the Medio »

The script in SP_WHUMSOOM.focs.txt that I got from your thread about them uses [[NATIVE_PLANETARY_DEFENSE]] without passing a parameter to the macro, which is required.

The macro is here: https://github.com/freeorion/freeorion/ ... .macros#L2

I located that by using the Find in Files feature of Notepad++ (similar to other text editors), pointed to the default/scripting directory and filtered to search: *.focs.txt;*.macros;*.txt

Your menu screen is missing the load and continue buttons because it doesn't think there are any save files it can read. Probably something in the format changed to make them unloadable. Does they reappear if you start a game and play a few turns so that some autosaves are generated?

The [[MAP_BTN_PEDIA]] label looks like a stringtable formatting error, but it's hard to tell without a log or stringtable file to inspect.

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

Re: Excruciating FOCS doubts

#60 Post by LienRag »

Thanks.

I should have checked the stringtable once more...
There was a "return" not easy to see at the end of one line.

I don't understand why it removed the "exit" button though ?

I've got a new parse error for the Whumsoom that I really don't understand :

Code: Select all

Expected PlanetType here:
      type = Tundra       environment = Uninhabitable
      type = Desert       environment = Uninhabitable
      type = Terran       environment = Uninhabitable
      type = Ocean        environment = Uninhabitable
      type = Asteroids    environment = Good
      type = Gasgiant     environment = Uninhabitable
             ^
    ]
I checked the code for the Sly and it's exactly the same syntax ?

(if it's relevant, here are the lines before to correct the faulty parameter-less call to the macro :

Code: Select all

        [[NATIVE_PLANETARY_DEFENSE(5*[[PLANET_DEFENSE_FACTOR]])]]
        [[NATIVE_PLANETARY_SHIELDS(5*[[PLANET_SHIELD_FACTOR]])]]
I counted many times the number of opening and closing brackets [] and I really believe that they're the right number)

Post Reply