Game Objects and Attributes resource?

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

Moderators: Oberlus, Committer

Post Reply
Message
Author
jhalfast
Space Krill
Posts: 5
Joined: Fri Sep 28, 2018 7:59 pm

Game Objects and Attributes resource?

#1 Post by jhalfast »

Is there a scripting object tree or any description of the game's objects (systems, buildings, ships, etc.) and their corresponding attributes (ID, population, attached parts, etc.) that is available somewhere? As I continue to play around with FOCS, I find it very frustrating to try and guess, or disseminate from given text files, how (and if) I can access things in effectsgroups and other aspects of making new things.

It would be great to know how to point to an empire's industry, or reference the shield strength of a planet... Does such a resource exist?

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

Re: Game Objects and Attributes resource?

#2 Post by Geoff the Medio »

There is no maintained list of referencable object properties, unfortunately. There have been lists made on the wiki, but nobody has the time and motivation to keep them updated and usable.

However, you can ask in a forum post, or review the parser code to get ideas what is available...

https://github.com/freeorion/freeorion/ ... Parser.cpp
https://github.com/freeorion/freeorion/ ... Parser.cpp
https://github.com/freeorion/freeorion/ ... Parser.cpp
https://github.com/freeorion/freeorion/ ... Parser.cpp
https://github.com/freeorion/freeorion/ ... Parser.cpp
https://github.com/freeorion/freeorion/ ... Parser.cpp

The actual code where the values you get within FOCS are calculated is perhaps more difficult to understand and works different for different cases, but an example is here: https://github.com/freeorion/freeorion/ ... f.cpp#L796

Some examples:

In DoubleValueRefParser, there is a list of items assigned to "bound_variable_name", including "tok.Fuel_". That means you can use an expression like Source.Fuel in FOCS and get a double-valued (floating point number) result back. For objects that have a fuel property (ie. ships), that will return their current fuel. For objects without a fuel property, it will return 0.0. Those types of expression should be understandable from the parser code without much trouble, I think.

Also in DoubleValueRefParser, there is a list of items assigned to "free_variable_name", including "tok.UniverseWidth_". That means you can use an expression like UniverseWidth (no Source. or similar) and get a double-valued result back

In IntComplexValueRefParser, there are various assignment expressions (like https://github.com/freeorion/freeorion/ ... er.cpp#L40 ) which are also expressions that can be used in FOCS without a referencing a specific object directly (like UniverseWidth), but which take parameters. For example

Code: Select all

ShipPartsOwned empire = Source.Owner class = Armour
will return the number of armour parts on ships owned by the source object's owner empire. Actually determining how that would work from the parser code is difficult though...
https://github.com/freeorion/freeorion/ ... r.cpp#L132
So if there is something potentially interesting in the parser code that you're not sure how to use, a forum post for an explanation would probably be the easiest way to find out. The things to look for in the parser code to find out what's usable are instances of something like

Code: Select all

tok.ShipPartsOwned_
where that bit is not enclosed in a label(...) wrapper like

Code: Select all

label(tok.Empire_)
as the latter indicates that the ShipPartsOwned value takes a parameter named empire, which indeed is the case in the above FOCS snippet. It's not always that easy to extract what parameters are possible or required to be supplied, though, as in the "part_class_as_int" that also appears in that parser.

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

Re: Game Objects and Attributes resource?

#3 Post by Geoff the Medio »

jhalfast wrote: Mon Oct 15, 2018 11:12 pmIt would be great to know how to point to an empire's industry, or reference the shield strength of a planet...
If the source is a planet or ship, Source.Shield should be it's current shield meter value.

A sum of the industry meters of all planets owned by an empire would probably use a statistic expression, like
https://github.com/freeorion/freeorion/ ... ocs.txt#L2

Code: Select all

Statistic Sum value = LocalCandidate.Industry condition = And [
    Planet
    OwnedBy empire = Source.Owner
]

Post Reply